Skip to content

Commit

Permalink
Add an add_analyzer example to the diagnostic_aggregator
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinCornelis2 committed Mar 1, 2024
1 parent 468203c commit 43b6a15
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion diagnostic_aggregator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ ament_python_install_package(${PROJECT_NAME})

# Install Example
set(ANALYZER_PARAMS_FILEPATH "${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/example_analyzers.yaml")
set(ADD_ANALYZER_PARAMS_FILEPATH "${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/example_add_analyzers.yaml")
configure_file(example/example.launch.py.in example.launch.py @ONLY)
install( # launch descriptor
FILES ${CMAKE_CURRENT_BINARY_DIR}/example.launch.py
Expand All @@ -172,7 +173,7 @@ install( # example publisher
DESTINATION lib/${PROJECT_NAME}
)
install( # example aggregator configration
FILES example/example_analyzers.yaml
FILES example/example_analyzers.yaml example/example_add_analyzers.yaml
DESTINATION share/${PROJECT_NAME}
)

Expand Down
8 changes: 8 additions & 0 deletions diagnostic_aggregator/example/example.launch.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import launch
import launch_ros.actions

analyzer_params_filepath = "@ANALYZER_PARAMS_FILEPATH@"
add_analyzer_params_filepath = "@ADD_ANALYZER_PARAMS_FILEPATH@"


def generate_launch_description():
Expand All @@ -12,11 +13,18 @@ def generate_launch_description():
executable='aggregator_node',
output='screen',
parameters=[analyzer_params_filepath])
add_analyzer = launch_ros.actions.Node(
package='diagnostic_aggregator',
executable='add_analyzer',
output='screen',
parameters=[add_analyzer_params_filepath]
)
diag_publisher = launch_ros.actions.Node(
package='diagnostic_aggregator',
executable='example_pub.py')
return launch.LaunchDescription([
aggregator,
add_analyzer,
diag_publisher,
launch.actions.RegisterEventHandler(
event_handler=launch.event_handlers.OnProcessExit(
Expand Down
6 changes: 6 additions & 0 deletions diagnostic_aggregator/example/example_add_analyzers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**:
ros__parameters:
optional:
type: diagnostic_aggregator/GenericAnalyzer
path: Optional
contains: [ '/optional' ]
4 changes: 4 additions & 0 deletions diagnostic_aggregator/example/example_pub.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ def __init__(self):
name='/sensors/front/cam', message='OK'),
DiagnosticStatus(level=DiagnosticStatus.OK,
name='/sensors/rear/cam', message='OK'),

# Optional
DiagnosticStatus(level=DiagnosticStatus.OK,
name='/optional/runtime/analyzer', message='OK'),
]

def timer_callback(self):
Expand Down

0 comments on commit 43b6a15

Please sign in to comment.