Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 import argparse
00031
00032 import rospy
00033
00034 import baxter_interface.digital_io as DIO
00035
00036
00037 def test_interface(io_component='left_itb_light_outer'):
00038 """Blinks a Digital Output on then off."""
00039 rospy.loginfo("Blinking Digital Output: %s", io_component)
00040 b = DIO.DigitalIO(io_component)
00041
00042 print "Initial state: ", b.state
00043
00044
00045 b.set_output(True)
00046 rospy.sleep(1)
00047 print "New state: ", b.state
00048
00049
00050 b.set_output(False)
00051 rospy.sleep(1)
00052 print "Final state:", b.state
00053
00054
00055 def main():
00056 """RSDK Digital IO Example: Blink
00057
00058 Turns the output of a DigitalIO component on then off again
00059 while printing the state at each step. Simple demonstration
00060 of using the baxter_interface.DigitalIO class.
00061
00062 Run this example with default arguments and watch the light
00063 on the left arm Navigator blink on and off while the console
00064 echos the state. Use the component_id argument or ROS Parameter
00065 to change the DigitalIO component used.
00066 """
00067 epilog = """
00068 ROS Parameters:
00069 ~component_id - name of DigitalIO component to use
00070
00071 Baxter DigitalIO
00072 Note that 'DigitalIO' components are only those that use
00073 the custom ROS Messages baxter_core_msgs/DigitalIOState
00074 and baxter_core_msgs/DigitalOutputCommand.
00075
00076 Component names can be found on the Wiki, or by echoing
00077 the names field of the digital_io_states topic:
00078 $ rostopic echo -n 1 /robot/digital_io_states/names
00079 """
00080 arg_fmt = argparse.RawDescriptionHelpFormatter
00081 parser = argparse.ArgumentParser(formatter_class=arg_fmt,
00082 description=main.__doc__,
00083 epilog=epilog)
00084 parser.add_argument(
00085 '-c', '--component', dest='component_id',
00086 default='left_itb_light_outer',
00087 help=('name of Digital IO component to use'
00088 ' (default: left_itb_light_outer)')
00089 )
00090 args = parser.parse_args(rospy.myargv()[1:])
00091
00092 rospy.init_node('rsdk_digital_io_blink', anonymous=True)
00093 io_component = rospy.get_param('~component_id', args.component_id)
00094 test_interface(io_component)
00095
00096 if __name__ == '__main__':
00097 main()