@@ -65,7 +65,7 @@ def dh_to_ets(cls, robot):
65
65
ETS representation
66
66
67
67
:param robot: The robot model to be converted
68
- :type robot: SerialLink, required
68
+ :type robot: SerialLink
69
69
:return: List of returned :class:`bluepy.btle.Characteristic` objects
70
70
:rtype: ets class
71
71
"""
@@ -119,6 +119,72 @@ def dh_to_ets(cls, robot):
119
119
robot .base ,
120
120
robot .tool )
121
121
122
+ @property
123
+ def name (self ):
124
+ return self ._name
125
+
126
+ @property
127
+ def manuf (self ):
128
+ return self ._manuf
129
+
130
+ @property
131
+ def base (self ):
132
+ return self ._base
133
+
134
+ @property
135
+ def tool (self ):
136
+ return self ._tool
137
+
138
+ @property
139
+ def n (self ):
140
+ return self ._n
141
+
142
+ @property
143
+ def M (self ):
144
+ return self ._M
145
+
146
+ @property
147
+ def ets (self ):
148
+ return self ._ets
149
+
150
+ @property
151
+ def q_idx (self ):
152
+ return self ._q_idx
153
+
154
+ def fkine (self , q ):
155
+ '''
156
+ Evaluates the forward kinematics of a robot based on its ETS and
157
+ joint angles q.
158
+
159
+ :param q: The joint coordinates of the robot
160
+ :type q: float np.ndarray(n,)
161
+ :return: The transformation matrix representing the pose of the
162
+ end-effector
163
+ :rtype: float np.ndarray(4,4)
164
+
165
+ References: Kinematic Derivatives using the Elementary Transform
166
+ Sequence, J. Haviland and P. Corke
167
+ '''
168
+
169
+ # if not isinstance(q, np.ndarray):
170
+ # raise TypeError('q array must be a numpy ndarray.')
171
+ # if q.shape != (self._n,):
172
+ # raise ValueError('q must be a 1 dim (n,) array')
173
+
174
+ j = 0
175
+ trans = np .eye (4 )
176
+
177
+ for i in range (self .M ):
178
+ if self ._ets [i ]._type == 1 :
179
+ T = self ._ets [i ].T (q [j ])
180
+ j += 1
181
+ else :
182
+ T = self ._ets [i ].T ()
183
+
184
+ trans = trans @ T
185
+
186
+ return trans
187
+
122
188
def __str__ (self ):
123
189
"""
124
190
Pretty prints the ETS Model of the robot. Will output angles in degrees
@@ -129,15 +195,15 @@ def __str__(self):
129
195
axes = ''
130
196
131
197
for i in range (self ._n ):
132
- axes += self ._ets [self ._q_idx [i ]]._axis_s
198
+ axes += self .ets [self .q_idx [i ]].axis
133
199
134
200
model = '\n %s (%s): %d axis, %s, ETS\n ' \
135
201
'Elementary Transform Sequence:\n ' \
136
202
'%s\n ' \
137
203
'tool: t = (%g, %g, %g), RPY/xyz = (%g, %g, %g) deg' % (
138
- self ._name , self ._manuf , self ._n , axes ,
139
- self ._ets ,
140
- self ._tool [0 , 3 ], self ._tool [1 , 3 ], self ._tool [2 , 3 ], 0 , 0 , 0
204
+ self .name , self .manuf , self .n , axes ,
205
+ self .ets ,
206
+ self .tool [0 , 3 ], self .tool [1 , 3 ], self .tool [2 , 3 ], 0 , 0 , 0
141
207
)
142
208
143
209
return model
@@ -161,25 +227,49 @@ class et(object):
161
227
References: Kinematic Derivatives using the Elementary Transform Sequence,
162
228
J. Haviland and P. Corke
163
229
"""
164
- def __init__ (self , axis , axis_s , eta = None , i = None ):
230
+ def __init__ (self , axis_func , axis , eta = None , i = None ):
165
231
166
232
super (et , self ).__init__ ()
167
233
self .STATIC = 0
168
234
self .VARIABLE = 1
169
235
170
236
self ._eta = eta
237
+ self ._axis_func = axis_func
171
238
self ._axis = axis
172
- self ._axis_s = axis_s
173
239
174
- if self ._eta is not None :
240
+ if self .eta is not None :
175
241
self ._type = self .STATIC
176
- self ._T = axis (eta )
242
+ self ._T = axis_func (eta )
177
243
else :
178
244
self ._type = self .VARIABLE
179
245
self ._i = i
180
246
181
- if self ._type is self .STATIC and self ._axis_s [0 ] == 'R' :
182
- self ._eta_deg = self ._eta * (180 / np .pi )
247
+ if self ._type is self .STATIC and self .axis [0 ] == 'R' :
248
+ self ._eta_deg = self .eta * (180 / np .pi )
249
+
250
+ @property
251
+ def eta (self ):
252
+ return self ._eta
253
+
254
+ @property
255
+ def eta_deg (self ):
256
+ return self ._eta_deg
257
+
258
+ @property
259
+ def axis_func (self ):
260
+ return self ._eta
261
+
262
+ @property
263
+ def axis_func (self ):
264
+ return self ._axis_func
265
+
266
+ @property
267
+ def axis (self ):
268
+ return self ._axis
269
+
270
+ @property
271
+ def i (self ):
272
+ return self ._i
183
273
184
274
def T (self , q = None ):
185
275
"""
@@ -193,7 +283,7 @@ def T(self, q=None):
193
283
if self ._type is self .STATIC :
194
284
return self ._T
195
285
else :
196
- return self ._axis (q )
286
+ return self .axis_func (q )
197
287
198
288
def __str__ (self ):
199
289
"""
@@ -203,12 +293,12 @@ def __str__(self):
203
293
:rtype: str
204
294
"""
205
295
if self ._type is self .STATIC :
206
- if self ._axis_s [0 ] == 'R' :
207
- return '%s(%g)' % (self ._axis_s , self ._eta_deg )
296
+ if self .axis [0 ] == 'R' :
297
+ return '%s(%g)' % (self .axis , self .eta_deg )
208
298
else :
209
- return '%s(%g)' % (self ._axis_s , self ._eta )
299
+ return '%s(%g)' % (self .axis , self .eta )
210
300
else :
211
- return '%s(q%d)' % (self ._axis_s , self ._i )
301
+ return '%s(q%d)' % (self .axis , self .i )
212
302
213
303
def __repr__ (self ):
214
304
return str (self )
0 commit comments