Skip to content

Commit 2ba339b

Browse files
committed
tidyup, sympy niceness
1 parent 6f15606 commit 2ba339b

File tree

1 file changed

+30
-11
lines changed

1 file changed

+30
-11
lines changed

roboticstoolbox/robot/ERobot.py

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,8 @@ def urdf_to_ets_args(self, file_path, tld=None):
423423
:type tld: str, optional
424424
:return: Links and robot name
425425
:rtype: tuple(ELink list, str)
426+
427+
File should be specified relative to ``RTBDATA/URDF/xacro``
426428
"""
427429

428430
# get the path to the class that defines the robot
@@ -1054,11 +1056,11 @@ def fkine(self, q, end=None, start=None, tool=None):
10541056
Tk = self.base.A @ Tk
10551057

10561058
# cast to pose class and append
1057-
T.append(T.__class__(Tk))
1059+
T.append(T.__class__(Tk, check=False))
10581060

10591061
return T
10601062

1061-
def fkine_all(self, q):
1063+
def fkine_all(self, q, old=None):
10621064
'''
10631065
Tall = robot.fkine_all(q) evaluates fkine for each joint within a
10641066
robot and returns a trajecotry of poses.
@@ -1070,6 +1072,7 @@ def fkine_all(self, q):
10701072
if not supplied will use the stored q values).
10711073
:type q: float ndarray(n)
10721074
1075+
:param old: for compatibility with DHRobot version, ignored.
10731076
:return T: Homogeneous transformation trajectory
10741077
:rtype T: SE3 list
10751078
@@ -1123,6 +1126,9 @@ def fkine_all(self, q):
11231126
for gi in link.geometry:
11241127
gi.wT = link._fk
11251128

1129+
# HACK, inefficient to convert back to SE3
1130+
return [SE3(link._fk) for link in self.elinks]
1131+
11261132
# def jacob0(self, q=None):
11271133
# """
11281134
# J0 = jacob0(q) is the manipulator Jacobian matrix which maps joint
@@ -1395,7 +1401,7 @@ def jacob0(self, q, end=None, start=None, tool=None, T=None, half=None, analytic
13951401
.. warning:: ``start`` and ``end`` must be on the same branch,
13961402
with ``start`` closest to the base.
13971403
""" # noqa
1398-
1404+
13991405
if tool is None:
14001406
tool = SE3()
14011407

@@ -1697,6 +1703,8 @@ def add_pdi(pdi):
16971703

16981704
def hessian0(self, q=None, J0=None, end=None, start=None):
16991705
r"""
1706+
Manipulator Hessian
1707+
17001708
The manipulator Hessian tensor maps joint acceleration to end-effector
17011709
spatial acceleration, expressed in the world-coordinate frame. This
17021710
function calulcates this based on the ETS of the robot. One of J0 or q
@@ -1715,7 +1723,7 @@ def hessian0(self, q=None, J0=None, end=None, start=None):
17151723
:return: The manipulator Hessian in 0 frame
17161724
:rtype: float ndarray(6,n,n)
17171725
1718-
This method computes the manipulator Hessian. If we take the
1726+
This method computes the manipulator Hessian in the base frame. If we take the
17191727
time derivative of the differential kinematic relationship
17201728
17211729
.. math::
@@ -1886,7 +1894,10 @@ def __str__(self):
18861894
color = "" if link.isjoint else "<<blue>>"
18871895
ee = "@" if link in self.ee_links else ""
18881896
ets = link.ets()
1889-
parent_name = link.parent.name if link.parent is not None else "_O_"
1897+
if link.parent is None:
1898+
parent_name = "BASE"
1899+
else:
1900+
parent_name = '{' + link.parent.name + '}'
18901901
s = ets.__str__(f"q{link._jindex}")
18911902
if len(s) > 0:
18921903
s = " * " + s
@@ -1895,10 +1906,10 @@ def __str__(self):
18951906
color + ee + link.name,
18961907
parent_name,
18971908
link._joint_name if link.parent is not None else "",
1898-
f"{{{link.name}}} = {{{parent_name}}}{s}"
1909+
f"{{{link.name}}} = {parent_name}{s}"
18991910
)
19001911

1901-
if self.manufacturer is None:
1912+
if self.manufacturer is None or len(self.manufacturer) == 0:
19021913
manuf = ""
19031914
else:
19041915
manuf = f" (by {self.manufacturer})"
@@ -2110,7 +2121,7 @@ def indiv_calculation(link, link_col, q):
21102121
return Ain, bin
21112122

21122123
# inverse dynamics (recursive Newton-Euler) using spatial vector notation
2113-
def rne(robot, q, qd, qdd, gravity=None):
2124+
def rne(robot, q, qd, qdd, symbolic=False, gravity=None):
21142125

21152126
n = robot.n
21162127

@@ -2123,12 +2134,18 @@ def rne(robot, q, qd, qdd, gravity=None):
21232134
f = SpatialForce.Alloc(n)
21242135
I = SpatialInertia.Alloc(n) # noqa
21252136
s = [None for i in range(n)] # joint motion subspace
2126-
Q = np.zeros((n,)) # joint torque/force
2137+
if symbolic:
2138+
Q = np.empty((n,), dtype='O') # joint torque/force
2139+
else:
2140+
Q = np.empty((n,)) # joint torque/force
21272141

21282142
# initialize intermediate variables
21292143
for j, link in enumerate(robot):
21302144
I[j] = SpatialInertia(m=link.m, r=link.r)
2131-
Xtree[j] = SE3(link.Ts)
2145+
if symbolic and link.Ts is None:
2146+
Xtree[j] = SE3(np.eye(4, dtype='O'), check=False)
2147+
else:
2148+
Xtree[j] = SE3(link.Ts, check=False)
21322149
s[j] = link.v.s
21332150

21342151
if gravity is None:
@@ -2157,7 +2174,9 @@ def rne(robot, q, qd, qdd, gravity=None):
21572174

21582175
# backward recursion
21592176
for j in reversed(range(0, n)):
2160-
Q[j] = f[j].dot(s[j])
2177+
2178+
# next line could be np.dot(), but fails for symbolic arguments
2179+
Q[j] = np.sum(f[j].A * s[j])
21612180

21622181
if robot[j].parent is not None:
21632182
jp = robot[j].parent.jindex

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy