tf2_msgs¶
mosaicolabs.ros_bridge.adapters.tf2_msgs ¶
FrameTransformAdapter ¶
Bases: ROSAdapterBase
Adapter for translating ROS TF2 messages to Mosaico FrameTransform.
Supported ROS Types:
Example
ros_msg = ROSMessage(
timestamp=17000,
topic="/tf",
msg_type="tf2_msgs/msg/TFMessage",
data={
"transforms": [
{
"header": {
"stamp": {
"sec": 17000,
"nanosec": 0,
},
"frame_id": "map",
"child_frame_id": "base_link",
},
"transform": {
"translation": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
},
"rotation": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"w": 1.0,
},
},
}
]
},
)
# Automatically resolves to a flat Mosaico FrameTransform with attached metadata
mosaico_frame_transform = FrameTransformAdapter.translate(ros_msg)
translate
classmethod
¶
Translates a ROS message into a Mosaico Message.
Returns:
| Name | Type | Description |
|---|---|---|
Message |
Message
|
The translated message containing a |
Raises:
| Type | Description |
|---|---|
Exception
|
Wraps any translation error with context (topic name, timestamp). |
from_dict
classmethod
¶
Converts the raw dictionary data into the specific Mosaico type.
Example
ros_data={
"transforms": [
{
"header": {
"stamp": {
"sec": 17000,
"nanosec": 0,
},
"frame_id": "map",
"child_frame_id": "base_link",
},
"transform": {
"translation": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
},
"rotation": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"w": 1.0,
},
},
}
]
}
# Automatically resolves to a flat Mosaico FrameTransform with attached metadata
mosaico_frame_transform = FrameTransformAdapter.from_dict(ros_data)
schema_metadata
classmethod
¶
Extract the ROS message specific schema metadata, if any.
ros_msg_type
abstractmethod
classmethod
¶
Returns the specific ROS message type handled by this adapter.
ontology_data_type
classmethod
¶
Returns the Ontology class type associated with this adapter.