SCurveTrajectory¶
- class SCurveTrajectory(start_position: AngularPosition, stop_position: AngularPosition, maximum_velocity: AngularSpeed, maximum_acceleration: AngularAcceleration, maximum_deceleration: AngularAcceleration, start_velocity: AngularSpeed | None = None, stop_velocity: AngularSpeed | None = None, start_time: Time | None = None)¶
Bases:
objectAdded in version 1.3.0.
SCurveTrajectoryobject.It computes the S curve trajectory from the
start_positionto thestop_position. The trajectory is divided into three parts:a constant acceleration part at
maximum_acceleration,a uniform velocity part at
maximum_velocity,a constant deceleration part at
maximum_deceleration.
The starting conditions, at the
start_time, are thestart_positionand thestart_velocity; while the final conditions are thestop_positionandstop_velocity.The
stop_positionmay also be lower than (but not equal to) thestart_positionfor backward motion.Methods¶
compute()It computes the angular position at the given
timeinstant, according to the S curve trajectory from thestart_positionto thestop_position.
Raises
TypeErrorIf
start_positionis not an instance ofAngularPosition,if
stop_positionis not an instance ofAngularPosition,if
maximum_velocityis not an instance ofAngularSpeed,if
maximum_accelerationis not an instance ofAngularAcceleration,if
maximum_decelerationis not an instance ofAngularAcceleration,if
start_velocityis not an instance ofAngularSpeed,if
stop_velocityis not an instance ofAngularSpeed,if
start_timeis not an instance ofTime.
ValueErrorIf
start_positionandstop_positionare equal,if
maximum_velocityis not positive,if
maximum_accelerationis not positive,if
maximum_decelerationis not positive,if
start_velocityis geater thanmaximum_velocity,if
stop_velocityis greater thanmaximum_velocity.
- compute(time: Time) AngularPosition¶
It computes the angular position at the given
timeinstant, according to the S curve trajectory from thestart_positionto thestop_position.Parameters¶
timeTimeSpecific instant of time in which to calculate the angular position in accordance with the S curve.
Returns¶
AngularPositionAngular position according to S curve trajectory at the given
time.
Raises
TypeErrorIf
timeis not an instance ofTime.
Notes
The input parameter
time\(t\) is compared to the S curve trajectory parameters, to establish the motion regime at that time instant. Five cases are be possibile:\(t \lt t_0\): The
time\(t\) instant preceeds thestart_time\(t_0\). The motion regime is uniform velocity atstart_velocity\(\dot{\theta}_0\). The angular position \(\theta\) is computed as:\[\theta = \dot{\theta}_0 t_l + \theta_0\]where \(t_l = t - t_0\).
\(t_0 \le t \lt t_0 + t_A\): The
time\(t\) instant is greater than thestart_time\(t_0\), but lower than the duration \(t_0 + t_A\). The motion regime is uniform acceleration atmaximum_acceleration\(\ddot{\theta}_{A,max}\). The angular position \(\theta\) is computed as:\[\theta = \frac{1}{2} \ddot{\theta}_{A,max} t^2_l + \dot{\theta}_0 t_l + \theta_0\]where \(t_l = t - t_0\).
\(t_0 + t_A \le t \lt t_0 + t_A + t_U\) The
time\(t\) instant is greater than the duration \(t_0 + t_A\), but lower than the duration \(t_0 + t_A + t_U\). The motion regime is uniform velocity atmaximum_velocity\(\dot{\theta}_{max}\). The angular position \(\theta\) is computed as:\[\theta = \dot{\theta}_{max} t_l + \theta_0 + \theta_A\]where \(t_l = t - t_0 - t_A\).
\(t_0 + t_A + t_U \le t \lt t_1\) The
time\(t\) instant is greater than the duration \(t_0 + t_A + t_U\), but lower than the duration \(t_1\). The motion regime is uniform deceleration atmaximum_deceleration\(\ddot{\theta}_{D,max}\). The angular position \(\theta\) is computed as:\[\theta = - \frac{1}{2} \ddot{\theta}_{D,max} t^2_l + \dot{\theta}_{max} t_l + \theta_0 + \theta_A + \theta_U\]where \(t_l = t - t_0 - t_A - t_U\).
\(t \ge t_1\) The
time\(t\) instant is greater than the duration \(t_1\). The motion regime is uniform velocity atstop_velocity\(\dot{\theta}_1\). The angular position \(\theta\) is computed as:\[\theta = \dot{\theta}_1 t_l + \theta_1\]where \(t_l = t - t_0 - t_A - t_U - t_D\).
In some cases, the difference between
stop_position\(\theta_1\) andstart_position\(\theta_0\) is small compared to the acceleration and deceleration distances \(\theta_A\) and \(\theta_D\). In that case, there is no room for uniform velocity regime atmaximum_velocity\(\dot{\theta}_{max}\), so the step 3 is skipped and themaximum_velocityis not reached.The acceleration duration \(t_A\) is computed as:
\[t_A = \frac{\dot{\theta}_{max} - \dot{\theta}_0}{\ddot{\theta}_{A,max}}\]The uniform duration \(t_U\) is computed as:
\[t_U = \frac{\theta_U}{\dot{\theta}_{max}}\]The deceleration duration \(t_D\) is computed as:
\[t_D = \frac{\dot{\theta}_{max} - \dot{\theta}_1}{\ddot{\theta}_{D,max}}\]The acceleration distance \(\theta_A\) is computed as:
\[\theta_A = \frac{1}{2} \frac{\dot{\theta}_{max}^2 - \dot{\theta}_0^2}{\ddot{\theta}_{A,max}}\]The uniform distance \(\theta_U\) is computed as:
\[\theta_U = | \theta_1 - \theta_0 | - \theta_A - \theta_D\]The deceleration distance \(\theta_D\) is computed as:
\[\theta_D = \frac{1}{2} \frac{\dot{\theta}_{max}^2 - \dot{\theta}_1^2}{\ddot{\theta}_{D,max}}\]The stop time is computed as:
\[t_1 = t_0 + t_A + t_U + t_D\]Here the list of the parameters used in the above equations:
\(\theta\) is the angular position,
\(\dot{\theta}_{max}\) is the
maximum_velocity,\(\ddot{\theta}_{A,max}\) is the
maximum_acceleration,\(\ddot{\theta}_{D,max}\) is the
maximum_deceleration,\(\theta_0\) is the
start_position,\(\theta_1\) is the
stop_position,\(\dot{\theta}_0\) is the
start_velocity,\(\dot{\theta}_1\)
stop_velocity,\(t_0\) is the
start_time.