class documentation

class ROS2SpatialMixin(ROS2MutationMixin):

Constructor: ROS2SpatialMixin(*args, **kwargs)

View In Hierarchy

Gives a machinery item that declared a TF Binding its SpatialObject and its TF reading.

Goes on the Machine and on Components, because OPC 10000-210 6.1.1 defines the SpatialObjectType as an AddIn extending an existing object. It also opens the item's TF watch. The facet reference-counts, so any number of items share one pair of subscriptions, and the watch must exist before a required TF Binding waits on it. Topics and depth come from the Machine's ~opensmi.ros2.server.config.TransformConfig, so every item reads the same frame network.

Method __init__ Start out with no SpatialObject, and pass every argument to opensmi.
Property ros2_spatial_object Return this item's SpatialObject, or None when it declared no TF Binding.
Property ros2_tf_binding Return the one TF Binding this item declared, or None.
Property ros2_transform_presence Return, per TF Binding name, whether anything is publishing transforms right now.
Property ros2_transform_settings Return where this item's Machine reads TF from, and how often it polls.
Async Method _init_ros2_spatial_object Create this item's SpatialObject and open its TF watch, if it declared a TF Binding.
Method _ros2_runtime_for_tf Return the Runtime this item reaches TF through.
Async Method _stop_spatial_object Close this item's TF watch. Idempotent.
Instance Variable _ros2_spatial_object Undocumented
Instance Variable _ros2_tf_watch Undocumented
def __init__(self, *args: Any, **kwargs: Any):

Start out with no SpatialObject, and pass every argument to opensmi.

@property
ros2_spatial_object: SpatialObject | None =

Return this item's SpatialObject, or None when it declared no TF Binding.

@property
ros2_tf_binding: TFBinding | None =

Return the one TF Binding this item declared, or None.

A machinery item has one head frame, and OPC 10000-210 gives a SpatialObject one PositionFrame.

Raises
DeclarationErrorWhen this item declares more than one.
@property
ros2_transform_presence: Mapping[str, bool] =

Return, per TF Binding name, whether anything is publishing transforms right now.

Presence only, never a particular frame: a required TF Binding that waited for tool0 would keep the Machine from starting until somebody switched an arm on.

@property
ros2_transform_settings: TransformConfig =

Return where this item's Machine reads TF from, and how often it polls.

A Component answers with its Machine's settings. An item whose Machine is not one of ours gets the defaults.

async def _init_ros2_spatial_object(self):

Create this item's SpatialObject and open its TF watch, if it declared a TF Binding.

The PositionFrame starts at zero metres on the World Frame; the first poll re-bases it onto its head frame's TF parent. The SpatialObject is created here instead of by opensmi's spatial-object mixin, because that mixin needs a typed-parent property a Component need not have.

Raises
DeclarationErrorWhen the Machine has no spatial-object list.
def _ros2_runtime_for_tf(self) -> RuntimeInterface:

Return the Runtime this item reaches TF through.

Raises
DeclarationErrorWhen there is none (a wiring fault).
async def _stop_spatial_object(self):

Close this item's TF watch. Idempotent.

It runs before the Runtime stops, so an item torn down alone stops reading.

_ros2_spatial_object: SpatialObject | None =

Undocumented

_ros2_tf_watch: TFWatch | None =

Undocumented