Skip to content

Commit

Permalink
Merge pull request #1725 from saka1-s/feat/report-safe-fault
Browse files Browse the repository at this point in the history
feat: customize hazard status converter
  • Loading branch information
saka1-s authored and kotaro-hihara committed Jan 29, 2025
1 parent 28225d7 commit cfec479
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
7 changes: 6 additions & 1 deletion launch/tier4_system_launch/launch/system.launch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
<arg name="launch_rqt_robot_monitor" default="false"/>
<arg name="launch_rqt_runtime_monitor_err" default="false"/>

<!-- Hazard Status Converter -->
<arg name="report_only_diag" default="false"/>

<group>
<push-ros-namespace namespace="/system"/>

Expand Down Expand Up @@ -121,7 +124,9 @@

<!-- Hazard Status Converter -->
<group unless="$(var use_emergency_handler)">
<include file="$(find-pkg-share hazard_status_converter)/launch/hazard_status_converter.launch.xml"/>
<include file="$(find-pkg-share hazard_status_converter)/launch/hazard_status_converter.launch.xml">
<arg name="report_only_diag" value="$(var report_only_diag)"/>
</include>
</group>

<!-- MRM Handler -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<launch>
<arg name="report_only_diag" default="false"/>
<node pkg="hazard_status_converter" exec="converter" name="hazard_status_converter">
<remap from="~/diagnostics_graph" to="/diagnostics_graph"/>
<remap from="~/hazard_status" to="/system/emergency/hazard_status"/>
<param name="report_only_diag" value="$(var report_only_diag)"/>
</node>
</launch>
5 changes: 4 additions & 1 deletion system/hazard_status_converter/src/converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ Converter::Converter(const rclcpp::NodeOptions & options) : Node("converter", op
sub_graph_.register_create_callback(std::bind(&Converter::on_create, this, _1));
sub_graph_.register_update_callback(std::bind(&Converter::on_update, this, _1));
sub_graph_.subscribe(*this, 1);

report_only_diag_ = declare_parameter<bool>("report_only_diag", false);
}

void Converter::on_create(DiagGraph::ConstSharedPtr graph)
Expand Down Expand Up @@ -93,7 +95,7 @@ void Converter::on_update(DiagGraph::ConstSharedPtr graph)
const auto get_hazards_vector = [](HazardStatus & status, HazardLevel level) {
if (level == HazardStatus::SINGLE_POINT_FAULT) return &status.diag_single_point_fault;
if (level == HazardStatus::LATENT_FAULT) return &status.diag_latent_fault;
if (level == HazardStatus::SAFE_FAULT) return &status.diag_safe_fault;
if (level == HazardStatus::SAFE_FAULT) return &status.diag_latent_fault;
if (level == HazardStatus::NO_FAULT) return &status.diag_no_fault;
return static_cast<std::vector<DiagnosticStatus> *>(nullptr);
};
Expand All @@ -107,6 +109,7 @@ void Converter::on_update(DiagGraph::ConstSharedPtr graph)
HazardStatusStamped hazard;
for (const auto & unit : graph->units()) {
if (unit->path().empty()) continue;
if (report_only_diag_ && unit->type() != "diag") continue;
const bool is_auto_tree = auto_mode_tree_.count(unit);
const auto root_level = is_auto_tree ? auto_mode_root_->level() : DiagnosticStatus::OK;
const auto unit_level = unit->level();
Expand Down
1 change: 1 addition & 0 deletions system/hazard_status_converter/src/converter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class Converter : public rclcpp::Node

DiagUnit * auto_mode_root_;
std::unordered_set<DiagUnit *> auto_mode_tree_;
bool report_only_diag_;
};

} // namespace hazard_status_converter
Expand Down

0 comments on commit cfec479

Please sign in to comment.