Skip to content

Commit d90607b

Browse files
committed
Added a copy_from method to copy inputs instead of just passing by reference to SE3
1 parent 3a93de3 commit d90607b

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

spatialmath/pose3d.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1934,6 +1934,27 @@ def Rt(
19341934
t = np.zeros((3,))
19351935
return cls(smb.rt2tr(R, t, check=check), check=check)
19361936

1937+
@classmethod
1938+
def CopyFrom(
1939+
cls,
1940+
T: SE3Array,
1941+
check: bool = True
1942+
) -> SE3:
1943+
"""
1944+
Create an SE(3) from a 4x4 numpy array that is passed by value.
1945+
1946+
:param T: homogeneous transformation
1947+
:type T: ndarray(4, 4)
1948+
:param check: check rotation validity, defaults to True
1949+
:type check: bool, optional
1950+
:raises ValueError: bad rotation matrix, bad transformation matrix
1951+
:return: SE(3) matrix representing that transformation
1952+
:rtype: SE3 instance
1953+
"""
1954+
if T is None:
1955+
raise ValueError("Transformation matrix must not be None")
1956+
return cls(np.copy(T), check=check)
1957+
19371958
def angdist(self, other: SE3, metric: int = 6) -> float:
19381959
r"""
19391960
Angular distance metric between poses

0 commit comments

Comments
 (0)