MBsysPy.mbsyspy.utilities.trajectories module

Define trajectory functions for package MBsysPy.

Summary

Defines the functions that are not specific to a MBS analysis.

MBsysPy.mbsyspy.utilities.trajectories.add_signal(q1, qd1, qdd1, q2, qd2, qdd2)

Compute the sum of 2 signals.

Compute the position, velocity and acceleration of the sum of 2 signals.

Parameters
  • q1 (float) – position of the first signal.

  • qd1 (float) – velocity of the first signal.

  • qdd1 (float) – acceleration of the first signal.

  • q2 (float) – position of the second signal.

  • qd2 (float) – velocity of the second signal.

  • qdd2 (float) – acceleration of the second signal.

Returns

  • q3 (float) – position of the sum.

  • qd3 (float) – velocity of the sum.

  • qdd3 (float) – acceleration of the sum.

MBsysPy.mbsyspy.utilities.trajectories.cosine_signal(tsim, ampl, phi, f, off)

Compute a cosine trajectory.

Compute the position, velocity and acceleration of a cosine trajectory.

Parameters
  • tsim (float) – simulation time.

  • ampl (float) – amplitude of the cosine function.

  • phi (float) – phase angle of the cosine function.

  • f (float) – frequency of the cosine function.

  • off (float) – position offset of the cosine function.

Returns

  • q (float) – position.

  • qd (float) – velocity.

  • qdd (float) – acceleration.

MBsysPy.mbsyspy.utilities.trajectories.div_signal(q1, qd1, qdd1, q2, qd2, qdd2)

Compute the division of 2 signals.

Compute the position, velocity and acceleration of the division of 2 signals.

Parameters
  • q1 (float) – position of the first signal.

  • qd1 (float) – velocity of the first signal.

  • qdd1 (float) – acceleration of the first signal.

  • q2 (float) – position of the second signal.

  • qd2 (float) – velocity of the second signal.

  • qdd2 (float) – acceleration of the second signal.

Raises

ZeroDivisionError – When q2 is equal to 0.

Returns

  • q3 (float) – position of the division.

  • qd3 (float) – velocity of the division.

  • qdd3 (float) – acceleration of the division.

MBsysPy.mbsyspy.utilities.trajectories.get_ramp_time(delta_q, v12, a01, a23, t0)

Compute the time related to a ramp trajectory.

Compute the time instant for a ramp when position, constant speed and acceleration/deceleration are given.

Parameters
  • delta_q (float) – difference between start and end position.

  • v12 (float) – constant speed (>0).

  • a01 (float) – acceleration (>0).

  • a23 (float) – deceleration (<0).

  • t0 (float) – start time.

Raises

ValueError – When there is a wrong choice of acceleration and velocity.

Returns

  • t1 (float) – stop time of the acceleration.

  • t2 (float) – stop time of the constant speed.

  • t3 (float) – stop time.

MBsysPy.mbsyspy.utilities.trajectories.mult_signal(q1, qd1, qdd1, q2, qd2, qdd2)

Compute the multplication of 2 signals.

Compute the position, velocity and acceleration of the multplication of 2 signals.

Parameters
  • q1 (float) – position of the first signal.

  • qd1 (float) – velocity of the first signal.

  • qdd1 (float) – acceleration of the first signal.

  • q2 (float) – position of the second signal.

  • qd2 (float) – velocity of the second signal.

  • qdd2 (float) – acceleration of the second signal.

Returns

  • q3 (float) – position of the multplication.

  • qd3 (float) – velocity of the multplication.

  • qdd3 (float) – acceleration of the multplication.

MBsysPy.mbsyspy.utilities.trajectories.ramp_2_order_3_piece(tsim, t0, t1, t2, t3, qmax)

Compute a 3-piece 2-order ramp trajectory.

Compute the position, velocity and acceleration of a 3-piece 2-order ramp trajectory. Position at start time and velocity at start and stop time are equal to zero. Position at end time is equal to qmax. Postion and velocity are continuous at intermediate times.

Parameters
  • tsim (float) – simulation time.

  • t0 (float) – start time.

  • t1 (float) – stop time of acceleration.

  • t2 (float) – start time of deceleration.

  • t3 (float) – stop time.

  • qmax (float) – amplitude of the ramp.

Raises
  • ZeroDivisionError – Some parameters are incorrect.

  • ValueError – When there is a wrong timing choice.

Returns

  • q (float) – position.

  • qd (float) – velocity.

  • qdd (float) – acceleration.

MBsysPy.mbsyspy.utilities.trajectories.ramp_2_order_3_piece_from_acc_vel(tsim, v12, a01, a23, t0, qmax)

Compute a 3-piece 2-order ramp trajectory.

Compute the position, velocity and acceleration of a 3-piece 2-order ramp trajectory from the constant acceleration in the first and third piece and the constant velocity in the second piece. Position at start time and velocity at start and stop time are equal to zero Position at end time is equal to qmax. Postion and velocity are continuous at intermediate time.

Parameters
  • tsim (float) – simulation time.

  • v12 (float) – constant speed (>0).

  • a01 (float) – acceleration (>0).

  • a23 (float) – deceleration (<0).

  • t0 (float) – start time.

  • qmax (float) – difference between start and end position.

Raises

ValueError – When there is a wrong choice of acceleration and velocity.

Returns

  • q (float) – position.

  • qd (float) – velocity.

  • qdd (float) – acceleration.

MBsysPy.mbsyspy.utilities.trajectories.ramp_3_order(tsim, t0, t1, qmax)

Compute a 3-order ramp trajectory.

Compute the position, velocity and acceleration of a 3-order ramp trajectory. Position at start time and velocity at start and stop time are equal to zero. Position at end time is equal to qmax.

Parameters
  • tsim (float) – simulation time.

  • t0 (float) – start time.

  • t1 (float) – stop time.

  • qmax (float) – amplitude of the ramp.

Raises
  • ZeroDivisionError – If t0 and t1 are equal.

  • ValueError – When there is a wrong timing choice.

Returns

  • q (float) – position.

  • qd (float) – velocity.

  • qdd (float) – acceleration.

MBsysPy.mbsyspy.utilities.trajectories.ramp_3_order_3_piece(tsim, t0, t1, t2, t3, qmax)

Compute a 3-piece 3-order ramp trajectory.

Compute the position, velocity and acceleration of a 3-piece 3-order ramp trajectory. Position at start time, velocity and acceleration at start and stop time are equal to zero. Position at end time is equal to qmax. Postion and velocity and acceleration are continuous at intermediate times. Position is cubic in the intermediate time interval.

Parameters
  • tsim (float) – simulation time.

  • t0 (float) – start time.

  • t1 (float) – stop time of acceleration.

  • t2 (float) – start time of deceleration.

  • t3 (float) – stop time.

  • qmax (float) – amplitude of the ramp.

Raises
  • ZeroDivisionError – Some parameters are incorrect.

  • ValueError – When there is a wrong timing choice.

Returns

  • q (float) – position.

  • qd (float) – velocity.

  • qdd (float) – acceleration.

MBsysPy.mbsyspy.utilities.trajectories.ramp_4_order_3_piece(tsim, t0, t1, t2, t3, qmax)

Compute a 3-piece 4-order ramp trajectory.

Compute the position, velocity and acceleration of a 3-piece 4-order ramp trajectory. Position at start time and velocity at start and stop time are equal to zero. Position at end time is equal to qmax. Postion and velocity and acceleration are continuous at intermediate times. Position is linear in the intermediate time interval.

Parameters
  • tsim (float) – simulation time.

  • t0 (float) – start time.

  • t1 (float) – stop time of acceleration.

  • t2 (float) – start time of deceleration.

  • t3 (float) – stop time.

  • qmax (float) – amplitude of the ramp.

Raises
  • ZeroDivisionError – Some parameters are incorrect.

  • ValueError – When there is a wrong timing choice.

Returns

  • q (float) – position.

  • qd (float) – velocity.

  • qdd (float) – acceleration.

MBsysPy.mbsyspy.utilities.trajectories.ramp_5_order(tsim, t0, t1, qmax)

Compute a 5-order ramp trajectory.

Compute the position, velocity and acceleration of a 5-order ramp trajectory. Position at start time and velocity at start and stop time are equal to zero. Position at end time is equal to qmax.

Parameters
  • tsim (float) – simulation time.

  • t0 (float) – start time.

  • t1 (float) – stop time.

  • qmax (float) – amplitude of the ramp.

Raises
  • ZeroDivisionError – If t0 and t1 are equal.

  • ValueError – When there is a wrong timing choice.

Returns

  • q (float) – position.

  • qd (float) – velocity.

  • qdd (float) – acceleration.

MBsysPy.mbsyspy.utilities.trajectories.sigmoid(tsim, lambda_, t0)

Compute a sigmoid signal.

Compute the position, velocity and acceleration of a sigmoid signal. See https://fr.wikipedia.org/wiki/Sigmoïde_(mathématiques)

Parameters
  • tsim (float) – simulation time.

  • lambda_ (float) – linked to the curvature. It is equal to four times the derivative at the inflection point.

  • t0 (float) – inflection point of the sigmoid.

Returns

  • q (float) – position.

  • qd (float) – velocity.

  • qdd (float) – acceleration.

MBsysPy.mbsyspy.utilities.trajectories.sine_signal(tsim, ampl, phi, f, off)

Compute a sine trajectory.

Compute the position, velocity and acceleration of a sine trajectory.

Parameters
  • tsim (float) – simulation time.

  • ampl (float) – amplitude of the sine function.

  • phi (float) – phase angle of the sine function.

  • f (float) – frequency of the sine function.

  • off (float) – position offset of the sine function.

Returns

  • q (float) – position.

  • qd (float) – velocity.

  • qdd (float) – acceleration.

MBsysPy.mbsyspy.utilities.trajectories.sub_signal(q1, qd1, qdd1, q2, qd2, qdd2)

Compute the substraction of 2 signals.

Compute the position, velocity and acceleration of the substraction of 2 signals.

Parameters
  • q1 (float) – position of the first signal.

  • qd1 (float) – velocity of the first signal.

  • qdd1 (float) – acceleration of the first signal.

  • q2 (float) – position of the second signal.

  • qd2 (float) – velocity of the second signal.

  • qdd2 (float) – acceleration of the second signal.

Returns

  • q3 (float) – position of the substraction (q1-q2).

  • qd3 (float) – velocity of the substraction.

  • qdd3 (float) – acceleration of the substraction.

MBsysPy.mbsyspy.utilities.trajectories.sweep(tsim, t0, f0, t1, f1, zmax)

Compute a frequency sweep on a sine signal.

Compute the position, velocity and acceleration of a sine signal with a frequency sweep. Frequency increases linearly with time.

Parameters
  • tsim (float) – simulation time.

  • t0 (float) – start time.

  • f0 (float) – start frequency.

  • t1 (float) – stop time.

  • f1 (float) – stop frequency.

  • zmax (float) – amplitude of oscillations.

Returns

  • z (float) – position.

  • zd (float) – velocity.

  • zdd (float) – acceleration.