Skip to content

Commit

Permalink
Empty default aggregator base_path (#305)
Browse files Browse the repository at this point in the history
* aggregator default base path is ""
* adding leading slash back
* testing for the empty root path
Signed-off-by: Christian Henkel <[email protected]>
  • Loading branch information
ct2034 authored Jun 6, 2023
1 parent 369a769 commit be6fec7
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 4 deletions.
6 changes: 4 additions & 2 deletions diagnostic_aggregator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ if(BUILD_TESTING)
set(create_analyzers_tests
"primitive_analyzers"
"all_analyzers"
"analyzer_group")
"analyzer_group"
"empty_root_path")

foreach(test_name ${create_analyzers_tests})
file(TO_CMAKE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/test/${test_name}.yaml" PARAMETER_FILE)
Expand All @@ -103,7 +104,8 @@ if(BUILD_TESTING)
set(analyzers_output_tests
"primitive_analyzers"
"all_analyzers"
"analyzer_group")
"analyzer_group"
"empty_root_path")

foreach(test_name ${create_analyzers_tests})
file(TO_CMAKE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/test/${test_name}.yaml" PARAMETER_FILE)
Expand Down
4 changes: 3 additions & 1 deletion diagnostic_aggregator/example/example.launch.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import launch_ros.actions

analyzer_params_filepath = "@ANALYZER_PARAMS_FILEPATH@"


def generate_launch_description():
aggregator = launch_ros.actions.Node(
package='diagnostic_aggregator',
Expand All @@ -20,6 +21,7 @@ def generate_launch_description():
launch.actions.RegisterEventHandler(
event_handler=launch.event_handlers.OnProcessExit(
target_action=aggregator,
on_exit=[launch.actions.EmitEvent(event=launch.events.Shutdown())],
on_exit=[launch.actions.EmitEvent(
event=launch.events.Shutdown())],
)),
])
6 changes: 5 additions & 1 deletion diagnostic_aggregator/src/aggregator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Aggregator::Aggregator()
pub_rate_(1.0),
history_depth_(1000),
clock_(n_->get_clock()),
base_path_("/")
base_path_("")
{
RCLCPP_DEBUG(logger_, "constructor");
bool other_as_errors = false;
Expand All @@ -79,6 +79,10 @@ Aggregator::Aggregator()
if (param.first.compare("pub_rate") == 0) {
pub_rate_ = param.second.as_double();
} else if (param.first.compare("path") == 0) {
// Leading slash when path is not empty
if (!param.second.as_string().empty()) {
base_path_.append("/");
}
base_path_.append(param.second.as_string());
} else if (param.first.compare("other_as_errors") == 0) {
other_as_errors = param.second.as_bool();
Expand Down
14 changes: 14 additions & 0 deletions diagnostic_aggregator/test/empty_root_path.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
analyzers:
ros__parameters:
primary:
type: 'diagnostic_aggregator/AnalyzerGroup'
path: Group01
analyzers:
primary:
type: 'diagnostic_aggregator/GenericAnalyzer'
path: Primary
startswith: [ 'primary' ]
secondary:
type: 'diagnostic_aggregator/GenericAnalyzer'
path: Secondary
startswith: [ 'secondary' ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/Group01/Primary
/Group01/Secondary
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
diagnostic_msgs.msg.DiagnosticStatus
name='/Group01/Primary', message='Stale'
diagnostic_msgs.msg.DiagnosticStatus
name='/Group01/Secondary', message='Stale'
diagnostic_msgs.msg.DiagnosticStatus
name='/Group01', message='Stale'

0 comments on commit be6fec7

Please sign in to comment.