def __init__(self, port_name='/dev/ttyUSB0', port_namespace='ttyUSB0', baud_rate=1000000, min_motor_id=1, max_motor_id=25, update_rate=5, diagnostics_rate=1, error_level_temp=75, warn_level_temp=70, readback_echo=False, protocol_version=2.0): # Initialize variables for Serial Proxy self.port_name = port_name self.port_namespace = port_namespace self.baud_rate = baud_rate self.min_motor_id = min_motor_id self.max_motor_id = max_motor_id self.update_rate = update_rate self.diagnostics_rate = diagnostics_rate self.error_level_temp = error_level_temp self.warn_level_temp = warn_level_temp self.readback_echp = readback_echo self.protocol_version = protocol_version self.actual_rate = update_rate self.error_counts = {'non_fatal': 0, 'checksum': 0, 'dropped': 0} # self.current_state = MotorStateList() self.num_ping_retries = 5 self.dynotools = dynamixel_tools.DynamixelTools() self.sdk_io = sdk_serial_wrapper.SDKSerialWrapper(port_name, baud_rate) self.angles = {}
def __init__(self, port, baudrate, feedback_echo=False, protocol_version=2.0): # Initialize Port and Packet Handler, also make needed variables / objects # TODO: Should try/catch in case of errors self.serial_mutex = Lock() self.port_handler = port_h.PortHandler(port) self.packet_handler = packet_h.PacketHandler(protocol_version) self.port_handler.openPort() self.port_handler.setBaudRate(baudrate) self.port = port self.baudrate = baudrate self.dynotools = dynamixel_tools.DynamixelTools() self.raw_to_deg_switch = { '54024': self.raw_to_deg_pulse, '311': self.raw_to_deg_static, '1120': self.raw_to_deg_static, '1020': self.raw_to_deg_static } self.deg_to_raw_switch = { '54024': self.deg_to_raw_pulse, '311': self.deg_to_raw_static, '1120': self.deg_to_raw_static, '1020': self.deg_to_raw_static }