Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions spatialmath/base/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@
"qprint",
"q2str",
# spatialmath.base.transforms2d
"pos2tr2",
"rot2",
"trot2",
"transl2",
Expand All @@ -219,6 +220,9 @@
"trexp2",
"trnorm2",
"tr2jac2",
"tr2pos2",
"tr2adjoint2",
"tradjoint2",
"trinterp2",
"trprint2",
"trplot2",
Expand Down
23 changes: 20 additions & 3 deletions spatialmath/base/transforms2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import sys
import math
import warnings
import numpy as np

try:
Expand Down Expand Up @@ -758,16 +759,16 @@ def trnorm2(T: SE2Array) -> SE2Array:


@overload # pragma: no cover
def tradjoint2(T: SO2Array) -> R1x1:
def tr2adjoint2(T: SO2Array) -> R1x1:
...


@overload # pragma: no cover
def tradjoint2(T: SE2Array) -> R3x3:
def tr2adjoint2(T: SE2Array) -> R3x3:
...


def tradjoint2(T):
def tr2adjoint2(T):
r"""
Adjoint matrix in 2D

Expand Down Expand Up @@ -818,6 +819,22 @@ def tradjoint2(T):
raise ValueError("bad argument")


def tradjoint2(T):
"""
Adjoint matrix in 2D (deprecated)

.. deprecated:: 1.1.16
Renamed to :func:`tr2adjoint2` for naming consistency. This alias
will be removed in a future release.
"""
warnings.warn(
"tradjoint2 is deprecated since 1.1.16, use tr2adjoint2 instead",
DeprecationWarning,
stacklevel=2,
)
return tr2adjoint2(T)


def tr2jac2(T: SE2Array) -> R3x3:
r"""
SE(2) Jacobian matrix
Expand Down
11 changes: 9 additions & 2 deletions tests/base/test_transforms2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,17 @@ def test_trinv2(self):
T = rt2tr(rot2(0.2), [1, 2])
nt.assert_array_almost_equal(trinv2(T) @ T, np.eye(3))

def test_tradjoint2(self):
def test_tr2adjoint2(self):
T = xyt2tr([1, 2, 0.2])
X = [1, 2, 3]
nt.assert_almost_equal(tradjoint2(T) @ X, vexa(T @ skewa(X) @ trinv2(T)))
nt.assert_almost_equal(tr2adjoint2(T) @ X, vexa(T @ skewa(X) @ trinv2(T)))

def test_tradjoint2_deprecated(self):
T = xyt2tr([1, 2, 0.2])
X = [1, 2, 3]
with self.assertWarns(DeprecationWarning):
result = tradjoint2(T)
nt.assert_almost_equal(result @ X, vexa(T @ skewa(X) @ trinv2(T)))

def test_points2tr2(self):
p1 = np.random.uniform(size=(2, 5))
Expand Down
Loading