Documentation
Summary
Mixin class for supported spatialmath-python classes adding the from_ros and to_ros conversion methods. |
|
Produce an instance of the class from a supported ROS message. |
|
Return an equivalent ROS message to this object. |
|
|
Spatialmath SE3 class with ROS compatibility |
|
Spatialmath SO3 class with ROS compatibility |
|
Spatialmath UnitQuaternion class with ROS compatibility |
Convert a supported spatialmath object to an equivalent ROS message. |
|
Convert a supported ROS message to an equivalent spatialmath object. |
|
Monkey-patch the spatialmath library, adding ROSCompatMixin to the base classes of SE3, SO3 and UnitQuaternion |
API Reference
Integration module between spatialmath-python and rospy.
- class spatialmath_rospy.ROSCompatMixin[source]
Bases:
objectMixin class for supported spatialmath-python classes adding the from_ros and to_ros conversion methods.
Expected only to work with
sm.SE3,sm.SO3andsm.UnitQuaternion.- classmethod from_ros(obj: Union[gm.Pose, gm.Transform, gm.Quaternion]) Self[source]
Produce an instance of the class from a supported ROS message.
The following conversions are supported:
Pose->SE3Quaternion->UnitQuaternionTransform->SE3
- Parameters
obj – The ROS message to convert. (
Pose|Transform|Quaternion).- Returns
An instance of this subclass.
- Raises
AssertionError – If this class type is not supported.
- to_ros(header: None = None, *, as_tf: Literal[False] = False) gm.Pose[source]
- to_ros(header: Header, *, as_tf: Literal[False] = False) gm.PoseStamped
- to_ros(header: None = None, *, as_tf: Literal[True]) gm.Transform
- to_ros(header: Header, *, as_tf: Literal[True]) gm.TransformStamped
- to_ros(header: None = None, *, as_tf: Literal[True]) gm.Quaternion
- to_ros(header: Header, *, as_tf: Literal[False]) gm.QuaternionStamped
Return an equivalent ROS message to this object. The following conversions are supported:
SE3|SO3|UnitQuaternion->Transform|TransformStamped.UnitQuaternion->Quaternion|QuaternionStamped
- Parameters
header – Optional ros msg
Header. If provided, the *Stamped equivalent message will be output.as_tf – Whether to return the result as a
Transform, instead of aPoseorQuaternion.
- Returns
The resulting ROS message.
- Raises
AssertionError – If this object is not a supported type.
- class spatialmath_rospy.SE3(*args, **kwargs)[source]
Bases:
SE3,ROSCompatMixinSpatialmath SE3 class with ROS compatibility
- class spatialmath_rospy.SO3(*args, **kwargs)[source]
Bases:
SO3,ROSCompatMixinSpatialmath SO3 class with ROS compatibility
- class spatialmath_rospy.UnitQuaternion(s: Optional[Any] = None, v=None, norm=True, check=True)[source]
Bases:
UnitQuaternion,ROSCompatMixinSpatialmath UnitQuaternion class with ROS compatibility
- spatialmath_rospy.monkey_patch_spatialmath()[source]
Monkey-patch the spatialmath library, adding ROSCompatMixin to the base classes of SE3, SO3 and UnitQuaternion
- spatialmath_rospy.to_ros(obj: Union[SE3, SO3, UnitQuaternion], header: Optional[Header] = None, *, as_tf: bool = False) Union[gm.Pose, gm.PoseStamped, gm.Quaternion, gm.QuaternionStamped, gm.Transform, gm.TransformStamped][source]
Convert a supported spatialmath object to an equivalent ROS message. The following conversions are supported:
SE3|SO3|UnitQuaternion->Transform|TransformStamped.UnitQuaternion->Quaternion|QuaternionStamped
- Parameters
obj – The spatialmath object to convert. Can be an
SE3,SO3or aUnitQuaternionheader – Optional ros msg
Header. If provided, the *Stamped equivalent message will be output.as_tf – Whether to return the result as a
Transform, instead of aPoseorQuaternion.
- Returns
The resulting ROS message.
- Raises
AssertionError – If obj’s type is not supported.
- spatialmath_rospy.to_spatialmath(obj: Union[gm.Pose, gm.Transform, gm.Quaternion]) Union[SE3, UnitQuaternion][source]
Convert a supported ROS message to an equivalent spatialmath object. The following conversions are supported:
gm.Pose->sm.SE3gm.Quaternion->sm.UnitQuaterniongm.Transform->sm.SE3
- Parameters
obj – The ROS message to convert. Can be a
gm.Pose,gm.Transformorgm.Quaternion.- Returns
The resulting spatialmath object. (
sm.SE3orsm.UnitQuaternion)- Raises
AssertionError – If obj’s type is not supported.