Skip to content

Commit

Permalink
Merge branch 'nobleo-ros2' into HARVEY-1380-ROS2-report-stale-on-no-e…
Browse files Browse the repository at this point in the history
…rror-but-stale
  • Loading branch information
Ferry Schoenmakers committed Apr 30, 2024
2 parents ecdc89e + feb72b0 commit 911cc7f
Show file tree
Hide file tree
Showing 26 changed files with 501 additions and 206 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
uncrustify,
xmllint,
]
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
env:
AMENT_CPPCHECK_ALLOW_SLOW_VERSIONS: 1
steps:
Expand Down
13 changes: 5 additions & 8 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,15 @@ jobs:
distro: [humble, iron, rolling]
include:
- distro: humble
os: ubuntu-22.04
os: 22.04
- distro: iron
os: ubuntu-22.04
os: 22.04
- distro: rolling
os: ubuntu-22.04
runs-on: ${{ matrix.os }}
os: 24.04
runs-on: ubuntu-latest
container: ubuntu:${{ matrix.os }}
steps:
- uses: ros-tooling/setup-ros@master
- run: |
sudo pip install pydocstyle==6.1.1 # downgrade to fix https://github.com/ament/ament_lint/pull/428
sudo pip install pip --upgrade
sudo pip install pyopenssl --upgrade # fix for AttributeError: module 'lib' has no attribute 'X509_V_FLAG_CB_ISSUER_CHECK'
- uses: ros-tooling/action-ros-ci@master
with:
target-ros2-distro: ${{ matrix.distro }}
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Overview

The diagnostics system collects information about hardware drivers and robot hardware to make them availaible to users and operators.
The diagnostics system collects information about hardware drivers and robot hardware to make them available to users and operators.
The diagnostics system contains tools to collect and analyze this data.

The diagnostics system is build around the `/diagnostics` topic. The topic is used for `diagnostic_msgs/DiagnosticArray` messages.
Expand Down Expand Up @@ -37,7 +37,11 @@ Diagnostics messages that are not aggregated can be visualized by [`rqt_runtime_
The [`ros2` branch](https://github.com/ros/diagnostics/tree/ros2) targets

- *Humble Hawksbill*
- *Iron Irwini* and
- *Iron Irwini*

The [`ros2-jazzy` branch](https://github.com/ros/diagnostics/tree/ros2-jazzy) targets

- *Jazzy Jalisco*
- *Rolling Ridley*

# License
Expand Down
10 changes: 10 additions & 0 deletions diagnostic_aggregator/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
Changelog for package diagnostic_aggregator
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

3.2.0 (2024-03-22)
------------------
* Avoid rolling up an ERROR state when empty GenericAnalyzer blocks are marked discard_stale, or when all of their items are STALE. (`#315 <https://github.com/ros/diagnostics/issues/315>`_)
* formatting fixes from PR324 (`#327 <https://github.com/ros/diagnostics/issues/327>`_)
* Debugging instability introduced by `#317 <https://github.com/ros/diagnostics/issues/317>`_ (`#323 <https://github.com/ros/diagnostics/issues/323>`_)
* feat: publish top level msg when error is received (`#317 <https://github.com/ros/diagnostics/issues/317>`_)
* Empty default aggregator base_path (`#305 <https://github.com/ros/diagnostics/issues/305>`_)
* using defined state for stale (`#298 <https://github.com/ros/diagnostics/issues/298>`_)
* Contributors: Andrew Symington, Christian Henkel, outrider-jhulas

3.1.2 (2023-03-24)
------------------

Expand Down
5 changes: 5 additions & 0 deletions diagnostic_aggregator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ if(BUILD_TESTING)
test/test_critical_pub.py
TIMEOUT 30
)

ament_add_pytest_test(test_discard_behavior
"${CMAKE_CURRENT_SOURCE_DIR}/test/test_discard_behavior.py"
TIMEOUT 60
)
endif()

install(
Expand Down
7 changes: 5 additions & 2 deletions diagnostic_aggregator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The robot has two of each, one on each side.
The robot also 4 camera sensors, one left and one right and one in the front and one in the back.
These are all the available diagnostic sources:

```
```
/arms/left/motor
/arms/right/motor
/legs/left/motor
Expand Down Expand Up @@ -119,6 +119,9 @@ Additional parameters depend on the type of the analyzer.
Any diagnostic item that is not matched by any analyzer will be published by an "Other" analyzer.
Items created by the "Other" analyzer will go stale after 5 seconds.

The `critical` parameter makes the aggregator react immediately to a degradation in diagnostic state.
This is useful if the toplevel state is parsed by a watchdog for example.

## Launching
You can launch the `aggregator_node` like this (see [example.launch.py.in](example/example.launch.py.in)):
``` python
Expand Down Expand Up @@ -213,4 +216,4 @@ This means that things that are ignored by the `IgnoreAnalyzer` will still be pu
- `analyzers` (map, default: {}) - The analyzers that will be used to aggregate the diagnostics

# Tutorials
TODO: Port tutorials #contributions-welcome
TODO: Port tutorials #contributions-welcome
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ class GenericAnalyzerBase : public Analyzer

auto header_status = std::make_shared<diagnostic_msgs::msg::DiagnosticStatus>();
header_status->name = path_;
header_status->level = 0;
header_status->level = diagnostic_msgs::msg::DiagnosticStatus::OK;
header_status->message = "OK";

std::vector<std::shared_ptr<diagnostic_msgs::msg::DiagnosticStatus>> processed;
Expand Down Expand Up @@ -224,22 +224,28 @@ class GenericAnalyzerBase : public Analyzer

// Header is not stale unless all subs are
if (all_stale) {
header_status->level = diagnostic_msgs::msg::DiagnosticStatus::STALE;
// If we elect to discard stale items, then it signals that the absence of an item
// is not considered problematic, so we should allow empty queues to roll up as OK.
if (discard_stale_) {
header_status->level = diagnostic_msgs::msg::DiagnosticStatus::OK;
} else {
header_status->level = diagnostic_msgs::msg::DiagnosticStatus::STALE;
}
} else if (header_status->level == diagnostic_msgs::msg::DiagnosticStatus::STALE) {
header_status->level = 2;
header_status->level = diagnostic_msgs::msg::DiagnosticStatus::ERROR;
}

header_status->message = valToMsg(header_status->level);

// If we expect a given number of items, check that we have this number
if (num_items_expected_ == 0 && items_.empty()) {
header_status->level = 0;
header_status->level = diagnostic_msgs::msg::DiagnosticStatus::OK;
header_status->message = "OK";
} else if ( // NOLINT
num_items_expected_ > 0 &&
static_cast<int8_t>(items_.size()) != num_items_expected_)
{ // NOLINT
int8_t lvl = 2;
int8_t lvl = diagnostic_msgs::msg::DiagnosticStatus::ERROR;
header_status->level = std::max(lvl, static_cast<int8_t>(header_status->level));

std::stringstream expec, item;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class OtherAnalyzer : public GenericAnalyzerBase
processed.begin();
for (; it != processed.end(); ++it) {
if ((*it)->name == path_) {
(*it)->level = 2;
(*it)->level = diagnostic_msgs::msg::DiagnosticStatus::ERROR;
(*it)->message = "Unanalyzed items found in \"Other\"";
break;
}
Expand Down
9 changes: 5 additions & 4 deletions diagnostic_aggregator/mainpage.dox
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ See Analyzer for more information on the base class.

\subsubsection generic_analyzer GenericAnalyzer

\b generic_analyzer holds the GenericAnalyzer class, which is the most basic of the Analyzer's. It is used by the diagnostic_aggregator/Aggregator to store, process and republish diagnostics data. The GenericAnalyzer is loaded by the pluginlib as a Analyzer plugin. It is the most basic of all Analyzer's.
\b generic_analyzer holds the GenericAnalyzer class, which is the most basic of the Analyzer's. It is used by the diagnostic_aggregator/Aggregator to store, process and republish diagnostics data. The GenericAnalyzer is loaded by the pluginlib as a Analyzer plugin. It is the most basic of all Analyzer's.

\subsubsection analyzer_group AnalyzerGroup

Expand All @@ -37,10 +37,10 @@ aggregator_node subscribes to "/diagnostics" and publishes an aggregated set of
\subsubsection topics ROS topics

Subscribes to:
- \b "/diagnostics": [diagnostics_msgs/DiagnosticArray]
- \b "/diagnostics": [diagnostics_msgs/DiagnosticArray]

Publishes to:
- \b "/diagnostics_agg": [diagnostics_msgs/DiagnosticArray]
- \b "/diagnostics_agg": [diagnostics_msgs/DiagnosticArray]

\subsubsection parameters ROS parameters

Expand All @@ -49,6 +49,7 @@ Reads the following parameters from the parameter server
- \b "~pub_rate" : \b double [optional] Rate that output diagnostics published
- \b "~base_path" : \b double [optional] Prepended to all analyzed output
- \b "~analyzers" : \b {} Configuration for loading analyzers
- \b "~critical" : \b bool [optional] React immediately to a degradation in diagnostic state

\subsection analyzer_loader analyzer_loader

Expand All @@ -61,4 +62,4 @@ Reads the following parameters from the parameter server
- \b "~analyzers" : \b {} Configuration for loading and testing analyzers


*/
*/
3 changes: 2 additions & 1 deletion diagnostic_aggregator/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>diagnostic_aggregator</name>
<version>3.1.2</version>
<version>3.2.0</version>
<description>diagnostic_aggregator</description>
<maintainer email="[email protected]">Austin Hendrix</maintainer>
<maintainer email="[email protected]">Brice Rebsamen</maintainer>
Expand Down Expand Up @@ -32,6 +32,7 @@
<test_depend>ament_cmake_pytest</test_depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
<test_depend>launch_pytest</test_depend>
<test_depend>launch_testing_ament_cmake</test_depend>
<test_depend>launch_testing_ros</test_depend>

Expand Down
Loading

0 comments on commit 911cc7f

Please sign in to comment.