Wiki

Author: Alessandro Di Fava < alessandro.difava@pal-robotics.com >

Maintainer: Jordi Pages < jordi.pages@pal-robotics.com >

Support: tiago-support@pal-robotics.com

Source: https://github.com/pal-robotics/tiago_dual_tutorials.git

(!) Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.

Joint Trajectory Controller

Description: Example of how to move TIAGo++'s arms using a joint trajectory action.

Keywords: joint, trajectory controller

Tutorial Level: BEGINNER

Next Tutorial: Moving individual joints

traj_2.png

Purpose

This tutorial shows how to use the joint_trajectory_controller to move the arms of TIAGo++. The action can be used to give a trajectory to the arm expressed in several waypoints.

Pre-requisites

First make sure that the tutorials are properly installed along with the TIAGo++ simulation, as shown in the Tutorials Installation Section.

Available interfaces

There are two mechanisms for sending trajectories to the controller, as written in joint_trajectory_controller. By means of the action interface or the topic interface. Both use the trajectory_msgs/JointTrajectory message to specify trajectories.

For the TIAGo++ the following interfaces are available: torso control, head control, arm left control, arm right control. The following interfaces are used.

Torso controller

The torso prismatic joint can be controlled with the following joint trajectory interfaces:

/torso_controller/command (trajectory_msgs/JointTrajectory)

/torso_controller/follow_joint_trajectory (control_msgs/FollowJointTrajectoryAction)

Head controller

The 2 joints of the head can be controlled defining trajectories using the following interfaces:

/head_controller/command (trajectory_msgs/JointTrajectory)

/head_controller/follow_joint_trajectory (control_msgs/FollowJointTrajectoryAction)

Arm left controller

Trajectories for the 7 joints of the left arm can be controlled using the following interfaces:

/arm_left_controller/command (trajectory_msgs/JointTrajectory)

/arm_left_controller/follow_joint_trajectory (control_msgs/FollowJointTrajectoryAction)

Arm right controller

Trajectories for the 7 joints of the right arm can be controlled using the following interfaces:

/arm_right_controller/command (trajectory_msgs/JointTrajectory)

/arm_right_controller/follow_joint_trajectory (control_msgs/FollowJointTrajectoryAction)

Hey5 left hand controller

For the version of TIAGo++ with the Hey5 hands the hand left control interface is also available:

/hand_left_controller/command (trajectory_msgs/JointTrajectory)

/hand_left_controller/follow_joint_trajectory (control_msgs/FollowJointTrajectory)

Hey5 right hand controller

For the version of TIAGo++ with the Hey5 hands the hand right control interface is also available:

/hand_right_controller/command (trajectory_msgs/JointTrajectory)

/hand_right_controller/follow_joint_trajectory (control_msgs/FollowJointTrajectory)

Gripper left controller

For the version of TIAGo++ with the grippers the gripper left control interface is available:

/parallel_gripper_left_controller/command (trajectory_msgs/JointTrajectory)

/parallel_gripper_left_controller/follow_joint_trajectory (control_msgs/FollowJointTrajectoryAction) /gripper_left_controller/command (trajectory_msgs/JointTrajectory)

Gripper right controller

For the version of TIAGo++ with the grippers the gripper right control interface is available:

/parallel_gripper_right_controller/command (trajectory_msgs/JointTrajectory)

/parallel_gripper_right_controller/follow_joint_trajectory (control_msgs/FollowJointTrajectoryAction) /gripper_right_controller/command (trajectory_msgs/JointTrajectory)

Execution

Open two consoles and source the public simulation workspace as follows:

Launching the simulation

In the first console launch for example the following simulation

Gazebo will show up with TIAGo++ in an empty world.

tiago++_gazebo_empty_gripper.jpg

Wait until TIAGo++ has tucked its arm. Then you may proceed with the next steps.

Launching the nodes

Now we are going to run an example with two waypoints that will bring TIAGo++ to the following joint space configurations both for the left and the right arms. First waypoint:

Second waypoint:

The node that will take care to execute the set of waypoints to reach such a kinematic configuration is run_dual_traj_control included in tiago_dual_trajectory_controller package and has to be called as follows

An example of plan executed by the node is depicted in the following sequence of images:

traj_1.png

traj_2.png

traj_3.png

traj_4.png

traj_5.png

traj_6.png

Inspecting the code

The code to implement such a node is shown below. Note that the key parts of the code are:

Note that for the first waypoint, for each joint in the trajectory, we use a velocity of 1.0 m/s. It specifies the velocity of the trajectory when reaching the waypoint. We obtain it with the following line of code

Toggle line numbers
  62     goal.trajectory.points[index].velocities[j] = 1.0;

As we want the robot to move smoothly when reaching the first target waypoint. By setting the velocity to 0.0 m/s will cause a step-wise movement, where the robot will stop in each waypoint. We set the velocity to 0.0 m/s just for the last waypoint.

The joint_trajectory_controller will map the position+velocity trajectory to position commands through a PID loop.

Joint trajectory messages allow to specify the time at which the trajectory should start executing by means of the header timestamp. In the following line of code, the node will start the given trajectory 1s from "now"

Toggle line numbers
 150   arm_left_goal.trajectory.header.stamp = ros::Time::now() + ros::Duration(1.0);

The required control commands are sent to the arms controller through the topic of their action interfaces:

Wiki: Robots/TIAGo++/Tutorials/motions/trajectory_controller (last edited 2023-03-06 14:09:16 by thomaspeyrucain)