irsim.util.message#
Helpers for applying irsim.msg messages to simulation objects.
These functions resolve which local objects an incoming message addresses. They only read the objects they are given, so a caller can validate a whole batch of updates before applying any of them.
Functions#
|
Pair each incoming odometry with the distinct local object it addresses. |
Module Contents#
- irsim.util.message.resolve_message_targets(objects: collections.abc.Iterable[Any], msg: irsim.msg.WorldState | irsim.msg.ObjectState | Any, object_name: str | None = None, object_id: int | None = None, *, default_target: collections.abc.Callable[[], Any]) list[tuple[Any, Any]][source]#
Pair each incoming odometry with the distinct local object it addresses.
A
WorldStateaddresses every object it contains, anObjectStateuses its embedded name and id, and a standalone odometry message goes todefault_targetunless a name or id selects another object.- Parameters:
objects (Iterable) – Local objects the message can address.
msg – A
WorldState, anObjectState, or an odometry-shaped message.object_name (str) – Explicit target name for a standalone odometry or object message.
object_id (int) – Explicit target id for the same messages. Names take precedence when both are given.
default_target (Callable) – Called only when a standalone odometry selects no object; returns the object that receives it.
- Returns:
(object, odometry)pairs, one per addressed object.- Return type:
list
- Raises:
ValueError – If a target cannot be found, a name or id is combined with a
WorldState, or one object is addressed more than once.