Trajectories

This file presents the different Trajectories - Command functions available with the Trajectories API

Trajectories - Command functions

This section reference all existing functions to control your robot, which include

  • Playing smoothed waypointed trajectories

  • Managing saved trajectories

All functions to control the robot are accessible via an instance of the class NiryoRobot

robot = NiryoRobot(<robot_ip_address>)

trajectories = robot.trajectories.get_saved_trajectory_list()
if len(trajectories) > 0:
    robot.trajectories.execute_trajectory_saved(trajectories[0])
...

See examples on Examples Section

List of functions subsections:

Trajectories functions

class Trajectories(client, action_timeout=3600)[source]
get_saved_trajectory(trajectory_name)[source]

Get saved trajectory from robot intern storage Will raise error if position does not exist

Example:

trajectories.get_saved_trajectory("trajectory_01")
Parameters

trajectory_name (str) – name of the trajectory

Raises

NiryoRosWrapperException – If trajectory file doesn’t exist

Returns

list of [j1, j2, j3, j4, j5, j6] in rad

Return type

list[list[float]]

execute_registered_trajectory(trajectory_name, callback=None)[source]

Execute trajectory from Ned’s memory If a callback function is not passed in parameter, the function will be blocking. Otherwise, the callback will be called when the execution of the function is finished.

Examples:

trajectories.execute_trajectory_saved("trajectory_01")

from threading import Event
trajectory_event = Event()
trajectory_event.clear()

def trajectory_callback(result):
    print(result)
    trajectory_event.set()

trajectories.execute_trajectory_saved("trajectory_01", callback=trajectory_callback)
trajectory_event.wait()
Parameters

callback (function) – Callback invoked on successful execution.

Return type

None

execute_trajectory_from_poses(list_poses, dist_smoothing=0.0, callback=None)[source]

Execute trajectory from list of poses If a callback function is not passed in parameter, the function will be blocking. Otherwise, the callback will be called when the execution of the function is finished.

Examples:

trajectory = [[0.3, 0.1, 0.3, 0., 0., 0., 1.],
              [0.3, -0.1, 0.3, 0., 0., 0., 1.],
              [0.3, -0.1, 0.4, 0., 0., 0., 1.],
              [0.3, 0.1, 0.4, 0., 0., 0., 1.]]

trajectories.execute_trajectory_from_poses(trajectory)
trajectories.execute_trajectory_from_poses(trajectory, dist_smoothing=0.02)
trajectories.execute_trajectory_from_poses([[0.3, 0.1, 0.3, 0., 0., 0., 1.], #[x,y,z,qx,qy,qz,qw]
                                     PoseObject(0.3, -0.1, 0.3, 0., 0., 0.),
                                     [0.3, -0.1, 0.4, 0., 0., 0.], #[x,y,z,roll,pitch,yaw]
                                     PoseObject(0.3, 0.1, 0.4, 0., 0., 0.)])

from threading import Event
trajectory_event = Event()
trajectory_event.clear()

def trajectory_callback(result):
    print(result)
    trajectory_event.set()

trajectories.execute_trajectory_from_poses(trajectory, callback=trajectory_callback)
trajectory_event.wait()
Parameters
  • callback (function) – Callback invoked on successful execution.

  • list_poses (list[Union[tuple[float], list[float], PoseObject]]) – List of: [x,y,z,qx,qy,qz,qw] or [x,y,z,roll,pitch,yaw] or PoseObject

  • dist_smoothing (float) – Distance from waypoints before smoothing trajectory

Return type

None

save_trajectory(trajectory, trajectory_name, description)[source]

Save trajectory in robot’s memory

Examples:

trajectory = [[0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
              [1.57, 0.0, 0.0, 0.0, -1.57, 0.0],
              [-1.57, 0.0, 0.0, 0.0, -1.57, 0.0]]

trajectories.save_trajectory(trajectory, "trajectory_1", "test description trajectory_1")
Parameters
  • trajectory (list[joints]) – list of joints positions the robot needs to pass by in the trajectory

  • trajectory_name (str) – name you give trajectory in the robot’s memory

  • description (str) – description you give trajectory in the robot’s memory

Return type

None

save_last_learned_trajectory(trajectory_name, description)[source]

Save last executed trajectory in robot’s memory

Examples:

trajectories.save_last_learned_trajectory("trajectory_1", "test description trajectory_1")
Parameters
  • trajectory_name (str) – name you give trajectory in the robot’s memory

  • description (str) – description you give trajectory in the robot’s memory

Return type

None

delete_trajectory(trajectory_name)[source]

Delete trajectory from robot’s memory

Example:

if "trajectory_1" in trajectories.get_saved_trajectory_list():
    trajectories.delete_trajectory("trajectory_1")
Return type

None

clean_trajectory_memory()[source]

Delete all trajectories from robot’s memory

Example:

trajectories.clean_trajectory_memory()
Return type

None

get_saved_trajectory_list()[source]

Get list of trajectories’ name saved in robot memory

Example:

if "trajectory_1" in trajectories.get_saved_trajectory_list():
    trajectories.delete_trajectory("trajectory_1")
Returns

list of tuple(trajectory name, trajectory definition)

Return type

list[tuple(str, str)]

update_trajectory_infos(name, new_name, description='')[source]

Update the trajectory informations: name and description

Example:

trajectories.update_trajectory_infos("trajectory_1", "trajectory_2", callback="change description")
Parameters
  • name (str) – name of the trajectory you want to change infos

  • new_name (str) – new name you want to give to the trajectory

  • description (str) – new description you want to give to the trajectory

Return type

None