# Trajectories¶

When imposing the trajectory of a driven joint all the coordinate, velocity and acceleration must be provided and consistent. Some common trajectories have been defined in the MBsysPy source code as well as the tools to combine trajectories.

## Example of trajectories¶

Find below some of the implemented trajectories. More are available in the module
`MBsysPy.trajectories`

.

### Cosine trajectory¶

A cosine trajectory is implemented by the function `cosine_signal()`

while
the sine trajecory is done by `sine_signal()`

.

### Ramps¶

The simpliest shape of a ramp (with consistent coordinate, velocity and acceleration) is achieved by imposing a step of constant acceleration, followed by a step at constant velocity and ending with a constant deceleration to reach the wanted ramp height in coordinate, at null velocity.

Such ramp is implemented with the function `ramp_2_order_3_piece_from_acc_vel()`

.
In this function, you impose the acceleration, deceleration and constant velocity.
On the other side with the function :py:func`ramp_2_order_3_piece` you impose the
time of each step (start of acceleration, constant velocity…) and the function
will determine the required acceleration, deceleration and velocity.

Other ramps are defined in the module using other intermediate shape between the initial and final coordinates.

## Combined trajectories¶

In some case you may require to combine trajectories, the simplest case being coordinate making a ramp in a direction and then a second ramp to come back to its inital position. Such a trajectory is avhieved by adding to ramp of opposite amplitude.

We provide four fonction to combine trajectories:
- `add_signal()`

- `sub_signal()`

- `mult_signal()`

- `div_signal()`

You can uses the functions with trajectories you defined yourself as it just required the current position, velocity and acceleration of the two trajectories to combine.