Firmware
|
TODO: document the algorithm |T1| T2 |T3|
__| |____ __ Jerk |_|
/ \ Acceleration ___/ ___
;" / / Velocity ; -—". More...
#include <VelocitySmoothing.hpp>
Public Member Functions | |
VelocitySmoothing (float initial_accel=0.f, float initial_vel=0.f, float initial_pos=0.f) | |
void | reset (float accel, float vel, float pos) |
Reset the state. More... | |
void | updateDurations (float dt, float vel_setpoint) |
Compute T1, T2, T3 depending on the current state and velocity setpoint. More... | |
void | integrate (float &accel_setpoint_smooth, float &vel_setpoint_smooth, float &pos_setpoint_smooth) |
Generate the trajectory (acceleration, velocity and position) by integrating the current jerk. More... | |
void | integrate (float dt, float integration_scale_factor, float &accel_setpoint_smooth, float &vel_setpoint_smooth, float &pos_setpoint_smooth) |
float | getMaxJerk () const |
void | setMaxJerk (float max_jerk) |
float | getMaxAccel () const |
void | setMaxAccel (float max_accel) |
float | getMaxVel () const |
void | setMaxVel (float max_vel) |
float | getCurrentJerk () const |
void | setCurrentAcceleration (const float accel) |
float | getCurrentAcceleration () const |
void | setCurrentVelocity (const float vel) |
float | getCurrentVelocity () const |
void | setCurrentPosition (const float pos) |
float | getCurrentPosition () const |
float | getTotalTime () const |
float | getT1 () const |
float | getT2 () const |
float | getT3 () const |
float | getVelSp () const |
Static Public Member Functions | |
static void | timeSynchronization (VelocitySmoothing *traj, int n_traj) |
Synchronize several trajectories to have the same total time. More... | |
TODO: document the algorithm |T1| T2 |T3|
__| |____ __ Jerk |_|
/ \ Acceleration ___/ ___
;" / / Velocity ; -—".
void VelocitySmoothing::integrate | ( | float & | accel_setpoint_smooth, |
float & | vel_setpoint_smooth, | ||
float & | pos_setpoint_smooth | ||
) |
Generate the trajectory (acceleration, velocity and position) by integrating the current jerk.
dt | optional integration period. If not given, the integration period provided during updateDuration call is used. A dt different from the one given during the computation of T1-T3 can be used to fast-forward or slow-down the trajectory. |
acc_setpoint_smooth | returned smoothed acceleration setpoint |
vel_setpoint_smooth | returned smoothed velocity setpoint |
pos_setpoint_smooth | returned smoothed position setpoint |
void VelocitySmoothing::reset | ( | float | accel, |
float | vel, | ||
float | pos | ||
) |
Reset the state.
accel | Current acceleration |
vel | Current velocity |
pos | Current position |
|
static |
Synchronize several trajectories to have the same total time.
This is required to generate straight lines. The resulting total time is the one of the longest trajectory.
traj | an array of VelocitySmoothing objects |
n_traj | the number of trajectories to be synchronized |
void VelocitySmoothing::updateDurations | ( | float | dt, |
float | vel_setpoint | ||
) |
Compute T1, T2, T3 depending on the current state and velocity setpoint.
This should be called on every cycle and before integrate().
dt | delta time between last updateDurations() call and now [s] |
vel_setpoint | velocity setpoint input |