Spatial momentum
- class SpatialMomentum(value=None)[source]
Bases:
spatialmath.spatialvector.SpatialF6
Spatial momentum class
Concrete subclass of SpatialF6 and represents the translational and rotational momentum of a rigid-body in 3D space.
- Seealso
- classmethod Alloc(n=1)
Construct an instance with N default values (BasePoseList superclass method)
- Parameters
n (int, optional) – Number of values, defaults to 1
- Return type
Self
- Returns
pose instance with
n
default values
X.Alloc(N)
creates an instance of the pose classX
withN
default values, ie.len(X)
will beN
.X
can be considered a vector of pose objects, and those elements can be referencedX[i]
or assigned toX[i] = ...
.Note
The default value depends on the pose class and is the result of the empty constructor. For
SO2
,SE2
,SO3
,SE3
it is an identity matrix, for a twist classTwist2
orTwist3
it is a zero vector, for aUnitQuaternion
orQuaternion
it is a zero vector.Example:
>>> x = X.Alloc(10) >>> len(x) 10
where
X
is any of the SMTB classes.
- classmethod Empty()
Construct an empty instance (BasePoseList superclass method)
- Return type
Self
- Returns
pose instance with zero values
Example:
>>> x = X.Empty() >>> len(x) 0
where
X
is any of the SMTB classes.
- __add__(right)
Overloaded
*
operator (superclass method)- Returns
sum of spatial vectors
- Return type
SpatialVector subclass instance
- Raises
TypeError – attempting to add SpatialVectors of different subclass
ValueErrror – attempting to add SpatialVectors with different numbers of values
v1 + v2
is a spatial vector of the same type asv1
andv2
whose value is the element-wise sum ofv1
andv2
. If both are arrays of spatial vectors V1 (1xN) and V2 (1xN) the result is an array (1xN).- Seealso
- __init__(value=None)[source]
Create a new spatial vector (abstract superclass)
- Parameters
value – Value of the
SpatialVector(vec)
is a spatial vector constructed from the 6-element array-likevec
SpatialVector([V1, V2, ... VN])
is a spatial vector array with N elements, constructed from the 6-element array-like valuesVi
SpatialVector(A)
is a spatial vector array with N elements, constructed from the columns of the 6xN arrayA
.
- __sub__(right)
Overloaded
-
operator (superclass method)- Returns
difference of spatial vectors
- Return type
SpatialVector subclass instance
- Raises
TypeError – attempting to subtract SpatialVectors of different subclass
ValueErrror – attempting to subtract SpatialVectors with different numbers of values
v1 - v2
is a spatial vector of the same type asv1
andv2
whose value is the element-wise difference ofv1
andv2
. If both are arrays of spatial vectors V1 (1xN) and V2 (1xN) the result is an array (1xN).- Seealso
__add__()
,__neg__()
- append(item)
Append a value to an instance (BasePoseList superclass method)
- Parameters
x (Quaternion or UnitQuaternion instance) – the value to append
- Raises
ValueError – incorrect type of appended object
Appends the argument to the object’s internal list of values.
Example:
>>> x = X.Alloc(10) >>> len(x) 10 >>> x.append(X()) # append to the list >>> len(x) 11
where
X
is any of the SMTB classes.- Return type
None
- clear() None -- remove all items from S
- dot(value)
- extend(iterable)
Extend sequence of values in an instance (BasePoseList superclass method)
- Parameters
x (instance of same type) – the value to extend
- Raises
ValueError – incorrect type of appended object
Appends the argument’s values to the object’s internal list of values.
Example:
>>> x = X.Alloc(10) >>> len(x) 10 >>> x.append(X.Alloc(5)) # extend the list >>> len(x) 15
where
X
is any of the SMTB classes.- Return type
None
- insert(i, item)
Insert a value to an instance (BasePoseList superclass method)
- Parameters
i (int) – element to insert value before
item (instance of same type) – the value to insert
- Raises
ValueError – incorrect type of inserted value
Inserts the argument into the object’s internal list of values.
Example:
>>> x = X.Alloc(10) >>> len(x) 10 >>> x.insert(0, X()) # insert at start of list >>> len(x) 11 >>> x.insert(10, X()) # append to the list >>> len(x) 11
where
X
is any of the SMTB classes.Note
If
i
is beyond the end of the list, the item is appended to the list- Return type
None
- isvalid(x, check)
Test if vector is valid spatial vector
- Parameters
x (numpy.ndarray) – vector to test
check (bool) – ignored
- Returns
True if the matrix has shape (6,).
- Return type
bool
- pop(i=- 1)
Pop value from an instance (BasePoseList superclass method)
- Parameters
i (int) – item in the list to pop, default is last
- Returns
the popped value
- Return type
instance of same type
- Raises
IndexError – if there are no values to pop
Removes a value from the value list and returns it. The original instance is modified.
Example:
>>> x = X.Alloc(10) >>> len(x) 10 >>> y = x.pop() # pop the last value x[9] >>> len(x) 9 >>> y = x.pop(0) # pop the first value x[0] >>> len(x) 8
where
X
is any of the SMTB classes.
- reverse()
S.reverse() – reverse IN PLACE
- property A: Union[List[numpy.ndarray[Any, numpy.dtype[numpy.typing._generic_alias.ScalarType]]], numpy.ndarray[Any, numpy.dtype[numpy.typing._generic_alias.ScalarType]]]
Array value of an instance (BasePoseList superclass method)
- Returns
NumPy array value of this instance
- Return type
ndarray
X.A
is a NumPy array that represents the value of this instance, and has a shape given byX.shape
.
Note
This assumes that
len(X)
== 1, ie. it is a single-valued instance.
- property shape
Shape of the object’s interal matrix representation
- Returns
(6,)
- Return type
tuple