def main(): """ Set the *return delay time* for the specified Dynamixel unit i.e. the time (in microsecond) for the status packets to return after the instruction packet is sent. """ # Parse options parser = common_argument_parser(desc=main.__doc__) parser.add_argument("--return-delay-time", "-r", help="The new return delay time assigned to the " "selected Dynamixel unit. It must be in range " "(0, 500). The default value is {default}µs " "({default} microseconds).".format(default=DEFAULT_VALUE), type=int, metavar="INT", default=DEFAULT_VALUE) args = parser.parse_args() # Connect to the serial port serial_connection = Connection(port=args.port, baudrate=args.baudrate, timeout=args.timeout, rpi_gpio=args.rpi) serial_connection.set_return_delay_time(args.dynamixel_id, args.return_delay_time) # Close the serial connection serial_connection.close()
def main(): """ A PyAX-12 demo. Ping the specified Dynamixel unit. Returns "True" if the specified unit is available, "False" otherwise. """ # Parse options parser = common_argument_parser(desc=main.__doc__) args = parser.parse_args() # Connect to the serial port serial_connection = Connection(port=args.port, baudrate=args.baudrate, timeout=args.timeout, rpi_gpio=args.rpi) # Ping the dynamixel unit(s) is_available = serial_connection.ping(args.dynamixel_id) print(is_available) # Close the serial connection serial_connection.close()
def main(): """ A PyAX-12 demo. Blink (only once) the LED of the specified Dynamixel unit. """ # Parse options parser = common_argument_parser(desc=main.__doc__) args = parser.parse_args() # Connect to the serial port serial_connection = Connection(args.port, args.baudrate, args.timeout) # Switch ON the LED serial_connection.write_data(args.dynamixel_id, pk.LED, 1) # Wait 2 seconds time.sleep(2) # Switch OFF the LED serial_connection.write_data(args.dynamixel_id, pk.LED, 0) # Close the serial connection serial_connection.close()
def main(): """ A PyAX-12 demo. Ping the specified Dynamixel unit. Returns "True" if the specified unit is available, "False" otherwise. """ # Parse options parser = common_argument_parser(desc=main.__doc__) args = parser.parse_args() # Connect to the serial port serial_connection = Connection(port=args.port, baudrate=args.baudrate, timeout=args.timeout, rpi_gpio=args.rpi) # Ping the dynamixel unit(s) is_available = serial_connection.ping(args.dynamixel_id) print(is_available) # Close the serial connection serial_connection.close()
def main(): """ A PyAX-12 demo. Prints the ID list of available Dynamixel units. """ # Parse options parser = common_argument_parser(desc=main.__doc__, id_arg=False) args = parser.parse_args() # Connect to the serial port serial_connection = Connection(port=args.port, baudrate=args.baudrate, timeout=args.timeout, rpi_gpio=args.rpi) # Ping the dynamixel unit(s) ids_available = serial_connection.scan() for dynamixel_id in ids_available: print(dynamixel_id) # Close the serial connection serial_connection.close()
def main(): """Set the *baud rate* for the specified Dynamixel unit i.e. set the connection speed with the actuator in kbps (kilo bauds per second). """ # Parse options parser = common_argument_parser(desc=main.__doc__) parser.add_argument("--new-baudrate", "-n", help="the new baud rate assigned to the selected " "Dynamixel unit (in kbps)." "The default value is {default}kbps.".format(default=DEFAULT_VALUE), type=float, metavar="FLOAT", default=DEFAULT_VALUE) args = parser.parse_args() # Connect to the serial port serial_connection = Connection(port=args.port, baudrate=args.baudrate, timeout=args.timeout, rpi_gpio=args.rpi) serial_connection.set_baud_rate(args.dynamixel_id, args.new_baudrate) # Close the serial connection serial_connection.close()
def main(): """ Set the *ID* for the specified Dynamixel unit i.e. the unique ID number assigned to actuators for identifying them. Different IDs are required for each Dynamixel actuators that are on the same network. """ # Parse options parser = common_argument_parser(desc=main.__doc__) parser.add_argument("--new-id", "-n", help="The new unique ID assigned to the selected " "Dynamixel unit. It must be in range (0, 0xFE).", type=int, metavar="INT", default=1) args = parser.parse_args() # Connect to the serial port serial_connection = Connection(port=args.port, baudrate=args.baudrate, timeout=args.timeout, rpi_gpio=args.rpi) serial_connection.set_id(args.dynamixel_id, args.new_id) # Close the serial connection serial_connection.close()
def main(): """ Set the *ID* for the specified Dynamixel unit i.e. the unique ID number assigned to actuators for identifying them. Different IDs are required for each Dynamixel actuators that are on the same network. """ # Parse options parser = common_argument_parser(desc=main.__doc__) parser.add_argument("--new-id", "-n", help="The new unique ID assigned to the selected " "Dynamixel unit. It must be in range (0, 0xFE).", type=int, metavar="INT", default=1) args = parser.parse_args() # Connect to the serial port serial_connection = Connection(port=args.port, baudrate=args.baudrate, timeout=args.timeout, rpi_gpio=args.rpi) serial_connection.set_id(args.dynamixel_id, args.new_id) # Close the serial connection serial_connection.close()
def main(): """ A PyAX-12 demo. Blink (only once) the LED of the specified Dynamixel unit. """ # Parse options parser = common_argument_parser(desc=main.__doc__) args = parser.parse_args() # Connect to the serial port serial_connection = Connection(port=args.port, baudrate=args.baudrate, timeout=args.timeout, rpi_gpio=args.rpi) # Switch ON the LED serial_connection.write_data(args.dynamixel_id, pk.LED, 1) # Wait 2 seconds time.sleep(2) # Switch OFF the LED serial_connection.write_data(args.dynamixel_id, pk.LED, 0) # Close the serial connection serial_connection.close()
def main(): # Parse options parser = common_argument_parser(desc=main.__doc__) args = parser.parse_args() # Connect to the serial port serial_connection = Connection(port='/dev/ttyS0', baudrate=1000000, timeout=0.01, rpi_gpio=18)
def main(): """ A PyAX-12 demo. Print the control table of the specified Dynamixel unit. """ # Parse options parser = common_argument_parser(desc=main.__doc__, id_arg_mandatory=True) args = parser.parse_args() # Connect to the serial port serial_connection = Connection(args.port, args.baudrate, args.timeout) # Print the control table of the specified Dynamixel unit serial_connection.pretty_print_control_table(args.dynamixel_id) # Close the serial connection serial_connection.close()
def main(): """ This is an *endless turn mode* demo. If both values for the *CW angle limit* and *CCW angle limit* are set to 0, an *endless turn mode* can be implemented by setting the *goal speed*. This feature can be used for implementing a continuously rotating wheel. """ # Parse options parser = common_argument_parser(desc=main.__doc__) args = parser.parse_args() # Connect to the serial port serial_connection = Connection(port=args.port, baudrate=args.baudrate, timeout=args.timeout, rpi_gpio=args.rpi) dynamixel_id = args.dynamixel_id # Set the "wheel mode" serial_connection.set_cw_angle_limit(dynamixel_id, 0, degrees=False) serial_connection.set_ccw_angle_limit(dynamixel_id, 0, degrees=False) # Activate the actuator (speed=512) serial_connection.set_speed(dynamixel_id, 512) # Lets the actuator turn 5 seconds time.sleep(5) # Stop the actuator (speed=0) serial_connection.set_speed(dynamixel_id, 0) # Leave the "wheel mode" serial_connection.set_ccw_angle_limit(dynamixel_id, 1023, degrees=False) # Go to the initial position (0 degree) serial_connection.goto(dynamixel_id, 0, speed=512, degrees=True) # Close the serial connection serial_connection.close()
def main(): """ A PyAX-12 demo. Print the internal temperature (in degrees celsius) of the specified Dynamixel unit. """ # Parse options parser = common_argument_parser(desc=main.__doc__) args = parser.parse_args() # Connect to the serial port serial_connection = Connection(args.port, args.baudrate, args.timeout) # Print the present internal temperature print(serial_connection.get_present_temperature(args.dynamixel_id)) # Close the serial connection serial_connection.close()
def main(): """ A PyAX-12 demo. Print the internal temperature (in degrees celsius) of the specified Dynamixel unit. """ # Parse options parser = common_argument_parser(desc=main.__doc__) args = parser.parse_args() # Connect to the serial port serial_connection = Connection(port=args.port, baudrate=args.baudrate, timeout=args.timeout, rpi_gpio=args.rpi) # Print the present internal temperature print(serial_connection.get_present_temperature(args.dynamixel_id)) # Close the serial connection serial_connection.close()
def main(): """ A PyAX-12 demo. Move the specified Dynamixel unit to 0° (0) then go to 300° (1023) then go back to 150° (511). """ # Parse options parser = common_argument_parser(desc=main.__doc__) args = parser.parse_args() # Connect to the serial port serial_connection = Connection(args.port, args.baudrate, args.timeout) ### dynamixel_id = 1 # Go to 0° serial_connection.goto(dynamixel_id, 0, speed=512, degrees=True) time.sleep(1) # Wait 1 second # Go to -45° (45° CW) serial_connection.goto(dynamixel_id, -45, speed=512, degrees=True) time.sleep(1) # Wait 1 second # Go to -90° (90° CW) serial_connection.goto(dynamixel_id, -90, speed=512, degrees=True) time.sleep(1) # Wait 1 second # Go to -135° (135° CW) serial_connection.goto(dynamixel_id, -135, speed=512, degrees=True) time.sleep(1) # Wait 1 second # Go to -150° (150° CW) serial_connection.goto(dynamixel_id, -150, speed=512, degrees=True) time.sleep(1) # Wait 1 second # Go to +150° (150° CCW) serial_connection.goto(dynamixel_id, 150, speed=512, degrees=True) time.sleep(2) # Wait 2 seconds # Go to +135° (135° CCW) serial_connection.goto(dynamixel_id, 135, speed=512, degrees=True) time.sleep(1) # Wait 1 second # Go to +90° (90° CCW) serial_connection.goto(dynamixel_id, 90, speed=512, degrees=True) time.sleep(1) # Wait 1 second # Go to +45° (45° CCW) serial_connection.goto(dynamixel_id, 45, speed=512, degrees=True) time.sleep(1) # Wait 1 second # Go back to 0° serial_connection.goto(dynamixel_id, 0, speed=512, degrees=True) ### # Close the serial connection serial_connection.close()
def main(): """ A PyAX-12 demo. Move the specified Dynamixel unit to 0° (0) then go to 300° (1023) then go back to 150° (511). """ # Parse options parser = common_argument_parser(desc=main.__doc__) args = parser.parse_args() # Connect to the serial port serial_connection = Connection(port=args.port, baudrate=args.baudrate, timeout=args.timeout, rpi_gpio=args.rpi) ### dynamixel_id = args.dynamixel_id # Go to 0° serial_connection.goto(dynamixel_id, 0, speed=512, degrees=True) time.sleep(1) # Wait 1 second # Go to -45° (45° CW) serial_connection.goto(dynamixel_id, -45, speed=512, degrees=True) time.sleep(1) # Wait 1 second # Go to -90° (90° CW) serial_connection.goto(dynamixel_id, -90, speed=512, degrees=True) time.sleep(1) # Wait 1 second # Go to -135° (135° CW) serial_connection.goto(dynamixel_id, -135, speed=512, degrees=True) time.sleep(1) # Wait 1 second # Go to -150° (150° CW) serial_connection.goto(dynamixel_id, -150, speed=512, degrees=True) time.sleep(1) # Wait 1 second # Go to +150° (150° CCW) serial_connection.goto(dynamixel_id, 150, speed=512, degrees=True) time.sleep(2) # Wait 2 seconds # Go to +135° (135° CCW) serial_connection.goto(dynamixel_id, 135, speed=512, degrees=True) time.sleep(1) # Wait 1 second # Go to +90° (90° CCW) serial_connection.goto(dynamixel_id, 90, speed=512, degrees=True) time.sleep(1) # Wait 1 second # Go to +45° (45° CCW) serial_connection.goto(dynamixel_id, 45, speed=512, degrees=True) time.sleep(1) # Wait 1 second # Go back to 0° serial_connection.goto(dynamixel_id, 0, speed=512, degrees=True) ### # Close the serial connection serial_connection.close()
def main(): """ A PyAX-12 demo. Find all the currently connected AX12s and jog them back and forth through a series of turns """ # Parse options parser = common_argument_parser(desc=main.__doc__) args = parser.parse_args() # Connect to the serial port serial_connection = Connection(port=args.port, baudrate=args.baudrate, timeout=args.timeout, rpi_gpio=args.rpi) # Ping the dynamixel unit(s) ids_available = serial_connection.scan() print("Found %d servos with ids %s" % (len(ids_available), ids_available)) prev_pos = [ int(serial_connection.get_present_position(i, degrees=False)) for i in ids_available ] print(prev_pos) #type(prev_pos[0]) for dynamixel_id in ids_available: print("Starting position for servo %d is %d" % (dynamixel_id, serial_connection.get_present_position(dynamixel_id, degrees=True))) # Go to -45° serial_connection.goto(dynamixel_id, -45, speed=512, degrees=True) print("-45 angle for servo %d is %d" % (dynamixel_id, serial_connection.get_present_position(dynamixel_id, degrees=False))) time.sleep(1) # Wait 1 second # Go to -90° (90° CW) serial_connection.goto(dynamixel_id, -90, speed=512, degrees=True) time.sleep(1) # Wait 1 second print("-90 angle for servo %d is %d" % (dynamixel_id, serial_connection.get_present_position(dynamixel_id, degrees=False))) # Go to +90° (90° CCW) serial_connection.goto(dynamixel_id, 45, speed=512, degrees=True) time.sleep(1) # Wait 1 second print("+45 angle for servo %d is %d" % (dynamixel_id, serial_connection.get_present_position(dynamixel_id, degrees=False))) # Go to +90° (90° CCW) serial_connection.goto(dynamixel_id, 90, speed=512, degrees=True) time.sleep(1) # Wait 1 second print("+90 angle for servo %d is %d" % (dynamixel_id, serial_connection.get_present_position(dynamixel_id, degrees=False))) serial_connection.goto(dynamixel_id, 340, speed=512, degrees=False) time.sleep(1) # Wait 1 second print("Home angle for servo %d is %d" % (dynamixel_id, serial_connection.get_present_position(dynamixel_id, degrees=False))) # Close the serial connection serial_connection.close()