Examples: Movement

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

If you want to see more, you can look at joints and poses functions

Important

In the following sections, you are supposed to be already connected to a calibrated robot. The robot’s instance is saved 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

Joints positions are represented by the object JointsPosition. It can take any number of joints values, but you’ll have to give it 6 values in order to work with a Ned2. The JointsPosition is an iterable object, which means you can operate with it as if it was a list, for example

To do a move joints, you can either use the move() function or give a JointsPosition to the joints() setter, at your convenience

1 JointsPosition(0.0, 0.0, 0.0, 0.0, 0.0, 0.0)
2
3 # with the move function:
4 robot.move(JointsPosition(0.0, 0.0, 0.0, 0.0, 0.0, 0.0))
5
6 #with setter
7 robot.joints = JointsPosition(-0.2, 0.3, 0.2, 0.3, -0.6, 0.0)

You should note that these 2 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 JointsPosition object

1 # with function
2 joints_read = robot.get_joints()
3
4 # with getter
5 joints_read = robot.joints

Pose

Move Pose

To perform a moveP, you have to use the PoseObject object:

As for MoveJ, it is possible to use the move() or the pose setter, at your convenience

1pose_target = PoseObject(0.2, 0.0, 0.2, 0.0, 0.0, 0.0)
2
3# Moving Pose with function
4robot.move(pose_target)
5
6# Moving Pose with setter
7robot.pose = pose_target

Get Pose

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

1  # Getting Joints with function
2  pose_read = robot.get_pose()
3
4  # Getting Joints with getter
5  pose_read = robot.pose

How to use the PoseObject

The PoseObject is a Python object which allows to store all poses’ 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 loop, you can use the copy_with_offsets() method

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