Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(mrm_handler): mrm handler publish emergecy holding #9285

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions system/mrm_handler/include/mrm_handler/mrm_handler_core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <autoware_vehicle_msgs/msg/control_mode_report.hpp>
#include <autoware_vehicle_msgs/msg/gear_command.hpp>
#include <autoware_vehicle_msgs/msg/hazard_lights_command.hpp>
#include <tier4_system_msgs/msg/emergency_holding_state.hpp>
#include <tier4_system_msgs/msg/mrm_behavior_status.hpp>
#include <tier4_system_msgs/msg/operation_mode_availability.hpp>
#include <tier4_system_msgs/srv/operate_mrm.hpp>
Expand Down Expand Up @@ -109,6 +110,10 @@ class MrmHandler : public rclcpp::Node
autoware_adapi_v1_msgs::msg::MrmState mrm_state_;
void publishMrmState();

rclcpp::Publisher<tier4_system_msgs::msg::EmergencyHoldingState>::SharedPtr
pub_emergency_holding_;
void publishEmergencyHolding();

// Clients
rclcpp::CallbackGroup::SharedPtr client_mrm_pull_over_group_;
rclcpp::Client<tier4_system_msgs::srv::OperateMrm>::SharedPtr client_mrm_pull_over_;
Expand Down
2 changes: 2 additions & 0 deletions system/mrm_handler/launch/mrm_handler.launch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<arg name="output_gear" default="/system/emergency/gear_cmd"/>
<arg name="output_hazard" default="/system/emergency/hazard_lights_cmd"/>
<arg name="output_mrm_state" default="/system/fail_safe/mrm_state"/>
<arg name="output_emergency_holding" default="/system/emergency_holding"/>
<arg name="output_mrm_pull_over_operate" default="/system/mrm/pull_over_manager/operate"/>
<arg name="output_mrm_comfortable_stop_operate" default="/system/mrm/comfortable_stop/operate"/>
<arg name="output_mrm_emergency_stop_operate" default="/system/mrm/emergency_stop/operate"/>
Expand All @@ -32,6 +33,7 @@
<remap from="~/output/gear" to="$(var output_gear)"/>
<remap from="~/output/hazard" to="$(var output_hazard)"/>
<remap from="~/output/mrm/state" to="$(var output_mrm_state)"/>
<remap from="~/output/emergency_holding" to="$(var output_emergency_holding)"/>
<remap from="~/output/mrm/pull_over/operate" to="$(var output_mrm_pull_over_operate)"/>
<remap from="~/output/mrm/comfortable_stop/operate" to="$(var output_mrm_comfortable_stop_operate)"/>
<remap from="~/output/mrm/emergency_stop/operate" to="$(var output_mrm_emergency_stop_operate)"/>
Expand Down
11 changes: 11 additions & 0 deletions system/mrm_handler/src/mrm_handler/mrm_handler_core.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 TIER IV, Inc.

Check notice on line 1 in system/mrm_handler/src/mrm_handler/mrm_handler_core.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

✅ Getting better: Overall Code Complexity

The mean cyclomatic complexity decreases from 5.77 to 5.57, threshold = 4. This file has many conditional statements (e.g. if, for, while) across its implementation, leading to lower code health. Avoid adding more conditionals.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -49,6 +49,8 @@
create_publisher<autoware_vehicle_msgs::msg::GearCommand>("~/output/gear", rclcpp::QoS{1});
pub_mrm_state_ =
create_publisher<autoware_adapi_v1_msgs::msg::MrmState>("~/output/mrm/state", rclcpp::QoS{1});
pub_emergency_holding_ = create_publisher<tier4_system_msgs::msg::EmergencyHoldingState>(
"~/output/emergency_holding", rclcpp::QoS{1});

Check warning on line 53 in system/mrm_handler/src/mrm_handler/mrm_handler_core.cpp

View check run for this annotation

Codecov / codecov/patch

system/mrm_handler/src/mrm_handler/mrm_handler_core.cpp#L52-L53

Added lines #L52 - L53 were not covered by tests

// Clients
client_mrm_pull_over_group_ = create_callback_group(rclcpp::CallbackGroupType::MutuallyExclusive);
Expand Down Expand Up @@ -153,6 +155,14 @@
pub_mrm_state_->publish(mrm_state_);
}

void MrmHandler::publishEmergencyHolding()

Check warning on line 158 in system/mrm_handler/src/mrm_handler/mrm_handler_core.cpp

View check run for this annotation

Codecov / codecov/patch

system/mrm_handler/src/mrm_handler/mrm_handler_core.cpp#L158

Added line #L158 was not covered by tests
{
tier4_system_msgs::msg::EmergencyHoldingState msg;
msg.stamp = this->now();
msg.is_holding = is_emergency_holding_;
pub_emergency_holding_->publish(msg);
}

Check warning on line 164 in system/mrm_handler/src/mrm_handler/mrm_handler_core.cpp

View check run for this annotation

Codecov / codecov/patch

system/mrm_handler/src/mrm_handler/mrm_handler_core.cpp#L161-L164

Added lines #L161 - L164 were not covered by tests

void MrmHandler::operateMrm()
{
using autoware_adapi_v1_msgs::msg::MrmState;
Expand Down Expand Up @@ -352,6 +362,7 @@
publishMrmState();
publishHazardCmd();
publishGearCmd();
publishEmergencyHolding();

Check warning on line 365 in system/mrm_handler/src/mrm_handler/mrm_handler_core.cpp

View check run for this annotation

Codecov / codecov/patch

system/mrm_handler/src/mrm_handler/mrm_handler_core.cpp#L365

Added line #L365 was not covered by tests
}

void MrmHandler::transitionTo(const int new_state)
Expand Down
Loading