Difference between revisions of "Joint Trajectory Playback Example"

Jump to: navigation , search
(Edit)
(Usage)
Line 2: Line 2:
 
<div class="title-block">
 
<div class="title-block">
  
<span style="font-size:120%;">'''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.'''</span>
+
<span style="font-size:120%;">'''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.'''</span>
  
 
</div>
 
</div>
Line 10: Line 10:
 
== Code Walkthrough ==  
 
== Code Walkthrough ==  
 
<span style="font-size:120%;">[[Joint Trajectory Playback Example -_Code_Walkthrough | Joint Trajectory Playback Example - Code Walkthrough]]</span>
 
<span style="font-size:120%;">[[Joint Trajectory Playback Example -_Code_Walkthrough | Joint Trajectory Playback Example - Code Walkthrough]]</span>
 +
 +
</div>
 +
 +
<div class="content-block">
 +
 +
== 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.
  
 
</div>
 
</div>
Line 23: Line 31:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 +
Record a joint position file using the recorder.py example, ex:
  
Start the joint position waypoints example program, you can specify the joint position motion speed ratio <code>-s</code> or joint position accuracy(rad) <code>-a</code> on which we will run the example.
 
 
For example, run the example with 0.1 speed ratio and 0.1 accuracy:
 
 
<syntaxhighlight lang="bash" enclose="div">
 
<syntaxhighlight lang="bash" enclose="div">
$ rosrun intera_examples joint_position_waypoints.py -s 0.1 -a 0.1
+
$ rosrun intera_examples recorder.py -f <position_file_name>
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 +
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.
  
Moving the arm in zero-g mode, when we reach a joint position configuration we would like to record, press that [[Navigator | navigator]] wheel.
+
NOTE: You can open and close the gripper while recording by using the robot's cuff buttons: Oval(lower) = Close, Circle(Upper) = Open
 
 
  
You will then be prompted with instructions for recording joint position waypoints.
+
Start the joint trajectory controller, ex:
  
 
<syntaxhighlight lang="bash" enclose="div">
 
<syntaxhighlight lang="bash" enclose="div">
Press Navigator 'OK/Wheel' button to record a new joint joint position waypoint.
+
$ rosrun intera_interface joint_trajectory_action_server.py --mode velocity
Press Navigator 'Rethink' button when finished recording waypoints to begin playback.
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
+
In another RSDK terminal session, Run the joint trajectory playback example program, ex:
Moving the arm in zero-g mode, when we reach a joint position configuration we would like to record, press that [[Navigator | navigator]] wheel.
 
 
 
 
 
You will get the feedback that the joint position waypoint has been recorded:
 
  
 
<syntaxhighlight lang="bash" enclose="div">
 
<syntaxhighlight lang="bash" enclose="div">
Waypoint Recorded
+
$ rosrun intera_examples joint_trajectory_file_playback.py -f <position_file_name>
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 +
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.
  
When done recording waypoints, pressing the [[Hardware_Components#Navigator | navigator's]] 'Rethink' button will begin playback.
+
</div>
  
<syntaxhighlight lang="bash" enclose="div">
+
<div class="content-block">
[INFO] [WallTime: 1399571721.540300] Waypoint Playback Started
 
  Press Ctrl-C to stop...
 
</syntaxhighlight>
 
  
 
+
== Arguments ==
The program will begin looping through the recorded joint positions. When the previous joint position command is fully achieved (within the accuracy threshold), the next recorded joint position will be commanded.
+
'''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:
  
 
<syntaxhighlight lang="bash" enclose="div">
 
<syntaxhighlight lang="bash" enclose="div">
Waypoint playback loop #1
+
$ rosrun intera_interface joint_trajectory_action_server.py -h
Waypoint playback loop #2
 
...
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Pressing <code> Control-C </code> at any time will stop playback and exit the example.
+
<syntaxhighlight lang="bash" enclose="div">
 +
Intera SDK Joint Trajectory Controller
  
</div>
+
    Unlike other robots running ROS, this is not a Motor Controller plugin,
 +
    but a regular node using the SDK interface.   
  
<div class="content-block">
+
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)
  
== Arguments ==
+
</syntaxhighlight>
  
'''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:
<code> -s </code> or <code> --speed </code>: The joint position motion speed ratio [0.0-1.0] (default:= 0.3)
 
 
 
<code> -a </code> or <code> --accuracy </code>: The threshold in Radians at which the current joint position command is considered successful before sending the next following joint position command. (default:= 0.008726646)
 
 
 
See the joint position waypoint's available arguments on the command line by passing joint_position_waypoints.py the <code>-h</code>, help argument:
 
 
<syntaxhighlight lang="bash" enclose="div">
 
<syntaxhighlight lang="bash" enclose="div">
$ rosrun baxter_examples joint_position_waypoints.py -h
+
$ rosrun intera_interface joint_trajectory_file_playback.py -h
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
<syntaxhighlight lang="bash" enclose="div">
 
<syntaxhighlight lang="bash" enclose="div">
usage: joint_position_waypoints.py [-h] [-s SPEED] [-a ACCURACY]
+
RSDK Joint Trajectory Example: File Playback
  
RSDK Joint Position Waypoints Example
+
    Plays back joint positions honoring timestamps recorded
 +
    via the joint_recorder example.
  
     Records joint positions each time the navigator 'OK/wheel'
+
     Run the joint_recorder.py example first to create a recording
     button is pressed.
+
     file for use with this example. Then make sure to start the
    Upon pressing the navigator 'Rethink' button, the recorded joint positions
+
     joint_trajectory_action_server before running this example.
     will begin playing back in a loop.
 
   
 
  
 +
    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:
 
optional arguments:
 
   -h, --help            show this help message and exit
 
   -h, --help            show this help message and exit
   -s SPEED, --speed SPEED
+
   -l LOOPS, --loops LOOPS
                        joint position motion speed ratio [0.0-1.0] (default:=
+
                        number of playback loops. 0=infinite. (default: 1)  
                        0.3)
+
</syntaxhighlight>
  -a ACCURACY, --accuracy ACCURACY
+
 
                        joint position accuracy (rad) at which waypoints must
 
                        achieve
 
  
</syntaxhighlight>
 
  
 
</div>
 
</div>

Revision as of 03:36, 7 November 2016

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)

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)