5
5
"""
6
6
7
7
from os .path import splitext
8
+ import copy
8
9
import tempfile
9
10
import subprocess
10
11
import webbrowser
@@ -129,7 +130,7 @@ def __init__(
129
130
# if link has no name, give it one
130
131
if link .name is None :
131
132
link .name = f"link-{ k } "
132
- link .number = k
133
+ link .number = k + 1
133
134
134
135
# put it in the link dictionary, check for duplicates
135
136
if link .name in self ._linkdict :
@@ -615,23 +616,23 @@ def recurse(link):
615
616
while True :
616
617
segs .append (link )
617
618
if link .nchildren == 0 :
618
- return segs
619
+ return [ segs ]
619
620
elif link .nchildren == 1 :
620
621
link = link .children [0 ]
621
622
continue
622
623
elif link .nchildren > 1 :
623
624
segs = [segs ]
624
625
625
626
for child in link .children :
626
- segs .append (recurse (child ))
627
+ segs .extend (recurse (child ))
627
628
628
629
return segs
629
630
630
631
return recurse (self .links [0 ])
631
632
632
633
# --------------------------------------------------------------------- #
633
634
634
- def fkine_path (self , q , old = None ):
635
+ def fkine_all (self , q , old = None ):
635
636
'''
636
637
Compute the pose of every link frame
637
638
@@ -640,11 +641,11 @@ def fkine_path(self, q, old=None):
640
641
:return: Pose of all links
641
642
:rtype: SE3 instance
642
643
643
- ``T = robot.fkine_path (q)`` is an SE3 instance with ``robot.nlinks +
644
+ ``T = robot.fkine_all (q)`` is an SE3 instance with ``robot.nlinks +
644
645
1`` values:
645
646
646
647
- ``T[0]`` is the base transform
647
- - ``T[i+1 ]`` is the pose of link whose ``number`` is ``i``
648
+ - ``T[i]`` is the pose of link whose ``number`` is ``i``
648
649
649
650
:references:
650
651
- Kinematic Derivatives using the Elementary Transform
@@ -660,7 +661,7 @@ def recurse(Tall, Tparent, q, link):
660
661
T = Tparent
661
662
while True :
662
663
T *= link .A (q [link .jindex ])
663
- Tall [link .number + 1 ] = T
664
+ Tall [link .number ] = T
664
665
665
666
if link .nchildren == 1 :
666
667
link = link .children [0 ]
@@ -1273,90 +1274,38 @@ def fkine(
1273
1274
1274
1275
return T
1275
1276
1276
- def fkine_all (self , q , old = None ):
1277
- '''
1278
- Tall = robot.fkine_all(q) evaluates fkine for each joint within a
1279
- robot and returns a trajecotry of poses.
1280
- Tall = fkine_all() as above except uses the stored q value of the
1281
- robot object.
1282
- :param q: The joint angles/configuration of the robot (Optional,
1283
- if not supplied will use the stored q values).
1284
- :type q: float ndarray(n)
1285
- :param old: for compatibility with DHRobot version, ignored.
1286
- :return T: Homogeneous transformation trajectory
1287
- :rtype T: SE3 list
1288
- .. note::
1289
- - The robot's base transform, if present, are incorporated
1290
- into the result.
1291
- :references:
1292
- - Kinematic Derivatives using the Elementary Transform
1293
- Sequence, J. Haviland and P. Corke
1294
- '''
1295
-
1296
- fknm .fkine_all (
1297
- self ._cache_m ,
1298
- self ._cache_links_fknm ,
1299
- q ,
1300
- self ._base .A )
1301
-
1302
- for i in range (len (self ._cache_grippers )):
1303
- fknm .fkine_all (
1304
- len (self ._cache_grippers [i ]),
1305
- self ._cache_grippers [i ],
1306
- self .grippers [i ].q ,
1307
- self ._base .A )
1308
1277
1309
- # for link in self.elinks:
1278
+ # def fkine_links(self, q):
1279
+ # '''
1280
+ # robot.fkine_links(q) evaluates fkine for each link within a
1281
+ # robot and stores that pose within the link.
1310
1282
1311
- # # Update the link model transforms as well
1312
- # for col in link.collision:
1313
- # col.wT = link._fk
1314
-
1315
- # for gi in link.geometry:
1316
- # gi.wT = link._fk
1317
-
1318
- # # Do the grippers now
1319
- # for gripper in self.grippers:
1320
- # for link in gripper.links:
1321
-
1322
- # # Update the link model transforms as well
1323
- # for col in link.collision:
1324
- # col.wT = link._fk
1325
-
1326
- # for gi in link.geometry:
1327
- # gi.wT = link._fk
1328
-
1329
- def fkine_links (self , q ):
1330
- '''
1331
- robot.fkine_links(q) evaluates fkine for each link within a
1332
- robot and stores that pose within the link.
1283
+ # :param q: The joint angles/configuration of the robot
1284
+ # :type q: float ndarray(n)
1333
1285
1334
- :param q: The joint angles/configuration of the robot
1335
- :type q: float ndarray(n)
1286
+ # .. note::
1336
1287
1337
- .. note::
1288
+ # - The robot's base transform, if present, are incorporated
1289
+ # into the result.
1338
1290
1339
- - The robot's base transform, if present, are incorporated
1340
- into the result.
1291
+ # :references:
1292
+ # - Kinematic Derivatives using the Elementary Transform
1293
+ # Sequence, J. Haviland and P. Corke
1341
1294
1342
- :references:
1343
- - Kinematic Derivatives using the Elementary Transform
1344
- Sequence, J. Haviland and P. Corke
1295
+ # '''
1345
1296
1346
- '''
1297
+ # fknm.fkine_all(
1298
+ # self._cache_m,
1299
+ # self._cache_links_fknm,
1300
+ # q,
1301
+ # self._base.A)
1347
1302
1348
- fknm .fkine_all (
1349
- self ._cache_m ,
1350
- self ._cache_links_fknm ,
1351
- q ,
1352
- self ._base .A )
1353
-
1354
- for i in range (len (self ._cache_grippers )):
1355
- fknm .fkine_all (
1356
- len (self ._cache_grippers [i ]),
1357
- self ._cache_grippers [i ],
1358
- self .grippers [i ].q ,
1359
- self ._base .A )
1303
+ # for i in range(len(self._cache_grippers)):
1304
+ # fknm.fkine_all(
1305
+ # len(self._cache_grippers[i]),
1306
+ # self._cache_grippers[i],
1307
+ # self.grippers[i].q,
1308
+ # self._base.A)
1360
1309
1361
1310
def get_path (self , end = None , start = None , _fknm = False ):
1362
1311
"""
0 commit comments