Joint Trajectory Playback Example

Revision as of 13:23, 7 November 2016 by Swang (talk | contribs) (Code Walkthrough)
Jump to: navigation , search

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

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 intera_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.

Usage

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

$ rosrun intera_interface robot_enable.py

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

$ rosrun intera_examples recorder.py -f <position_file_name>

The recorder is now recording joint positions with corresponding timestamps for robot arm. Move the arms while holding the cuffs. If the position file name exists, the function will overwrite existing file.

NOTE: You can open and close the gripper while recording by using the robot's cuff buttons: Oval(lower) = Close, Circle(Upper) = Open

Start the joint trajectory controller, ex:

$ rosrun intera_interface joint_trajectory_action_server.py --mode velocity

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

$ rosrun intera_examples joint_trajectory_file_playback.py -f <position_file_name>

The robot arm 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.

Arguments

Important Arguments: Arguments for joint_trajectory_action_server.py

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

$ rosrun intera_interface joint_trajectory_action_server.py -h
Intera SDK Joint Trajectory Controller

    Unlike other robots running ROS, this is not a Motor Controller plugin,
    but a regular node using the SDK interface.    

optional arguments:
  -h, --help            show this help message and exit
  -l {right}, --limb {right}
                        joint trajectory action server limb (default: right)
  -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)

Important Arguments: Arguments for joint_trajectory_file_playback.py

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

$ rosrun intera_interface joint_trajectory_file_playback.py -h
RSDK Joint Trajectory Example: File Playback

    Plays back joint positions honoring timestamps recorded
    via the joint_recorder example.

    Run the joint_recorder.py example first to create a recording
    file for use with this example. Then make sure to start the
    joint_trajectory_action_server before running this example.

    This example will use the joint trajectory action server
    with velocity control to follow the positions and times of
    the recorded motion, accurately replicating movement speed
    necessary to hit each trajectory point on time.

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

Interfaces

ROS APIs:

See the API Reference page for details.

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

Intera_interface APIs:

JointTrajectoryActionServer class: joint_trajectory_action_server.py