class documentation

class Projection(ABC):

View In Hierarchy

How one ROS2 type is rendered, as the steps and the type they answer for.

Abstract: an author writes one of the classes in opensmi.ros2.server.recipes.

Method decode Return what one payload writes, keyed by the names shape created.
Method inverse_of Run this entry backwards, refusing rather than inventing when it has no inverse.
Method inverts Return whether this entry runs backwards for one ROS2 type.
Method matches Return whether this entry answers for a ROS2 type.
Method shape Return the nodes this type becomes, named relative to whatever contains them.
Instance Variable override Whether this entry may shadow one already registered for its type. A duplicate is fatal without it, so the address space never depends on registration order.
Instance Variable type_hash The RIHS01 hash of the definition this entry was authored against, or None. It lets CI report that a type moved under a curated entry. It never selects an entry, since that would render different address spaces for different vendor builds.
Instance Variable type_name The ROS2 type this entry answers for, or ANY_TYPE for the entry that answers for every one. Keying is by type name alone.
Property inverse Return the function that runs this entry backwards, or None when it has none.
@abstractmethod
def decode(self, message: Message, context: ProjectionContext) -> Mapping[str, object]:

Return what one payload writes, keyed by the names shape created.

def inverse_of(self, message_type: type[Message], values: Mapping[str, object], context: ProjectionContext) -> Message:

Run this entry backwards, refusing rather than inventing when it has no inverse.

Raises
NotInvertibleErrorWhen this entry has no inverse, which is a declaration fault wherever it is reached.
def inverts(self, message_type: type[Message]) -> bool:

Return whether this entry runs backwards for one ROS2 type.

It takes a type because an Object inverts only if its field plan is total, which depends on the message as well as the recipe. That lets the check run at init.

def matches(self, type_name: str) -> bool:

Return whether this entry answers for a ROS2 type.

@abstractmethod
def shape(self, message_type: type[Message], context: ProjectionContext) -> tuple[PlanEntry, ...]:

Return the nodes this type becomes, named relative to whatever contains them.

override: bool =

Whether this entry may shadow one already registered for its type. A duplicate is fatal without it, so the address space never depends on registration order.

type_hash: str | None =

The RIHS01 hash of the definition this entry was authored against, or None. It lets CI report that a type moved under a curated entry. It never selects an entry, since that would render different address spaces for different vendor builds.

type_name: str =

The ROS2 type this entry answers for, or ANY_TYPE for the entry that answers for every one. Keying is by type name alone.

@property
inverse: EncodeFunction | None =

Return the function that runs this entry backwards, or None when it has none.

Each recipe derives it from what it is. None means nothing can be published through the entry, and a publishing Binding that reaches one fails at init.