Skip to content

Commit 00605bb

Browse files
committed
add options to prod() method relevant to composition of many transforms
1 parent 6ba8539 commit 00605bb

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

spatialmath/baseposematrix.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ def simplify(self) -> Self:
556556
:rtype: pose instance
557557
558558
Apply symbolic simplification to every element of every value in the
559-
pose instane.
559+
pose instance.
560560
561561
Example::
562562
@@ -1041,10 +1041,14 @@ def animate(self, *args, start=None, **kwargs) -> None:
10411041
return smb.tranimate(self.A, start=start, *args, **kwargs)
10421042

10431043
# ------------------------------------------------------------------------ #
1044-
def prod(self) -> Self:
1044+
def prod(self, norm=False, check=True) -> Self:
10451045
r"""
10461046
Product of elements (superclass method)
10471047
1048+
:param norm: normalize the product, defaults to False
1049+
:type norm: bool, optional
1050+
:param check: check that computed matrix is valid member of group, default True
1051+
:bool check: bool, optional
10481052
:return: Product of elements
10491053
:rtype: pose instance
10501054
@@ -1056,11 +1060,18 @@ def prod(self) -> Self:
10561060
>>> from spatialmath import SE3
10571061
>>> x = SE3.Rx([0, 0.1, 0.2, 0.3])
10581062
>>> x.prod()
1063+
1064+
.. note:: When compounding many transformations the product may become
1065+
denormalized resulting in a result that is not a proper member of the
1066+
group. You can either disable membership checking by ``check=False``
1067+
which is risky, or normalize the result by ``norm=True``.
10591068
"""
10601069
Tprod = self.__class__._identity() # identity value
10611070
for T in self.data:
10621071
Tprod = Tprod @ T
1063-
return self.__class__(Tprod)
1072+
if norm:
1073+
Tprod = smb.trnorm(Tprod)
1074+
return self.__class__(Tprod, check=check)
10641075

10651076
def __pow__(self, n: int) -> Self:
10661077
"""

0 commit comments

Comments
 (0)