reachy.trajectory.interpolation

Trajectory interpolation utility module.

This module defines various interpolation technique (linear, minimum jerk). They can be used in all goto functions.

Module Contents

Classes

TrajectoryInterpolation

Trajectory interpolation abstraction class.

Linear

Linear implementation implementation.

MinimumJerk

Minimum Jerk interpolation implementation.

Functions

cubic_smooth(traj, nb_kp, out_points=-1)

Trjaectory cubic smooth interpolation.

class reachy.trajectory.interpolation.TrajectoryInterpolation(initial_position, goal_position, duration)

Bases: object

Trajectory interpolation abstraction class.

Parameters
  • initial_position (float) – starting position (in degrees)

  • goal_position (float) – end position (in degrees)

  • duration (float) – duration of the movement (in seconds)

You can defined your own interpolation technique by respecting this abstraction so they can be used in goto functions.

abstract interpolate(self, t)

Interpolate the position at given time.

Parameters

t (float) – time where to interpolate

You are responsible for implementing this method in your own interpolation technique. Please refer to the implementation of Linear of MinimumJerk for examples.

start(self, motor, update_freq=100)

Start the interpolation trajectory thread.

Parameters
  • motor (motor) – motor to apply the trajectory to

  • update_freq (float) – Update sample frequency (in Hz)

property is_playing(self)

Check if the trajectory is currently playing.

stop(self, wait=True)

Stop the interpolation trajectory.

wait(self)

Block until the end of the trajectory interpolation.

_follow_traj_loop(self, motor, update_freq)
class reachy.trajectory.interpolation.Linear(initial_position, goal_position, duration)

Bases: reachy.trajectory.interpolation.TrajectoryInterpolation

Linear implementation implementation.

interpolate(self, t)

Linear interpolation at time t.

class reachy.trajectory.interpolation.MinimumJerk(initial_position, goal_position, duration, initial_velocity=0, final_velocity=0, initial_acceleration=0, final_acceleration=0)

Bases: reachy.trajectory.interpolation.TrajectoryInterpolation

Minimum Jerk interpolation implementation.

Parameters
  • initial_position (float) – starting position (in degrees)

  • goal_position (float) – end position (in degrees)

  • duration (float) – duration of the movement (in seconds)

  • initial_velocity (float) – initial velocity used for interpolation

  • final_velocity (float) – final velocity used for interpolation

  • initial_acceleration (float) – initial acceleration used for interpolation

  • final_acceleration (float) – final acceleration used for interpolation

interpolate(self, t)

Minjerk interpolation at time t.

reachy.trajectory.interpolation.cubic_smooth(traj, nb_kp, out_points=- 1)

Trjaectory cubic smooth interpolation.

Parameters
  • traj (dict) – trajectory to smooth ({motor_name: list of motor pos})

  • nb_kp (int) – number of keypoints to use for the cubic smoothing

  • out_points (int) – number of samples in the output trajectory (use -1 to conserve the same number as the input trajectory)

reachy.trajectory.interpolation.interpolation_modes