apply¶
- PositionAndVelocityControl.apply() None | float | int
It computes the
pwmto apply to thepowertrain’s motor in order to stick to position and velocity set by thetrajectorythrough the two nestedposition_PIDandvelocity_PID.Returns¶
floatorintorNonePWM value to apply to the
powertrain’s motor in order to stick to the S curve trajectory.
Notes
It computes a velocity reference through the
position_PIDas:\[\dot{\theta}_{ref} = PID_{pos}(\theta - \theta_{ref})\]where:
\(\dot{\theta}_{ref}\) is the velocity reference,
\(\theta\) is the current angular position, tracked by the
encoder,\(\theta_{ref}\) is the reference angular position, get by the S curve
trajectory.
Then, it computes a PWM through the
velocity_PIDas:\[PWM_{ref} = PID_{vel}(\dot{\theta} - \dot{\theta}_{ref})\]where:
\(PWM_{ref}\) is the reference PWM,
\(\dot{\theta}\) is the current angular speed, tracked by the
tachometer.