Skip to content

Commit 9189558

Browse files
authored
Merge pull request #41 from micro-ROS/dev
Merges current dev to master
2 parents c1e5683 + 49b095d commit 9189558

25 files changed

+300
-307
lines changed

.github/workflows/lint.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Lint system modes
2+
on:
3+
pull_request:
4+
5+
jobs:
6+
ament_xmllint:
7+
name: ament_xmllint
8+
runs-on: ubuntu-18.04
9+
steps:
10+
- uses: actions/checkout@v2
11+
- uses: ros-tooling/setup-ros@0.0.25
12+
- uses: ros-tooling/action-ros2-lint@0.0.6
13+
with:
14+
linter: xmllint
15+
package-name: system_modes system_modes_examples
16+
17+
ament_lint_cpp:
18+
name: ament_${{ matrix.linter }}
19+
runs-on: ubuntu-18.04
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
linter: [cppcheck, cpplint, uncrustify]
24+
steps:
25+
- uses: actions/checkout@v2
26+
- uses: ros-tooling/setup-ros@0.0.25
27+
- uses: ros-tooling/action-ros2-lint@0.0.6
28+
with:
29+
linter: ${{ matrix.linter }}
30+
package-name: system_modes system_modes_examples
31+
32+
ament_lint_py:
33+
name: ament_${{ matrix.linter }}
34+
runs-on: ubuntu-18.04
35+
strategy:
36+
fail-fast: false
37+
matrix:
38+
linter: [flake8, pep257]
39+
steps:
40+
- uses: actions/checkout@v2
41+
- uses: ros-tooling/setup-ros@0.0.25
42+
- uses: ros-tooling/action-ros2-lint@0.0.6
43+
with:
44+
linter: ${{ matrix.linter }}
45+
package-name: system_modes system_modes_examples

.github/workflows/test.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Test system modes
2+
on:
3+
pull_request:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
build_and_test:
10+
runs-on: ${{ matrix.os }}
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
os: [ubuntu-18.04]
15+
steps:
16+
- uses: ros-tooling/setup-ros@0.0.25
17+
- uses: ros-tooling/action-ros-ci@0.0.15
18+
with:
19+
package-name: system_modes system_modes_examples
20+
target-ros2-distro: foxy
21+
colcon-mixin-name: coverage-gcc
22+
colcon-mixin-repository: https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml

system_modes/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ find_package(rclcpp_lifecycle REQUIRED)
2525
find_package(rosidl_typesupport_cpp REQUIRED)
2626
find_package(rosidl_default_generators REQUIRED)
2727
find_package(lifecycle_msgs REQUIRED)
28-
find_package(Boost 1.58 COMPONENTS program_options REQUIRED)
2928

3029
# generate service
3130
rosidl_generate_interfaces(${PROJECT_NAME}
@@ -52,8 +51,6 @@ ament_target_dependencies(mode
5251
"lifecycle_msgs"
5352
"rosidl_typesupport_cpp"
5453
"std_msgs"
55-
"Boost"
56-
"Boost_PROGRAM_OPTIONS"
5754
"builtin_interfaces"
5855
)
5956
#rosidl_target_interfaces(mode

system_modes/changelog.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22
Changelog for package system_modes
33
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
44

5-
0.2.3 (2020-02-13)
5+
0.3.0 (2020-07-23)
6+
-----------
7+
* removed boost dependencies (was: program options)
8+
* changed mode service specifications (less redundancy)
9+
* https://github.com/micro-ROS/system_modes/issues/24
10+
11+
0.2.3 (2020-07-23)
612
-----------
713
* improved StateAndMode struct
814
* testing

system_modes/include/system_modes/mode_manager.hpp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ namespace system_modes
4040
class ModeManager : public rclcpp::Node
4141
{
4242
public:
43-
explicit ModeManager(const std::string & model_path);
43+
ModeManager();
4444
ModeManager(const ModeManager &) = delete;
4545

4646
std::shared_ptr<ModeInference> inference();
@@ -65,26 +65,30 @@ class ModeManager : public rclcpp::Node
6565

6666
// Mode service callbacks
6767
virtual void on_change_mode(
68-
const std::shared_ptr<rmw_request_id_t>,
68+
const std::string &,
6969
const std::shared_ptr<system_modes::srv::ChangeMode::Request>,
7070
std::shared_ptr<system_modes::srv::ChangeMode::Response>);
7171
virtual void on_get_mode(
72-
const std::shared_ptr<rmw_request_id_t>,
73-
const std::shared_ptr<system_modes::srv::GetMode::Request>,
72+
const std::string &,
7473
std::shared_ptr<system_modes::srv::GetMode::Response>);
7574
virtual void on_get_available_modes(
76-
const std::shared_ptr<rmw_request_id_t>,
77-
const std::shared_ptr<system_modes::srv::GetAvailableModes::Request>,
75+
const std::string &,
7876
std::shared_ptr<system_modes::srv::GetAvailableModes::Response>);
7977

8078
virtual bool change_state(
81-
const std::string & node,
79+
const std::string &,
8280
unsigned int,
8381
bool transitive = true);
84-
virtual bool change_mode(const std::string & node, const std::string & mode);
82+
virtual bool change_mode(
83+
const std::string &,
84+
const std::string &);
8585

86-
virtual void change_part_state(const std::string & node, unsigned int);
87-
virtual void change_part_mode(const std::string & node, const std::string & mode);
86+
virtual void change_part_state(
87+
const std::string &,
88+
unsigned int);
89+
virtual void change_part_mode(
90+
const std::string &,
91+
const std::string &);
8892

8993
private:
9094
std::shared_ptr<ModeInference> mode_inference_;

system_modes/include/system_modes/mode_monitor.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ namespace system_modes
3737
class ModeMonitor : public rclcpp::Node
3838
{
3939
public:
40-
ModeMonitor(const std::string & model_path, unsigned int rate, bool verbose, bool clear);
40+
ModeMonitor();
4141
ModeMonitor(const ModeMonitor &) = delete;
4242

4343
std::shared_ptr<ModeInference> inference();

system_modes/launch/mode_manager.launch.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,12 @@
2121

2222

2323
def generate_launch_description():
24-
launch.actions.DeclareLaunchArgument('modelfile', description='Path to modelfile')
25-
26-
node = launch_ros.actions.Node(
27-
package='system_modes',
28-
node_executable='mode_manager',
29-
parameters=[{'modelfile': launch.substitutions.LaunchConfiguration('modelfile')}],
30-
output='screen')
31-
32-
description = launch.LaunchDescription()
33-
description.add_action(node)
34-
35-
return description
24+
return launch.LaunchDescription([
25+
launch.actions.DeclareLaunchArgument(
26+
'modelfile',
27+
description='Path to modelfile'),
28+
launch_ros.actions.Node(
29+
package='system_modes',
30+
executable='mode_manager',
31+
parameters=[{'modelfile': launch.substitutions.LaunchConfiguration('modelfile')}],
32+
output='screen')])

system_modes/launch/mode_monitor.launch.py

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,34 @@
1515

1616
import launch
1717
import launch.actions
18-
import launch.substitutions
1918

2019
import launch_ros.actions
2120

2221

2322
def generate_launch_description():
24-
launch.actions.DeclareLaunchArgument('modelfile', description='Path to modelfile')
25-
26-
node = launch_ros.actions.Node(
27-
package='system_modes',
28-
node_executable='mode_monitor',
29-
parameters=[{'modelfile': launch.substitutions.LaunchConfiguration('modelfile')}],
30-
output='screen')
31-
32-
description = launch.LaunchDescription()
33-
description.add_action(node)
34-
35-
return description
23+
return launch.LaunchDescription([
24+
launch.actions.DeclareLaunchArgument(
25+
'modelfile',
26+
description='Path to modelfile'),
27+
launch.actions.DeclareLaunchArgument(
28+
'debug',
29+
default_value='false',
30+
description='Debug'),
31+
launch.actions.DeclareLaunchArgument(
32+
'verbose',
33+
default_value='false',
34+
description='Print mode parametrization'),
35+
launch.actions.DeclareLaunchArgument(
36+
'rate',
37+
default_value='1000',
38+
description='Monitor refresh rate in ms'),
39+
launch_ros.actions.Node(
40+
package='system_modes',
41+
executable='mode_monitor',
42+
parameters=[{
43+
'modelfile': launch.substitutions.LaunchConfiguration('modelfile'),
44+
'debug': launch.substitutions.LaunchConfiguration('debug'),
45+
'verbose': launch.substitutions.LaunchConfiguration('verbose'),
46+
'rate': launch.substitutions.LaunchConfiguration('rate')
47+
}],
48+
output='screen')])

system_modes/package.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
33
<package format="3">
44
<name>system_modes</name>
5-
<version>0.2.3</version>
5+
<version>0.3.0</version>
66
<description>Model-based distributed configuration handling.</description>
77
<maintainer email="arne.nordmann@bosch.com">Arne Nordmann</maintainer>
88
<license>Apache License 2.0</license>
@@ -14,7 +14,6 @@
1414
<depend>std_msgs</depend>
1515
<depend>builtin_interfaces</depend>
1616
<depend>rosidl_default_generators</depend>
17-
<depend>libboost-program-options-dev</depend>
1817

1918
<test_depend>ament_cmake_gtest</test_depend>
2019
<test_depend>ament_cmake_gmock</test_depend>

system_modes/src/mode_manager_node.cpp

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
#include <lifecycle_msgs/msg/state.hpp>
1919
#include <lifecycle_msgs/msg/transition_event.hpp>
2020

21-
#include <boost/program_options.hpp>
22-
2321
#include <chrono>
2422
#include <memory>
2523
#include <string>
@@ -46,47 +44,12 @@ using system_modes::msg::ModeEvent;
4644
using lifecycle_msgs::msg::State;
4745
using lifecycle_msgs::msg::TransitionEvent;
4846

49-
using boost::program_options::value;
50-
using boost::program_options::variables_map;
51-
using boost::program_options::command_line_parser;
52-
using boost::program_options::options_description;
53-
using boost::program_options::positional_options_description;
54-
5547
using rcl_interfaces::msg::ParameterType;
5648
using rcl_interfaces::msg::ParameterEvent;
5749

5850
string modelfile, loglevel;
59-
options_description options("Allowed options");
60-
6151
shared_ptr<ModeManager> manager;
6252

63-
bool parseOptions(int argc, char * argv[])
64-
{
65-
options.add_options()("help", "Help message and options")(
66-
"modelfile", value<string>(&modelfile),
67-
"Path to yaml model file")(
68-
"__log_level", value<string>(&loglevel),
69-
"ROS2 log level")(
70-
"ros-args", value<vector<string>>()->multitoken(), "ROS args")(
71-
"params-file", value<vector<string>>()->multitoken(), "ROS params file");
72-
73-
positional_options_description positional_options;
74-
positional_options.add("modelfile", 1);
75-
76-
variables_map map;
77-
store(
78-
command_line_parser(argc, argv)
79-
.options(options)
80-
.positional(positional_options)
81-
.run(), map);
82-
notify(map);
83-
84-
if (map.count("help")) {
85-
return true;
86-
}
87-
return false;
88-
}
89-
9053
void transition_callback(
9154
const TransitionEvent::SharedPtr msg,
9255
const string & node_name)
@@ -147,26 +110,10 @@ int main(int argc, char * argv[])
147110
{
148111
using namespace std::placeholders;
149112

150-
// Handle commandline arguments.
151-
try {
152-
if (parseOptions(argc, argv)) {
153-
cout << "Usage: mode_manager MODELFILE" << std::endl;
154-
cout << options;
155-
cout << "Or specify the MODELFILE by ROS parameter 'modelfile'." << std::endl << std::endl;
156-
return EXIT_SUCCESS;
157-
}
158-
} catch (const std::exception & e) {
159-
cerr << "Error parsing command line: " << e.what() << std::endl;
160-
cout << "Usage: mode_manager [MODELFILE]" << std::endl;
161-
cout << options;
162-
cout << "Or specify the MODELFILE by ROS parameter 'modelfile'." << std::endl << std::endl;
163-
return EXIT_FAILURE;
164-
}
165-
166113
setvbuf(stdout, NULL, _IONBF, BUFSIZ);
167114
rclcpp::init(argc, argv);
168115

169-
manager = std::make_shared<ModeManager>(modelfile);
116+
manager = std::make_shared<ModeManager>();
170117

171118
vector<shared_ptr<rclcpp::Subscription<TransitionEvent>>>
172119
state_sub_;

0 commit comments

Comments
 (0)