34 from __future__
import division
35 from threading
import Thread
43 from std_msgs.msg
import Float64, Int32, Float64MultiArray
44 from svenzva_msgs.msg
import MotorState, MotorStateList, GripperFeedback, GripperResult, GripperAction
45 from sensor_msgs.msg
import JointState
50 Teaching mode should be enabled when the motors are context-switched into force control mode. 51 This mode allows full movement and compliance from a human. 53 Otherwise, it is assumed the arm is in current-based position control mode, where compliance is 54 intelligently turned on while the arm is not carying out a trajectory, or has failed in doing so. 57 def __init__(self, controller_namespace, mx_io, teaching_mode=False):
61 rospy.Subscriber(
"revel/motor_states", MotorStateList, self.
motor_state_cb, queue_size=1)
62 rospy.Subscriber(
"revel/model_efforts", JointState, self.
model_effort_cb)
63 self.
test_pub = rospy.Publisher(
"/revel/smoothed_current", Float64)
64 self.
gr = [4,6,6,3,4,1,1]
80 torque_ar = [0
for x
in range(7)]
81 for i,state
in enumerate(data.motor_states):
82 torque_ar[i] = state.load
84 self.torque_window.pop(0)
85 self.torque_window.append(torque_ar)
92 window.append(windows[index])
102 Triangular smoothing function for noisy torque reading 107 smoothed=[0.0]*(len(list_val)-window)
108 for x
in range(1,2*degree):
109 weight.append(degree-abs(degree-x))
110 w=numpy.array(weight)
111 for i
in range(len(smoothed)):
112 smoothed[i]=sum(numpy.array(list_val[i:i+window])*w)/float(sum(w))
117 df = pd.DataFrame(data)
118 return df.rolling(window=5).mean()
136 mag = int(math.copysign(1, model_torque - self.motor_state.motor_states[motor_id-1].load ))
146 return (motor_id, goal)
151 return (motor_id, goal)
157 return int(round(tau / 1.083775 / .00336))
163 moving_status = self.mx_io.get_multi_moving_status(range(1,7))
165 for status
in moving_status:
166 is_moving |= status[1] & 0x2
173 vals.append( (i,1900) )
174 self.mx_io.set_multi_current(tuple(vals))
188 vals = [x
for x
in vals
if x
is not None]
191 self.mx_io.set_multi_current(tuple(vals))
196 return int(round( angle * 4096.0 / 6.2831853 ))
199 for i
in range(0, 6):
206 while not rospy.is_shutdown():
def feel_and_react_motor(self, motor_id, threshold=3, offset=0)
def rad_to_raw(self, angle)
def __init__(self, controller_namespace, mx_io, teaching_mode=False)
def extract_motor_window(self, index)
def model_effort_cb(self, msg)
def get_raw_current(self, tau)
def smoothListTriangle(self, list_val, strippedXs=False, degree=3)
def motor_state_cb(self, data)