Skip to content

Commit 6f1fd66

Browse files
committed
wip: update: create MRM operator libraries
Signed-off-by: veqcc <ryuta.kambe@tier4.jp>
1 parent 97d6042 commit 6f1fd66

29 files changed

+147
-829
lines changed

launch/tier4_system_launch/launch/system.launch.xml

+6
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@
8383
<include file="$(find-pkg-share emergency_handler)/launch/emergency_handler.launch.xml">
8484
<arg name="config_file" value="$(var emergency_handler_param_path)"/>
8585
</include>
86+
<include file="$(find-pkg-share mrm_comfortable_stop_operator)/launch/mrm_comfortable_stop_operator.launch.xml">
87+
<arg name="config_file" value="$(var mrm_comfortable_stop_operator_param_path)"/>
88+
</include>
89+
<include file="$(find-pkg-share mrm_emergency_stop_operator)/launch/mrm_emergency_stop_operator.launch.xml">
90+
<arg name="config_file" value="$(var mrm_emergency_stop_operator_param_path)"/>
91+
</include>
8692
</group>
8793

8894
<group>

system/emergency_handler/CMakeLists.txt

-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ autoware_package()
77
ament_auto_add_executable(emergency_handler
88
src/emergency_handler_node.cpp
99
src/emergency_handler_core.cpp
10-
src/emergency_stop_operator.cpp
11-
src/comfortable_stop_operator.cpp
1210
)
1311

1412
ament_auto_package(INSTALL_TO_SHARE

system/emergency_handler/config/emergency_handler.param.yaml

-14
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,3 @@
55
update_rate: 10
66
timeout_hazard_status: 0.5
77
use_comfortable_stop: false
8-
9-
# emergency stop operator class
10-
emergency_stop_operator:
11-
update_rate: 30
12-
target_acceleration: -2.5
13-
target_jerk: -1.5
14-
turning_hazard_on: true
15-
use_parking_after_stopped: false
16-
17-
# comfortable stop operator class
18-
comfortable_stop_operator:
19-
min_acceleration: -1.0
20-
max_jerk: 0.3
21-
min_jerk: -0.3
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,15 @@
11
<launch>
2-
<!-- emergency_handler -->
32
<arg name="input_hazard_status" default="/system/emergency/hazard_status"/>
43
<arg name="input_odometry" default="/localization/kinematic_state"/>
54
<arg name="input_control_mode" default="/vehicle/status/control_mode"/>
65
<arg name="output_mrm_state" default="/system/fail_safe/mrm_state"/>
7-
86
<arg name="config_file" default="$(find-pkg-share emergency_handler)/config/emergency_handler.param.yaml"/>
97

10-
<!-- emergency stop operator class-->
11-
<arg name="input_control_command" default="/control/command/control_cmd"/>
12-
<arg name="output_emergency_command" default="/system/emergency/control_cmd"/>
13-
<arg name="output_hazard" default="/system/emergency/hazard_lights_cmd"/>
14-
<arg name="output_gear" default="/system/emergency/gear_cmd"/>
15-
16-
<!-- comfortable stop operator class -->
17-
<arg name="output_velocity_limit" default="/planning/scenario_planning/max_velocity_candidates"/>
18-
<arg name="output_velocity_limit_clear" default="/planning/scenario_planning/clear_velocity_limit"/>
19-
20-
<!-- emergency_handler -->
218
<node pkg="emergency_handler" exec="emergency_handler" name="emergency_handler" output="screen">
229
<remap from="~/input/hazard_status" to="$(var input_hazard_status)"/>
2310
<remap from="~/input/odometry" to="$(var input_odometry)"/>
2411
<remap from="~/input/control_mode" to="$(var input_control_mode)"/>
2512
<remap from="~/output/mrm/state" to="$(var output_mrm_state)"/>
26-
2713
<param from="$(var config_file)"/>
28-
29-
<!-- emergency stop operator class -->
30-
<remap from="~/input/control/control_cmd" to="$(var input_control_command)"/>
31-
<remap from="~/output/mrm/emergency_stop/control_cmd" to="$(var output_emergency_command)"/>
32-
<remap from="~/output/gear" to="$(var output_gear)"/>
33-
<remap from="~/output/hazard" to="$(var output_hazard)"/>
34-
35-
<!-- comfortable stop operator class -->
36-
<remap from="~/output/velocity_limit" to="$(var output_velocity_limit)"/>
37-
<remap from="~/output/velocity_limit/clear" to="$(var output_velocity_limit_clear)"/>
3814
</node>
3915
</launch>

system/emergency_handler/package.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
<depend>nav_msgs</depend>
2020
<depend>rclcpp</depend>
2121
<depend>std_msgs</depend>
22-
<depend>tier4_planning_msgs</depend>
22+
<depend>mrm_comfortable_stop_operator</depend>
23+
<depend>mrm_emergency_stop_operator</depend>
2324

2425
<test_depend>ament_lint_auto</test_depend>
2526
<test_depend>autoware_lint_common</test_depend>

system/emergency_handler/schema/emergency_handler.schema.json

+1-61
Original file line numberDiff line numberDiff line change
@@ -20,72 +20,12 @@
2020
"type": "boolean",
2121
"description": "If this parameter is true, operate comfortable stop when latent faults occur.",
2222
"default": "false"
23-
},
24-
"emergency_stop_operator": {
25-
"type": "object",
26-
"update_rate": {
27-
"type": "integer",
28-
"description": "Timer callback period.",
29-
"default": 30
30-
},
31-
"properties": {
32-
"target_acceleration": {
33-
"type": "number",
34-
"description": "Target acceleration for emergency stop [m/s^2]",
35-
"default": -2.5
36-
},
37-
"target_jerk": {
38-
"type": "number",
39-
"description": "Target jerk for emergency stop [m/s^3]",
40-
"default": -1.5
41-
},
42-
"turning_hazard_on": {
43-
"type": "boolean",
44-
"description": "Whether to turn on hazard lamps when emergency_stop is being operated",
45-
"default": "true"
46-
},
47-
"use_parking_after_stopped": {
48-
"type": "boolean",
49-
"description": "Whether to enable GearCommand::PARK after emergency_stop succeeded",
50-
"default": "false"
51-
}
52-
},
53-
"required": [
54-
"update_rate",
55-
"target_acceleration",
56-
"target_jerk",
57-
"turning_hazard_on",
58-
"use_parking_after_stopped"
59-
]
60-
},
61-
"comfortable_stop_operator": {
62-
"type": "object",
63-
"properties": {
64-
"min_acceleration": {
65-
"type": "number",
66-
"description": "Minimum acceleration for comfortable stop [m/s^2]",
67-
"default": -1.0
68-
},
69-
"max_jerk": {
70-
"type": "number",
71-
"description": "Maximum jerk for comfortable stop [m/s^3]",
72-
"default": 0.3
73-
},
74-
"min_jerk": {
75-
"type": "number",
76-
"description": "Minimum jerk for comfortable stop [m/s^3]",
77-
"default": -0.3
78-
}
79-
},
80-
"required": ["min_acceleration", "max_jerk", "min_jerk"]
8123
}
8224
},
8325
"required": [
8426
"update_rate",
8527
"timeout_hazard_status",
86-
"use_comfortable_stop",
87-
"emergency_stop",
88-
"comfortable_stop"
28+
"use_comfortable_stop"
8929
],
9030
"additionalProperties": false
9131
}

system/emergency_handler/src/emergency_handler_core.cpp

+9-8
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,11 @@ EmergencyHandler::EmergencyHandler() : Node("emergency_handler")
5252
mrm_state_.behavior = autoware_adapi_v1_msgs::msg::MrmState::NONE;
5353
is_hazard_status_timeout_ = false;
5454

55-
// Opertors
56-
emergency_stop_operator_ = std::make_unique<emergency_stop_operator::EmergencyStopOperator>(this);
57-
comfortable_stop_operator_ =
58-
std::make_unique<comfortable_stop_operator::ComfortableStopOperator>(this);
55+
// MRM opertors
56+
mrm_emergency_stop_operator_ =
57+
std::make_unique<mrm_emergency_stop_operator::MrmEmergencyStopOperator>();
58+
mrm_comfortable_stop_operator_ =
59+
std::make_unique<mrm_comfortable_stop_operator::MrmComfortableStopOperator>();
5960

6061
// Timer
6162
const auto update_period_ns = rclcpp::Rate(param_.update_rate).period();
@@ -131,15 +132,15 @@ void EmergencyHandler::callMrmBehavior(
131132
return;
132133
}
133134
if (mrm_behavior == MrmState::COMFORTABLE_STOP) {
134-
if (comfortable_stop_operator_->operate()) {
135+
if (mrm_comfortable_stop_operator_->operate()) {
135136
RCLCPP_WARN(this->get_logger(), "Comfortable stop is operated");
136137
} else {
137138
RCLCPP_ERROR(this->get_logger(), "Comfortable stop is failed to operate");
138139
}
139140
return;
140141
}
141142
if (mrm_behavior == MrmState::EMERGENCY_STOP) {
142-
if (emergency_stop_operator_->operate()) {
143+
if (mrm_emergency_stop_operator_->operate()) {
143144
RCLCPP_WARN(this->get_logger(), "Emergency stop is operated");
144145
} else {
145146
RCLCPP_ERROR(this->get_logger(), "Emergency stop is failed to operate");
@@ -159,15 +160,15 @@ void EmergencyHandler::cancelMrmBehavior(
159160
return;
160161
}
161162
if (mrm_behavior == MrmState::COMFORTABLE_STOP) {
162-
if (comfortable_stop_operator_->cancel()) {
163+
if (mrm_comfortable_stop_operator_->cancel()) {
163164
RCLCPP_WARN(this->get_logger(), "Comfortable stop is canceled");
164165
} else {
165166
RCLCPP_ERROR(this->get_logger(), "Comfortable stop is failed to cancel");
166167
}
167168
return;
168169
}
169170
if (mrm_behavior == MrmState::EMERGENCY_STOP) {
170-
if (emergency_stop_operator_->cancel()) {
171+
if (mrm_emergency_stop_operator_->cancel()) {
171172
RCLCPP_WARN(this->get_logger(), "Emergency stop is canceled");
172173
} else {
173174
RCLCPP_ERROR(this->get_logger(), "Emergency stop is failed to cancel");

system/emergency_handler/src/emergency_handler_core.hpp

+6-10
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,13 @@
2323
#include <autoware_adapi_v1_msgs/msg/mrm_state.hpp>
2424
#include <autoware_auto_system_msgs/msg/hazard_status_stamped.hpp>
2525
#include <autoware_auto_vehicle_msgs/msg/control_mode_report.hpp>
26-
27-
// ROS 2 core
28-
#include <rclcpp/rclcpp.hpp>
29-
3026
#include <diagnostic_msgs/msg/diagnostic_array.hpp>
3127
#include <nav_msgs/msg/odometry.hpp>
28+
#include <mrm_emergency_stop_operator/mrm_emergency_stop_operator.hpp>
29+
#include <mrm_comfortable_stop_operator/mrm_comfortable_stop_operator.hpp>
3230

33-
// Operators
34-
#include "comfortable_stop_operator.hpp"
35-
#include "emergency_stop_operator.hpp"
31+
// ROS 2 core
32+
#include <rclcpp/rclcpp.hpp>
3633

3734
namespace emergency_handler
3835
{
@@ -41,7 +38,6 @@ struct Param
4138
{
4239
int update_rate;
4340
double timeout_hazard_status;
44-
bool use_parking_after_stopped;
4541
bool use_comfortable_stop;
4642
};
4743

@@ -92,8 +88,8 @@ class EmergencyHandler : public rclcpp::Node
9288
void checkHazardStatusTimeout();
9389

9490
// Operators
95-
std::unique_ptr<emergency_stop_operator::EmergencyStopOperator> emergency_stop_operator_;
96-
std::unique_ptr<comfortable_stop_operator::ComfortableStopOperator> comfortable_stop_operator_;
91+
std::unique_ptr<mrm_emergency_stop_operator::MrmEmergencyStopOperator> mrm_emergency_stop_operator_;
92+
std::unique_ptr<mrm_comfortable_stop_operator::MrmComfortableStopOperator> mrm_comfortable_stop_operator_;
9793

9894
// Algorithm
9995
void transitionTo(const int new_state);

system/mrm_comfortable_stop_operator/CMakeLists.txt

+2-6
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,10 @@ project(mrm_comfortable_stop_operator)
44
find_package(autoware_cmake REQUIRED)
55
autoware_package()
66

7-
ament_auto_add_library(mrm_comfortable_stop_operator_component SHARED
8-
src/mrm_comfortable_stop_operator/mrm_comfortable_stop_operator_core.cpp
7+
ament_auto_add_library(mrm_comfortable_stop_operator SHARED
8+
src/mrm_comfortable_stop_operator.cpp
99
)
1010

11-
rclcpp_components_register_node(mrm_comfortable_stop_operator_component
12-
PLUGIN "mrm_comfortable_stop_operator::MrmComfortableStopOperator"
13-
EXECUTABLE mrm_comfortable_stop_operator)
14-
1511
ament_auto_package(INSTALL_TO_SHARE
1612
launch
1713
config

system/mrm_comfortable_stop_operator/README.md

-11
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,15 @@ MRM comfortable stop operator is a node that generates comfortable stop commands
1010

1111
### Input
1212

13-
| Name | Type | Description |
14-
| -------------------------------------- | ------------------------------------ | ------------------- |
15-
| `~/input/mrm/comfortable_stop/operate` | `tier4_system_msgs::srv::OperateMrm` | MRM execution order |
16-
1713
### Output
1814

1915
| Name | Type | Description |
2016
| -------------------------------------- | ----------------------------------------------------- | ---------------------------- |
21-
| `~/output/mrm/comfortable_stop/status` | `tier4_system_msgs::msg::MrmBehaviorStatus` | MRM execution status |
2217
| `~/output/velocity_limit` | `tier4_planning_msgs::msg::VelocityLimit` | Velocity limit command |
2318
| `~/output/velocity_limit/clear` | `tier4_planning_msgs::msg::VelocityLimitClearCommand` | Velocity limit clear command |
2419

2520
## Parameters
2621

27-
### Node Parameters
28-
29-
| Name | Type | Default value | Explanation |
30-
| ----------- | ---- | ------------- | ----------------------------- |
31-
| update_rate | int | `10` | Timer callback frequency [Hz] |
32-
3322
### Core Parameters
3423

3524
| Name | Type | Default value | Explanation |
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/**:
22
ros__parameters:
3-
update_rate: 10
43
min_acceleration: -1.0
54
max_jerk: 0.3
65
min_jerk: -0.3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2024 TIER IV, Inc.
1+
// Copyright 2022 Tier IV, Inc.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -12,47 +12,49 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#ifndef COMFORTABLE_STOP_OPERATOR_HPP_
16-
#define COMFORTABLE_STOP_OPERATOR_HPP_
15+
#ifndef MRM_COMFORTABLE_STOP_OPERATOR_HPP_
16+
#define MRM_COMFORTABLE_STOP_OPERATOR_HPP_
1717

18-
#include <rclcpp/rclcpp.hpp>
18+
// Core
19+
#include <memory>
1920

21+
// Autoware
2022
#include <tier4_planning_msgs/msg/velocity_limit.hpp>
2123
#include <tier4_planning_msgs/msg/velocity_limit_clear_command.hpp>
2224

23-
namespace emergency_handler::comfortable_stop_operator
25+
// ROS 2 core
26+
#include <rclcpp/rclcpp.hpp>
27+
28+
namespace mrm_comfortable_stop_operator
2429
{
2530

26-
struct Param
31+
struct Parameters
2732
{
28-
double min_acceleration;
29-
double max_jerk;
30-
double min_jerk;
33+
double min_acceleration; // [m/s^2]
34+
double max_jerk; // [m/s^3]
35+
double min_jerk; // [m/s^3]
3136
};
3237

33-
class ComfortableStopOperator
38+
class MrmComfortableStopOperator : public rclcpp::Node
3439
{
3540
public:
36-
explicit ComfortableStopOperator(rclcpp::Node * node);
41+
explicit MrmComfortableStopOperator();
3742
bool operate();
3843
bool cancel();
3944

4045
private:
4146
// Parameters
42-
Param params_;
47+
Parameters params_;
4348

4449
// Publisher
4550
rclcpp::Publisher<tier4_planning_msgs::msg::VelocityLimit>::SharedPtr pub_velocity_limit_;
4651
rclcpp::Publisher<tier4_planning_msgs::msg::VelocityLimitClearCommand>::SharedPtr
4752
pub_velocity_limit_clear_command_;
4853

49-
// Algorithm
50-
void publishVelocityLimit();
51-
void publishVelocityLimitClearCommand();
52-
53-
rclcpp::Node * node_;
54+
void publishVelocityLimit() const;
55+
void publishVelocityLimitClearCommand() const;
5456
};
5557

56-
} // namespace emergency_handler::comfortable_stop_operator
58+
} // namespace mrm_comfortable_stop_operator
5759

58-
#endif // COMFORTABLE_STOP_OPERATOR_HPP_
60+
#endif // MRM_COMFORTABLE_STOP_OPERATOR_HPP_

0 commit comments

Comments
 (0)