File tree Expand file tree Collapse file tree 3 files changed +5
-2
lines changed Expand file tree Collapse file tree 3 files changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -418,7 +418,8 @@ void BLDCMotor::move(float new_target) {
418418 // angle set point
419419 shaft_angle_sp = target;
420420 // calculate velocity set point
421- shaft_velocity_sp = P_angle ( shaft_angle_sp - shaft_angle );
421+ shaft_velocity_sp = feed_forward_velocity + P_angle ( shaft_angle_sp - shaft_angle );
422+ shaft_angle_sp = _constrain (shaft_angle_sp,-velocity_limit, velocity_limit);
422423 // calculate the torque command - sensor precision: this calculation is ok, but based on bad value from previous calculation
423424 current_sp = PID_velocity (shaft_velocity_sp - shaft_velocity); // if voltage torque control
424425 // if torque controlled through voltage
Original file line number Diff line number Diff line change @@ -307,7 +307,8 @@ void StepperMotor::move(float new_target) {
307307 // angle set point
308308 shaft_angle_sp = target;
309309 // calculate velocity set point
310- shaft_velocity_sp = P_angle ( shaft_angle_sp - shaft_angle );
310+ shaft_velocity_sp = feed_forward_velocity + P_angle ( shaft_angle_sp - shaft_angle );
311+ shaft_angle_sp = _constrain (shaft_angle_sp, -velocity_limit, velocity_limit);
311312 // calculate the torque command
312313 current_sp = PID_velocity (shaft_velocity_sp - shaft_velocity); // if voltage torque control
313314 // if torque controlled through voltage
Original file line number Diff line number Diff line change @@ -155,6 +155,7 @@ class FOCMotor
155155
156156 // state variables
157157 float target; // !< current target value - depends of the controller
158+ float feed_forward_velocity = 0 .0f ; // !< current feed forward velocity
158159 float shaft_angle;// !< current motor angle
159160 float electrical_angle;// !< current electrical angle
160161 float shaft_velocity;// !< current motor velocity
You can’t perform that action at this time.
0 commit comments