Skip to content

Commit

Permalink
add gear history
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Sanchez <[email protected]>
  • Loading branch information
danielsanchezaran committed Jun 5, 2024
1 parent 96b6321 commit d48b060
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ class EmergencyHandler : public rclcpp::Node
void checkHazardStatusTimeout();

// Algorithm
uint8_t last_gear_command_{autoware_auto_vehicle_msgs::msg::GearCommand::DRIVE};
void transitionTo(const int new_state);
void updateMrmState();
void operateMrm();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,22 +167,15 @@ void EmergencyHandler::publishControlCommands()
{
GearCommand msg;
msg.stamp = stamp;

if (isStopped()) {
if (param_.use_parking_after_stopped) {
msg.command = GearCommand::PARK;
pub_gear_cmd_->publish(msg);
}
return;
}

if (isDrivingBackwards()) {
msg.command = GearCommand::REVERSE;
pub_gear_cmd_->publish(msg);
return;
}

msg.command = GearCommand::DRIVE;
const auto command = [&]() {
// If stopped and use_parking is not true, send the last gear command
if (isStopped())
return (param_.use_parking_after_stopped) ? GearCommand::PARK : last_gear_command_;
return (isDrivingBackwards()) ? GearCommand::REVERSE : GearCommand::DRIVE;
}();

msg.command = command;
last_gear_command_ = msg.command;
pub_gear_cmd_->publish(msg);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ class MrmHandler : public rclcpp::Node

// Algorithm
bool is_emergency_holding_ = false;
uint8_t last_gear_command_{autoware_auto_vehicle_msgs::msg::GearCommand::DRIVE};
void transitionTo(const int new_state);
void updateMrmState();
void operateMrm();
Expand Down
25 changes: 9 additions & 16 deletions system/mrm_handler/src/mrm_handler/mrm_handler_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,22 +191,15 @@ void MrmHandler::publishGearCmd()
GearCommand msg;

msg.stamp = this->now();

if (isStopped()) {
if (param_.use_parking_after_stopped) {
msg.command = GearCommand::PARK;
pub_gear_cmd_->publish(msg);
}
return;
}

if (isDrivingBackwards()) {
msg.command = GearCommand::REVERSE;
pub_gear_cmd_->publish(msg);
return;
}

msg.command = GearCommand::DRIVE;
const auto command = [&]() {
// If stopped and use_parking is not true, send the last gear command
if (isStopped())
return (param_.use_parking_after_stopped) ? GearCommand::PARK : last_gear_command_;
return (isDrivingBackwards()) ? GearCommand::REVERSE : GearCommand::DRIVE;
}();

msg.command = command;
last_gear_command_ = msg.command;
pub_gear_cmd_->publish(msg);
return;
}
Expand Down

0 comments on commit d48b060

Please sign in to comment.