[SRC] Baxter_examples

Source: Internet
Author: User

__init__.py

# Copyright (c) 2013-2015, Rethink robotics# All rights reserved.## redistribution and use in source and binary forms, wit h or without# modification, is permitted provided that the following conditions is met:## 1. Redistributions of source code must retain the above copyright notice,# this list of conditions and the following DISCL aimer.# 2. Redistributions in binary form must reproduce the above copyright# notice, this list of conditions and the following di Sclaimer in the# documentation and/or other materials provided with the distribution.# 3. Neither the name of the Rethink robotics nor the names of its# contributors may be used to endorse or promote products Derived from# this software without specific prior written permission.## This software are provided by the COPYRIGHT HOL DERs and CONTRIBUTORS "as is" # and any EXPRESS OR implied warranties, including, but not LIMITED to, the# implied Warranti ES of merchantability and FITNESS for A particular purpose# is DISCLAimed. In NO EVENT shall the COPYRIGHT OWNER OR CONTRIBUTORS be# liable for any DIRECT, INDIRECT, incidental, special, exemplary, or# consequential damages (including, but not LIMITED to, procurement of# substitute GOODS OR SERVICES; LOSS of Use, DATA, OR profits; or business# interruption) however caused and on any theory of liability, WHETHER in# contract, STRICT liability, OR TORT (including negligence OR OTHERWISE) # arising in any-out-of-the-----the-software, even IF advised of the# Possibili TY of SUCH damage.from. Recorder Import Jointrecorder

recorder.py

# Copyright (c) 2013-2015, Rethink robotics# All rights reserved.## redistribution and use in source and binary forms, wit h or without# modification, is permitted provided that the following conditions is met:## 1. Redistributions of source code must retain the above copyright notice,# this list of conditions and the following DISCL aimer.# 2. Redistributions in binary form must reproduce the above copyright# notice, this list of conditions and the following di Sclaimer in the# documentation and/or other materials provided with the distribution.# 3. Neither the name of the Rethink robotics nor the names of its# contributors may be used to endorse or promote products Derived from# this software without specific prior written permission.## This software are provided by the COPYRIGHT HOL DERs and CONTRIBUTORS "as is" # and any EXPRESS OR implied warranties, including, but not LIMITED to, the# implied Warranti ES of merchantability and FITNESS for A particular purpose# is DISCLAimed.  In NO EVENT shall the COPYRIGHT OWNER OR CONTRIBUTORS be# liable for any DIRECT, INDIRECT, incidental, special, exemplary, or# consequential damages (including, but not LIMITED to, procurement of# substitute GOODS OR SERVICES; LOSS of Use, DATA, OR profits; or business# interruption) however caused and on any theory of liability, WHETHER in# contract, STRICT liability, OR TORT (including negligence OR OTHERWISE) # arising in any-out-of-the-----the-software, even IF advised of the# Possibili TY of SUCH damage.import rospyimport baxter_interfacefrom baxter_interface import Check_versionclass JointRecorder (        Object): Def __init__ (self, filename, rate): "" "Records joint data to a file at a specified. "" "self._filename = filename Self._raw_rate = Rate Self._rate = rospy. Rate Self._start_time = rospy.get_time () Self._done = False Self._limb_left = baxter_interface. Limb ("left") Self._limb_right =Baxter_interface. Limb ("right") Self._gripper_left = Baxter_interface. Gripper ("left", check_version) Self._gripper_right = Baxter_interface. Gripper ("right", check_version) Self._io_left_lower = Baxter_interface. Digitalio (' Left_lower_button ') Self._io_left_upper = Baxter_interface. Digitalio (' Left_upper_button ') Self._io_right_lower = Baxter_interface. Digitalio (' Right_lower_button ') Self._io_right_upper = Baxter_interface. Digitalio (' Right_upper_button ') # Verify grippers have No Errors and is calibrated if self._gripper_left.er         Ror (): Self._gripper_left.reset () if Self._gripper_right.error (): Self._gripper_right.reset () if (not self._gripper_left.calibrated () and Self._gripper_left.type ()! = ' Custom '): Self._gr Ipper_left.calibrate () if (not self._gripper_right.calibrated () and Self._gripper_right.type ()! = ' Custo M '): Self._gripper_right.calibrate ()    def _time_stamp (self): return Rospy.get_time ()-Self._start_time def Stop (self): "" "Stop Rec        Ording.        "" "If Rospy.is_shutdown (): Self.stop () return Self._done def record (self):" ""  Records the current joint positions to a CSV file if OutputFileName is provided at construction this function would        Record the latest set of joint angles in a CSV format.        This function does the not test to see if a file exists and would overwrite existing files. "" "If Self._filename:joints_left = Self._limb_left.joint_names () Joints_right = Self._limb_ Right.joint_names () with open (Self._filename, ' W ') as F:f.write (' time, ') f.write        (', '. Join ([J for J in Joints_left]) + ', ') f.write (' Left_gripper, ')        F.write (', '. Join ([J for J in Joints_right]) + ', ') f.write (' right_gripper\n ') while                        Not Self.done (): # Gripper button Presses if self._io_left_lower.state: Self._gripper_left.open () elif Self._io_left_upper.state:se Lf._gripper_left.close () if Self._io_right_lower.state:self._gripper_right.open                    () elif Self._io_right_upper.state:self._gripper_right.close ()                    Angles_left = [Self._limb_left.joint_angle (j) for J in Joints_left]                    Angles_right = [Self._limb_right.joint_angle (j) for J in Joints_right]                    F.write ("%f,"% (Self._time_stamp (),)) F.write (', '. Join ([STR (x) for x in Angles_left]) + ', ') F.write (STR (self._gripper_left.position ()) + ', ') f.write (', '. Join ([STR (x) for x in angles_right]) + ', ') F.write (str (self._gripper_right.position ()) + ' \ n ') Self._rate.sleep ()

[SRC] Baxter_examples

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.