@@ -146,6 +146,9 @@ def __init__(
146
146
for link in links :
147
147
if isinstance (link .parent , str ):
148
148
link ._parent = self ._linkdict [link .parent ]
149
+ # Update the fast kinematics object
150
+ if isinstance (self , ERobot ):
151
+ link ._init_fknm ()
149
152
150
153
if all ([link .parent is None for link in links ]):
151
154
# no parent links were given, assume they are sequential
@@ -1039,6 +1042,8 @@ def URDF(cls, file_path, gripper=None):
1039
1042
1040
1043
return cls (links , name = name , gripper_links = gripper )
1041
1044
1045
+ # --------------------------------------------------------------------- #
1046
+
1042
1047
def _reset_cache (self ):
1043
1048
self ._path_cache = {}
1044
1049
self ._path_cache_fknm = {}
@@ -1080,9 +1085,9 @@ def _reset_cache(self):
1080
1085
# path.reverse()
1081
1086
# return path
1082
1087
1083
- def to_dict (self , show_robot = True , show_collision = False ):
1088
+ def _to_dict (self , show_robot = True , show_collision = False ):
1084
1089
1085
- self .fkine_links (self .q )
1090
+ self ._set_link_fk (self .q )
1086
1091
1087
1092
ob = []
1088
1093
@@ -1108,7 +1113,7 @@ def to_dict(self, show_robot=True, show_collision=False):
1108
1113
1109
1114
return ob
1110
1115
1111
- def fk_dict (self , show_robot = True , show_collision = False ):
1116
+ def _fk_dict (self , show_robot = True , show_collision = False ):
1112
1117
ob = []
1113
1118
1114
1119
# Do the robot
@@ -1133,6 +1138,47 @@ def fk_dict(self, show_robot=True, show_collision=False):
1133
1138
1134
1139
return ob
1135
1140
1141
+ def _set_link_fk (self , q ):
1142
+ '''
1143
+ robot._set_link_fk(q) evaluates fkine for each link within a
1144
+ robot and stores that pose in a private variable within the link.
1145
+
1146
+ This method is not for general use.
1147
+
1148
+ :param q: The joint angles/configuration of the robot
1149
+ :type q: float ndarray(n)
1150
+
1151
+ .. note::
1152
+
1153
+ - The robot's base transform, if present, are incorporated
1154
+ into the result.
1155
+
1156
+ :references:
1157
+ - Kinematic Derivatives using the Elementary Transform
1158
+ Sequence, J. Haviland and P. Corke
1159
+
1160
+ '''
1161
+
1162
+ if self ._base is None :
1163
+ base = self ._eye_fknm
1164
+ else :
1165
+ base = self ._base .A
1166
+
1167
+ fknm .fkine_all (
1168
+ self ._cache_m ,
1169
+ self ._cache_links_fknm ,
1170
+ q ,
1171
+ base )
1172
+
1173
+ for i in range (len (self ._cache_grippers )):
1174
+ fknm .fkine_all (
1175
+ len (self ._cache_grippers [i ]),
1176
+ self ._cache_grippers [i ],
1177
+ self .grippers [i ].q ,
1178
+ base )
1179
+
1180
+ # --------------------------------------------------------------------- #
1181
+
1136
1182
@staticmethod
1137
1183
def URDF_read (file_path , tld = None ):
1138
1184
"""
@@ -1279,38 +1325,6 @@ def fkine(
1279
1325
1280
1326
return T
1281
1327
1282
- # def fkine_links(self, q):
1283
- # '''
1284
- # robot.fkine_links(q) evaluates fkine for each link within a
1285
- # robot and stores that pose within the link.
1286
-
1287
- # :param q: The joint angles/configuration of the robot
1288
- # :type q: float ndarray(n)
1289
-
1290
- # .. note::
1291
-
1292
- # - The robot's base transform, if present, are incorporated
1293
- # into the result.
1294
-
1295
- # :references:
1296
- # - Kinematic Derivatives using the Elementary Transform
1297
- # Sequence, J. Haviland and P. Corke
1298
-
1299
- # '''
1300
-
1301
- # fknm.fkine_all(
1302
- # self._cache_m,
1303
- # self._cache_links_fknm,
1304
- # q,
1305
- # self._base.A)
1306
-
1307
- # for i in range(len(self._cache_grippers)):
1308
- # fknm.fkine_all(
1309
- # len(self._cache_grippers[i]),
1310
- # self._cache_grippers[i],
1311
- # self.grippers[i].q,
1312
- # self._base.A)
1313
-
1314
1328
def get_path (self , end = None , start = None , _fknm = False ):
1315
1329
"""
1316
1330
Find a path from start to end. The end must come after
0 commit comments