Documentation

Summary

spatialmath_rospy.ROSCompatMixin()

Mixin class for supported spatialmath-python classes adding the from_ros and to_ros conversion methods.

spatialmath_rospy.ROSCompatMixin.from_ros(obj)

Produce an instance of the class from a supported ROS message.

spatialmath_rospy.ROSCompatMixin.to_ros()

Return an equivalent ROS message to this object.

spatialmath_rospy.SE3(*args, **kwargs)

Spatialmath SE3 class with ROS compatibility

spatialmath_rospy.SO3(*args, **kwargs)

Spatialmath SO3 class with ROS compatibility

spatialmath_rospy.UnitQuaternion([s, v, ...])

Spatialmath UnitQuaternion class with ROS compatibility

spatialmath_rospy.to_ros()

Convert a supported spatialmath object to an equivalent ROS message.

spatialmath_rospy.to_spatialmath()

Convert a supported ROS message to an equivalent spatialmath object.

spatialmath_rospy.monkey_patch_spatialmath()

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: object

Mixin class for supported spatialmath-python classes adding the from_ros and to_ros conversion methods.

Expected only to work with sm.SE3, sm.SO3 and sm.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:

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:

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 a Pose or Quaternion.

Returns

The resulting ROS message.

Raises

AssertionError – If this object is not a supported type.

class spatialmath_rospy.SE3(*args, **kwargs)[source]

Bases: SE3, ROSCompatMixin

Spatialmath SE3 class with ROS compatibility

class spatialmath_rospy.SO3(*args, **kwargs)[source]

Bases: SO3, ROSCompatMixin

Spatialmath SO3 class with ROS compatibility

class spatialmath_rospy.UnitQuaternion(s: Optional[Any] = None, v=None, norm=True, check=True)[source]

Bases: UnitQuaternion, ROSCompatMixin

Spatialmath 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:

Parameters
  • obj – The spatialmath object to convert. Can be an SE3, SO3 or a UnitQuaternion

  • 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 a Pose or Quaternion.

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.SE3

  • gm.Quaternion -> sm.UnitQuaternion

  • gm.Transform -> sm.SE3

Parameters

obj – The ROS message to convert. Can be a gm.Pose, gm.Transform or gm.Quaternion.

Returns

The resulting spatialmath object. (sm.SE3 or sm.UnitQuaternion)

Raises

AssertionError – If obj’s type is not supported.

Indices and tables