Skip to content

Commit 52d6f4c

Browse files
committed
fixup fkine_all
1 parent 672650f commit 52d6f4c

File tree

1 file changed

+32
-83
lines changed

1 file changed

+32
-83
lines changed

β€Žroboticstoolbox/robot/ERobot.pyβ€Ž

Lines changed: 32 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"""
66

77
from os.path import splitext
8+
import copy
89
import tempfile
910
import subprocess
1011
import webbrowser
@@ -129,7 +130,7 @@ def __init__(
129130
# if link has no name, give it one
130131
if link.name is None:
131132
link.name = f"link-{k}"
132-
link.number = k
133+
link.number = k + 1
133134

134135
# put it in the link dictionary, check for duplicates
135136
if link.name in self._linkdict:
@@ -615,23 +616,23 @@ def recurse(link):
615616
while True:
616617
segs.append(link)
617618
if link.nchildren == 0:
618-
return segs
619+
return [segs]
619620
elif link.nchildren == 1:
620621
link = link.children[0]
621622
continue
622623
elif link.nchildren > 1:
623624
segs = [segs]
624625

625626
for child in link.children:
626-
segs.append(recurse(child))
627+
segs.extend(recurse(child))
627628

628629
return segs
629630

630631
return recurse(self.links[0])
631632

632633
# --------------------------------------------------------------------- #
633634

634-
def fkine_path(self, q, old=None):
635+
def fkine_all(self, q, old=None):
635636
'''
636637
Compute the pose of every link frame
637638
@@ -640,11 +641,11 @@ def fkine_path(self, q, old=None):
640641
:return: Pose of all links
641642
:rtype: SE3 instance
642643
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 +
644645
1`` values:
645646
646647
- ``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``
648649
649650
:references:
650651
- Kinematic Derivatives using the Elementary Transform
@@ -660,7 +661,7 @@ def recurse(Tall, Tparent, q, link):
660661
T = Tparent
661662
while True:
662663
T *= link.A(q[link.jindex])
663-
Tall[link.number + 1] = T
664+
Tall[link.number] = T
664665

665666
if link.nchildren == 1:
666667
link = link.children[0]
@@ -1273,90 +1274,38 @@ def fkine(
12731274

12741275
return T
12751276

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)
13081277

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.
13101282

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)
13331285

1334-
:param q: The joint angles/configuration of the robot
1335-
:type q: float ndarray(n)
1286+
# .. note::
13361287

1337-
.. note::
1288+
# - The robot's base transform, if present, are incorporated
1289+
# into the result.
13381290

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
13411294

1342-
:references:
1343-
- Kinematic Derivatives using the Elementary Transform
1344-
Sequence, J. Haviland and P. Corke
1295+
# '''
13451296

1346-
'''
1297+
# fknm.fkine_all(
1298+
# self._cache_m,
1299+
# self._cache_links_fknm,
1300+
# q,
1301+
# self._base.A)
13471302

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)
13601309

13611310
def get_path(self, end=None, start=None, _fknm=False):
13621311
"""

0 commit comments

Comments
 (0)