Skip to content

Commit afa7a52

Browse files
TetsuKawapre-commit-ci[bot]
authored andcommitted
feat(mrm_handler): mrm handler publish emergecy holding (autowarefoundation#9285)
* feat: add publisher for emrgency holding Signed-off-by: TetsuKawa <kawaguchitnon@icloud.com> * modify: fix msg element Signed-off-by: TetsuKawa <kawaguchitnon@icloud.com> * style(pre-commit): autofix --------- Signed-off-by: TetsuKawa <kawaguchitnon@icloud.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 8dcdbc4 commit afa7a52

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

system/mrm_handler/include/mrm_handler/mrm_handler_core.hpp

+5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <autoware_vehicle_msgs/msg/control_mode_report.hpp>
3030
#include <autoware_vehicle_msgs/msg/gear_command.hpp>
3131
#include <autoware_vehicle_msgs/msg/hazard_lights_command.hpp>
32+
#include <tier4_system_msgs/msg/emergency_holding_state.hpp>
3233
#include <tier4_system_msgs/msg/mrm_behavior_status.hpp>
3334
#include <tier4_system_msgs/msg/operation_mode_availability.hpp>
3435
#include <tier4_system_msgs/srv/operate_mrm.hpp>
@@ -109,6 +110,10 @@ class MrmHandler : public rclcpp::Node
109110
autoware_adapi_v1_msgs::msg::MrmState mrm_state_;
110111
void publishMrmState();
111112

113+
rclcpp::Publisher<tier4_system_msgs::msg::EmergencyHoldingState>::SharedPtr
114+
pub_emergency_holding_;
115+
void publishEmergencyHolding();
116+
112117
// Clients
113118
rclcpp::CallbackGroup::SharedPtr client_mrm_pull_over_group_;
114119
rclcpp::Client<tier4_system_msgs::srv::OperateMrm>::SharedPtr client_mrm_pull_over_;

system/mrm_handler/launch/mrm_handler.launch.xml

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<arg name="output_gear" default="/system/emergency/gear_cmd"/>
1313
<arg name="output_hazard" default="/system/emergency/hazard_lights_cmd"/>
1414
<arg name="output_mrm_state" default="/system/fail_safe/mrm_state"/>
15+
<arg name="output_emergency_holding" default="/system/emergency_holding"/>
1516
<arg name="output_mrm_pull_over_operate" default="/system/mrm/pull_over_manager/operate"/>
1617
<arg name="output_mrm_comfortable_stop_operate" default="/system/mrm/comfortable_stop/operate"/>
1718
<arg name="output_mrm_emergency_stop_operate" default="/system/mrm/emergency_stop/operate"/>
@@ -32,6 +33,7 @@
3233
<remap from="~/output/gear" to="$(var output_gear)"/>
3334
<remap from="~/output/hazard" to="$(var output_hazard)"/>
3435
<remap from="~/output/mrm/state" to="$(var output_mrm_state)"/>
36+
<remap from="~/output/emergency_holding" to="$(var output_emergency_holding)"/>
3537
<remap from="~/output/mrm/pull_over/operate" to="$(var output_mrm_pull_over_operate)"/>
3638
<remap from="~/output/mrm/comfortable_stop/operate" to="$(var output_mrm_comfortable_stop_operate)"/>
3739
<remap from="~/output/mrm/emergency_stop/operate" to="$(var output_mrm_emergency_stop_operate)"/>

system/mrm_handler/src/mrm_handler/mrm_handler_core.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ MrmHandler::MrmHandler(const rclcpp::NodeOptions & options) : Node("mrm_handler"
4949
create_publisher<autoware_vehicle_msgs::msg::GearCommand>("~/output/gear", rclcpp::QoS{1});
5050
pub_mrm_state_ =
5151
create_publisher<autoware_adapi_v1_msgs::msg::MrmState>("~/output/mrm/state", rclcpp::QoS{1});
52+
pub_emergency_holding_ = create_publisher<tier4_system_msgs::msg::EmergencyHoldingState>(
53+
"~/output/emergency_holding", rclcpp::QoS{1});
5254

5355
// Clients
5456
client_mrm_pull_over_group_ = create_callback_group(rclcpp::CallbackGroupType::MutuallyExclusive);
@@ -153,6 +155,14 @@ void MrmHandler::publishMrmState()
153155
pub_mrm_state_->publish(mrm_state_);
154156
}
155157

158+
void MrmHandler::publishEmergencyHolding()
159+
{
160+
tier4_system_msgs::msg::EmergencyHoldingState msg;
161+
msg.stamp = this->now();
162+
msg.is_holding = is_emergency_holding_;
163+
pub_emergency_holding_->publish(msg);
164+
}
165+
156166
void MrmHandler::operateMrm()
157167
{
158168
using autoware_adapi_v1_msgs::msg::MrmState;
@@ -352,6 +362,7 @@ void MrmHandler::onTimer()
352362
publishMrmState();
353363
publishHazardCmd();
354364
publishGearCmd();
365+
publishEmergencyHolding();
355366
}
356367

357368
void MrmHandler::transitionTo(const int new_state)

0 commit comments

Comments
 (0)