Joint Trajectory Playback Example

From sdk-wiki
Revision as of 19:42, 22 November 2016 by Imcmahon (talk | contribs) (Usage)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Summary

Enable the robot joint trajectory interface, parse a file created using the joint position recorder example, and send a the resulting joint trajectory to the action server.

Code Walkthrough

Joint Position Recorder - Code Walkthrough, Joint Trajectory File Playback - Code Walkthrough

Quickstart

Verify that the robot is enabled from an RSDK terminal session, ex:

$ rosrun baxter_tools enable_robot.py -e

Record a joint position file using the joint_recorder.py example, ex:

$ rosrun baxter_examples joint_recorder.py -f <example_file>

The recorder is now recording joint positions with corresponding timestamps for both arms. Move the arms while holding the cuffs.

NOTE: You can open and close the grippers while recording by using Baxter's cuff buttons: Oval = Close, Circle = Open

Press any key to exit when done recording.

Start the joint trajectory controller, ex:

$ rosrun baxter_interface joint_trajectory_action_server.py --mode velocity

In another RSDK terminal session, Run the joint trajectory playback example program, ex:

$ rosrun baxter_examples joint_trajectory_file_playback.py -f <example_file>

Both arms will then be commanded to repeat the trajectory recorded during the joint position recording. The difference between this example and the joint_position playback example is that the trajectory controller has the ability to honor the velocities (due to the timestamps) to more accurately repeating the recorded trajectory.

Overview

A commonly used ROS method for robot arm motion control is the joint trajectory action interface. The trajectory_controller and it's corresponding joint trajectory action server is the baxter_interface implementation to support this action interface. This example shows usage for launching the joint trajectory action server, and parsing of a text file describing timestamped joint position goals into a joint trajectory action call to be commanded to the joint trajectory action server.

For more information on Baxter's arms, see Using the Arms.

Usage

See the trajectory controller's usage on the command line by passing trajectory_controller.py the -h, help argument:

Joint Trajectory Action Server Usage:

$ rosrun baxter_interface joint_trajectory_action_server.py -h

usage: joint_trajectory_action_server.py [-h] [-l {both,left,right}] [-r RATE]
                                         [-m {position_w_id,position,velocity}]

optional arguments:
  -h, --help            show this help message and exit
  -l {both,left,right}, --limb {both,left,right}
                        joint trajectory action server limb (default: both)
  -r RATE, --rate RATE  trajectory control rate (Hz) (default: 100.0)
  -m {position_w_id,position,velocity}, --mode {position_w_id,position,velocity}
                        control mode for trajectory execution (default:
                        position_w_id)

Joint Trajectory File Playback Usage:

$ rosrun baxter_examples joint_trajectory_file_playback.py -h

usage: joint_trajectory_file_playback.py [-h] -f PATH [-l LOOPS]

required arguments:
  -f PATH, --file PATH  path to input file
optional arguments:
  -h, --help            show this help message and exit
  -l LOOPS, --loops LOOPS
                        number of playback loops. 0=infinite.

Video

Interfaces

ROS APIs

See the API Reference page for details.

  • Joint Trajectory Action Server - /robot/limb/right/follow_joint_trajectory [control_msgs/FollowJointTrajectoryAction]
  • Joint Trajectory Action Server - /robot/limb/left/follow_joint_trajectory [control_msgs/FollowJointTrajectoryAction]

baxter_interface APIs

  • JointTrajectoryActionServer class: joint_trajectory_action_server.py

Troubleshooting

The arm is not executing the trajectory

Verify that the robot is enabled:

rosrun baxter_tools enable_robot.py -e

Verify that the trajectory controller has been started:

rosrun baxter_interface joint_trajectory_action_server.py --mode velocity