Skip to content

Commit bf575b6

Browse files
authored
feat(default_ad_api): use diagnostic graph (#7043)
Signed-off-by: Takagi, Isamu <isamu.takagi@tier4.jp>
1 parent d5e691e commit bf575b6

File tree

4 files changed

+53
-71
lines changed

4 files changed

+53
-71
lines changed

launch/tier4_system_launch/launch/system.launch.xml

+38-36
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@
2525
<arg name="run_mode" default="online" description="options: online, logging_simulation, planning_simulation"/>
2626
<arg name="sensor_model" description="sensor model name"/>
2727

28-
<arg name="use_diagnostic_graph" default="false" description="use diagnostic graph packages"/>
29-
<arg name="mrm_handler_param_path" if="$(var use_diagnostic_graph)"/>
30-
<arg name="diagnostic_graph_aggregator_param_path" if="$(var use_diagnostic_graph)"/>
31-
<arg name="diagnostic_graph_aggregator_graph_path" if="$(var use_diagnostic_graph)"/>
32-
<arg name="diagnostic_graph_aggregator_planning_simulator_graph_path" if="$(var use_diagnostic_graph)"/>
28+
<!-- Emergency handler will be replaced by MRM handler. -->
29+
<arg name="use_emergency_handler" default="true" description="use emergency handler packages"/>
30+
<arg name="mrm_handler_param_path"/>
31+
<arg name="diagnostic_graph_aggregator_param_path"/>
32+
<arg name="diagnostic_graph_aggregator_graph_path_main"/>
33+
<arg name="diagnostic_graph_aggregator_graph_path_psim"/>
3334

3435
<let name="sensor_launch_pkg" value="$(find-pkg-share $(var sensor_model)_launch)"/>
3536

@@ -57,6 +58,13 @@
5758
</include>
5859
</group>
5960

61+
<!-- Duplicated Node Checker -->
62+
<group>
63+
<include file="$(find-pkg-share duplicated_node_checker)/launch/duplicated_node_checker.launch.xml">
64+
<arg name="config_file" value="$(var duplicated_node_checker_param_path)"/>
65+
</include>
66+
</group>
67+
6068
<!-- Service Log Checker -->
6169
<group>
6270
<include file="$(find-pkg-share component_interface_tools)/launch/service_log_checker.launch.xml"/>
@@ -70,8 +78,20 @@
7078
</include>
7179
</group>
7280

81+
<!-- MRM Operator -->
82+
<group>
83+
<include file="$(find-pkg-share mrm_comfortable_stop_operator)/launch/mrm_comfortable_stop_operator.launch.py">
84+
<arg name="config_file" value="$(var mrm_comfortable_stop_operator_param_path)"/>
85+
</include>
86+
</group>
87+
<group>
88+
<include file="$(find-pkg-share mrm_emergency_stop_operator)/launch/mrm_emergency_stop_operator.launch.py">
89+
<arg name="config_file" value="$(var mrm_emergency_stop_operator_param_path)"/>
90+
</include>
91+
</group>
92+
7393
<!-- Error Monitor -->
74-
<group unless="$(var use_diagnostic_graph)">
94+
<group if="$(var use_emergency_handler)">
7595
<let name="config_file" value="$(var system_error_monitor_param_path)" if="$(eval &quot;'$(var run_mode)'=='online'&quot;)"/>
7696
<let name="config_file" value="$(var system_error_monitor_param_path)" if="$(eval &quot;'$(var run_mode)'=='logging_simulation'&quot;)"/>
7797
<let name="config_file" value="$(var system_error_monitor_planning_simulator_param_path)" if="$(eval &quot;'$(var run_mode)'=='planning_simulation'&quot;)"/>
@@ -85,52 +105,34 @@
85105
</group>
86106

87107
<!-- Emergency Handler -->
88-
<group unless="$(var use_diagnostic_graph)">
108+
<group if="$(var use_emergency_handler)">
89109
<include file="$(find-pkg-share emergency_handler)/launch/emergency_handler.launch.xml">
90110
<arg name="config_file" value="$(var emergency_handler_param_path)"/>
91111
</include>
92112
</group>
93113

114+
<!-- Diagnostic Graph Aggregator -->
94115
<group>
95-
<include file="$(find-pkg-share duplicated_node_checker)/launch/duplicated_node_checker.launch.xml">
96-
<arg name="config_file" value="$(var duplicated_node_checker_param_path)"/>
116+
<let name="diagnostic_graph_aggregator_graph_path" value="$(var diagnostic_graph_aggregator_graph_path_main)" if="$(eval &quot;'$(var run_mode)'=='online'&quot;)"/>
117+
<let name="diagnostic_graph_aggregator_graph_path" value="$(var diagnostic_graph_aggregator_graph_path_main)" if="$(eval &quot;'$(var run_mode)'=='logging_simulation'&quot;)"/>
118+
<let name="diagnostic_graph_aggregator_graph_path" value="$(var diagnostic_graph_aggregator_graph_path_psim)" if="$(eval &quot;'$(var run_mode)'=='planning_simulation'&quot;)"/>
119+
<include file="$(find-pkg-share system_diagnostic_monitor)/launch/system_diagnostic_monitor.launch.xml">
120+
<arg name="param_file" value="$(var diagnostic_graph_aggregator_param_path)"/>
121+
<arg name="graph_file" value="$(var diagnostic_graph_aggregator_graph_path)"/>
97122
</include>
98123
</group>
99124

100-
<!-- MRM Operator -->
101-
<group>
102-
<include file="$(find-pkg-share mrm_comfortable_stop_operator)/launch/mrm_comfortable_stop_operator.launch.py">
103-
<arg name="config_file" value="$(var mrm_comfortable_stop_operator_param_path)"/>
104-
</include>
105-
</group>
106-
<group>
107-
<include file="$(find-pkg-share mrm_emergency_stop_operator)/launch/mrm_emergency_stop_operator.launch.py">
108-
<arg name="config_file" value="$(var mrm_emergency_stop_operator_param_path)"/>
109-
</include>
125+
<!-- Hazard Status Converter -->
126+
<group unless="$(var use_emergency_handler)">
127+
<include file="$(find-pkg-share hazard_status_converter)/launch/hazard_status_converter.launch.xml"/>
110128
</group>
111129

112130
<!-- MRM Handler -->
113-
<group if="$(var use_diagnostic_graph)">
131+
<group unless="$(var use_emergency_handler)">
114132
<include file="$(find-pkg-share mrm_handler)/launch/mrm_handler.launch.xml">
115133
<arg name="config_file" value="$(var mrm_handler_param_path)"/>
116134
</include>
117135
</group>
118-
119-
<!-- Diagnostic Graph Aggregator -->
120-
<group if="$(var use_diagnostic_graph)">
121-
<let name="graph_file" value="$(var diagnostic_graph_aggregator_graph_path)" if="$(eval &quot;'$(var run_mode)'=='online'&quot;)"/>
122-
<let name="graph_file" value="$(var diagnostic_graph_aggregator_graph_path)" if="$(eval &quot;'$(var run_mode)'=='logging_simulation'&quot;)"/>
123-
<let name="graph_file" value="$(var diagnostic_graph_aggregator_planning_simulator_graph_path)" if="$(eval &quot;'$(var run_mode)'=='planning_simulation'&quot;)"/>
124-
<include file="$(find-pkg-share diagnostic_graph_aggregator)/launch/aggregator.launch.xml">
125-
<arg name="param_file" value="$(var diagnostic_graph_aggregator_param_path)"/>
126-
<arg name="graph_file" value="$(var graph_file)"/>
127-
</include>
128-
</group>
129-
130-
<!-- Hazard Status Converter -->
131-
<group if="$(var use_diagnostic_graph)">
132-
<include file="$(find-pkg-share hazard_status_converter)/launch/hazard_status_converter.launch.xml"/>
133-
</group>
134136
</group>
135137

136138
<!-- Dummy Diag Publisher -->

system/default_ad_api/src/operation_mode.cpp

+10-30
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,15 @@ OperationModeNode::OperationModeNode(const rclcpp::NodeOptions & options)
3939
adaptor.init_cli(cli_mode_, group_cli_);
4040
adaptor.init_cli(cli_control_, group_cli_);
4141

42-
const std::vector<std::string> module_names = {
43-
"sensing", "perception", "map", "localization", "planning", "control", "vehicle", "system",
42+
const auto name = "/system/operation_mode/availability";
43+
const auto qos = rclcpp::QoS(1);
44+
const auto callback = [this](const OperationModeAvailability::ConstSharedPtr msg) {
45+
mode_available_[OperationModeState::Message::STOP] = msg->stop;
46+
mode_available_[OperationModeState::Message::AUTONOMOUS] = msg->autonomous;
47+
mode_available_[OperationModeState::Message::LOCAL] = msg->local;
48+
mode_available_[OperationModeState::Message::REMOTE] = msg->remote;
4449
};
45-
46-
for (size_t i = 0; i < module_names.size(); ++i) {
47-
const auto name = "/system/component_state_monitor/component/autonomous/" + module_names[i];
48-
const auto qos = rclcpp::QoS(1).transient_local();
49-
const auto callback = [this, i, module_names](const ModeChangeAvailable::ConstSharedPtr msg) {
50-
module_states_[module_names[i]] = msg->available;
51-
};
52-
sub_module_states_.push_back(create_subscription<ModeChangeAvailable>(name, qos, callback));
53-
}
50+
sub_availability_ = create_subscription<OperationModeAvailability>(name, qos, callback);
5451

5552
timer_ = rclcpp::create_timer(
5653
this, get_clock(), rclcpp::Rate(5.0).period(), std::bind(&OperationModeNode::on_timer, this));
@@ -60,8 +57,8 @@ OperationModeNode::OperationModeNode(const rclcpp::NodeOptions & options)
6057
mode_available_[OperationModeState::Message::UNKNOWN] = false;
6158
mode_available_[OperationModeState::Message::STOP] = true;
6259
mode_available_[OperationModeState::Message::AUTONOMOUS] = false;
63-
mode_available_[OperationModeState::Message::LOCAL] = true;
64-
mode_available_[OperationModeState::Message::REMOTE] = true;
60+
mode_available_[OperationModeState::Message::LOCAL] = false;
61+
mode_available_[OperationModeState::Message::REMOTE] = false;
6562
}
6663

6764
template <class ResponseT>
@@ -135,23 +132,6 @@ void OperationModeNode::on_state(const OperationModeState::Message::ConstSharedP
135132

136133
void OperationModeNode::on_timer()
137134
{
138-
bool autonomous_available = true;
139-
std::string unhealthy_components = "";
140-
for (const auto & state : module_states_) {
141-
if (!state.second) {
142-
unhealthy_components += unhealthy_components.empty() ? state.first : ", " + state.first;
143-
}
144-
autonomous_available &= state.second;
145-
}
146-
mode_available_[OperationModeState::Message::AUTONOMOUS] = autonomous_available;
147-
148-
if (!unhealthy_components.empty()) {
149-
RCLCPP_INFO_THROTTLE(
150-
get_logger(), *get_clock(), 3000,
151-
"%s component state is unhealthy. Autonomous is not available.",
152-
unhealthy_components.c_str());
153-
}
154-
155135
update_state();
156136
}
157137

system/default_ad_api/src/operation_mode.hpp

+3-5
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include <vector>
2626

2727
// TODO(Takagi, Isamu): define interface
28-
#include <tier4_system_msgs/msg/mode_change_available.hpp>
28+
#include <tier4_system_msgs/msg/operation_mode_availability.hpp>
2929

3030
// This file should be included after messages.
3131
#include "utils/types.hpp"
@@ -47,7 +47,7 @@ class OperationModeNode : public rclcpp::Node
4747
using ChangeToRemote = autoware_ad_api::operation_mode::ChangeToRemote;
4848
using OperationModeRequest = system_interface::ChangeOperationMode::Service::Request;
4949
using AutowareControlRequest = system_interface::ChangeAutowareControl::Service::Request;
50-
using ModeChangeAvailable = tier4_system_msgs::msg::ModeChangeAvailable;
50+
using OperationModeAvailability = tier4_system_msgs::msg::OperationModeAvailability;
5151

5252
OperationModeState::Message curr_state_;
5353
OperationModeState::Message prev_state_;
@@ -65,9 +65,7 @@ class OperationModeNode : public rclcpp::Node
6565
Sub<system_interface::OperationModeState> sub_state_;
6666
Cli<system_interface::ChangeOperationMode> cli_mode_;
6767
Cli<system_interface::ChangeAutowareControl> cli_control_;
68-
69-
std::unordered_map<std::string, bool> module_states_;
70-
std::vector<rclcpp::Subscription<ModeChangeAvailable>::SharedPtr> sub_module_states_;
68+
rclcpp::Subscription<OperationModeAvailability>::SharedPtr sub_availability_;
7169

7270
void on_change_to_stop(
7371
const ChangeToStop::Service::Request::SharedPtr req,

system/system_diagnostic_monitor/launch/system_diagnostic_monitor.launch.xml

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<launch>
2+
<arg name="param_file" default="$(find-pkg-share diagnostic_graph_aggregator)/config/default.param.yaml"/>
23
<arg name="graph_file" default="$(find-pkg-share system_diagnostic_monitor)/config/autoware-main.yaml"/>
34
<include file="$(find-pkg-share diagnostic_graph_aggregator)/launch/aggregator.launch.xml">
5+
<arg name="param_file" value="$(var param_file)"/>
46
<arg name="graph_file" value="$(var graph_file)"/>
57
</include>
68
<node pkg="system_diagnostic_monitor" exec="component_state_diagnostics" name="component_state_diagnostics"/>

0 commit comments

Comments
 (0)