from pydynamixel import dynamixel, registers # You'll need to change this to the serial port of your USB2Dynamixel serial_port = '/dev/tty.usbserial-A921X77J' # You'll need to change this to the ID of your servo servo_id = 9 # Turn the LED on led_value = dynamixel.registers.LED_STATE.ON try: ser = dynamixel.get_serial_for_url(serial_port) dynamixel.set_led(ser, servo_id, led_value) print('LED set successfully!') except Exception as e: print('Unable to set LED.') print(e)
# You'll need to modify this for your setup servo_id = 9 target_position = 0 velocity = 20 # very slow # If this is the first time the robot was powered on, we need to read # and set the current position. # (See the documentation above.) first_move = True try: ser = dynamixel.get_serial_for_url(serial_port) # Turn the LED off dynamixel.set_led(ser, servo_id, registers.LED_STATE.OFF) if first_move == True: dynamixel.init(ser, servo_id) # Set the desired position dynamixel.set_position(ser, servo_id, target_position) # Set the velocity dynamixel.set_velocity(ser, servo_id, velocity) # Move to the desired position dynamixel.send_action_packet(ser) # Wait for the arm to stop moving print('Waiting...')
""" The following code can be used to turn on the LED on a connected servo (on a POSIX-compliant platform.) """ from pydynamixel import dynamixel, registers # You'll need to change this to the serial port of your USB2Dynamixel serial_port = '/dev/tty.usbserial-A921X77J' # You'll need to change this to the ID of your servo servo_id = 9 # Turn the LED on led_value = registers.LED_STATE.ON try: ser = dynamixel.get_serial_for_url(serial_port) dynamixel.set_led(ser, servo_id, led_value) print('LED set successfully!') except Exception as e: print('Unable to set LED.') print(e)