Examples: Movement

This document shows how to control Ned in order to make Move Joints & Move Pose.

If you want see more, you can look at PyNiryo - Arm

Important

In following sections, it is supposed that you are already connected to a calibrated robot. The robot instance is save in the variable robot. To know how to do so, go look at section Examples: Basics

Danger

If you are using the real robot, make sure the environment around it is clear

Joints

Move Joints

To make a moveJ, you need to pass :

  • a list of 6 floats : [j1, j2, j3, j4, j5, j6]

It is possible to pass these parameters the function move_joints() or a via the joints setter, at your convenience:

# Moving Joints with function & a list of floats
robot.arm.move_joints([-0.5, -0.6, 0.0, 0.3, 0.0, 0.0])

# Moving Joints with setter & 6 floats
robot.arm.joints = 0.2, -0.4, 0.0, 0.0, 0.0, 0.0

# Moving Joints with setter & a list of floats
robot.arm.joints = [-0.2, 0.3, 0.2, 0.3, -0.6, 0.0]

You should note that these 4 commands are doing exactly the same thing ! In your future scripts, chose the one you prefer, but try to remain consistent to keep a good readability

Get Joints

To get actual joint positions, you can use the function get_joints() or the joints getter. Both will return a list of the 6 joints position:

# Getting Joints with function
joints_read = robot.arm.get_joints()

# Getting Joints with getter
joints_read = robot.arm.joints

Hint

As we are developing in Python, we can unpack list very easily, which means that we can retrieve joints value in 6 variables by writing j1, j2, j3, j4, j5, j6 = robot.arm.get_joints()

Pose

Move Pose

To perform a moveP, you can pass :

  • a list of 6 floats : [x, y, z, roll, pitch, yaw]

  • a PoseObject

As for MoveJ, it is possible to pass these parameters the function move_pose() or the pose setter, at your convenience:

pose_target = [0.2, 0.0, 0.2, 0.0, 0.0, 0.0]
pose_target_obj = PoseObject(0.2, 0.0, 0.2, 0.0, 0.0, 0.0)

# Moving Pose with function
robot.arm.move_pose(0.2, 0.0, 0.2, 0.0, 0.0, 0.0)
robot.arm.move_pose(pose_target)
robot.arm.move_pose(pose_target_obj)

# Moving Pose with setter
robot.arm.pose = (0.2, 0.0, 0.2, 0.0, 0.0, 0.0)
robot.arm.pose = pose_target
robot.arm.pose = pose_target_obj

Each of these 6 commands are doing the same thing

Get Pose

To get end effector actual pose, you can use the function get_pose or the pose getter. Both will return a PoseObject

# Getting Joints with function
pose_read = robot.arm.get_pose()

# Getting Joints with getter
pose_read = robot.arm.pose

How to use the PoseObject

The PoseObject is a Python Object which allow to store all pose’s 6 coordinates (x, y, z, roll, pitch, yaw) in one single instance. It can be converted into a list if needed with the method to_list()

It also allows to create new PoseObject with some offset, much easier than copying list and editing only 1 or 2 values. For instance, imagine that we want to shift the place pose by 5 centimeters at each iteration of a for loop, you can use the copy_with_offsets() method:

pick_pose = PoseObject(
x=0.30, y=0.0, z=0.15,
roll=0, pitch=1.57, yaw=0.0
)
first_place_pose = PoseObject(
    x=0.0, y=0.2, z=0.15,
    roll=0, pitch=1.57, yaw=0.0
)
for i in range(5):
    robot.arm.move_pose(pick_pose)
    new_place_pose = first_place_pose.copy_with_offsets(x_offset=0.05 * i)
    robot.arm.move_pose(new_place_pose)