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
00031
00032
00033
00034
00035
00036
00037 __author__ = 'Antons Rebguns'
00038 __copyright__ = 'Copyright (c) 2010-2011 Antons Rebguns'
00039
00040 __license__ = 'BSD'
00041 __maintainer__ = 'Antons Rebguns'
00042 __email__ = 'anton@email.arizona.edu'
00043
00044
00045 import sys
00046 from optparse import OptionParser
00047
00048 import roslib
00049 roslib.load_manifest('dynamixel_driver')
00050
00051 from dynamixel_driver import dynamixel_io
00052
00053 if __name__ == '__main__':
00054 parser = OptionParser(usage='Usage: %prog [options] OLD_ID NEW_ID', description='Changes the unique ID of a Dynamixel servo motor.')
00055 parser.add_option('-p', '--port', metavar='PORT', default='/dev/ttyUSB0',
00056 help='motors of specified controllers are connected to PORT [default: %default]')
00057 parser.add_option('-b', '--baud', metavar='BAUD', type="int", default=1000000,
00058 help='connection to serial port will be established at BAUD bps [default: %default]')
00059
00060 (options, args) = parser.parse_args(sys.argv)
00061
00062 if len(args) < 3:
00063 parser.print_help()
00064 exit(1)
00065
00066 port = options.port
00067 baudrate = options.baud
00068 old_id = int(args[1])
00069 new_id = int(args[2])
00070
00071 try:
00072 dxl_io = dynamixel_io.DynamixelIO(port, baudrate)
00073 except dynamixel_io.SerialOpenError, soe:
00074 print 'ERROR:', soe
00075 else:
00076 print 'Changing motor id from %d to %d...' %(old_id, new_id),
00077 if dxl_io.ping(old_id):
00078 dxl_io.set_id(old_id, new_id)
00079 print ' done'
00080 print 'Verifying new id...' ,
00081 if dxl_io.ping(new_id):
00082 print ' done'
00083 else:
00084 print 'ERROR: The motor did not respond to a ping to its new id.'
00085 else:
00086 print 'ERROR: The specified motor did not respond to id %d. Make sure to specify the correct baudrate.' % old_id