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.analog_io as AIO
00035
00036
00037 def test_interface(io_component='torso_fan'):
00038 """Ramps an Analog component from 0 to 100, then back down to 0."""
00039 rospy.loginfo("Ramping output of Analog IO component: %s", io_component)
00040
00041 b = AIO.AnalogIO(io_component)
00042 rate = rospy.Rate(2)
00043
00044
00045 print b.state()
00046
00047
00048 for i in range(0, 101, 10):
00049 b.set_output(i)
00050 print i
00051 rate.sleep()
00052
00053 print b.state()
00054
00055
00056 for i in range(100, -1, -10):
00057 b.set_output(i)
00058 print i
00059 rate.sleep()
00060
00061 b.set_output(0)
00062
00063
00064 def main():
00065 """RSDK Analog IO Example: Ramp
00066
00067 Ramps the output of an AnalogIO component from 0 to 100,
00068 and then back down again. Demonstrates the use of the
00069 baxter_interface.AnalogIO class.
00070
00071 Run this example and listen to the fan as output changes.
00072 """
00073 epilog = """
00074 ROS Parameters:
00075 ~component_id - name of AnalogIO component to use
00076
00077 Baxter AnalogIO
00078 Note that 'AnalogIO' components are only those that use
00079 the custom ROS Messages baxter_core_msgs/AnalogIOState
00080 and baxter_core_msgs/AnalogOutputCommand.
00081
00082 AnalogIO component names can be found on the Wiki or by
00083 echoing the names field of the analog_io_states topic:
00084 $ rostopic echo -n 1 /robot/analog_io_states/names
00085 """
00086 arg_fmt = argparse.RawDescriptionHelpFormatter
00087 parser = argparse.ArgumentParser(formatter_class=arg_fmt,
00088 description=main.__doc__,
00089 epilog=epilog)
00090 parser.add_argument(
00091 '-c', '--component', dest='component_id', default='torso_fan',
00092 help='name of Analog IO component to use (default:= torso_fan)'
00093 )
00094 args = parser.parse_args(rospy.myargv()[1:])
00095
00096 rospy.init_node('rsdk_analog_io_rampup', anonymous=True)
00097 io_component = rospy.get_param('~component_id', args.component_id)
00098 test_interface(io_component)
00099
00100 if __name__ == '__main__':
00101 main()