sensor_msgs Adapters
mosaicolabs.ros_bridge.adapters.sensor_msgs ¶
CameraInfoAdapter ¶
Bases: ROSAdapterBase[CameraInfo]
Adapter for translating ROS CameraInfo messages to Mosaico CameraInfo.
Supported ROS Types:
Example
ros_msg = ROSMessage(
timestamp=17000,
topic="/camera_info",
msg_type="sensor_msgs/msg/CameraInfo",
data = {
"height": 480,
"width": 640,
"binning_x": 1,
"binning_y": 1,
"roi": {
"x_offset": 0,
"y_offset": 0,
"height": 480,
"width": 640,
"do_rectify": False,
},
"distortion_model": "plumb_bob",
"d": [0.0, 0.0, 0.0, 0.0, 0.0],
"k": [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0],
"p": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
"r": [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0],
}
)
# Automatically resolves to a flat Mosaico CameraInfo with attached metadata
mosaico_camera_info = CameraInfoAdapter.translate(ros_msg)
translate
classmethod
¶
Translates a ROS message into a Mosaico Message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ros_msg
|
ROSMessage
|
The ROS message to translate. |
required |
**kwargs
|
Any
|
Additional keyword arguments for translation. |
{}
|
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 = {
"height": 480,
"width": 640,
"binning_x": 1,
"binning_y": 1,
"roi": {
"x_offset": 0,
"y_offset": 0,
"height": 480,
"width": 640,
"do_rectify": False,
},
"distortion_model": "plumb_bob",
"d": [0.0, 0.0, 0.0, 0.0, 0.0],
"k": [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0],
"p": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
"r": [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0],
}
# Automatically resolves to a flat Mosaico CameraInfo with attached metadata
mosaico_camera_info = CameraInfoAdapter.from_dict(ros_data)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ros_data
|
dict
|
The raw dictionary from the ROS message. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
CameraInfo |
CameraInfo
|
The constructed Mosaico CameraInfo object. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If required keys are missing. |
to_ros
classmethod
¶
Converts a Mosaico CameraInfo (or a Message wrapping one) into a
sensor_msgs/msg/CameraInfo message.
Handles both ROS 1 (uppercase field names D, K, R, P) and
ROS 2 (lowercase d, k, r, p) field conventions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mosaico_data
|
Union[Message, CameraInfo]
|
A |
required |
typestore
|
Typestore
|
The rosbags typestore for target type resolution. |
required |
ros_msg_type
|
Optional[str]
|
Override for the output ROS type. Only
|
None
|
Returns:
| Name | Type | Description |
|---|---|---|
MsgType |
MsgType
|
A
|
schema_metadata
classmethod
¶
Extract the ROS message specific schema metadata, if any.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
typestore
|
Typestore
|
The rosbags typestore for target type resolution. |
required |
ros_msg_type
|
str
|
The ROS message type to extract metadata for. |
required |
ros_version
|
int
|
The ROS version (1 or 2) to consider for metadata extraction. |
required |
Returns:
| Type | Description |
|---|---|
Optional[dict]
|
Optional[dict]: A dictionary containing the schema metadata, or None if not applicable. |
ros_msg_type
abstractmethod
classmethod
¶
Returns the specific ROS message type handled by this adapter.
is_rosmsg_type_valid
classmethod
¶
Checks whether a given ROS message type string is handled by this adapter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type_to_validate
|
str
|
The full ROS message type string to check
(e.g., |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
|
unpack_mosaico_msg
classmethod
¶
Extracts the typed Mosaico payload and its Header (if present) from a wrapped or bare message.
Handles two input cases:
Messagewrapper: the typed data is extracted viaget_data().- Raw ontology instance: returned as-is with
the Header is extracted from the ontology (if supported), otherwise an default Header (empty frame_id and zero Time) is returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mosaico_msg
|
Union[Message, T]
|
Either a |
required |
Returns:
| Type | Description |
|---|---|
T
|
tuple[T, Header]: A |
Header
|
header is the corresponding |
tuple[T, Header]
|
zero |
Raises:
| Type | Description |
|---|---|
TypeError
|
If mosaico_msg is neither a |
ontology_data_type
classmethod
¶
Returns the Ontology class type associated with this adapter.
NavSatStatusAdapter ¶
Bases: ROSAdapterBase[GPSStatus]
Adapter for translating ROS NavSatStatus messages to Mosaico GPSStatus.
Supported ROS Types:
Example
translate
classmethod
¶
Translates a ROS message into a Mosaico Message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ros_msg
|
ROSMessage
|
The ROS message to translate. |
required |
**kwargs
|
Any
|
Additional keyword arguments for translation. |
{}
|
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
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ros_data
|
dict
|
The raw dictionary from the ROS message. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
GPSStatus |
GPSStatus
|
The constructed Mosaico GPSStatus object. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If a required key is missing from |
to_ros
classmethod
¶
Converts a Mosaico GPSStatus (or a Message wrapping one) into a
sensor_msgs/msg/NavSatStatus message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mosaico_data
|
Union[Message, GPSStatus]
|
A |
required |
typestore
|
Typestore
|
The rosbags typestore for target type resolution. |
required |
ros_msg_type
|
Optional[str]
|
Override for the output ROS type. Only
|
None
|
Returns:
| Name | Type | Description |
|---|---|---|
MsgType |
MsgType
|
A
|
schema_metadata
classmethod
¶
Extract the ROS message specific schema metadata, if any.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
typestore
|
Typestore
|
The rosbags typestore for target type resolution. |
required |
ros_msg_type
|
str
|
The ROS message type to extract metadata for. |
required |
ros_version
|
int
|
The ROS version (1 or 2) to consider for metadata extraction. |
required |
Returns:
| Type | Description |
|---|---|
Optional[dict]
|
Optional[dict]: A dictionary containing the schema metadata, or None if not applicable. |
ros_msg_type
abstractmethod
classmethod
¶
Returns the specific ROS message type handled by this adapter.
is_rosmsg_type_valid
classmethod
¶
Checks whether a given ROS message type string is handled by this adapter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type_to_validate
|
str
|
The full ROS message type string to check
(e.g., |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
|
unpack_mosaico_msg
classmethod
¶
Extracts the typed Mosaico payload and its Header (if present) from a wrapped or bare message.
Handles two input cases:
Messagewrapper: the typed data is extracted viaget_data().- Raw ontology instance: returned as-is with
the Header is extracted from the ontology (if supported), otherwise an default Header (empty frame_id and zero Time) is returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mosaico_msg
|
Union[Message, T]
|
Either a |
required |
Returns:
| Type | Description |
|---|---|
T
|
tuple[T, Header]: A |
Header
|
header is the corresponding |
tuple[T, Header]
|
zero |
Raises:
| Type | Description |
|---|---|
TypeError
|
If mosaico_msg is neither a |
ontology_data_type
classmethod
¶
Returns the Ontology class type associated with this adapter.
GPSAdapter ¶
Bases: ROSAdapterBase[GPS]
Adapter for translating ROS NavSatFix messages to Mosaico GPS.
Supported ROS Types:
Example
ros_msg = ROSMessage(
timestamp=17000,
topic="/gps",
msg_type="sensor_msgs/msg/NavSatFix",
data = {
"latitude": 45.5,
"longitude": -122.5,
"altitude": 100.0,
"status": {
"status": 0,
"service": 1,
},
}
)
# Automatically resolves to a flat Mosaico GPS with attached metadata
mosaico_gps = GPSAdapter.translate(ros_msg)
translate
classmethod
¶
Translates a ROS message into a Mosaico Message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ros_msg
|
ROSMessage
|
The ROS message to translate. |
required |
**kwargs
|
Any
|
Additional keyword arguments for translation. |
{}
|
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
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ros_data
|
dict
|
The raw dictionary from the ROS message. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
GPS |
GPS
|
The constructed Mosaico GPS object. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If a required key is missing from |
to_ros
classmethod
¶
Converts a Mosaico GPS (or a Message wrapping one) into a
sensor_msgs/msg/NavSatFix message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mosaico_data
|
Union[Message, GPS]
|
A |
required |
typestore
|
Typestore
|
The rosbags typestore for target type resolution. |
required |
ros_msg_type
|
Optional[str]
|
Override for the output ROS type. Only
|
None
|
Returns:
| Name | Type | Description |
|---|---|---|
MsgType |
MsgType
|
A
|
schema_metadata
classmethod
¶
Extract the ROS message specific schema metadata, if any.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
typestore
|
Typestore
|
The rosbags typestore for target type resolution. |
required |
ros_msg_type
|
str
|
The ROS message type to extract metadata for. |
required |
ros_version
|
int
|
The ROS version (1 or 2) to consider for metadata extraction. |
required |
Returns:
| Type | Description |
|---|---|
Optional[dict]
|
Optional[dict]: A dictionary containing the schema metadata, or None if not applicable. |
ros_msg_type
abstractmethod
classmethod
¶
Returns the specific ROS message type handled by this adapter.
is_rosmsg_type_valid
classmethod
¶
Checks whether a given ROS message type string is handled by this adapter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type_to_validate
|
str
|
The full ROS message type string to check
(e.g., |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
|
unpack_mosaico_msg
classmethod
¶
Extracts the typed Mosaico payload and its Header (if present) from a wrapped or bare message.
Handles two input cases:
Messagewrapper: the typed data is extracted viaget_data().- Raw ontology instance: returned as-is with
the Header is extracted from the ontology (if supported), otherwise an default Header (empty frame_id and zero Time) is returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mosaico_msg
|
Union[Message, T]
|
Either a |
required |
Returns:
| Type | Description |
|---|---|
T
|
tuple[T, Header]: A |
Header
|
header is the corresponding |
tuple[T, Header]
|
zero |
Raises:
| Type | Description |
|---|---|
TypeError
|
If mosaico_msg is neither a |
ontology_data_type
classmethod
¶
Returns the Ontology class type associated with this adapter.
IMUAdapter ¶
Bases: ROSAdapterBase[IMU]
Adapter for translating ROS Imu messages to Mosaico IMU.
Supported ROS Types:
Example
ros_msg = ROSMessage(
timestamp=17000,
topic="/imu",
msg_type="sensor_msgs/msg/Imu",
data = {
"linear_acceleration": {"x": 0.0, "y": 0.0, "z": 0.0},
"angular_velocity": {"x": 0.0, "y": 0.0, "z": 0.0},
"orientation": {"x": 0.0, "y": 0.0, "z": 0.0, "w": 1.0},
"orientation_covariance": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
"linear_acceleration_covariance": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
"angular_velocity_covariance": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
"header": {"seq": 0, "stamp": {"sec": 0, "nanosec": 0}, "frame_id": "robot_link"},
}
)
# Automatically resolves to a flat Mosaico IMU with attached metadata
mosaico_imu = IMUAdapter.translate(ros_msg)
translate
classmethod
¶
Translates a ROS message into a Mosaico Message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ros_msg
|
ROSMessage
|
The ROS message to translate. |
required |
**kwargs
|
Any
|
Additional keyword arguments for translation. |
{}
|
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 = {
"linear_acceleration": {"x": 0.0, "y": 0.0, "z": 0.0},
"angular_velocity": {"x": 0.0, "y": 0.0, "z": 0.0},
"orientation": {"x": 0.0, "y": 0.0, "z": 0.0, "w": 1.0},
"orientation_covariance": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
"linear_acceleration_covariance": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
"angular_velocity_covariance": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
"header": {"seq": 0, "stamp": {"sec": 0, "nanosec": 0}, "frame_id": "robot_link"},
}
# Automatically resolves to a flat Mosaico IMU with attached metadata
mosaico_imu = IMUAdapter.from_dict(ros_data)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ros_data
|
dict
|
The raw dictionary from the ROS message. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
IMU |
IMU
|
The constructed Mosaico IMU object. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If a required key is missing from |
to_ros
classmethod
¶
Converts a Mosaico IMU (or a Message wrapping one) into a
sensor_msgs/msg/Imu message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mosaico_data
|
Union[Message, IMU]
|
A |
required |
typestore
|
Typestore
|
The rosbags typestore for target type resolution. |
required |
ros_msg_type
|
Optional[str]
|
Override for the output ROS type. Only
|
None
|
Returns:
| Name | Type | Description |
|---|---|---|
MsgType |
MsgType
|
A
|
schema_metadata
classmethod
¶
Extract the ROS message specific schema metadata, if any.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
typestore
|
Typestore
|
The rosbags typestore for target type resolution. |
required |
ros_msg_type
|
str
|
The ROS message type to extract metadata for. |
required |
ros_version
|
int
|
The ROS version (1 or 2) to consider for metadata extraction. |
required |
Returns:
| Type | Description |
|---|---|
Optional[dict]
|
Optional[dict]: A dictionary containing the schema metadata, or None if not applicable. |
ros_msg_type
abstractmethod
classmethod
¶
Returns the specific ROS message type handled by this adapter.
is_rosmsg_type_valid
classmethod
¶
Checks whether a given ROS message type string is handled by this adapter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type_to_validate
|
str
|
The full ROS message type string to check
(e.g., |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
|
unpack_mosaico_msg
classmethod
¶
Extracts the typed Mosaico payload and its Header (if present) from a wrapped or bare message.
Handles two input cases:
Messagewrapper: the typed data is extracted viaget_data().- Raw ontology instance: returned as-is with
the Header is extracted from the ontology (if supported), otherwise an default Header (empty frame_id and zero Time) is returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mosaico_msg
|
Union[Message, T]
|
Either a |
required |
Returns:
| Type | Description |
|---|---|
T
|
tuple[T, Header]: A |
Header
|
header is the corresponding |
tuple[T, Header]
|
zero |
Raises:
| Type | Description |
|---|---|
TypeError
|
If mosaico_msg is neither a |
ontology_data_type
classmethod
¶
Returns the Ontology class type associated with this adapter.
NMEASentenceAdapter ¶
Bases: ROSAdapterBase[NMEASentence]
Adapter for translating ROS NMEASentence messages to Mosaico NMEASentence.
Supported ROS Types:
Example
ros_msg = ROSMessage(
timestamp=17000,
topic="/nmea_sentence",
msg_type="nmea_msgs/msg/Sentence",
data = {
"sentence": "GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47",
}
)
# Automatically resolves to a flat Mosaico NMEASentence with attached metadata
mosaico_nmea_sentence = NMEASentenceAdapter.translate(ros_msg)
translate
classmethod
¶
Translates a ROS message into a Mosaico Message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ros_msg
|
ROSMessage
|
The ROS message to translate. |
required |
**kwargs
|
Any
|
Additional keyword arguments for translation. |
{}
|
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
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ros_data
|
dict
|
The raw dictionary from the ROS message. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
NMEASentence |
NMEASentence
|
The constructed Mosaico NMEASentence object. |
to_ros
classmethod
¶
Converts a Mosaico NMEASentence (or a Message wrapping one) into a
nmea_msgs/msg/Sentence message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mosaico_data
|
Union[Message, NMEASentence]
|
A |
required |
typestore
|
Typestore
|
The rosbags typestore for target type resolution. |
required |
ros_msg_type
|
Optional[str]
|
Override for the output ROS type. Only
|
None
|
Returns:
| Name | Type | Description |
|---|---|---|
MsgType |
MsgType
|
A
|
schema_metadata
classmethod
¶
Extract the ROS message specific schema metadata, if any.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
typestore
|
Typestore
|
The rosbags typestore for target type resolution. |
required |
ros_msg_type
|
str
|
The ROS message type to extract metadata for. |
required |
ros_version
|
int
|
The ROS version (1 or 2) to consider for metadata extraction. |
required |
Returns:
| Type | Description |
|---|---|
Optional[dict]
|
Optional[dict]: A dictionary containing the schema metadata, or None if not applicable. |
ros_msg_type
abstractmethod
classmethod
¶
Returns the specific ROS message type handled by this adapter.
is_rosmsg_type_valid
classmethod
¶
Checks whether a given ROS message type string is handled by this adapter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type_to_validate
|
str
|
The full ROS message type string to check
(e.g., |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
|
unpack_mosaico_msg
classmethod
¶
Extracts the typed Mosaico payload and its Header (if present) from a wrapped or bare message.
Handles two input cases:
Messagewrapper: the typed data is extracted viaget_data().- Raw ontology instance: returned as-is with
the Header is extracted from the ontology (if supported), otherwise an default Header (empty frame_id and zero Time) is returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mosaico_msg
|
Union[Message, T]
|
Either a |
required |
Returns:
| Type | Description |
|---|---|
T
|
tuple[T, Header]: A |
Header
|
header is the corresponding |
tuple[T, Header]
|
zero |
Raises:
| Type | Description |
|---|---|
TypeError
|
If mosaico_msg is neither a |
ontology_data_type
classmethod
¶
Returns the Ontology class type associated with this adapter.
ImageAdapter ¶
Bases: ROSAdapterBase[Image]
Adapter for translating ROS Image messages to Mosaico Image.
Supported ROS Types:
Example
translate
classmethod
¶
Translates a ROS message into a Mosaico Message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ros_msg
|
ROSMessage
|
The ROS message to translate. |
required |
**kwargs
|
Any
|
Additional keyword arguments for translation. |
{}
|
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
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ros_data
|
dict
|
The raw dictionary from the ROS message. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Image |
Image
|
The constructed Mosaico Image object. |
to_ros
classmethod
¶
Converts a Mosaico Image (or a Message wrapping one) into a
sensor_msgs/msg/Image message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mosaico_data
|
Union[Message, Image]
|
A |
required |
typestore
|
Typestore
|
The rosbags typestore for target type resolution. |
required |
ros_msg_type
|
Optional[str]
|
Override for the output ROS type. Only
|
None
|
Returns:
| Name | Type | Description |
|---|---|---|
MsgType |
MsgType
|
A
|
schema_metadata
classmethod
¶
Extract the ROS message specific schema metadata, if any.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
typestore
|
Typestore
|
The rosbags typestore for target type resolution. |
required |
ros_msg_type
|
str
|
The ROS message type to extract metadata for. |
required |
ros_version
|
int
|
The ROS version (1 or 2) to consider for metadata extraction. |
required |
Returns:
| Type | Description |
|---|---|
Optional[dict]
|
Optional[dict]: A dictionary containing the schema metadata, or None if not applicable. |
ros_msg_type
abstractmethod
classmethod
¶
Returns the specific ROS message type handled by this adapter.
is_rosmsg_type_valid
classmethod
¶
Checks whether a given ROS message type string is handled by this adapter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type_to_validate
|
str
|
The full ROS message type string to check
(e.g., |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
|
unpack_mosaico_msg
classmethod
¶
Extracts the typed Mosaico payload and its Header (if present) from a wrapped or bare message.
Handles two input cases:
Messagewrapper: the typed data is extracted viaget_data().- Raw ontology instance: returned as-is with
the Header is extracted from the ontology (if supported), otherwise an default Header (empty frame_id and zero Time) is returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mosaico_msg
|
Union[Message, T]
|
Either a |
required |
Returns:
| Type | Description |
|---|---|
T
|
tuple[T, Header]: A |
Header
|
header is the corresponding |
tuple[T, Header]
|
zero |
Raises:
| Type | Description |
|---|---|
TypeError
|
If mosaico_msg is neither a |
ontology_data_type
classmethod
¶
Returns the Ontology class type associated with this adapter.
CompressedImageAdapter ¶
Bases: ROSAdapterBase[CompressedImage]
Adapter for translating ROS CompressedImage messages to Mosaico CompressedImage.
Supported ROS Types:
Example
ros_msg = ROSMessage(
timestamp=17000,
topic="/compressed_image",
msg_type="sensor_msgs/msg/CompressedImage",
data = {
"data": [...],
"format": "jpeg",
}
)
# Automatically resolves to a flat Mosaico CompressedImage with attached metadata
mosaico_compressed_image = CompressedImageAdapter.translate(ros_msg)
translate
classmethod
¶
Translates a ROS message into a Mosaico Message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ros_msg
|
ROSMessage
|
The ROS message to translate. |
required |
**kwargs
|
Any
|
Additional keyword arguments for translation. |
{}
|
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
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ros_data
|
dict
|
The raw dictionary from the ROS message. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
CompressedImage |
CompressedImage
|
The constructed Mosaico CompressedImage object. |
to_ros
classmethod
¶
Converts a Mosaico CompressedImage (or a Message wrapping one) into a
sensor_msgs/msg/CompressedImage message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mosaico_data
|
Union[Message, CompressedImage]
|
A |
required |
typestore
|
Typestore
|
The rosbags typestore for target type resolution. |
required |
ros_msg_type
|
Optional[str]
|
Override for the output ROS type. Only
|
None
|
Returns:
| Name | Type | Description |
|---|---|---|
MsgType |
MsgType
|
A
|
schema_metadata
classmethod
¶
Extract the ROS message specific schema metadata, if any.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
typestore
|
Typestore
|
The rosbags typestore for target type resolution. |
required |
ros_msg_type
|
str
|
The ROS message type to extract metadata for. |
required |
ros_version
|
int
|
The ROS version (1 or 2) to consider for metadata extraction. |
required |
Returns:
| Type | Description |
|---|---|
Optional[dict]
|
Optional[dict]: A dictionary containing the schema metadata, or None if not applicable. |
ros_msg_type
abstractmethod
classmethod
¶
Returns the specific ROS message type handled by this adapter.
is_rosmsg_type_valid
classmethod
¶
Checks whether a given ROS message type string is handled by this adapter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type_to_validate
|
str
|
The full ROS message type string to check
(e.g., |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
|
unpack_mosaico_msg
classmethod
¶
Extracts the typed Mosaico payload and its Header (if present) from a wrapped or bare message.
Handles two input cases:
Messagewrapper: the typed data is extracted viaget_data().- Raw ontology instance: returned as-is with
the Header is extracted from the ontology (if supported), otherwise an default Header (empty frame_id and zero Time) is returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mosaico_msg
|
Union[Message, T]
|
Either a |
required |
Returns:
| Type | Description |
|---|---|
T
|
tuple[T, Header]: A |
Header
|
header is the corresponding |
tuple[T, Header]
|
zero |
Raises:
| Type | Description |
|---|---|
TypeError
|
If mosaico_msg is neither a |
ontology_data_type
classmethod
¶
Returns the Ontology class type associated with this adapter.
ROIAdapter ¶
Bases: ROSAdapterBase[ROI]
Adapter for translating ROS RegionOfInterest messages to Mosaico ROI.
Supported ROS Types:
Example
translate
classmethod
¶
Translates a ROS message into a Mosaico Message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ros_msg
|
ROSMessage
|
The ROS message to translate. |
required |
**kwargs
|
Any
|
Additional keyword arguments for translation. |
{}
|
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
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ros_data
|
dict
|
The raw dictionary from the ROS message. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
ROI |
ROI
|
The constructed Mosaico ROI object. |
to_ros
classmethod
¶
Converts a Mosaico ROI (or a Message wrapping one) into a
sensor_msgs/msg/RegionOfInterest message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mosaico_data
|
Union[Message, ROI]
|
A |
required |
typestore
|
Typestore
|
The rosbags typestore for target type resolution. |
required |
ros_msg_type
|
Optional[str]
|
Override for the output ROS type. Only
|
None
|
Returns:
| Name | Type | Description |
|---|---|---|
MsgType |
MsgType
|
A
|
schema_metadata
classmethod
¶
Extract the ROS message specific schema metadata, if any.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
typestore
|
Typestore
|
The rosbags typestore for target type resolution. |
required |
ros_msg_type
|
str
|
The ROS message type to extract metadata for. |
required |
ros_version
|
int
|
The ROS version (1 or 2) to consider for metadata extraction. |
required |
Returns:
| Type | Description |
|---|---|
Optional[dict]
|
Optional[dict]: A dictionary containing the schema metadata, or None if not applicable. |
ros_msg_type
abstractmethod
classmethod
¶
Returns the specific ROS message type handled by this adapter.
is_rosmsg_type_valid
classmethod
¶
Checks whether a given ROS message type string is handled by this adapter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type_to_validate
|
str
|
The full ROS message type string to check
(e.g., |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
|
unpack_mosaico_msg
classmethod
¶
Extracts the typed Mosaico payload and its Header (if present) from a wrapped or bare message.
Handles two input cases:
Messagewrapper: the typed data is extracted viaget_data().- Raw ontology instance: returned as-is with
the Header is extracted from the ontology (if supported), otherwise an default Header (empty frame_id and zero Time) is returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mosaico_msg
|
Union[Message, T]
|
Either a |
required |
Returns:
| Type | Description |
|---|---|
T
|
tuple[T, Header]: A |
Header
|
header is the corresponding |
tuple[T, Header]
|
zero |
Raises:
| Type | Description |
|---|---|
TypeError
|
If mosaico_msg is neither a |
ontology_data_type
classmethod
¶
Returns the Ontology class type associated with this adapter.
BatteryStateAdapter ¶
Bases: ROSAdapterBase[BatteryState]
Adapter for translating ROS BatteryState messages to Mosaico BatteryState.
Supported ROS Types:
Example
ros_msg = ROSMessage(
timestamp=17000,
topic="/battery_state",
msg_type="sensor_msgs/msg/BatteryState",
data = {
"voltage": 12.6,
"capacity": 100,
"cell_temperature": [25.0],
"cell_voltage": [12.6],
"location": "battery",
"charge": 100,
"current": 0,
"design_capacity": 100,
"location": "battery",
"percentage": 100,
"power_supply_health": "good",
"power_supply_status": "charging",
"power_supply_technology": "li-ion",
"present": True,
"serial_number": "1234567890",
"temperature": 25,
}
)
# Automatically resolves to a flat Mosaico BatteryState with attached metadata
mosaico_battery_state = BatteryStateAdapter.translate(ros_msg)
translate
classmethod
¶
Translates a ROS message into a Mosaico Message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ros_msg
|
ROSMessage
|
The ROS message to translate. |
required |
**kwargs
|
Any
|
Additional keyword arguments for translation. |
{}
|
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 = {
"voltage": 12.6,
"capacity": 100,
"cell_temperature": [25.0],
"cell_voltage": [12.6],
"location": "battery",
"charge": 100,
"current": 0,
"design_capacity": 100,
"location": "battery",
"percentage": 100,
"power_supply_health": "good",
"power_supply_status": "charging",
"power_supply_technology": "li-ion",
"present": True,
"serial_number": "1234567890",
"temperature": 25,
}
# Automatically resolves to a flat Mosaico BatteryState with attached metadata
mosaico_battery_state = BatteryStateAdapter.from_dict(ros_data)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ros_data
|
dict
|
The raw dictionary from the ROS message. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
BatteryState |
BatteryState
|
The constructed Mosaico BatteryState object. |
to_ros
classmethod
¶
Converts a Mosaico BatteryState (or a Message wrapping one) into a
sensor_msgs/msg/BatteryState message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mosaico_data
|
Union[Message, BatteryState]
|
A |
required |
typestore
|
Typestore
|
The rosbags typestore for target type resolution. |
required |
ros_msg_type
|
Optional[str]
|
Override for the output ROS type. Only
|
None
|
Returns:
| Name | Type | Description |
|---|---|---|
MsgType |
MsgType
|
A
|
schema_metadata
classmethod
¶
Extract the ROS message specific schema metadata, if any.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
typestore
|
Typestore
|
The rosbags typestore for target type resolution. |
required |
ros_msg_type
|
str
|
The ROS message type to extract metadata for. |
required |
ros_version
|
int
|
The ROS version (1 or 2) to consider for metadata extraction. |
required |
Returns:
| Type | Description |
|---|---|
Optional[dict]
|
Optional[dict]: A dictionary containing the schema metadata, or None if not applicable. |
ros_msg_type
abstractmethod
classmethod
¶
Returns the specific ROS message type handled by this adapter.
is_rosmsg_type_valid
classmethod
¶
Checks whether a given ROS message type string is handled by this adapter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type_to_validate
|
str
|
The full ROS message type string to check
(e.g., |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
|
unpack_mosaico_msg
classmethod
¶
Extracts the typed Mosaico payload and its Header (if present) from a wrapped or bare message.
Handles two input cases:
Messagewrapper: the typed data is extracted viaget_data().- Raw ontology instance: returned as-is with
the Header is extracted from the ontology (if supported), otherwise an default Header (empty frame_id and zero Time) is returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mosaico_msg
|
Union[Message, T]
|
Either a |
required |
Returns:
| Type | Description |
|---|---|
T
|
tuple[T, Header]: A |
Header
|
header is the corresponding |
tuple[T, Header]
|
zero |
Raises:
| Type | Description |
|---|---|
TypeError
|
If mosaico_msg is neither a |
ontology_data_type
classmethod
¶
Returns the Ontology class type associated with this adapter.
RobotJointAdapter ¶
Bases: ROSAdapterBase[RobotJoint]
Adapter for translating ROS JointState messages to Mosaico RobotJoint.
Supported ROS Types:
Example
ros_msg = ROSMessage(
timestamp=17000,
topic="/joint_states",
msg_type="sensor_msgs/msg/JointState",
data={
"header": {
"stamp": {
"sec": 17000,
"nanosec": 0,
},
"frame_id": "",
},
"name": ["joint1", "joint2"],
"position": [0.0, 0.0],
"velocity": [0.0, 0.0],
"effort": [0.0, 0.0],
},
)
# Automatically resolves to a flat Mosaico RobotJoint with attached metadata
mosaico_robot_joint = RobotJointAdapter.translate(ros_msg)
translate
classmethod
¶
Translates a ROS message into a Mosaico Message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ros_msg
|
ROSMessage
|
The ROS message to translate. |
required |
**kwargs
|
Any
|
Additional keyword arguments for translation. |
{}
|
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={
"header": {
"stamp": {
"sec": 17000,
"nanosec": 0,
},
"frame_id": "",
},
"name": ["joint1", "joint2"],
"position": [0.0, 0.0],
"velocity": [0.0, 0.0],
"effort": [0.0, 0.0],
}
# Automatically resolves to a flat Mosaico RobotJoint with attached metadata
mosaico_robot_joint = RobotJointAdapter.from_dict(ros_data)
to_ros
classmethod
¶
Converts a Mosaico RobotJoint (or a Message wrapping one) into a
sensor_msgs/msg/JointState message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mosaico_data
|
Union[Message, RobotJoint]
|
A |
required |
typestore
|
Typestore
|
The rosbags typestore for target type resolution. |
required |
ros_msg_type
|
Optional[str]
|
Override for the output ROS type. Only
|
None
|
Returns:
| Name | Type | Description |
|---|---|---|
MsgType |
MsgType
|
A
|
schema_metadata
classmethod
¶
Extract the ROS message specific schema metadata, if any.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
typestore
|
Typestore
|
The rosbags typestore for target type resolution. |
required |
ros_msg_type
|
str
|
The ROS message type to extract metadata for. |
required |
ros_version
|
int
|
The ROS version (1 or 2) to consider for metadata extraction. |
required |
Returns:
| Type | Description |
|---|---|
Optional[dict]
|
Optional[dict]: A dictionary containing the schema metadata, or None if not applicable. |
ros_msg_type
abstractmethod
classmethod
¶
Returns the specific ROS message type handled by this adapter.
is_rosmsg_type_valid
classmethod
¶
Checks whether a given ROS message type string is handled by this adapter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type_to_validate
|
str
|
The full ROS message type string to check
(e.g., |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
|
unpack_mosaico_msg
classmethod
¶
Extracts the typed Mosaico payload and its Header (if present) from a wrapped or bare message.
Handles two input cases:
Messagewrapper: the typed data is extracted viaget_data().- Raw ontology instance: returned as-is with
the Header is extracted from the ontology (if supported), otherwise an default Header (empty frame_id and zero Time) is returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mosaico_msg
|
Union[Message, T]
|
Either a |
required |
Returns:
| Type | Description |
|---|---|
T
|
tuple[T, Header]: A |
Header
|
header is the corresponding |
tuple[T, Header]
|
zero |
Raises:
| Type | Description |
|---|---|
TypeError
|
If mosaico_msg is neither a |
ontology_data_type
classmethod
¶
Returns the Ontology class type associated with this adapter.
PointCloudAdapterBase ¶
Bases: ROSAdapterBase[PointCloudModel]
Base adapter for translating ROS PointCloud2 message to Mosaico specific ontology.
decode
classmethod
¶
Deserialize the binary buffer of a ROS sensor_msgs/msg/PointCloud2 message into named field arrays.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ros_data
|
dict
|
Raw ROS message payload. Relevant keys: |
required |
Returns:
| Type | Description |
|---|---|
dict[str, list]
|
dict[str, list]: Dictionary mapping each field name to a list of decoded values. Returns empty lists for all fields if |
Raises:
| Type | Description |
|---|---|
ValueError
|
If a field exposes an unsupported |
encode
classmethod
¶
Serializes a dictionary of named field arrays into the binary layout required
by a sensor_msgs/msg/PointCloud2 message. This is the inverse operation of :meth:decode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pcl_model
|
dict[str, list]
|
Mapping from field name to a list of scalar values, one per
point. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
A dictionary with all keys required to populate a |
to_ros
classmethod
¶
Converts a Mosaico PointCloudModel subtype (or a Message wrapping one)
into a sensor_msgs/msg/PointCloud2 message.
Fields are serialized via :meth:encode. Only non-None model fields are
included in the output point cloud.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mosaico_data
|
Union[Message, PointCloudModel]
|
A |
required |
typestore
|
Typestore
|
The rosbags typestore for target type resolution. |
required |
ros_msg_type
|
Optional[str]
|
Override for the output ROS type. Only
|
None
|
Returns:
| Name | Type | Description |
|---|---|---|
MsgType |
MsgType
|
A
|
from_dict
classmethod
¶
Convert a raw ROS PointCloud2 message dictionary into a typed Mosaico model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ros_data
|
dict
|
Raw ROS message payload as a dictionary. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
PointCloudModel |
PointCloudModel
|
A fully populated instance of the target |
Raises:
| Type | Description |
|---|---|
ValueError
|
If any required message key is missing from |
Note
This method is not meant to be overridden in most subclasses.
Only PointCloudAdapter overrides it,
as it operates at a different abstraction level, returning the raw
PointCloud2 message instead of a decoded model.
schema_metadata
classmethod
¶
Extract the ROS message specific schema metadata, if any.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
typestore
|
Typestore
|
The rosbags typestore for target type resolution. |
required |
ros_msg_type
|
str
|
The ROS message type to extract metadata for. |
required |
ros_version
|
int
|
The ROS version (1 or 2) to consider for metadata extraction. |
required |
Returns:
| Type | Description |
|---|---|
Optional[dict]
|
Optional[dict]: A dictionary containing the schema metadata, or None if not applicable. |
ros_msg_type
abstractmethod
classmethod
¶
Returns the specific ROS message type handled by this adapter.
translate
classmethod
¶
Translates a ROS message instance into a Mosaico Message.
Implementation should handle recursive unwrapping, unit conversion, and validation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ros_msg
|
ROSMessage
|
The source container yielded by the ROSLoader. |
required |
**kwargs
|
Any
|
Contextual data such as calibration parameters or frame overrides. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
Message |
Message
|
A Mosaico Message object containing the instantiated ontology data. |
Raises:
| Type | Description |
|---|---|
Exception
|
If translation fails due to missing fields, type mismatches, or other errors. |
is_rosmsg_type_valid
classmethod
¶
Checks whether a given ROS message type string is handled by this adapter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type_to_validate
|
str
|
The full ROS message type string to check
(e.g., |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
|
unpack_mosaico_msg
classmethod
¶
Extracts the typed Mosaico payload and its Header (if present) from a wrapped or bare message.
Handles two input cases:
Messagewrapper: the typed data is extracted viaget_data().- Raw ontology instance: returned as-is with
the Header is extracted from the ontology (if supported), otherwise an default Header (empty frame_id and zero Time) is returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mosaico_msg
|
Union[Message, T]
|
Either a |
required |
Returns:
| Type | Description |
|---|---|
T
|
tuple[T, Header]: A |
Header
|
header is the corresponding |
tuple[T, Header]
|
zero |
Raises:
| Type | Description |
|---|---|
TypeError
|
If mosaico_msg is neither a |
ontology_data_type
classmethod
¶
Returns the Ontology class type associated with this adapter.
PointCloudAdapter ¶
Bases: PointCloudAdapterBase[PointCloud2]
Adapter for translating ROS PointCloud2 messages to Mosaico PointCloud2.
Supported ROS Types:
Example:
ros_msg = ROSMessage(
timestamp=17000,
topic="/point_cloud",
msg_type="sensor_msgs/PointCloud2",
data = {
"height": 1,
"width": 3,
"fields": [
{"name": "x", "offset": 0, "datatype": 7, "count": 1},
{"name": "y", "offset": 4, "datatype": 7, "count": 1},
{"name": "z", "offset": 8, "datatype": 7, "count": 1},
],
"is_bigendian": False,
"point_step": 12,
"row_step": 36,
"data": ...,
"is_dense": True,
}
)
# Automatically resolves to a flat Mosaico PointCloud2 with attached metadata
mosaico_point_cloud = PointCloudAdapter.translate(ros_msg)
translate
classmethod
¶
Translates a ROS message into a Mosaico Message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ros_msg
|
ROSMessage
|
The ROS message to translate. |
required |
**kwargs
|
Any
|
Additional keyword arguments for translation. |
{}
|
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 = {
"height": 1, # unorganized point cloud = 1 row
"width": 3, # 3 points
"fields": [
{
"name": "x",
"offset": 0,
"datatype": 7, # FLOAT32
"count": 1
},
{
"name": "y",
"offset": 4,
"datatype": 7, # FLOAT32
"count": 1
},
{
"name": "z",
"offset": 8,
"datatype": 7, # FLOAT32
"count": 1
},
],
"is_bigendian": False,
"point_step": 12, # 3 fields * 4 bytes (float32) = 12 bytes per point
"row_step": 36, # point_step * width = 12 * 3 = 36 bytes per row
"data": ...,
"is_dense": True
}
to_ros
classmethod
¶
Converts a Mosaico PointCloud2 (or a Message wrapping one) into a
sensor_msgs/msg/PointCloud2 message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mosaico_data
|
Union[Message, PointCloud2]
|
A |
required |
typestore
|
Typestore
|
The rosbags typestore for target type resolution. |
required |
ros_msg_type
|
Optional[str]
|
Override for the output ROS type. Only
|
None
|
Returns:
| Name | Type | Description |
|---|---|---|
MsgType |
MsgType
|
A
|
schema_metadata
classmethod
¶
Extract the ROS message specific schema metadata, if any.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
typestore
|
Typestore
|
The rosbags typestore for target type resolution. |
required |
ros_msg_type
|
str
|
The ROS message type to extract metadata for. |
required |
ros_version
|
int
|
The ROS version (1 or 2) to consider for metadata extraction. |
required |
Returns:
| Type | Description |
|---|---|
Optional[dict]
|
Optional[dict]: A dictionary containing the schema metadata, or None if not applicable. |
ros_msg_type
abstractmethod
classmethod
¶
Returns the specific ROS message type handled by this adapter.
is_rosmsg_type_valid
classmethod
¶
Checks whether a given ROS message type string is handled by this adapter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type_to_validate
|
str
|
The full ROS message type string to check
(e.g., |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
|
unpack_mosaico_msg
classmethod
¶
Extracts the typed Mosaico payload and its Header (if present) from a wrapped or bare message.
Handles two input cases:
Messagewrapper: the typed data is extracted viaget_data().- Raw ontology instance: returned as-is with
the Header is extracted from the ontology (if supported), otherwise an default Header (empty frame_id and zero Time) is returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mosaico_msg
|
Union[Message, T]
|
Either a |
required |
Returns:
| Type | Description |
|---|---|
T
|
tuple[T, Header]: A |
Header
|
header is the corresponding |
tuple[T, Header]
|
zero |
Raises:
| Type | Description |
|---|---|
TypeError
|
If mosaico_msg is neither a |
ontology_data_type
classmethod
¶
Returns the Ontology class type associated with this adapter.
decode
classmethod
¶
Deserialize the binary buffer of a ROS sensor_msgs/msg/PointCloud2 message into named field arrays.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ros_data
|
dict
|
Raw ROS message payload. Relevant keys: |
required |
Returns:
| Type | Description |
|---|---|
dict[str, list]
|
dict[str, list]: Dictionary mapping each field name to a list of decoded values. Returns empty lists for all fields if |
Raises:
| Type | Description |
|---|---|
ValueError
|
If a field exposes an unsupported |
encode
classmethod
¶
Serializes a dictionary of named field arrays into the binary layout required
by a sensor_msgs/msg/PointCloud2 message. This is the inverse operation of :meth:decode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pcl_model
|
dict[str, list]
|
Mapping from field name to a list of scalar values, one per
point. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
A dictionary with all keys required to populate a |
LaserScannerAdapterBase ¶
Bases: ROSAdapterBase[_LT]
Base adapter for translating ROS LaserScan and MultiEchoLaserScan messages to Mosaico LaserScan and MultiEchoLaserScan .
translate
classmethod
¶
Translates a ROS message into a Mosaico Message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ros_msg
|
ROSMessage
|
The ROS message to translate. |
required |
**kwargs
|
Any
|
Additional keyword arguments for translation. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
Message |
Message
|
The translated message containing a |
Raises:
| Type | Description |
|---|---|
Exception
|
Wraps any translation error with context (topic name, timestamp). |
schema_metadata
classmethod
¶
Extract the ROS message specific schema metadata, if any.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
typestore
|
Typestore
|
The rosbags typestore for target type resolution. |
required |
ros_msg_type
|
str
|
The ROS message type to extract metadata for. |
required |
ros_version
|
int
|
The ROS version (1 or 2) to consider for metadata extraction. |
required |
Returns:
| Type | Description |
|---|---|
Optional[dict]
|
Optional[dict]: A dictionary containing the schema metadata, or None if not applicable. |
ros_msg_type
abstractmethod
classmethod
¶
Returns the specific ROS message type handled by this adapter.
from_dict
abstractmethod
classmethod
¶
Maps the raw ROS dictionary to the Pydantic model.
This method performs field validation and reconstruction.
is_rosmsg_type_valid
classmethod
¶
Checks whether a given ROS message type string is handled by this adapter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type_to_validate
|
str
|
The full ROS message type string to check
(e.g., |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
|
unpack_mosaico_msg
classmethod
¶
Extracts the typed Mosaico payload and its Header (if present) from a wrapped or bare message.
Handles two input cases:
Messagewrapper: the typed data is extracted viaget_data().- Raw ontology instance: returned as-is with
the Header is extracted from the ontology (if supported), otherwise an default Header (empty frame_id and zero Time) is returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mosaico_msg
|
Union[Message, T]
|
Either a |
required |
Returns:
| Type | Description |
|---|---|
T
|
tuple[T, Header]: A |
Header
|
header is the corresponding |
tuple[T, Header]
|
zero |
Raises:
| Type | Description |
|---|---|
TypeError
|
If mosaico_msg is neither a |
to_ros
abstractmethod
classmethod
¶
Converts a Mosaico message or ontology object back into a native ROS message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mosaico_data
|
Union[Message, T]
|
A |
required |
typestore
|
Typestore
|
The rosbags typestore used to resolve and construct target ROS types. |
required |
ros_msg_type
|
Optional[str]
|
Override for the output ROS type string. If |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
MsgType |
MsgType
|
The constructed ROS message instance, or raises an error if:
|
ontology_data_type
classmethod
¶
Returns the Ontology class type associated with this adapter.
LaserScanAdapter ¶
Bases: LaserScannerAdapterBase[LaserScan]
Adapter for translating ROS LaserScan messages to Mosaico LaserScan.
Supported ROS Types:
from_dict
classmethod
¶
Create a LaserScan instance from a ROS message dictionary.
Example:
ros_data = {
"angle_min": -1.57,
"angle_max": 1.57,
"angle_increment": 0.01,
"time_increment": 0.0,
"scan_time": 0.1,
"range_min": 0.2,
"range_max": 10.0,
"ranges": [1.0, 1.1, 1.2],
"intensities": [100.0, 110.0, 120.0],
}
# Automatically resolves to a flat Mosaico LaserScan with attached data
mosaico_laser_scan = LaserScanAdapter.from_dict(ros_data)
to_ros
classmethod
¶
Converts a Mosaico LaserScan (or a Message wrapping one) into a
sensor_msgs/msg/LaserScan message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mosaico_data
|
Union[Message, LaserScan]
|
A |
required |
typestore
|
Typestore
|
The rosbags typestore for target type resolution. |
required |
ros_msg_type
|
Optional[str]
|
Override for the output ROS type. Only
|
None
|
Returns:
| Name | Type | Description |
|---|---|---|
MsgType |
MsgType
|
A
|
ros_msg_type
abstractmethod
classmethod
¶
Returns the specific ROS message type handled by this adapter.
translate
classmethod
¶
Translates a ROS message into a Mosaico Message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ros_msg
|
ROSMessage
|
The ROS message to translate. |
required |
**kwargs
|
Any
|
Additional keyword arguments for translation. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
Message |
Message
|
The translated message containing a |
Raises:
| Type | Description |
|---|---|
Exception
|
Wraps any translation error with context (topic name, timestamp). |
is_rosmsg_type_valid
classmethod
¶
Checks whether a given ROS message type string is handled by this adapter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type_to_validate
|
str
|
The full ROS message type string to check
(e.g., |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
|
unpack_mosaico_msg
classmethod
¶
Extracts the typed Mosaico payload and its Header (if present) from a wrapped or bare message.
Handles two input cases:
Messagewrapper: the typed data is extracted viaget_data().- Raw ontology instance: returned as-is with
the Header is extracted from the ontology (if supported), otherwise an default Header (empty frame_id and zero Time) is returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mosaico_msg
|
Union[Message, T]
|
Either a |
required |
Returns:
| Type | Description |
|---|---|
T
|
tuple[T, Header]: A |
Header
|
header is the corresponding |
tuple[T, Header]
|
zero |
Raises:
| Type | Description |
|---|---|
TypeError
|
If mosaico_msg is neither a |
schema_metadata
classmethod
¶
Extract the ROS message specific schema metadata, if any.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
typestore
|
Typestore
|
The rosbags typestore for target type resolution. |
required |
ros_msg_type
|
str
|
The ROS message type to extract metadata for. |
required |
ros_version
|
int
|
The ROS version (1 or 2) to consider for metadata extraction. |
required |
Returns:
| Type | Description |
|---|---|
Optional[dict]
|
Optional[dict]: A dictionary containing the schema metadata, or None if not applicable. |
ontology_data_type
classmethod
¶
Returns the Ontology class type associated with this adapter.
MultiEchoLaserScanAdapter ¶
Bases: LaserScannerAdapterBase[MultiEchoLaserScan]
Adapter for translating ROS MultiEchoLaserScan messages to Mosaico MultiEchoLaserScan.
Supported ROS Types:
from_dict
classmethod
¶
Create a MultiEchoLaserScan instance from a ROS message dictionary.
Example:
ros_data = {
"angle_min": -1.57,
"angle_max": 1.57,
"angle_increment": 0.01,
"time_increment": 0.0,
"scan_time": 0.1,
"range_min": 0.2,
"range_max": 10.0,
"ranges": [{"echoes": [1.0, 1.1, 1.2]}, {"echoes": [2.0, 2.1, 2.2]}, {"echoes": [3.0, 3.1, 3.2]}],
"intensities": [{"echoes": [100.0, 110.0, 120.0]}, {"echoes": [200.0, 210.0, 220.0]}, {"echoes": [300.0, 310.0, 320.0]}],
}
# Automatically resolves to a flat Mosaico MultiEchoLaserScan with attached data
mosaico_laser_scan = MultiEchoLaserScanAdapter.from_dict(ros_data)
to_ros
classmethod
¶
Converts a Mosaico MultiEchoLaserScan (or a Message wrapping one) into a
sensor_msgs/msg/MultiEchoLaserScan message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mosaico_data
|
Union[Message, MultiEchoLaserScan]
|
A |
required |
typestore
|
Typestore
|
The rosbags typestore for target type resolution. |
required |
ros_msg_type
|
Optional[str]
|
Override for the output ROS type. Only
|
None
|
Returns:
| Name | Type | Description |
|---|---|---|
MsgType |
MsgType
|
A
|
ros_msg_type
abstractmethod
classmethod
¶
Returns the specific ROS message type handled by this adapter.
translate
classmethod
¶
Translates a ROS message into a Mosaico Message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ros_msg
|
ROSMessage
|
The ROS message to translate. |
required |
**kwargs
|
Any
|
Additional keyword arguments for translation. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
Message |
Message
|
The translated message containing a |
Raises:
| Type | Description |
|---|---|
Exception
|
Wraps any translation error with context (topic name, timestamp). |
is_rosmsg_type_valid
classmethod
¶
Checks whether a given ROS message type string is handled by this adapter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type_to_validate
|
str
|
The full ROS message type string to check
(e.g., |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
|
unpack_mosaico_msg
classmethod
¶
Extracts the typed Mosaico payload and its Header (if present) from a wrapped or bare message.
Handles two input cases:
Messagewrapper: the typed data is extracted viaget_data().- Raw ontology instance: returned as-is with
the Header is extracted from the ontology (if supported), otherwise an default Header (empty frame_id and zero Time) is returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mosaico_msg
|
Union[Message, T]
|
Either a |
required |
Returns:
| Type | Description |
|---|---|
T
|
tuple[T, Header]: A |
Header
|
header is the corresponding |
tuple[T, Header]
|
zero |
Raises:
| Type | Description |
|---|---|
TypeError
|
If mosaico_msg is neither a |
schema_metadata
classmethod
¶
Extract the ROS message specific schema metadata, if any.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
typestore
|
Typestore
|
The rosbags typestore for target type resolution. |
required |
ros_msg_type
|
str
|
The ROS message type to extract metadata for. |
required |
ros_version
|
int
|
The ROS version (1 or 2) to consider for metadata extraction. |
required |
Returns:
| Type | Description |
|---|---|
Optional[dict]
|
Optional[dict]: A dictionary containing the schema metadata, or None if not applicable. |
ontology_data_type
classmethod
¶
Returns the Ontology class type associated with this adapter.
MagneticFieldAdapter ¶
Bases: ROSAdapterBase[Magnetometer]
Adapter for translating ROS MagneticField messages to Mosaico Magnetometer.
Supported ROS Types:
Example
translate
classmethod
¶
Translates a ROS message into a Mosaico Message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ros_msg
|
ROSMessage
|
The ROS message to translate. |
required |
**kwargs
|
Any
|
Additional keyword arguments for translation. |
{}
|
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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ros_data
|
dict
|
The raw dictionary from the ROS message. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Magnetometer |
Magnetometer
|
The constructed Mosaico Magnetometer object. |
to_ros
classmethod
¶
Converts a Mosaico Magnetometer (or a Message wrapping one) into a
sensor_msgs/msg/MagneticField message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mosaico_data
|
Union[Message, Magnetometer]
|
A |
required |
typestore
|
Typestore
|
The rosbags typestore for target type resolution. |
required |
ros_msg_type
|
Optional[str]
|
Override for the output ROS type. Only
|
None
|
Returns:
| Name | Type | Description |
|---|---|---|
MsgType |
MsgType
|
A
|
schema_metadata
classmethod
¶
Extract the ROS message specific schema metadata, if any.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
typestore
|
Typestore
|
The rosbags typestore for target type resolution. |
required |
ros_msg_type
|
str
|
The ROS message type to extract metadata for. |
required |
ros_version
|
int
|
The ROS version (1 or 2) to consider for metadata extraction. |
required |
Returns:
| Type | Description |
|---|---|
Optional[dict]
|
Optional[dict]: A dictionary containing the schema metadata, or None if not applicable. |
ros_msg_type
abstractmethod
classmethod
¶
Returns the specific ROS message type handled by this adapter.
is_rosmsg_type_valid
classmethod
¶
Checks whether a given ROS message type string is handled by this adapter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type_to_validate
|
str
|
The full ROS message type string to check
(e.g., |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
|
unpack_mosaico_msg
classmethod
¶
Extracts the typed Mosaico payload and its Header (if present) from a wrapped or bare message.
Handles two input cases:
Messagewrapper: the typed data is extracted viaget_data().- Raw ontology instance: returned as-is with
the Header is extracted from the ontology (if supported), otherwise an default Header (empty frame_id and zero Time) is returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mosaico_msg
|
Union[Message, T]
|
Either a |
required |
Returns:
| Type | Description |
|---|---|
T
|
tuple[T, Header]: A |
Header
|
header is the corresponding |
tuple[T, Header]
|
zero |
Raises:
| Type | Description |
|---|---|
TypeError
|
If mosaico_msg is neither a |
ontology_data_type
classmethod
¶
Returns the Ontology class type associated with this adapter.
JoyAdapter ¶
Bases: ROSAdapterBase[Joy]
Adapter for translating ROS Joy messages to Mosaico Joy.
Supported ROS Types:
Example
translate
classmethod
¶
Translates a ROS message into a Mosaico Message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ros_msg
|
ROSMessage
|
The ROS message to translate. |
required |
**kwargs
|
Any
|
Additional keyword arguments for translation. |
{}
|
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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ros_data
|
dict
|
The raw dictionary from the ROS message. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Joy |
Joy
|
The constructed Mosaico Joy object. |
to_ros
classmethod
¶
Converts a Mosaico Joy (or a Message wrapping one) into a
sensor_msgs/msg/Joy message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mosaico_data
|
Union[Message, Joy]
|
A |
required |
typestore
|
Typestore
|
The rosbags typestore for target type resolution. |
required |
ros_msg_type
|
Optional[str]
|
Override for the output ROS type. Only
|
None
|
Returns:
| Name | Type | Description |
|---|---|---|
MsgType |
MsgType
|
A
|
schema_metadata
classmethod
¶
Extract the ROS message specific schema metadata, if any.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
typestore
|
Typestore
|
The rosbags typestore for target type resolution. |
required |
ros_msg_type
|
str
|
The ROS message type to extract metadata for. |
required |
ros_version
|
int
|
The ROS version (1 or 2) to consider for metadata extraction. |
required |
Returns:
| Type | Description |
|---|---|
Optional[dict]
|
Optional[dict]: A dictionary containing the schema metadata, or None if not applicable. |
ros_msg_type
abstractmethod
classmethod
¶
Returns the specific ROS message type handled by this adapter.
is_rosmsg_type_valid
classmethod
¶
Checks whether a given ROS message type string is handled by this adapter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type_to_validate
|
str
|
The full ROS message type string to check
(e.g., |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
|
unpack_mosaico_msg
classmethod
¶
Extracts the typed Mosaico payload and its Header (if present) from a wrapped or bare message.
Handles two input cases:
Messagewrapper: the typed data is extracted viaget_data().- Raw ontology instance: returned as-is with
the Header is extracted from the ontology (if supported), otherwise an default Header (empty frame_id and zero Time) is returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mosaico_msg
|
Union[Message, T]
|
Either a |
required |
Returns:
| Type | Description |
|---|---|
T
|
tuple[T, Header]: A |
Header
|
header is the corresponding |
tuple[T, Header]
|
zero |
Raises:
| Type | Description |
|---|---|
TypeError
|
If mosaico_msg is neither a |
ontology_data_type
classmethod
¶
Returns the Ontology class type associated with this adapter.
TemperatureAdapter ¶
Bases: ROSAdapterBase[Temperature]
Adapter for translating ROS Temperature messages to Mosaico Temperature.
Supported ROS Types:
Example
translate
classmethod
¶
Translates a ROS message into a Mosaico Message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ros_msg
|
ROSMessage
|
The ROS message to translate. |
required |
**kwargs
|
Any
|
Additional keyword arguments for translation. |
{}
|
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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ros_data
|
dict
|
The raw dictionary from the ROS message. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Temperature |
Temperature
|
The constructed Mosaico Temperature object. |
to_ros
classmethod
¶
Converts a Mosaico Temperature (or a Message wrapping one) into a
sensor_msgs/msg/Temperature message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mosaico_data
|
Union[Message, Temperature]
|
A |
required |
typestore
|
Typestore
|
The rosbags typestore for target type resolution. |
required |
ros_msg_type
|
Optional[str]
|
Override for the output ROS type. Only
|
None
|
Returns:
| Name | Type | Description |
|---|---|---|
MsgType |
MsgType
|
A
|
schema_metadata
classmethod
¶
Extract the ROS message specific schema metadata, if any.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
typestore
|
Typestore
|
The rosbags typestore for target type resolution. |
required |
ros_msg_type
|
str
|
The ROS message type to extract metadata for. |
required |
ros_version
|
int
|
The ROS version (1 or 2) to consider for metadata extraction. |
required |
Returns:
| Type | Description |
|---|---|
Optional[dict]
|
Optional[dict]: A dictionary containing the schema metadata, or None if not applicable. |
ros_msg_type
abstractmethod
classmethod
¶
Returns the specific ROS message type handled by this adapter.
is_rosmsg_type_valid
classmethod
¶
Checks whether a given ROS message type string is handled by this adapter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type_to_validate
|
str
|
The full ROS message type string to check
(e.g., |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
|
unpack_mosaico_msg
classmethod
¶
Extracts the typed Mosaico payload and its Header (if present) from a wrapped or bare message.
Handles two input cases:
Messagewrapper: the typed data is extracted viaget_data().- Raw ontology instance: returned as-is with
the Header is extracted from the ontology (if supported), otherwise an default Header (empty frame_id and zero Time) is returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mosaico_msg
|
Union[Message, T]
|
Either a |
required |
Returns:
| Type | Description |
|---|---|
T
|
tuple[T, Header]: A |
Header
|
header is the corresponding |
tuple[T, Header]
|
zero |
Raises:
| Type | Description |
|---|---|
TypeError
|
If mosaico_msg is neither a |
ontology_data_type
classmethod
¶
Returns the Ontology class type associated with this adapter.
PressureAdapter ¶
Bases: ROSAdapterBase[Pressure]
Adapter for translating ROS FluidPressure messages to Mosaico Pressure.
Supported ROS Types:
Example
translate
classmethod
¶
Translates a ROS message into a Mosaico Message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ros_msg
|
ROSMessage
|
The ROS message to translate. |
required |
**kwargs
|
Any
|
Additional keyword arguments for translation. |
{}
|
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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ros_data
|
dict
|
The raw dictionary from the ROS message. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Pressure |
Pressure
|
The constructed Mosaico Pressure object. |
to_ros
classmethod
¶
Converts a Mosaico Pressure (or a Message wrapping one) into a
sensor_msgs/msg/FluidPressure message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mosaico_data
|
Union[Message, Pressure]
|
A |
required |
typestore
|
Typestore
|
The rosbags typestore for target type resolution. |
required |
ros_msg_type
|
Optional[str]
|
Override for the output ROS type. Only
|
None
|
Returns:
| Name | Type | Description |
|---|---|---|
MsgType |
MsgType
|
A
|
schema_metadata
classmethod
¶
Extract the ROS message specific schema metadata, if any.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
typestore
|
Typestore
|
The rosbags typestore for target type resolution. |
required |
ros_msg_type
|
str
|
The ROS message type to extract metadata for. |
required |
ros_version
|
int
|
The ROS version (1 or 2) to consider for metadata extraction. |
required |
Returns:
| Type | Description |
|---|---|
Optional[dict]
|
Optional[dict]: A dictionary containing the schema metadata, or None if not applicable. |
ros_msg_type
abstractmethod
classmethod
¶
Returns the specific ROS message type handled by this adapter.
is_rosmsg_type_valid
classmethod
¶
Checks whether a given ROS message type string is handled by this adapter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type_to_validate
|
str
|
The full ROS message type string to check
(e.g., |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
|
unpack_mosaico_msg
classmethod
¶
Extracts the typed Mosaico payload and its Header (if present) from a wrapped or bare message.
Handles two input cases:
Messagewrapper: the typed data is extracted viaget_data().- Raw ontology instance: returned as-is with
the Header is extracted from the ontology (if supported), otherwise an default Header (empty frame_id and zero Time) is returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mosaico_msg
|
Union[Message, T]
|
Either a |
required |
Returns:
| Type | Description |
|---|---|
T
|
tuple[T, Header]: A |
Header
|
header is the corresponding |
tuple[T, Header]
|
zero |
Raises:
| Type | Description |
|---|---|
TypeError
|
If mosaico_msg is neither a |
ontology_data_type
classmethod
¶
Returns the Ontology class type associated with this adapter.