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

refactor(mrm_handler): delete control_cmd publish function #6514

Merged
merged 5 commits into from
Mar 6, 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
5 changes: 2 additions & 3 deletions system/mrm_handler/include/mrm_handler/mrm_handler_core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,8 @@ class MrmHandler : public rclcpp::Node
pub_hazard_cmd_;
rclcpp::Publisher<autoware_auto_vehicle_msgs::msg::GearCommand>::SharedPtr pub_gear_cmd_;

autoware_auto_vehicle_msgs::msg::HazardLightsCommand createHazardCmdMsg();
autoware_auto_vehicle_msgs::msg::GearCommand createGearCmdMsg();
void publishControlCommands();
void publishHazardCmd();
void publishGearCmd();

rclcpp::Publisher<autoware_adapi_v1_msgs::msg::MrmState>::SharedPtr pub_mrm_state_;

Expand Down
47 changes: 21 additions & 26 deletions system/mrm_handler/src/mrm_handler/mrm_handler_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,48 +161,39 @@
operation_mode_state_ = msg;
}

autoware_auto_vehicle_msgs::msg::HazardLightsCommand MrmHandler::createHazardCmdMsg()
void MrmHandler::publishHazardCmd()

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#L164

Added line #L164 was not covered by tests
{
using autoware_auto_vehicle_msgs::msg::HazardLightsCommand;
HazardLightsCommand msg;
veqcc marked this conversation as resolved.
Show resolved Hide resolved

// Check emergency
const bool is_emergency = isEmergency();

msg.stamp = this->now();

Check warning on line 169 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#L169

Added line #L169 was not covered by tests
if (is_emergency_holding_) {
// turn hazard on during emergency holding
msg.command = HazardLightsCommand::ENABLE;
} else if (is_emergency && param_.turning_hazard_on.emergency) {
} else if (isEmergency() && param_.turning_hazard_on.emergency) {

Check warning on line 173 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#L173

Added line #L173 was not covered by tests
// turn hazard on if vehicle is in emergency state and
// turning hazard on if emergency flag is true
msg.command = HazardLightsCommand::ENABLE;
} else {
msg.command = HazardLightsCommand::NO_COMMAND;
}
return msg;

pub_hazard_cmd_->publish(msg);

Check warning on line 181 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#L181

Added line #L181 was not covered by tests
}

void MrmHandler::publishControlCommands()
void MrmHandler::publishGearCmd()

Check warning on line 184 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#L184

Added line #L184 was not covered by tests
{
using autoware_auto_vehicle_msgs::msg::GearCommand;
GearCommand msg;

// Create timestamp
const auto stamp = this->now();

// Publish hazard command
pub_hazard_cmd_->publish(createHazardCmdMsg());

// Publish gear
{
GearCommand msg;
msg.stamp = stamp;
if (param_.use_parking_after_stopped && isStopped()) {
msg.command = GearCommand::PARK;
} else {
msg.command = GearCommand::DRIVE;
}
pub_gear_cmd_->publish(msg);
msg.stamp = this->now();
if (param_.use_parking_after_stopped && isStopped()) {
msg.command = GearCommand::PARK;

Check warning on line 191 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#L189-L191

Added lines #L189 - L191 were not covered by tests
} else {
msg.command = GearCommand::DRIVE;

Check warning on line 193 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#L193

Added line #L193 was not covered by tests
}

pub_gear_cmd_->publish(msg);

Check warning on line 196 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#L196

Added line #L196 was not covered by tests
}

void MrmHandler::publishMrmState()
Expand Down Expand Up @@ -380,17 +371,21 @@
this->get_logger(), *this->get_clock(), std::chrono::milliseconds(1000).count(),
"heartbeat operation_mode_availability is timeout");
mrm_state_.state = autoware_adapi_v1_msgs::msg::MrmState::MRM_OPERATING;
publishControlCommands();
publishHazardCmd();
publishGearCmd();

Check warning on line 375 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#L374-L375

Added lines #L374 - L375 were not covered by tests
return;
}

// Update Emergency State
updateMrmState();

// Publish control commands
publishControlCommands();
// Operate MRM
operateMrm();

// Publish
publishMrmState();
publishHazardCmd();
publishGearCmd();

Check warning on line 388 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#L387-L388

Added lines #L387 - L388 were not covered by tests
}

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