-
Notifications
You must be signed in to change notification settings - Fork 0
/
reboot_all_servos
executable file
·34 lines (29 loc) · 1005 Bytes
/
reboot_all_servos
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/python
"""!
Reboot all servos
"""
import dynamixel_sdk as dxl_sdk
# Protocol version
PROTOCOL = 2.0 # See which protocol version is used in the Dynamixel
# Default setting
BAUDRATE = 1000000 # Dynamixel default baudrate : 57600
DEVICENAME = '/dev/ttyDXL' # Check which port is being used on your controller
# ex) Windows: "COM1" Linux: "/dev/ttyUSB0" Mac: "/dev/tty.usbserial-*"
# Initialize PortHandler instance
# Set the port path
# Get methods and members of PortHandlerLinux or PortHandlerWindows
port_handler = dxl_sdk.PortHandler(DEVICENAME)
# Open port
if port_handler.openPort():
print("Succeeded to open port")
else:
quit()
if port_handler.setBaudRate(BAUDRATE):
print("Succeeded to change the baudrate")
else:
quit()
packet_handler = dxl_sdk.PacketHandler(2)
servos, _ = packet_handler.broadcastPing(port_handler)
for servo in servos.keys():
packet_handler.reboot(port_handler, servo)
print('Rebooted servo {}'.format(servo))