This example demonstrates the usage of the Joint Recorder interface to record the joint positions traversed by the robot. It records the timestamped joint and gripper positions to a file.
Interface - JointRecorder.record()
Now, let's break down the code.
- import argparse
- import rospy
- import baxter_interface
- from baxter_examples import JointRecorder
- from baxter_interface import CHECK_VERSION
This imports the baxter interface for accessing the limb and the gripper class. The
baxter_interface is imported to use its
JointRecorder class. The
CHECK_VERSION is imported to check if the software running on the robot would be compatible with this local version. It is not necessary to check the version in custom programs.
- def main():
- """RSDK Joint Recorder Example
- Record timestamped joint and gripper positions to a file for
- later play back.
- Run this example while moving the robot's arms and grippers
- to record a time series of joint and gripper positions to a
- new csv file with the provided *filename*. This example can
- be run in parallel with any other example or standalone
- (moving the arms in zero-g mode while pressing the cuff
- buttons to open/close grippers).
- You can later play the movements back using one of the
- *_file_playback examples.
- epilog = """
- Related examples:
- joint_position_file_playback.py; joint_trajectory_file_playback.py.
- arg_fmt = argparse.RawDescriptionHelpFormatter
- parser = argparse.ArgumentParser(formatter_class=arg_fmt,
- required = parser.add_argument_group('required arguments')
- '-f', '--file', dest='filename', required=True,
- help='the file name to record to'
- '-r', '--record-rate', type=int, default=100, metavar='RECORDRATE',
- help='rate at which to record (default: 100)'
- args = parser.parse_args(rospy.myargv()[1:])
The destination file to store the joint positions along with its path is captured by the parser. The rate at which the positions are to be captured and stored is also captured.
- print("Initializing node... ")
- print("Getting robot state... ")
- rs = baxter_interface.RobotEnable(CHECK_VERSION)
- print("Enabling robot... ")
- recorder = JointRecorder(args.filename, args.record_rate)
- print("Recording. Press Ctrl-C to stop.")
- if __name__ == '__main__':
The node is initialized and the robot is enabled. The
record() method captures the joint and gripper positions at a specified rate and stores them to the destination file.