sensor_msgs¶
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.
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 the recursive 'roi' key exists but is not a dict, or if required keys are missing. |
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.
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.
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 the recursive 'roi' key exists but is not a dict, or if required keys are missing. |
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.
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.
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 the recursive 'roi' key exists but is not a dict, or if required keys are missing. |
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.
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.
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 the recursive 'roi' key exists but is not a dict, or if required keys are missing. |
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.
NMEASentenceAdapter ¶
Bases: ROSAdapterBase[NMEASentence]
Adapter for translating ROS NMEASentence messages to Mosaico NMEASentence.
Supported ROS Types:
Example
ros_msg = ROSMessage(
timestamp=17000,
topic="/gps/fix",
msg_type="sensor_msgs/msg/GPSFix",
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 GPS with attached metadata
mosaico_gps = NMEASentenceAdapter.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
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. |
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.
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.
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. |
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.
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.
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. |
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.
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.
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. |
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.
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,
"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.
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,
"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. |
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.
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.
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)
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.