def write_pos(angle): """ Writes to goal position register in the dxl control table. Works only in position control mode. Args: angle: A float. Angle in radians """ block = dxl_mx64.MX64.subblock('goal_pos', 'goal_pos', ret_dxl_type=use_ctypes_driver) packet = dxl_commv1.packet_write_buffer(idn, block, block.data_from_vals([angle])) dxl_commv1.loop_until_written(port, idn, packet)
def write_to_register(reg_name, val): """ General function to write a value to any given register Args: reg_name: A string containing the name of the register to write to val: An int or a float depending on the register """ block = dxl_mx64.MX64.subblock(reg_name, reg_name, ret_dxl_type=use_ctypes_driver) packet = dxl_commv1.packet_write_buffer(idn, block, block.data_from_vals([val])) dxl_commv1.loop_until_written(port, idn, packet)
def write_torque(current): """ Write a value to goal torque register. Torque control is done by controlling the current in DXL. This command is valid only for select DXL models. Args: current: A float between -1024 and 1024 """ block = dxl_mx64.MX64.subblock('goal_torque', 'goal_torque', ret_dxl_type=use_ctypes_driver) packet = dxl_commv1.packet_write_buffer(idn, block, block.data_from_vals([current])) dxl_commv1.loop_until_written(port, idn, packet)
def write_torque_enable(enable, id = 0): """ Enables/Disables torque Args: enable: 0 or 1 id: An integer representing the DXL ID number """ if id == 0: id = idn block = dxl_mx64.MX64.subblock('torque_enable', 'torque_enable', ret_dxl_type=use_ctypes_driver) packet = dxl_commv1.packet_write_buffer(id, block, block.data_from_vals([enable])) dxl_commv1.loop_until_written(port, id, packet)
def write_angle_limit(angle_low, angle_high): """ Sets the cw_angle_limit (clockwise) and ccw_angle_limit (counter clockwise) The angles limits are set by writing to the corresponding registers. This chooses wheel or joint mode for the dxl servo. Only wheel mode is available in torque control mode. Args: angle_low: A float. Angle in radians angle_high: A float. Angle in radians """ block = dxl_mx64.MX64.subblock('angle_limit_ccw', 'angle_limit_cw') packet = dxl_commv1.packet_write_buffer(idn, block, block.data_from_vals([angle_low, angle_high])) dxl_commv1.loop_until_written(port, idn, packet)