joint_recorder.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 # Copyright (c) 2013-2015, Rethink Robotics
00004 # All rights reserved.
00005 #
00006 # Redistribution and use in source and binary forms, with or without
00007 # modification, are permitted provided that the following conditions are met:
00008 #
00009 # 1. Redistributions of source code must retain the above copyright notice,
00010 #    this list of conditions and the following disclaimer.
00011 # 2. Redistributions in binary form must reproduce the above copyright
00012 #    notice, this list of conditions and the following disclaimer in the
00013 #    documentation and/or other materials provided with the distribution.
00014 # 3. Neither the name of the Rethink Robotics nor the names of its
00015 #    contributors may be used to endorse or promote products derived from
00016 #    this software without specific prior written permission.
00017 #
00018 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00019 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00020 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00021 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00022 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00023 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00024 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00025 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00026 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00027 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00028 # POSSIBILITY OF SUCH DAMAGE.
00029 
00030 import argparse
00031 
00032 import rospy
00033 
00034 import baxter_interface
00035 from baxter_examples import JointRecorder
00036 
00037 from baxter_interface import CHECK_VERSION
00038 
00039 
00040 def main():
00041     """RSDK Joint Recorder Example
00042 
00043     Record timestamped joint and gripper positions to a file for
00044     later play back.
00045 
00046     Run this example while moving the robot's arms and grippers
00047     to record a time series of joint and gripper positions to a
00048     new csv file with the provided *filename*. This example can
00049     be run in parallel with any other example or standalone
00050     (moving the arms in zero-g mode while pressing the cuff
00051     buttons to open/close grippers).
00052 
00053     You can later play the movements back using one of the
00054     *_file_playback examples.
00055     """
00056     epilog = """
00057 Related examples:
00058   joint_position_file_playback.py; joint_trajectory_file_playback.py.
00059     """
00060     arg_fmt = argparse.RawDescriptionHelpFormatter
00061     parser = argparse.ArgumentParser(formatter_class=arg_fmt,
00062                                      description=main.__doc__,
00063                                      epilog=epilog)
00064     required = parser.add_argument_group('required arguments')
00065     required.add_argument(
00066         '-f', '--file', dest='filename', required=True,
00067         help='the file name to record to'
00068     )
00069     parser.add_argument(
00070         '-r', '--record-rate', type=int, default=100, metavar='RECORDRATE',
00071         help='rate at which to record (default: 100)'
00072     )
00073     args = parser.parse_args(rospy.myargv()[1:])
00074 
00075     print("Initializing node... ")
00076     rospy.init_node("rsdk_joint_recorder")
00077     print("Getting robot state... ")
00078     rs = baxter_interface.RobotEnable(CHECK_VERSION)
00079     print("Enabling robot... ")
00080     rs.enable()
00081 
00082     recorder = JointRecorder(args.filename, args.record_rate)
00083     rospy.on_shutdown(recorder.stop)
00084 
00085     print("Recording. Press Ctrl-C to stop.")
00086     recorder.record()
00087 
00088     print("\nDone.")
00089 
00090 if __name__ == '__main__':
00091     main()


baxter_examples
Author(s): Rethink Robotics Inc.
autogenerated on Thu Aug 27 2015 12:31:14