Skip to content

Instantly share code, notes, and snippets.

@adammck
Created January 3, 2014 03:02
Show Gist options
  • Save adammck/8231885 to your computer and use it in GitHub Desktop.
Save adammck/8231885 to your computer and use it in GitHub Desktop.
Change a the ID of a Dynamixel servo
#!/usr/bin/env python
import sys
import time
import optparse
import dynamixel
if __name__ == "__main__":
parser = optparse.OptionParser()
parser.add_option("-p", "--port", help="Serial port", default="/dev/tty.usbserial-A9ITPZVR")
parser.add_option("-b", "--baud", help="Baud rate", default="1000000")
parser.add_option("-o", "--old-id", dest="old_id", help="Old servo ID", default="1")
parser.add_option("-n", "--new-id", dest="new_id", help="New servo ID", default="1")
(options, args) = parser.parse_args()
old_id = int(options.old_id)
new_id = int(options.new_id)
serial = dynamixel.SerialStream(port=options.port, baudrate=options.baud, timeout=1)
network = dynamixel.DynamixelNetwork(serial)
network.scan(old_id, old_id) # wat
servo = network[old_id]
if servo:
servo.id = new_id
print "Changed Dynamixel #%s to #%s" % (old_id, new_id)
else:
print "No such Dynamixel: #%s" % old_id
sys.exit(1)
@cyphunk
Copy link

cyphunk commented Nov 7, 2022

just for personal note, this code appears to be written for the ros framework, not the dynamixel sdk. thank you for the contribution <3

wrote a different version that uses dynamixel python sdk over here:

https://gist.github.com/cyphunk/0593502bf86932a18fc042609be3f7bc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment