Initializes a new client. Args: motor_ids: All motor IDs being used by the client. port: The Dynamixel device to talk to. e.g. - Linux: /dev/ttyUSB0 - Mac: /dev/tty.usbserial-* - Windows: COM1 baudrate: The
(self,
motor_ids: Sequence[int],
port: str = '/dev/ttyUSB0',
baudrate: int = 1000000,
lazy_connect: bool = False,
pos_scale: Optional[float] = None,
vel_scale: Optional[float] = None,
cur_scale: Optional[float] = None)
| 67 | OPEN_CLIENTS = set() |
| 68 | |
| 69 | def __init__(self, |
| 70 | motor_ids: Sequence[int], |
| 71 | port: str = '/dev/ttyUSB0', |
| 72 | baudrate: int = 1000000, |
| 73 | lazy_connect: bool = False, |
| 74 | pos_scale: Optional[float] = None, |
| 75 | vel_scale: Optional[float] = None, |
| 76 | cur_scale: Optional[float] = None): |
| 77 | """Initializes a new client. |
| 78 | |
| 79 | Args: |
| 80 | motor_ids: All motor IDs being used by the client. |
| 81 | port: The Dynamixel device to talk to. e.g. |
| 82 | - Linux: /dev/ttyUSB0 |
| 83 | - Mac: /dev/tty.usbserial-* |
| 84 | - Windows: COM1 |
| 85 | baudrate: The Dynamixel baudrate to communicate with. |
| 86 | lazy_connect: If True, automatically connects when calling a method |
| 87 | that requires a connection, if not already connected. |
| 88 | pos_scale: The scaling factor for the positions. This is |
| 89 | motor-dependent. If not provided, uses the default scale. |
| 90 | vel_scale: The scaling factor for the velocities. This is |
| 91 | motor-dependent. If not provided uses the default scale. |
| 92 | cur_scale: The scaling factor for the currents. This is |
| 93 | motor-dependent. If not provided uses the default scale. |
| 94 | """ |
| 95 | import dynamixel_sdk |
| 96 | self.dxl = dynamixel_sdk |
| 97 | |
| 98 | self.motor_ids = list(motor_ids) |
| 99 | self.port_name = port |
| 100 | self.baudrate = baudrate |
| 101 | self.lazy_connect = lazy_connect |
| 102 | |
| 103 | self.port_handler = self.dxl.PortHandler(port) |
| 104 | self.packet_handler = self.dxl.PacketHandler(PROTOCOL_VERSION) |
| 105 | |
| 106 | self._pos_vel_cur_reader = DynamixelPosVelCurReader( |
| 107 | self, |
| 108 | self.motor_ids, |
| 109 | pos_scale=pos_scale if pos_scale is not None else DEFAULT_POS_SCALE, |
| 110 | vel_scale=vel_scale if vel_scale is not None else DEFAULT_VEL_SCALE, |
| 111 | cur_scale=cur_scale if cur_scale is not None else DEFAULT_CUR_SCALE, |
| 112 | ) |
| 113 | self._pos_reader = DynamixelPosReader( |
| 114 | self, |
| 115 | self.motor_ids, |
| 116 | pos_scale=pos_scale if pos_scale is not None else DEFAULT_POS_SCALE, |
| 117 | vel_scale=vel_scale if vel_scale is not None else DEFAULT_VEL_SCALE, |
| 118 | cur_scale=cur_scale if cur_scale is not None else DEFAULT_CUR_SCALE, |
| 119 | ) |
| 120 | self._vel_reader = DynamixelVelReader( |
| 121 | self, |
| 122 | self.motor_ids, |
| 123 | pos_scale=pos_scale if pos_scale is not None else DEFAULT_POS_SCALE, |
| 124 | vel_scale=vel_scale if vel_scale is not None else DEFAULT_VEL_SCALE, |
| 125 | cur_scale=cur_scale if cur_scale is not None else DEFAULT_CUR_SCALE, |
| 126 | ) |
no test coverage detected