35 from __future__
import division
38 __author__ =
'Antons Rebguns' 39 __copyright__ =
'Copyright (c) 2010-2011 Antons Rebguns' 40 __credits__ =
'Cara Slutter' 43 __maintainer__ =
'Antons Rebguns' 44 __email__ =
'anton@email.arizona.edu' 52 from dynamixel_msgs.msg
import JointState
55 def __init__(self, dxl_io, controller_namespace, port_namespace):
56 JointController.__init__(self, dxl_io, controller_namespace, port_namespace)
72 available_ids = rospy.get_param(
'dynamixel/%s/connected_ids' % self.
port_namespace, [])
73 if not (self.
master_id in available_ids
and 75 rospy.logwarn(
'The specified motor id is not connected and responding.')
76 rospy.logwarn(
'Available ids: %s' % str(available_ids))
124 return (mcv_master, mcv_slave)
135 mcv_master = (self.
master_id, torque_enable)
136 mcv_slave = (self.
slave_id, torque_enable)
137 self.dxl_io.set_multi_torque_enabled([mcv_master, mcv_slave])
143 mcv_master = (self.
master_id, speed_raw
if speed_raw > 0
else 1)
144 mcv_slave = (self.
slave_id, mcv_master[1])
145 self.dxl_io.set_multi_speed([mcv_master, mcv_slave])
148 if slope < DXL_MIN_COMPLIANCE_SLOPE: slope = DXL_MIN_COMPLIANCE_SLOPE
149 elif slope > DXL_MAX_COMPLIANCE_SLOPE: slope = DXL_MAX_COMPLIANCE_SLOPE
150 mcv_master = (self.
master_id, slope, slope)
151 mcv_slave = (self.
slave_id, slope, slope)
152 self.dxl_io.set_multi_compliance_slopes([mcv_master, mcv_slave])
155 if margin < DXL_MIN_COMPLIANCE_MARGIN: margin = DXL_MIN_COMPLIANCE_MARGIN
156 elif margin > DXL_MAX_COMPLIANCE_MARGIN: margin = DXL_MAX_COMPLIANCE_MARGIN
157 else: margin = int(margin)
158 mcv_master = (self.
master_id, margin, margin)
159 mcv_slave = (self.
slave_id, margin, margin)
160 self.dxl_io.set_multi_compliance_margins([mcv_master, mcv_slave])
163 if punch < DXL_MIN_PUNCH: punch = DXL_MIN_PUNCH
164 elif punch > DXL_MAX_PUNCH: punch = DXL_MAX_PUNCH
165 else: punch = int(punch)
168 self.dxl_io.set_multi_punch([mcv_master, mcv_slave])
171 if max_torque > 1: max_torque = 1.0
172 elif max_torque < 0: max_torque = 0.0
173 raw_torque_val = int(DXL_MAX_TORQUE_TICK * max_torque)
174 mcv_master = (self.
master_id, raw_torque_val)
175 mcv_slave = (self.
slave_id, raw_torque_val)
176 self.dxl_io.set_multi_torque_limit([mcv_master, mcv_slave])
182 for state
in state_list.motor_states:
187 self.joint_state.motor_temps = [state.temperature, states[self.
slave_id].temperature]
192 self.joint_state.load = state.load
193 self.joint_state.is_moving = state.moving
194 self.joint_state.header.stamp = rospy.Time.from_sec(state.timestamp)
203 if mcv_slave[1] < 0: mcv_slave[1] = 0
205 self.dxl_io.set_multi_position([mcv_master, mcv_slave])
def spd_rad_to_raw(self, spd_rad)
def raw_to_rad(self, raw, initial_position_raw, flipped, radians_per_encoder_tick)
master_initial_position_raw
def __init__(self, dxl_io, controller_namespace, port_namespace)
def set_compliance_slope(self, slope)
def pos_rad_to_raw(self, angle)
def set_compliance_margin(self, margin)
def set_compliance_punch(self, punch)
def set_torque_enable(self, torque_enable)
def set_speed(self, speed)
def process_motor_states(self, state_list)
def set_compliance_margin(self, margin)
def set_torque_limit(self, max_torque)
def set_speed(self, speed)
def process_command(self, msg)
def set_compliance_slope(self, slope)
def rad_to_raw(self, angle, initial_position_raw, flipped, encoder_ticks_per_radian)
def set_compliance_punch(self, punch)
def set_torque_limit(self, max_torque)