Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
3f3a2f6
Introduce state/mode deviation
norro Feb 19, 2020
115a5a3
Merge branch 'dev' into feature/rules
norro Jul 15, 2020
d3075f8
Comparison operator for StateAndMode
norro Jul 15, 2020
24761f0
Minor changes
norro Jul 15, 2020
3fe186a
Inference now properly reporting system deviation
norro Jul 17, 2020
eb5e448
Inference now properly reporting system deviation
norro Jul 17, 2020
fd1c3ac
Starts prototyping rules
norro Jul 17, 2020
8a16ef4
Moved helpers to mode_impl
norro Jul 20, 2020
4c4fbf0
Moves rules parsing to ModeHandling
norro Jul 20, 2020
8fd5959
Tests for StateAndMode struct
norro Jul 21, 2020
2f66713
Mode manager finds applicable rules
norro Jul 21, 2020
3445f16
First exemplary set of mode rules working
norro Jul 21, 2020
c1a62bc
Documentation of the rules example
norro Jul 22, 2020
4905cfc
rules documentation
norro Jul 22, 2020
61504da
Adds screenshot of mode manager applying rule
norro Jul 22, 2020
559c1b0
Minor fix in model path handling
norro Jul 22, 2020
9f60c40
Merge branch 'master' into feature/rules
norro Jul 22, 2020
ffe02c6
Version push to 0.3.0
norro Jul 22, 2020
95caac6
Clarifications in documentation
norro Aug 7, 2020
8ea52a2
Stricter constness in mode inference
norro Sep 23, 2020
ff8f91d
ModeEvent now includes start mode (of transition)
norro Sep 23, 2020
5681534
Adds inference of transitions to mode inference
norro Sep 23, 2020
412fe61
Tests for transition inference
norro Sep 23, 2020
c883230
Mode manager publishs inferred transitions
norro Sep 29, 2020
f2305e3
Version push to 0.4.0
norro Sep 30, 2020
0ada932
Add dependencies to launch
norro Sep 30, 2020
5b40cf1
Merge branch 'dev' into feature/rules
norro Oct 15, 2020
198cd35
Resolved fight between cpplint and uncrustify
norro Oct 16, 2020
3605dd5
Note that rules feature is still experimental
norro Oct 19, 2020
07b3190
Note that rules feature is still experimental
norro Oct 19, 2020
761dcda
Merge pull request #29 from micro-ROS/feature/rules
norro Oct 19, 2020
145200f
CI on ubuntu 20.04 ROS 2 rolling
norro Oct 19, 2020
4942f25
Version bump to 0.4.1
norro Oct 19, 2020
24e8b93
Merge branch 'master' into dev
norro Oct 19, 2020
a30763e
Don't CI build on rolling just yet
norro Oct 19, 2020
874eeb8
Rules feature no longer experimental
norro Dec 11, 2020
48ba20c
Updates github workflow
norro Dec 16, 2020
72949f4
Suppress cppcheck unknownmacro false positive
norro Dec 16, 2020
39b2149
Adds CIand coverage info to README
norro Dec 16, 2020
a19a482
More robust inference
norro Dec 16, 2020
4858e3f
Fixes cppcheck unknownMacro suppresion
norro Dec 17, 2020
20facfb
Merge branch 'master' into dev
norro Dec 17, 2020
53cfd1c
Version push to 0.4.2
norro Dec 17, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: "Build action: Foxy + Rolling"

on:
push:
branches: [ master, dev ]
pull_request:
branches: [ master, dev ]
schedule:
# Run once per day to detect broken dependencies.
- cron: '17 6 * * *'

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-20.04 ]
ros_distribution: [ foxy, rolling ]
steps:
- uses: actions/checkout@v2
- uses: ros-tooling/setup-ros@0.0.26
with:
required-ros-distributions: ${{ matrix.ros_distribution }}
- uses : ros-tooling/action-ros-ci@0.1.0
with:
package-name: "system_modes system_modes_examples"
target-ros2-distro: ${{ matrix.ros_distribution }}
colcon-mixin-name: coverage-gcc
colcon-mixin-repository: https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml
- uses: codecov/codecov-action@v1
with:
file: ros_ws/lcov/total_coverage.info
45 changes: 0 additions & 45 deletions .github/workflows/lint.yaml

This file was deleted.

22 changes: 0 additions & 22 deletions .github/workflows/test.yaml

This file was deleted.

14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# ROS 2 System Modes

[![License](https://img.shields.io/badge/License-Apache%202-blue.svg)](https://github.com/micro-ROS/system_modes/blob/master/LICENSE)
[![Build status](https://build.ros2.org/job/Ddev__system_modes__ubuntu_bionic_amd64/badge/icon?subject=Build%20farm%3A%20Dashing)](https://build.ros2.org/job/Ddev__system_modes__ubuntu_bionic_amd64/)
[![Build status](http://build.ros2.org/job/Edev__system_modes__ubuntu_bionic_amd64/badge/icon?subject=Build%20farm%3A%20Eloquent)](http://build.ros2.org/job/Edev__system_modes__ubuntu_bionic_amd64/)
[![Build status](http://build.ros2.org/job/Fdev__system_modes__ubuntu_focal_amd64/badge/icon?subject=Build%20farm%3A%20Foxy)](http://build.ros2.org/job/Fdev__system_modes__ubuntu_focal_amd64/)
[![Build status](http://build.ros2.org/job/Rdev__system_modes__ubuntu_focal_amd64/badge/icon?subject=Build%20farm%3A%20Rolling)](http://build.ros2.org/job/Rdev__system_modes__ubuntu_focal_amd64/)
[![Build status](https://github.com/micro-ROS/system_modes/workflows/Build%20action%3A%20Foxy%20%2B%20Rolling/badge.svg)](https://github.com/micro-ROS/system_modes/actions)
[![Code coverage](https://codecov.io/gh/micro-ROS/system_modes/branch/master/graph/badge.svg)](https://codecov.io/gh/micro-ROS/system_modes)

This repository explores a system modes concept that is implemented for ROS 2 in two packages:
* [system_modes](./system_modes/) provides a library for system mode inference, a mode manager, and a mode monitor
* [system_modes_examples](./system_modes_examples/) implements a simple example
Expand Down Expand Up @@ -32,6 +40,12 @@ ROS 2 System Modes are open-sourced under the Apache-2.0 license. See the
For a list of other open-source components included in ROS 2 system_modes,
see the file [3rd-party-licenses.txt](3rd-party-licenses.txt).

## Quality assurance

The colcon_test tool is used for quality assurances, which includes cpplint, uncrustify, flake8, xmllint and various other tools.

Unit tests based on [gtest](https://github.com/google/googletest) are located in the [./system_modes/test](system_modes/test) folder.

## Known Issues/Limitations

Please notice the following issues/limitations:
Expand Down
5 changes: 1 addition & 4 deletions system_modes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ include_directories(../../build/system_modes/rosidl_generator_cpp/)
link_directories(../../build/system_modes/)
target_link_libraries(mode system_modes__rosidl_typesupport_cpp)

# Causes the visibility macros to use dllexport rather than dllimport,
# Causes the visibility macros to use dllexport rather than dllimport,
# which is appropriate when building the dll but not consuming it.
target_compile_definitions(mode PRIVATE "SYSTEMMODES_BUILDING_LIBRARY")

Expand Down Expand Up @@ -106,9 +106,6 @@ if(BUILD_TESTING)
# the following line skips the linter which checks for copyrights
# remove the line when a copyright and license is present in all source files
set(ament_cmake_copyright_FOUND TRUE)
# the following line skips cpplint (only works in a git repo)
# remove the line when this package is a git repo
set(ament_cmake_cpplint_FOUND TRUE)
ament_lint_auto_find_test_dependencies()

set(MODE_FILE_CORRECT ${CMAKE_CURRENT_SOURCE_DIR}/test/test_modes.yaml)
Expand Down
5 changes: 5 additions & 0 deletions system_modes/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
Changelog for package system_modes_examples
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0.4.2 (2020-12-17)
-----------
* Error handling and rules feature no longer experimental
* Fixed bugs in monitor and tests

0.4.1 (2020-10-29)
-----------
* Include experimental error handling and rules feature
Expand Down
4 changes: 4 additions & 0 deletions system_modes/include/system_modes/mode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "system_modes/mode_impl.hpp"

#include <rclcpp/macros.hpp>
#include <rclcpp/node_interfaces/node_parameters.hpp>
#include <rclcpp/parameter_map.hpp>

Expand Down Expand Up @@ -46,6 +47,7 @@ class ModeBase
public:
explicit ModeBase(const std::string & mode_name);
virtual ~ModeBase() = default;
// cppcheck-suppress unknownMacro
RCLCPP_DISABLE_COPY(ModeBase)

std::string get_name() const;
Expand Down Expand Up @@ -74,6 +76,7 @@ class DefaultMode : public ModeBase
public:
DefaultMode();
explicit DefaultMode(const std::string & mode_name) = delete;
// cppcheck-suppress unknownMacro
RCLCPP_DISABLE_COPY(DefaultMode)

virtual void set_parameter(const rclcpp::Parameter & parameter);
Expand All @@ -89,6 +92,7 @@ class Mode : public ModeBase
public:
explicit Mode(const std::string & mode_name) = delete;
Mode(const std::string & mode_name, const DefaultModePtr default_mode);
// cppcheck-suppress unknownMacro
RCLCPP_DISABLE_COPY(Mode)

virtual ~Mode() = default;
Expand Down
1 change: 1 addition & 0 deletions system_modes/include/system_modes/mode_handling.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class ModeHandling
{
public:
explicit ModeHandling(const std::string & model_path);
// cppcheck-suppress unknownMacro
RCLCPP_DISABLE_COPY(ModeHandling)

virtual ~ModeHandling() = default;
Expand Down
1 change: 1 addition & 0 deletions system_modes/include/system_modes/mode_inference.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class ModeInference
{
public:
explicit ModeInference(const std::string & model_path);
// cppcheck-suppress unknownMacro
RCLCPP_DISABLE_COPY(ModeInference)

virtual const std::vector<std::string> get_all_parts() const;
Expand Down
2 changes: 1 addition & 1 deletion system_modes/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>system_modes</name>
<version>0.4.1</version>
<version>0.4.2</version>
<description>
The system modes concept assumes that a robotics system is built
from components with a lifecycle. It adds a notion of (sub-)systems,
Expand Down
28 changes: 23 additions & 5 deletions system_modes/src/system_modes/mode_inference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ void
ModeInference::update(const string & node, const StateAndMode & sm)
{
this->update_state(node, sm.state);
this->update_mode(node, sm.mode);
if (sm.state == State::PRIMARY_STATE_ACTIVE) {
this->update_mode(node, sm.mode);
} else {
this->update_mode(node, "");
}
}

void
Expand Down Expand Up @@ -162,7 +166,14 @@ ModeInference::get(const string & part) const
throw std::runtime_error("No solid information about state and mode of '" + part + "'.");
}

return this->nodes_.at(part);
auto sam = this->nodes_.at(part);
if (sam.state != State::PRIMARY_STATE_ACTIVE &&
sam.state != State::TRANSITION_STATE_ACTIVATING)
{
sam.mode = "";
}

return sam;
}

StateAndMode
Expand Down Expand Up @@ -422,7 +433,7 @@ ModeInference::get_or_infer(const string & part)
return stateAndMode;
}
} catch (...) {
// not a node, so try inference
// so try inference
}

try {
Expand All @@ -441,6 +452,9 @@ ModeInference::get_or_infer(const string & part)
if (stateAndMode.state == 0 && stateAndMode.mode.empty()) {
throw std::runtime_error("Not able to infer anything for part " + part);
}
if (stateAndMode.state != State::PRIMARY_STATE_ACTIVE) {
stateAndMode.mode = "";
}

return stateAndMode;
}
Expand Down Expand Up @@ -555,9 +569,13 @@ ModeInference::read_modes_from_model(const string & model_path)

} else {
if (param.value_to_string().compare("node") != 0) {
this->systems_.emplace(part_name, StateAndMode(0, ""));
this->systems_.emplace(
part_name,
StateAndMode(State::PRIMARY_STATE_UNKNOWN, ""));
} else {
this->nodes_.emplace(part_name, StateAndMode(0, ""));
this->nodes_.emplace(
part_name,
StateAndMode(State::PRIMARY_STATE_UNKNOWN, ""));
}
}
}
Expand Down
8 changes: 5 additions & 3 deletions system_modes/src/system_modes/mode_monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,11 @@ ModeMonitor::refresh() const

// state/mode inference
try {
auto stateAndMode = mode_inference_->infer(node);
state_infer = stateAndMode.state;
mode_infer = stateAndMode.mode;
if (state_actual == State::PRIMARY_STATE_ACTIVE) {
auto stateAndMode = mode_inference_->infer(node);
state_infer = stateAndMode.state;
mode_infer = stateAndMode.mode;
}
} catch (std::out_of_range & ex) {
RCLCPP_DEBUG(
get_logger(),
Expand Down
5 changes: 5 additions & 0 deletions system_modes_examples/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
Changelog for package system_modes_examples
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0.4.2 (2020-12-17)
-----------
* Error handling and rules feature no longer experimental
* Fixed bugs in monitor and tests

0.4.1 (2020-10-29)
-----------
* Include experimental error handling and rules feature
Expand Down
2 changes: 1 addition & 1 deletion system_modes_examples/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>system_modes_examples</name>
<version>0.4.1</version>
<version>0.4.2</version>
<description>
Simple example system and according launch files for the system_modes
package.
Expand Down