class documentation

class ROS2TransformMirrorMixin(_OutwardPublishing):

Constructor: ROS2TransformMirrorMixin(*args, **kwargs)

View In Hierarchy

Keeps every SpatialObject on one Machine in step with the TF tree, on a timer.

Machine only: a frame belongs to the nearest declared head above it, and the heads are spread over the Machine and its Components. The period is declared on the Machine for the same reason (~opensmi.ros2.server.config.TransformConfig.interval). How many Locations one TF Binding may gain is ~opensmi.ros2.server.mutation.ROS2MutationMixin.mutation_node_cap on the declaring item; a robot with more frames says so once.

Method __init__ Start out with nothing rendered, and pass every argument to opensmi.
Async Method lifecycle_ros2_transform_mirror Start the poll once the whole Machine is built, and stop it before teardown.
Async Method refresh_transforms Read the frame network once and bring every SpatialObject into step with it.
Property ros2_frame_nodes Return the frame-to-node index: every rendered frame and the node holding it, as NodeId text.
Property ros2_transform_polls Return how often the frame network has been read, which a Machine with no TF leaves at 0.
Method _declared_spatial_objects Return this Machine's SpatialObject and every Component's, in browse order.
Async Method _init_transform_mirror Collect every SpatialObject on this Machine and start the poll, if there are any.
Async Method _poll_transforms Read the frame network on the interval and render it, until cancelled.
Async Method _pose_nodes Browse the nine value-bearing nodes of one Location, once, on its first bad write.
Async Method _report_separate_trees Say, as a BindingEvent, that more than one coordinate system is being presented as one.
Method _require_one_direction_per_frame Refuse a Machine on which two declarations claim one frame.
Async Method _stop_transform_mirror Stop the poll. Idempotent, and it leaves the watches to the items that opened them.
Async Method _write_alternatives Compose and write every alternative this object declared, creating new ones.
Async Method _write_faulted Write one bad reading onto the Location, its pose and its six scalars.
Async Method _write_locations Write every Location of one object: its pose, and the Base its TF parent implies.
Async Method _write_one Write one Location from the transform its TF parent published, and say how it is.
Async Method _write_pose Write one Location's pose, status and Base, and only what changed.
Async Method _write_reading Put one pose on a Location's nine value-bearing nodes, with its status.
Instance Variable _transform_interval Undocumented
Instance Variable _transform_objects Undocumented
Instance Variable _transform_outward Undocumented
Instance Variable _transform_polls Undocumented
Instance Variable _transform_quiet_after Undocumented
Instance Variable _transform_roots Undocumented
Instance Variable _transform_task Undocumented
Instance Variable _transform_world Undocumented
def __init__(self, *args: Any, **kwargs: Any):

Start out with nothing rendered, and pass every argument to opensmi.

@lifecycle(after=BaseMachineryItem.lifecycle_machinery_item)
async def lifecycle_ros2_transform_mirror(self) -> AsyncGenerator[None]:

Start the poll once the whole Machine is built, and stop it before teardown.

It starts after the Machine's _init because the Components' objects must exist first, and stops before _shutdown so no tick writes into a Component that is going away.

async def refresh_transforms(self):

Read the frame network once and bring every SpatialObject into step with it.

Public so that tests can drive the inward path without waiting for the timer.

@property
ros2_frame_nodes: Mapping[str, str] =

Return the frame-to-node index: every rendered frame and the node holding it, as NodeId text.

@property
ros2_transform_polls: int =

Return how often the frame network has been read, which a Machine with no TF leaves at 0.

def _declared_spatial_objects(self) -> tuple[_Owner, ...]:

Return this Machine's SpatialObject and every Component's, in browse order.

async def _init_transform_mirror(self):

Collect every SpatialObject on this Machine and start the poll, if there are any.

Nothing is created for frames the robot publishes and nothing is asked of it: the first tick is one interval away. Declared outward frames are created here, so a client may write them before the robot is on. The cross-object direction check runs first.

Raises
FrameDirectionErrorWhen two declarations on this Machine claim one frame.
async def _poll_transforms(self):

Read the frame network on the interval and render it, until cancelled.

async def _pose_nodes(self, node: Node) -> _Bearers:

Browse the nine value-bearing nodes of one Location, once, on its first bad write.

The result is safe to keep because nodes are never moved.

async def _report_separate_trees(self, roots: tuple[str, ...]):

Say, as a BindingEvent, that more than one coordinate system is being presented as one.

Once per distinct set of roots, and there is no clearing event. Nothing is said while no robot is publishing: before that, a Machine that publishes two frames under different bases has two roots by construction. Reported on the Machine's own TF Binding.

def _require_one_direction_per_frame(self, objects: Sequence[_Owner]):

Refuse a Machine on which two declarations claim one frame.

This is the cross-object half of the inward/outward rule, which no single declaration can see. It runs before anything is created.

Raises
FrameDirectionErrorWhen one frame is claimed twice.
async def _stop_transform_mirror(self):

Stop the poll. Idempotent, and it leaves the watches to the items that opened them.

async def _write_alternatives(self, owner: _Owner, *, frames: Mapping[str, FrameLink], quiet: _Quiet):

Compose and write every alternative this object declared, creating new ones.

This is the only place the transform buffer is asked anything. The lookup is synchronous, and a chain it cannot complete is skipped. An alternative carries the status of the frame it views, so two nodes never disagree about a quiet frame.

async def _write_faulted(self, held: _Frame, position: Position, orientation: Orientation, status: ua.StatusCode):

Write one bad reading onto the Location, its pose and its six scalars.

The scalars too, because clients subscribe to Position/X. Not the Base, which stays true while the frame is unreachable. The Location is written first; opensmi's child sync ignores a null value, so the children keep what is written to them next.

async def _write_locations(self, owner: _Owner, *, frames: Mapping[str, FrameLink], parents: Mapping[str, str], quiet: _Quiet):

Write every Location of one object: its pose, and the Base its TF parent implies.

This runs after all new Locations exist, so a Base never points at the World Frame for one tick and at a Location the next.

async def _write_one(self, held: _Frame, link: FrameLink | None, *, base: ua.NodeId, status: ua.StatusCode):

Write one Location from the transform its TF parent published, and say how it is.

A frame nothing has published yet still gets its Base and status.

async def _write_pose(self, held: _Frame, pose: tuple[tuple[float, float, float], tuple[float, float, float, float]] | None, *, base: ua.NodeId, status: ua.StatusCode):

Write one Location's pose, status and Base, and only what changed.

Writing an unchanged value still wakes every MonitoredItem on the node. The status counts as a change: a bad status nulls its value (OPC UA Part 4 7.7.1), so a frame that returns at the pose it left must still be written. Used for both a frame's Location and an alternative's, which differ only in where the pose came from.

async def _write_reading(self, held: _Frame, position: Position, orientation: Orientation, status: ua.StatusCode):

Put one pose on a Location's nine value-bearing nodes, with its status.

A Good pose goes through opensmi's write_pose. opensmi cannot write a status code, so a bad status is written by hand, always with the value, because a status alone leaves the variant null (see ~opensmi.ros2.server.status).

_transform_interval =

Undocumented

_transform_objects: tuple =

Undocumented

_transform_outward: frozenset[str] =

Undocumented

_transform_polls: int =

Undocumented

_transform_quiet_after =

Undocumented

_transform_roots: tuple[str, ...] =

Undocumented

_transform_task: asyncio.Task[None] | None =

Undocumented

_transform_world =

Undocumented