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

fix(vehicle_cmd_gate): fix the problems while transition from/to stopped state (#5183) #1328

Merged
merged 1 commit into from
Jun 7, 2024
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
19 changes: 17 additions & 2 deletions control/vehicle_cmd_gate/src/vehicle_cmd_gate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,13 +430,17 @@ void VehicleCmdGate::publishControlCommands(const Commands & commands)

// Check engage
if (!is_engaged_) {
filtered_commands.control = createStopControlCmd();
filtered_commands.control.longitudinal = createLongitudinalStopControlCmd();
}

// Check pause. Place this check after all other checks as it needs the final output.
adapi_pause_->update(filtered_commands.control);
if (adapi_pause_->is_paused()) {
filtered_commands.control = createStopControlCmd();
if (is_engaged_) {
filtered_commands.control.longitudinal = createLongitudinalStopControlCmd();
} else {
filtered_commands.control = createStopControlCmd();
}
}

// Check if command filtering option is enable
Expand Down Expand Up @@ -599,6 +603,17 @@ AckermannControlCommand VehicleCmdGate::createStopControlCmd() const
return cmd;
}

LongitudinalCommand VehicleCmdGate::createLongitudinalStopControlCmd() const
{
LongitudinalCommand cmd;
const auto t = this->now();
cmd.stamp = t;
cmd.speed = 0.0;
cmd.acceleration = stop_hold_acceleration_;

return cmd;
}

AckermannControlCommand VehicleCmdGate::createEmergencyStopControlCmd() const
{
AckermannControlCommand cmd;
Expand Down
2 changes: 2 additions & 0 deletions control/vehicle_cmd_gate/src/vehicle_cmd_gate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ namespace vehicle_cmd_gate
using autoware_adapi_v1_msgs::msg::MrmState;
using autoware_adapi_v1_msgs::msg::OperationModeState;
using autoware_auto_control_msgs::msg::AckermannControlCommand;
using autoware_auto_control_msgs::msg::LongitudinalCommand;
using autoware_auto_vehicle_msgs::msg::GearCommand;
using autoware_auto_vehicle_msgs::msg::HazardLightsCommand;
using autoware_auto_vehicle_msgs::msg::SteeringReport;
Expand Down Expand Up @@ -220,6 +221,7 @@ class VehicleCmdGate : public rclcpp::Node
// Algorithm
AckermannControlCommand prev_control_cmd_;
AckermannControlCommand createStopControlCmd() const;
LongitudinalCommand createLongitudinalStopControlCmd() const;
AckermannControlCommand createEmergencyStopControlCmd() const;

std::shared_ptr<rclcpp::Time> prev_time_;
Expand Down
Loading