@@ -26,8 +26,6 @@ MrmHandler::MrmHandler() : Node("mrm_handler")
26
26
declare_parameter<double >(" timeout_operation_mode_availability" , 0.5 );
27
27
param_.use_emergency_holding = declare_parameter<bool >(" use_emergency_holding" , false );
28
28
param_.timeout_emergency_recovery = declare_parameter<double >(" timeout_emergency_recovery" , 5.0 );
29
- param_.timeout_takeover_request = declare_parameter<double >(" timeout_takeover_request" , 10.0 );
30
- param_.use_takeover_request = declare_parameter<bool >(" use_takeover_request" , false );
31
29
param_.use_parking_after_stopped = declare_parameter<bool >(" use_parking_after_stopped" , false );
32
30
param_.use_pull_over = declare_parameter<bool >(" use_pull_over" , false );
33
31
param_.use_comfortable_stop = declare_parameter<bool >(" use_comfortable_stop" , false );
@@ -164,48 +162,39 @@ void MrmHandler::onOperationModeState(
164
162
operation_mode_state_ = msg;
165
163
}
166
164
167
- autoware_auto_vehicle_msgs::msg::HazardLightsCommand MrmHandler::createHazardCmdMsg ()
165
+ void MrmHandler::publishHazardCmd ()
168
166
{
169
167
using autoware_auto_vehicle_msgs::msg::HazardLightsCommand;
170
168
HazardLightsCommand msg;
171
169
172
- // Check emergency
173
- const bool is_emergency = isEmergency ();
174
-
170
+ msg.stamp = this ->now ();
175
171
if (is_emergency_holding_) {
176
172
// turn hazard on during emergency holding
177
173
msg.command = HazardLightsCommand::ENABLE;
178
- } else if (is_emergency && param_.turning_hazard_on .emergency ) {
174
+ } else if (isEmergency () && param_.turning_hazard_on .emergency ) {
179
175
// turn hazard on if vehicle is in emergency state and
180
176
// turning hazard on if emergency flag is true
181
177
msg.command = HazardLightsCommand::ENABLE;
182
178
} else {
183
179
msg.command = HazardLightsCommand::NO_COMMAND;
184
180
}
185
- return msg;
181
+
182
+ pub_hazard_cmd_->publish (msg);
186
183
}
187
184
188
- void MrmHandler::publishControlCommands ()
185
+ void MrmHandler::publishGearCmd ()
189
186
{
190
187
using autoware_auto_vehicle_msgs::msg::GearCommand;
188
+ GearCommand msg;
191
189
192
- // Create timestamp
193
- const auto stamp = this ->now ();
194
-
195
- // Publish hazard command
196
- pub_hazard_cmd_->publish (createHazardCmdMsg ());
197
-
198
- // Publish gear
199
- {
200
- GearCommand msg;
201
- msg.stamp = stamp;
202
- if (param_.use_parking_after_stopped && isStopped ()) {
203
- msg.command = GearCommand::PARK;
204
- } else {
205
- msg.command = GearCommand::DRIVE;
206
- }
207
- pub_gear_cmd_->publish (msg);
190
+ msg.stamp = this ->now ();
191
+ if (param_.use_parking_after_stopped && isStopped ()) {
192
+ msg.command = GearCommand::PARK;
193
+ } else {
194
+ msg.command = GearCommand::DRIVE;
208
195
}
196
+
197
+ pub_gear_cmd_->publish (msg);
209
198
}
210
199
211
200
void MrmHandler::publishMrmState ()
@@ -396,10 +385,13 @@ void MrmHandler::onTimer()
396
385
// Update Emergency State
397
386
updateMrmState ();
398
387
399
- // Publish control commands
400
- publishControlCommands ();
388
+ // Operate MRM
401
389
operateMrm ();
390
+
391
+ // Publish
402
392
publishMrmState ();
393
+ publishHazardCmd ();
394
+ publishGearCmd ();
403
395
}
404
396
405
397
void MrmHandler::transitionTo (const int new_state)
@@ -441,41 +433,23 @@ void MrmHandler::updateMrmState()
441
433
442
434
// Get mode
443
435
const bool is_auto_mode = control_mode_->mode == ControlModeReport::AUTONOMOUS;
444
- const bool is_takeover_done = control_mode_->mode == ControlModeReport::MANUAL;
445
436
446
437
// State Machine
447
438
if (mrm_state_.state == MrmState::NORMAL) {
448
439
// NORMAL
449
440
if (is_auto_mode && is_emergency) {
450
- if (param_.use_takeover_request ) {
451
- takeover_requested_time_ = this ->get_clock ()->now ();
452
- is_takeover_request_ = true ;
453
- return ;
454
- } else {
455
- transitionTo (MrmState::MRM_OPERATING);
456
- return ;
457
- }
441
+ transitionTo (MrmState::MRM_OPERATING);
442
+ return ;
458
443
}
459
444
} else {
460
445
// Emergency
461
- // Send recovery events if "not emergency" or "takeover done"
446
+ // Send recovery events if "not emergency"
462
447
if (!is_emergency) {
463
448
transitionTo (MrmState::NORMAL);
464
449
return ;
465
450
}
466
- // TODO(TetsuKawa): Check if human can safely override, for example using DSM
467
- if (is_takeover_done) {
468
- transitionTo (MrmState::NORMAL);
469
- return ;
470
- }
471
451
472
- if (is_takeover_request_) {
473
- const auto time_from_takeover_request = this ->get_clock ()->now () - takeover_requested_time_;
474
- if (time_from_takeover_request.seconds () > param_.timeout_takeover_request ) {
475
- transitionTo (MrmState::MRM_OPERATING);
476
- return ;
477
- }
478
- } else if (mrm_state_.state == MrmState::MRM_OPERATING) {
452
+ if (mrm_state_.state == MrmState::MRM_OPERATING) {
479
453
// TODO(TetsuKawa): Check MRC is accomplished
480
454
if (mrm_state_.behavior == MrmState::PULL_OVER) {
481
455
if (isStopped () && isArrivedAtGoal ()) {
0 commit comments