The Joint Position Control Examples demonstrate how to use position control to move and sense the arm based on joint angles. Examples include keyboard or joystick based user control of arm angles, along with complementary example programs to record and playback joint positions.
The joint_position example allows control of Baxter's arm in joint position mode. Either the keyboard or a joystick can be used as a controller. Joint names are labeled below.
Note: For control of Head Joints, see the Head Wobbler Example.
Start the example joint_position program using the keyboard to control Baxter:
$ rosrun baxter_examples joint_position_keyboard.py
To run the example joint_position program using a joystick game controller to control the joints:
First ensure that joy drivers are installed.
$ rospack find joy
If it returns an error.
[rospack] Error: stack/package joy not found
$ sudo apt-get install ros-indigo-joystick-drivers
Run the above
rospack command again to ensure that the drivers are successfully installed. If it again returns an error <redirect to troubleshooting section that shows to source the bash script>
To run the example:
$ roslaunch baxter_examples joint_position_joystick.launch joystick:=<joystick_type>
<joystick_type> is 'xbox', 'logitech', or 'ps3'.
(If using a ps3, make sure you run the node from the ROS ps3joy package in a separate sudo terminal. See instructions here: ps3joy )
Joystick Button Mappings
NOTE: Don't forget to calibrate each gripper before using gripper open/close.
|Function 1 or 2 (e.g. Select/Select)||Help||<Any Keyboard key>||Quit|
|Left Button (X)||right: gripper calibrate||Right Button (B)||left: gripper calibrate|
|Top Button (Y)||Bottom Button (A)|
|Left Trigger [PRESS]||right: gripper close||Right Trigger [PRESS]||left: gripper close|
|Left Trigger [RELEASE]||right: gripper open||Right Trigger [RELEASE]||left: gripper open|
|Left Bumper|| right: cycle
||Right Bumper|| left: cycle |
|Left Stick Horizontal|| right: increase/decrease |
|Left Stick Vertical|| right: increase/decrease |
|Right Stick Horizontal|| left: increase/decrease |
|Right Stick Vertical|| left: increase/decrease |
NOTE: The 'joystick left <-> robot right' mappings are not typos; they assume the user is in front of the robot when using the joystick. Press any keyboard key to quit.
NOTE: The left and right bumper buttons will cycle through the joints that are controlled with the left and right stick (
<current joint 1> and
<current joint 2>). The order the joints are cycled through is S0-S1-E0-E1-W0-W1-W2.
Alternative Manual Start
Alternatively, you can run the joint_position example and the joy_node (joystick driver) independently in their own shells:
1. Initialize an environment and run the
$ cd ~/ros_ws $ ./baxter.sh $ rosrun joy joy_node
2. From another shell, repeat the initialization and run the example program:
= repeat lines 1-2 above = $ rosrun baxter_examples joint_position_joystick.py -j xbox
For the joystick examples to work, the joy_node driver must be running at the same time as the example. Using any of the other one-line launch commands to start the joystick examples is really just using a short-cut to start two programs at once.
Recording Joint Positions
To start recording the joint positions at any time use:
$ rosrun baxter_examples joint_recorder.py -f <filename>
NOTE: You can open and close the grippers while recording by using Baxter's cuff buttons: Oval = Close, Circle = Open
After you have finished recording, stop the joint_position program using <Ctrl-C> or hit one of the function 1 or 2 buttons on the game controller.
To playback the recording use:
$ rosrun baxter_examples joint_position_file_playback.py -f <filename>