Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def set_control_mode(self, mode_for_id):
models = ['MX' if m.startswith('MX') else '*'
for m in self.get_model(list(mode_for_id.keys()))]
pos_max = [conv.position_range[m][0] for m in models]
limits = ((0, 0) if mode == 'wheel' else (0, pos_max[i] - 1)
for i, mode in enumerate(mode_for_id.itervalues()))
self._set_angle_limit(dict(zip(mode_for_id.keys(), limits)), convert=False)
self._known_mode.update(mode_for_id.items())
setter_name=None):
control = _DxlControl(name,
address, length, nb_elem,
access,
models,
dxl_to_si, si_to_dxl,
getter_name, setter_name)
DxlIO._generate_accessors(control)
_add_control('model',
address=0x00,
access=_DxlAccess.readonly,
dxl_to_si=conv.dxl_to_model)
_add_control('firmware',
address=0x02, length=1,
access=_DxlAccess.readonly)
_add_control('id',
address=0x03, length=1,
access=_DxlAccess.writeonly,
setter_name='change_id')
_add_control('baudrate',
address=0x04, length=1,
access=_DxlAccess.writeonly,
setter_name='change_baudrate',
si_to_dxl=conv.baudrate_to_dxl)
dxl_to_si=lambda value, model: (conv.dxl_to_voltage(value[0], model),
conv.dxl_to_voltage(value[1], model)),
si_to_dxl=lambda value, model: (conv.voltage_to_dxl(value[0], model),
dxl_to_si=lambda value, model: (conv.dxl_to_degree(value[0], model),
conv.dxl_to_speed(value[1], model),
conv.dxl_to_load(value[2], model)))
_add_control('present temperature',
address=0x2B, length=1,
access=_DxlAccess.readonly,
dxl_to_si=conv.dxl_to_temperature)
_add_control('moving',
address=0x2E, length=1,
access=_DxlAccess.readonly,
dxl_to_si=conv.dxl_to_bool,
getter_name='is_moving')
_add_control('goal acceleration',
address=0x49,
models=('MX-28', 'MX-64', 'MX-106'),
dxl_to_si=conv.dxl_to_acc,
si_to_dxl=conv.acc_to_dxl)
'dxl_to_si': conv.dxl_to_pid,
'si_to_dxl': conv.pid_to_dxl
},
'goal position': {
'address': 0x1E,
'dxl_to_si': conv.dxl_to_degree,
'si_to_dxl': conv.degree_to_dxl
},
'moving speed': {
'address': 0x20,
'dxl_to_si': conv.dxl_to_speed,
'si_to_dxl': conv.speed_to_dxl
},
'torque limit': {
'address': 0x23,
'dxl_to_si': conv.dxl_to_torque,
'si_to_dxl': conv.torque_to_dxl
},
'goal position speed': {
'address': 0x1E,
'nb_elem': 2,
'dxl_to_si': lambda value, model: (conv.dxl_to_degree(value[0], model),
conv.dxl_to_speed(value[1], model)),
'si_to_dxl': lambda value, model: (conv.degree_to_dxl(value[0], model),
conv.speed_to_dxl(value[1], model)),
'getter_name': '_get_goal_pos_speed',
'setter_name': '_set_goal_pos_speed'
},
'present position': {
'address': 0x25,
'access': _DxlAccess.readonly,
'dxl_to_si': conv.dxl_to_degree
def _add_control(name,
address, length=2, nb_elem=1,
access=_DxlAccess.readwrite,
models=set(conv.dynamixelModels.values()),
dxl_to_si=lambda val, model: val,
si_to_dxl=lambda val, model: val,
getter_name=None,
setter_name=None):
control = _DxlControl(name,
address, length, nb_elem,
access,
models,
dxl_to_si, si_to_dxl,
getter_name, setter_name)
DxlIO._generate_accessors(control)
dxl_to_si=conv.dxl_to_rdt,
si_to_dxl=conv.rdt_to_dxl)
_add_control('angle limit',
address=0x06, nb_elem=2,
dxl_to_si=lambda value, model: (conv.dxl_to_degree(value[0], model),
conv.dxl_to_degree(value[1], model)),
si_to_dxl=lambda value, model: (conv.degree_to_dxl(value[0], model),
conv.degree_to_dxl(value[1], model)))
_add_control('drive mode',
address=0x0A, length=1,
access=_DxlAccess.readwrite,
models=('MX-106', ),
dxl_to_si=conv.dxl_to_drive_mode,
si_to_dxl=conv.drive_mode_to_dxl)
_add_control('highest temperature limit',
address=0x0B, length=1,
dxl_to_si=conv.dxl_to_temperature,
si_to_dxl=conv.temperature_to_dxl)
_add_control('voltage limit',
address=0x0C, length=1, nb_elem=2,
dxl_to_si=lambda value, model: (conv.dxl_to_voltage(value[0], model),
conv.dxl_to_voltage(value[1], model)),
si_to_dxl=lambda value, model: (conv.voltage_to_dxl(value[0], model),
conv.voltage_to_dxl(value[1], model)))
_add_control('max torque',
address=0x0E,
dxl_to_si=conv.dxl_to_torque,
_add_control('id',
address=0x03, length=1,
access=_DxlAccess.writeonly,
setter_name='change_id')
_add_control('baudrate',
address=0x04, length=1,
access=_DxlAccess.writeonly,
setter_name='change_baudrate',
si_to_dxl=conv.baudrate_to_dxl)
_add_control('return delay time',
address=0x05, length=1,
dxl_to_si=conv.dxl_to_rdt,
si_to_dxl=conv.rdt_to_dxl)
_add_control('angle limit',
address=0x06, nb_elem=2,
dxl_to_si=lambda value, model: (conv.dxl_to_degree(value[0], model),
conv.dxl_to_degree(value[1], model)),
si_to_dxl=lambda value, model: (conv.degree_to_dxl(value[0], model),
conv.degree_to_dxl(value[1], model)))
_add_control('drive mode',
address=0x0A, length=1,
access=_DxlAccess.readwrite,
models=('MX-106', ),
dxl_to_si=conv.dxl_to_drive_mode,
si_to_dxl=conv.drive_mode_to_dxl)
_add_control('highest temperature limit',
_add_control('highest temperature limit',
address=0x0B, length=1,
dxl_to_si=conv.dxl_to_temperature,
si_to_dxl=conv.temperature_to_dxl)
_add_control('voltage limit',
address=0x0C, length=1, nb_elem=2,
dxl_to_si=lambda value, model: (conv.dxl_to_voltage(value[0], model),
conv.dxl_to_voltage(value[1], model)),
si_to_dxl=lambda value, model: (conv.voltage_to_dxl(value[0], model),
conv.voltage_to_dxl(value[1], model)))
_add_control('max torque',
address=0x0E,
dxl_to_si=conv.dxl_to_torque,
si_to_dxl=conv.torque_to_dxl)
_add_control('status return level',
address=0x10, length=1,
dxl_to_si=conv.dxl_to_status,
si_to_dxl=conv.status_to_dxl)
_add_control('alarm LED',
address=0x11, length=1,
dxl_to_si=conv.dxl_to_alarm,
si_to_dxl=conv.alarm_to_dxl)
_add_control('alarm shutdown',
address=0x12, length=1,
dxl_to_si=conv.dxl_to_alarm,
si_to_dxl=conv.alarm_to_dxl)