34 from numpy
import matrix, vsplit, sin, cos, reshape, pi, array
39 This represents a chain of actuated joints 40 parameters = [gearing*num_of_joints] 44 self.
tip = config[
'tip']
47 self.
_M = len(config[
'active_joints'])
49 rospy.logdebug(
"Initializing joint chain with [%u] links", self.
_M)
52 self.
_axis = numpy.matrix([ eval(str(x))
for x
in config[
'axis']], float)
57 return [x == 1
for x
in free_config[
'gearing']]
61 config_dict[
'axis'] = self._axis.tolist()
62 config_dict[
'gearing'] = (array(param_vec)[:,0]).tolist()
64 config_dict[
'root'] = self.
root 65 config_dict[
'tip'] = self.
tip 70 self.
_gearing = array(param_vec)[:,0].tolist()
83 def fk(self, chain_state, link_num=-1):
87 pos_trimmed = chain_state.position[0:(link_num+1)]
88 gearing_trimmed = self.
_gearing[0:(link_num+1)]
90 pos_scaled = [cur_pos * cur_gearing
for cur_pos, cur_gearing
in zip(pos_trimmed, gearing_trimmed)]
92 T = matrix([ [ 1, 0, 0, 0 ],
103 k = int(self.
_axis[0,m])
104 p = transform.deflate()
107 p[k-1] = p[k-1] + pos_scaled[m]
109 p[abs(k)-1] = p[abs(k)-1] - pos_scaled[m]
113 T = T * transform.transform
122 T_roll = matrix([ [ 1, 0, 0, 0 ],
123 [ 0, cos(r), -sin(r), 0 ],
124 [ 0, sin(r), cos(r), 0 ],
127 T_pitch = matrix([ [ cos(p), 0, sin(p), 0 ],
129 [ -sin(p), 0, cos(p), 0 ],
132 T_yaw = matrix([ [ cos(y), -sin(y), 0, 0 ],
133 [ sin(y), cos(y), 0, 0 ],
138 T_trans = matrix([ [ 1, 0, 0, link_params[0] ],
139 [ 0, 1, 0, link_params[1] ],
140 [ 0, 0, 1, link_params[2] ],
143 return T_trans * T_roll * T_pitch * T_yaw
def inflate(self, param_vec)
def calc_free(self, free_config)
def fk(self, chain_state, link_num=-1)
def __init__(self, config)
def params_to_config(self, param_vec)