Diagnostic Bridge Configuration
The ros2_medkit_diagnostic_bridge node converts standard ROS 2 /diagnostics messages
to fault events, providing a migration path for existing diagnostic infrastructure.
Overview
The diagnostic bridge:
Subscribes to
/diagnostics(or custom topic)Maps
DiagnosticStatusnames to fault codesReports faults to the FaultManager via
ReportFaultservice
Status Mapping:
Diagnostic Level |
Fault Event |
Severity |
|---|---|---|
OK |
PASSED |
(healing event) |
WARN |
FAILED |
SEVERITY_WARN (1) |
ERROR |
FAILED |
SEVERITY_ERROR (2) |
STALE |
FAILED |
SEVERITY_ERROR (2) |
Parameters
diagnostic_bridge:
ros__parameters:
diagnostics_topic: "/diagnostics" # Topic to subscribe to
auto_generate_codes: true # Auto-generate fault codes from names
Parameter |
Default |
Description |
|---|---|---|
|
|
Topic to subscribe for |
|
|
Automatically generate fault codes from diagnostic names when no explicit mapping exists. |
Custom Fault Code Mappings
Map specific diagnostic names to custom fault codes using the name_to_code parameter prefix:
diagnostic_bridge:
ros__parameters:
diagnostics_topic: "/diagnostics"
auto_generate_codes: true
name_to_code:
motor_temp: "MOTOR_OVERHEAT"
battery_level: "LOW_BATTERY"
camera_driver: "CAMERA_FAILURE"
Or via command line:
ros2 run ros2_medkit_diagnostic_bridge diagnostic_bridge \
--ros-args \
-p "name_to_code.motor_temp:=MOTOR_OVERHEAT" \
-p "name_to_code.battery_level:=LOW_BATTERY"
Auto-Generated Fault Codes
When auto_generate_codes: true and no explicit mapping exists, fault codes are
generated from the diagnostic name:
Convert to uppercase
Replace spaces, slashes, and dashes with underscores
Remove non-alphanumeric characters (except underscore)
Prepend
DIAG_prefix
Examples:
Diagnostic Name |
Generated Fault Code |
|---|---|
|
|
|
|
|
|
Launch File Configuration
Example launch file:
from launch import LaunchDescription
from launch_ros.actions import Node
def generate_launch_description():
return LaunchDescription([
Node(
package='ros2_medkit_diagnostic_bridge',
executable='diagnostic_bridge_node',
name='diagnostic_bridge',
parameters=[{
'diagnostics_topic': '/diagnostics',
'auto_generate_codes': True,
'name_to_code': {
'motor_temp': 'MOTOR_OVERHEAT',
'battery_level': 'LOW_BATTERY',
}
}],
),
])
Integration with FaultManager
The diagnostic bridge requires a running FaultManager to report faults. Ensure the FaultManager is started before the bridge:
# Terminal 1: Start FaultManager
ros2 run ros2_medkit_fault_manager fault_manager_node
# Terminal 2: Start Diagnostic Bridge
ros2 run ros2_medkit_diagnostic_bridge diagnostic_bridge_node
Or use a combined launch file:
from launch import LaunchDescription
from launch_ros.actions import Node
def generate_launch_description():
return LaunchDescription([
Node(
package='ros2_medkit_fault_manager',
executable='fault_manager_node',
name='fault_manager',
),
Node(
package='ros2_medkit_diagnostic_bridge',
executable='diagnostic_bridge_node',
name='diagnostic_bridge',
),
])
Migration Strategy
For transitioning from standard ROS 2 diagnostics to direct fault reporting:
Phase 1: Deploy diagnostic bridge alongside existing diagnostics infrastructure
Phase 2: Create explicit mappings for important diagnostics
Phase 3: Migrate critical nodes to direct FaultReporter usage
Phase 4: Disable auto_generate_codes, rely only on explicit mappings
Phase 5: Remove diagnostic bridge when all nodes use FaultReporter
See also
ros2_medkit_fault_reporter - Direct fault reporting with FaultReporter
See Also
Fault Manager Configuration - FaultManager configuration
ros2_medkit_fault_reporter - Direct fault reporting guide
Message Definitions - ReportFault service definition
ros2_medkit_diagnostic_bridge - Bridge architecture