37 __author__ =
'Antons Rebguns' 38 __copyright__ =
'Copyright (c) 2010-2011 Antons Rebguns' 41 __maintainer__ =
'Antons Rebguns' 42 __email__ =
'anton@email.arizona.edu' 46 from optparse
import OptionParser
49 roslib.load_manifest(
'dynamixel_driver')
51 from dynamixel_driver
import dynamixel_io
53 if __name__ ==
'__main__':
54 parser = OptionParser(usage=
'Usage: %prog [options] OLD_ID NEW_ID', description=
'Changes the unique ID of a Dynamixel servo motor.')
55 parser.add_option(
'-p',
'--port', metavar=
'PORT', default=
'/dev/ttyUSB0',
56 help=
'motors of specified controllers are connected to PORT [default: %default]')
57 parser.add_option(
'-b',
'--baud', metavar=
'BAUD', type=
"int", default=1000000,
58 help=
'connection to serial port will be established at BAUD bps [default: %default]')
60 (options, args) = parser.parse_args(sys.argv)
67 baudrate = options.baud
72 dxl_io = dynamixel_io.DynamixelIO(port, baudrate)
73 except dynamixel_io.SerialOpenError, soe:
76 print 'Changing motor id from %d to %d...' %(old_id, new_id),
77 if dxl_io.ping(old_id):
78 dxl_io.set_id(old_id, new_id)
80 print 'Verifying new id...' ,
81 if dxl_io.ping(new_id):
84 print 'ERROR: The motor did not respond to a ping to its new id.' 86 print 'ERROR: The specified motor did not respond to id %d. Make sure to specify the correct baudrate.' % old_id