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

feat(mrm_pull_over_manager): add pull over mrm #5634

Closed
Closed
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
1a09522
wip
TomohitoAndo Oct 12, 2023
0fa11f4
wip
TomohitoAndo Oct 12, 2023
9b7857f
wip
TomohitoAndo Oct 15, 2023
34cdca0
wip
TomohitoAndo Oct 15, 2023
4872082
wip
TomohitoAndo Oct 15, 2023
c5e4b4c
feat(emergency_goal_manager): add an emergency_goal_manager package
mkuri Oct 15, 2023
fa81555
feat: add mrm_pull_over_manager
TomohitoAndo Oct 15, 2023
171d4aa
change update rate to param
TomohitoAndo Oct 15, 2023
08fe546
fix
TomohitoAndo Oct 15, 2023
542c80d
change INFO to DEBUG
TomohitoAndo Oct 15, 2023
c9e9dff
update pull over point
TomohitoAndo Oct 16, 2023
8411b80
chore(emergency_goal_manager): add main callbacks
mkuri Oct 16, 2023
c779c5d
replace activate pull over with operate mrm service
TomohitoAndo Oct 16, 2023
16e9f0e
publish emergency goals clear command when deactivated
TomohitoAndo Oct 16, 2023
0701a53
replace PoseArray with EmergencyGoalsStamped
TomohitoAndo Oct 16, 2023
3d2e3cc
fix function name
TomohitoAndo Oct 16, 2023
d620dfc
fix condition of the num of goals
TomohitoAndo Oct 16, 2023
5e0a19e
Merge remote-tracking branch 'awf/main' into feat/mrm-pull-over-manager
veqcc Nov 9, 2023
b2952c2
create emergency_goal_manager node
veqcc Nov 10, 2023
113f07e
fix
veqcc Nov 10, 2023
5e7ef7c
style(pre-commit): autofix
pre-commit-ci[bot] Nov 20, 2023
d65b056
fix: set timeout for ClearMRMMRoute
veqcc Nov 22, 2023
e9681ba
Merge branch 'main' into feat/mrm-pull-over-manager
kosuke55 Dec 4, 2023
8b59d16
fix optional to build
kosuke55 Dec 4, 2023
10dbca2
feat(mission_planner): use ClearRoute instead of Trigger
kosuke55 Dec 4, 2023
302b133
Merge remote-tracking branch 'origin/main' into feat/mrm-pull-over-ma…
kosuke55 Dec 5, 2023
68bf448
fix reference goal queue
kosuke55 Dec 5, 2023
b5d3b03
while (rclcpp::ok())
kosuke55 Dec 5, 2023
114cc76
add timeout
kosuke55 Dec 5, 2023
197cc94
feat(mission_planner): print modified goal reroute
kosuke55 Dec 5, 2023
756c594
add sleep after service fails
kosuke55 Dec 5, 2023
5dcec44
fix(behavior_path_planner): reset previou modified goal
kosuke55 Dec 5, 2023
eaf26fd
fix sleep
kosuke55 Dec 5, 2023
37183b7
feat(behavior_path_planner): allow reroute when always executable mod…
kosuke55 Dec 5, 2023
a062b7a
feat(mission_planner): judge reroute safe when ego is stopped
kosuke55 Dec 5, 2023
83e60b8
fix(mission_planner): fix reroute chattering when mrm route clear fails
kosuke55 Dec 5, 2023
c4ed177
modify error message
kosuke55 Dec 5, 2023
b811f38
Merge remote-tracking branch 'origin/main' into feat/mrm-pull-over-ma…
kosuke55 Dec 5, 2023
b0e0804
Merge remote-tracking branch 'origin/main' into feat/mrm-pull-over-ma…
kosuke55 Dec 5, 2023
483b14b
Merge branch 'main' into feat/mrm-pull-over-manager
mkuri Jan 11, 2024
f98a3db
chore(emergency_goal_manager): fix todo
mkuri Mar 5, 2024
8a4cd75
fix(mrm_pull_over_manager): fix typo
mkuri Mar 11, 2024
bceda6b
fix(mrm_pull_over_manager): fix typo
mkuri Mar 11, 2024
ba1b293
chore(mrm_pull_over_manager): remove the command field from the clear
mkuri Mar 22, 2024
341730b
docs(emergency_goal_manager): add readme
mkuri Mar 22, 2024
92933ee
docs(mrm_pull_over_manager): add readme
mkuri Mar 22, 2024
d5b65ba
Merge branch 'main' into feat/mrm-pull-over-manager
mkuri Mar 22, 2024
908aa4a
style(pre-commit): autofix
pre-commit-ci[bot] Mar 22, 2024
fbf494e
Merge branch 'main' into feat/mrm-pull-over-manager
mkuri Mar 25, 2024
10723f4
chore(emergency_goal_manager): fix copyright year
mkuri Apr 2, 2024
ee81466
chore(emergency_goal_manager): remove comments in the include section
mkuri Apr 2, 2024
abfe52e
fix(emergency_goal_manager): remove the clear process
mkuri Apr 2, 2024
d4364ef
style(pre-commit): autofix
pre-commit-ci[bot] Apr 2, 2024
d8013b7
Merge branch 'main' into feat/mrm-pull-over-manager
mkuri Apr 2, 2024
9e75f1b
chore(mrm_pull_over_manager): change default pull over points
mkuri Apr 4, 2024
bcbb83d
feat(emergency_goal_manager): change service for route selector
mkuri Apr 4, 2024
7fa0cf5
style(pre-commit): autofix
pre-commit-ci[bot] Apr 4, 2024
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
6 changes: 6 additions & 0 deletions launch/tier4_system_launch/launch/system.launch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@
<arg name="config_file" value="$(var mrm_emergency_stop_operator_param_path)"/>
</include>
</group>
<group>
<include file="$(find-pkg-share mrm_pull_over_manager)/launch/mrm_pull_over_manager.launch.xml"/>
</group>
<group>
<include file="$(find-pkg-share emergency_goal_manager)/launch/emergency_goal_manager.launch.xml"/>
</group>

<!-- MRM Handler -->
<group if="$(var use_diagnostic_graph)">
Expand Down
15 changes: 15 additions & 0 deletions system/emergency_goal_manager/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 3.14)
project(emergency_goal_manager)

find_package(autoware_cmake REQUIRED)
autoware_package()

ament_auto_add_executable(emergency_goal_manager
src/emergency_goal_manager_node.cpp
src/emergency_goal_manager_core.cpp
)

ament_auto_package(INSTALL_TO_SHARE
launch
config
)
33 changes: 33 additions & 0 deletions system/emergency_goal_manager/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# emergency_goal_manager

## Purpose

The Emergency goal manager is responsible for coordinating the goal poses for emergency rerouting and communicating it to the mission planner.

## Inner-workings / Algorithms

TBD.

## Inputs / Outputs

### Input

| Name | Type | Description |
| --------------------------------------- | ---------------------------------------------------- | ----------------------------- |
| `~/input/emergency_goals` | `tier4_system_msgs::msg::EmergencyGoalsStamped` | Candidates for emergency goal |
| `~/input/emergency_goals_clear_command` | `tier4_system_msgs::msg::EmergencyGoalsClearCommand` | Clear command |

### Output

| Name | Type | Description |
| ---------------------------------------------------------------- | --------------------------------------------- | ------------------------ |
| `/planning/mission_planning/mission_planner/srv/set_mrm_route` | `autoware_adapi_v1_msgs::srv::SetRoutePoints` | Set route points for MRM |
| `/planning/mission_planning/mission_planner/srv/clear_mrm_route` | `autoware_adapi_v1_msgs::srv::ClearRoute` | Clear route for MRM |

## Parameters

No parameters.

## Assumptions / Known limits

TBD.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// Copyright 2022 Tier IV, Inc.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The copyright year is 2022. Is there a original file for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef EMERGENCY_GOAL_MANAGER_CORE_HPP_
#define EMERGENCY_GOAL_MANAGER_CORE_HPP_

// Autoware
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#include <autoware_adapi_v1_msgs/srv/clear_route.hpp>
#include <autoware_adapi_v1_msgs/srv/set_route_points.hpp>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the internal route interfaces for route_selector. I think that these are more suitable for this node.
https://github.com/tier4/tier4_autoware_msgs/tree/tier4/universe/tier4_planning_msgs/srv

#include <tier4_system_msgs/msg/emergency_goals_clear_command.hpp>
#include <tier4_system_msgs/msg/emergency_goals_stamped.hpp>

// ROS 2 core
#include <rclcpp/rclcpp.hpp>

#include <geometry_msgs/msg/pose.hpp>
#include <std_srvs/srv/trigger.hpp>

#include <queue>
#include <string>
#include <unordered_map>

namespace emergency_goal_manager
{
class EmergencyGoalManager : public rclcpp::Node
{
public:
EmergencyGoalManager();

private:
using SetRoutePoints = autoware_adapi_v1_msgs::srv::SetRoutePoints;
using ClearRoute = autoware_adapi_v1_msgs::srv::ClearRoute;

// Subscriber
rclcpp::Subscription<tier4_system_msgs::msg::EmergencyGoalsStamped>::SharedPtr
sub_emergency_goals_;
rclcpp::Subscription<tier4_system_msgs::msg::EmergencyGoalsClearCommand>::SharedPtr
sub_emergency_goals_clear_command_;

void onEmergencyGoals(const tier4_system_msgs::msg::EmergencyGoalsStamped::SharedPtr msg);
void onEmergencyGoalsClearCommand(
const tier4_system_msgs::msg::EmergencyGoalsClearCommand::SharedPtr msg);

// Client
rclcpp::CallbackGroup::SharedPtr client_set_mrm_route_points_callback_group_;
rclcpp::Client<SetRoutePoints>::SharedPtr client_set_mrm_route_points_;
rclcpp::CallbackGroup::SharedPtr client_clear_mrm_route_callback_group_;
rclcpp::Client<ClearRoute>::SharedPtr client_clear_mrm_route_;

// Variables
std::unordered_map<std::string, std::queue<geometry_msgs::msg::Pose>> emergency_goals_map_;

// Algorithm
void callSetMrmRoutePoints();
void callClearMrmRoute();
};
} // namespace emergency_goal_manager

#endif // EMERGENCY_GOAL_MANAGER_CORE_HPP_
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<launch>
<arg name="input_emergency_goals" default="/system/mrm/pull_over_manager/emergency_goals"/>
<arg name="input_goals_clear_command" default="/system/mrm/pull_over_manager/goals_clear_command"/>

<node pkg="emergency_goal_manager" exec="emergency_goal_manager" name="emergency_goal_manager" output="screen">
<remap from="~/input/emergency_goals" to="$(var input_emergency_goals)"/>
<remap from="~/input/emergency_goals_clear_command" to="$(var input_goals_clear_command)"/>
</node>
</launch>
26 changes: 26 additions & 0 deletions system/emergency_goal_manager/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>emergency_goal_manager</name>
<version>0.1.0</version>
<description>The emergency goal manager package</description>
<maintainer email="makoto.kurihara@tier4.jp">Makoto Kurihara</maintainer>
<maintainer email="tomohito.ando@tier4.jp">Tomohito Ando</maintainer>
<maintainer email="ryuta.kambe@tier4.jp">Ryuta Kambe</maintainer>
<license>Apache License 2.0</license>

<buildtool_depend>ament_cmake_auto</buildtool_depend>
<buildtool_depend>autoware_cmake</buildtool_depend>

<depend>autoware_adapi_v1_msgs</depend>
<depend>rclcpp_components</depend>
<depend>std_srvs</depend>
<depend>tier4_system_msgs</depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>autoware_lint_common</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
150 changes: 150 additions & 0 deletions system/emergency_goal_manager/src/emergency_goal_manager_core.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
// Copyright 2022 Tier IV, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include <emergency_goal_manager_core.hpp>

namespace emergency_goal_manager
{
EmergencyGoalManager::EmergencyGoalManager() : Node("emergency_goal_manager")

Check warning on line 19 in system/emergency_goal_manager/src/emergency_goal_manager_core.cpp

View check run for this annotation

Codecov / codecov/patch

system/emergency_goal_manager/src/emergency_goal_manager_core.cpp#L19

Added line #L19 was not covered by tests
{
// Subscriber
sub_emergency_goals_ = create_subscription<tier4_system_msgs::msg::EmergencyGoalsStamped>(
"~/input/emergency_goals", rclcpp::QoS{1},
std::bind(&EmergencyGoalManager::onEmergencyGoals, this, std::placeholders::_1));

Check warning on line 24 in system/emergency_goal_manager/src/emergency_goal_manager_core.cpp

View check run for this annotation

Codecov / codecov/patch

system/emergency_goal_manager/src/emergency_goal_manager_core.cpp#L22-L24

Added lines #L22 - L24 were not covered by tests
sub_emergency_goals_clear_command_ =
create_subscription<tier4_system_msgs::msg::EmergencyGoalsClearCommand>(
"~/input/emergency_goals_clear_command", rclcpp::QoS{1},
std::bind(&EmergencyGoalManager::onEmergencyGoalsClearCommand, this, std::placeholders::_1));

Check warning on line 28 in system/emergency_goal_manager/src/emergency_goal_manager_core.cpp

View check run for this annotation

Codecov / codecov/patch

system/emergency_goal_manager/src/emergency_goal_manager_core.cpp#L26-L28

Added lines #L26 - L28 were not covered by tests

// Client
client_set_mrm_route_points_callback_group_ =
create_callback_group(rclcpp::CallbackGroupType::MutuallyExclusive);
client_set_mrm_route_points_ = create_client<SetRoutePoints>(

Check warning on line 33 in system/emergency_goal_manager/src/emergency_goal_manager_core.cpp

View check run for this annotation

Codecov / codecov/patch

system/emergency_goal_manager/src/emergency_goal_manager_core.cpp#L32-L33

Added lines #L32 - L33 were not covered by tests
"/planning/mission_planning/mission_planner/srv/set_mrm_route",
rmw_qos_profile_services_default, client_set_mrm_route_points_callback_group_);
client_clear_mrm_route_callback_group_ =
create_callback_group(rclcpp::CallbackGroupType::MutuallyExclusive);
client_clear_mrm_route_ = create_client<ClearRoute>(

Check warning on line 38 in system/emergency_goal_manager/src/emergency_goal_manager_core.cpp

View check run for this annotation

Codecov / codecov/patch

system/emergency_goal_manager/src/emergency_goal_manager_core.cpp#L37-L38

Added lines #L37 - L38 were not covered by tests
"/planning/mission_planning/mission_planner/srv/clear_mrm_route",
rmw_qos_profile_services_default, client_clear_mrm_route_callback_group_);

// Initialize
while (!client_set_mrm_route_points_->wait_for_service(std::chrono::seconds(1)) && rclcpp::ok()) {

Check warning on line 43 in system/emergency_goal_manager/src/emergency_goal_manager_core.cpp

View check run for this annotation

Codecov / codecov/patch

system/emergency_goal_manager/src/emergency_goal_manager_core.cpp#L43

Added line #L43 was not covered by tests
}
while (!client_clear_mrm_route_->wait_for_service(std::chrono::seconds(1)) && rclcpp::ok()) {

Check warning on line 45 in system/emergency_goal_manager/src/emergency_goal_manager_core.cpp

View check run for this annotation

Codecov / codecov/patch

system/emergency_goal_manager/src/emergency_goal_manager_core.cpp#L45

Added line #L45 was not covered by tests
}
}

Check warning on line 47 in system/emergency_goal_manager/src/emergency_goal_manager_core.cpp

View check run for this annotation

Codecov / codecov/patch

system/emergency_goal_manager/src/emergency_goal_manager_core.cpp#L47

Added line #L47 was not covered by tests

void EmergencyGoalManager::onEmergencyGoals(

Check warning on line 49 in system/emergency_goal_manager/src/emergency_goal_manager_core.cpp

View check run for this annotation

Codecov / codecov/patch

system/emergency_goal_manager/src/emergency_goal_manager_core.cpp#L49

Added line #L49 was not covered by tests
const tier4_system_msgs::msg::EmergencyGoalsStamped::SharedPtr msg)
{
if (!emergency_goals_map_.empty()) {

Check warning on line 52 in system/emergency_goal_manager/src/emergency_goal_manager_core.cpp

View check run for this annotation

Codecov / codecov/patch

system/emergency_goal_manager/src/emergency_goal_manager_core.cpp#L52

Added line #L52 was not covered by tests
emergency_goals_map_.clear();
}

std::queue<geometry_msgs::msg::Pose> emergency_goals_queue;
for (const auto & goal : msg->goals) {

Check warning on line 57 in system/emergency_goal_manager/src/emergency_goal_manager_core.cpp

View check run for this annotation

Codecov / codecov/patch

system/emergency_goal_manager/src/emergency_goal_manager_core.cpp#L57

Added line #L57 was not covered by tests
emergency_goals_queue.push(goal);
}
emergency_goals_map_.emplace(msg->sender, emergency_goals_queue);

Check warning on line 60 in system/emergency_goal_manager/src/emergency_goal_manager_core.cpp

View check run for this annotation

Codecov / codecov/patch

system/emergency_goal_manager/src/emergency_goal_manager_core.cpp#L60

Added line #L60 was not covered by tests

callSetMrmRoutePoints();
}

Check warning on line 63 in system/emergency_goal_manager/src/emergency_goal_manager_core.cpp

View check run for this annotation

Codecov / codecov/patch

system/emergency_goal_manager/src/emergency_goal_manager_core.cpp#L62-L63

Added lines #L62 - L63 were not covered by tests

void EmergencyGoalManager::onEmergencyGoalsClearCommand(

Check warning on line 65 in system/emergency_goal_manager/src/emergency_goal_manager_core.cpp

View check run for this annotation

Codecov / codecov/patch

system/emergency_goal_manager/src/emergency_goal_manager_core.cpp#L65

Added line #L65 was not covered by tests
const tier4_system_msgs::msg::EmergencyGoalsClearCommand::SharedPtr msg)
{
if (emergency_goals_map_.count(msg->sender) == 0) {
RCLCPP_WARN(get_logger(), "Emergency goals from %s is empty.", msg->sender.c_str());

Check warning on line 69 in system/emergency_goal_manager/src/emergency_goal_manager_core.cpp

View check run for this annotation

Codecov / codecov/patch

system/emergency_goal_manager/src/emergency_goal_manager_core.cpp#L68-L69

Added lines #L68 - L69 were not covered by tests
}

emergency_goals_map_.erase(msg->sender);

Check warning on line 72 in system/emergency_goal_manager/src/emergency_goal_manager_core.cpp

View check run for this annotation

Codecov / codecov/patch

system/emergency_goal_manager/src/emergency_goal_manager_core.cpp#L72

Added line #L72 was not covered by tests

if (emergency_goals_map_.empty()) {
callClearMrmRoute();

Check warning on line 75 in system/emergency_goal_manager/src/emergency_goal_manager_core.cpp

View check run for this annotation

Codecov / codecov/patch

system/emergency_goal_manager/src/emergency_goal_manager_core.cpp#L74-L75

Added lines #L74 - L75 were not covered by tests
} else {
callSetMrmRoutePoints();

Check warning on line 77 in system/emergency_goal_manager/src/emergency_goal_manager_core.cpp

View check run for this annotation

Codecov / codecov/patch

system/emergency_goal_manager/src/emergency_goal_manager_core.cpp#L77

Added line #L77 was not covered by tests
}
}

Check warning on line 79 in system/emergency_goal_manager/src/emergency_goal_manager_core.cpp

View check run for this annotation

Codecov / codecov/patch

system/emergency_goal_manager/src/emergency_goal_manager_core.cpp#L79

Added line #L79 was not covered by tests

void EmergencyGoalManager::callSetMrmRoutePoints()

Check warning on line 81 in system/emergency_goal_manager/src/emergency_goal_manager_core.cpp

View check run for this annotation

Codecov / codecov/patch

system/emergency_goal_manager/src/emergency_goal_manager_core.cpp#L81

Added line #L81 was not covered by tests
{
auto request = std::make_shared<SetRoutePoints::Request>();
request->header.frame_id = "map";
request->header.stamp = this->now();
request->option.allow_goal_modification = true;

Check warning on line 86 in system/emergency_goal_manager/src/emergency_goal_manager_core.cpp

View check run for this annotation

Codecov / codecov/patch

system/emergency_goal_manager/src/emergency_goal_manager_core.cpp#L84-L86

Added lines #L84 - L86 were not covered by tests

while (!emergency_goals_map_.empty()) {

Check warning on line 88 in system/emergency_goal_manager/src/emergency_goal_manager_core.cpp

View check run for this annotation

Codecov / codecov/patch

system/emergency_goal_manager/src/emergency_goal_manager_core.cpp#L88

Added line #L88 was not covered by tests
// TODO(Makoto Kurihara): set goals with the highest priority
auto goals = emergency_goals_map_.begin();

auto sender = goals->first;
auto & goal_queue = goals->second;
if (goal_queue.empty()) {

Check warning on line 94 in system/emergency_goal_manager/src/emergency_goal_manager_core.cpp

View check run for this annotation

Codecov / codecov/patch

system/emergency_goal_manager/src/emergency_goal_manager_core.cpp#L94

Added line #L94 was not covered by tests
emergency_goals_map_.erase(sender);
continue;

Check warning on line 96 in system/emergency_goal_manager/src/emergency_goal_manager_core.cpp

View check run for this annotation

Codecov / codecov/patch

system/emergency_goal_manager/src/emergency_goal_manager_core.cpp#L96

Added line #L96 was not covered by tests
}

request->goal = goal_queue.front();

Check warning on line 99 in system/emergency_goal_manager/src/emergency_goal_manager_core.cpp

View check run for this annotation

Codecov / codecov/patch

system/emergency_goal_manager/src/emergency_goal_manager_core.cpp#L99

Added line #L99 was not covered by tests
goal_queue.pop();

auto future = client_set_mrm_route_points_->async_send_request(request);
const auto duration = std::chrono::duration<double, std::ratio<1>>(10);
if (future.wait_for(duration) != std::future_status::ready) {
RCLCPP_WARN(get_logger(), "MRM Route service timeout.");
continue;
} else {
if (future.get()->status.success) {
RCLCPP_INFO(get_logger(), "MRM Route has been successfully sent.");

Check warning on line 109 in system/emergency_goal_manager/src/emergency_goal_manager_core.cpp

View check run for this annotation

Codecov / codecov/patch

system/emergency_goal_manager/src/emergency_goal_manager_core.cpp#L102-L109

Added lines #L102 - L109 were not covered by tests
return;
} else {
RCLCPP_WARN(get_logger(), "MRM Route service has failed.");
std::this_thread::sleep_for(std::chrono::seconds(1));
continue;
}

Check warning on line 115 in system/emergency_goal_manager/src/emergency_goal_manager_core.cpp

View check run for this annotation

Codecov / codecov/patch

system/emergency_goal_manager/src/emergency_goal_manager_core.cpp#L112-L115

Added lines #L112 - L115 were not covered by tests
}
}

callClearMrmRoute();

Check warning on line 119 in system/emergency_goal_manager/src/emergency_goal_manager_core.cpp

View check run for this annotation

Codecov / codecov/patch

system/emergency_goal_manager/src/emergency_goal_manager_core.cpp#L119

Added line #L119 was not covered by tests
}

Check warning on line 120 in system/emergency_goal_manager/src/emergency_goal_manager_core.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ New issue: Bumpy Road Ahead

EmergencyGoalManager::callSetMrmRoutePoints has 2 blocks with nested conditional logic. Any nesting of 2 or deeper is considered. Threshold is one single, nested block per function. The Bumpy Road code smell is a function that contains multiple chunks of nested conditional logic. The deeper the nesting and the more bumps, the lower the code health.

void EmergencyGoalManager::callClearMrmRoute()

Check warning on line 122 in system/emergency_goal_manager/src/emergency_goal_manager_core.cpp

View check run for this annotation

Codecov / codecov/patch

system/emergency_goal_manager/src/emergency_goal_manager_core.cpp#L122

Added line #L122 was not covered by tests
{
auto request = std::make_shared<ClearRoute::Request>();
const auto duration = std::chrono::duration<double, std::ratio<1>>(10);
const auto start_time = std::chrono::steady_clock::now();

Check warning on line 126 in system/emergency_goal_manager/src/emergency_goal_manager_core.cpp

View check run for this annotation

Codecov / codecov/patch

system/emergency_goal_manager/src/emergency_goal_manager_core.cpp#L125-L126

Added lines #L125 - L126 were not covered by tests

while (rclcpp::ok()) {
if (std::chrono::steady_clock::now() - start_time > duration) {
RCLCPP_WARN(get_logger(), "Clear MRM Route operation timeout.");
return;

Check warning on line 131 in system/emergency_goal_manager/src/emergency_goal_manager_core.cpp

View check run for this annotation

Codecov / codecov/patch

system/emergency_goal_manager/src/emergency_goal_manager_core.cpp#L128-L131

Added lines #L128 - L131 were not covered by tests
}

auto future = client_clear_mrm_route_->async_send_request(request);
if (future.wait_for(duration) != std::future_status::ready) {
RCLCPP_WARN(get_logger(), "Clear MRM Route service timeout.");
return;

Check warning on line 137 in system/emergency_goal_manager/src/emergency_goal_manager_core.cpp

View check run for this annotation

Codecov / codecov/patch

system/emergency_goal_manager/src/emergency_goal_manager_core.cpp#L134-L137

Added lines #L134 - L137 were not covered by tests
} else {
if (future.get()->status.success) {
RCLCPP_INFO(get_logger(), "Clear MRM Route has been successfully sent.");
return;

Check warning on line 141 in system/emergency_goal_manager/src/emergency_goal_manager_core.cpp

View check run for this annotation

Codecov / codecov/patch

system/emergency_goal_manager/src/emergency_goal_manager_core.cpp#L139-L141

Added lines #L139 - L141 were not covered by tests
} else {
std::this_thread::sleep_for(std::chrono::seconds(1));
RCLCPP_WARN(get_logger(), "Clear MRM Route has failed.");

Check warning on line 144 in system/emergency_goal_manager/src/emergency_goal_manager_core.cpp

View check run for this annotation

Codecov / codecov/patch

system/emergency_goal_manager/src/emergency_goal_manager_core.cpp#L143-L144

Added lines #L143 - L144 were not covered by tests
continue;
}

Check warning on line 146 in system/emergency_goal_manager/src/emergency_goal_manager_core.cpp

View check run for this annotation

Codecov / codecov/patch

system/emergency_goal_manager/src/emergency_goal_manager_core.cpp#L146

Added line #L146 was not covered by tests
}
}
}

Check warning on line 149 in system/emergency_goal_manager/src/emergency_goal_manager_core.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ New issue: Bumpy Road Ahead

EmergencyGoalManager::callClearMrmRoute has 2 blocks with nested conditional logic. Any nesting of 2 or deeper is considered. Threshold is one single, nested block per function. The Bumpy Road code smell is a function that contains multiple chunks of nested conditional logic. The deeper the nesting and the more bumps, the lower the code health.
} // namespace emergency_goal_manager
28 changes: 28 additions & 0 deletions system/emergency_goal_manager/src/emergency_goal_manager_node.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright 2023 Tier IV, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "emergency_goal_manager_core.hpp"

int main(int argc, char ** argv)

Check warning on line 17 in system/emergency_goal_manager/src/emergency_goal_manager_node.cpp

View check run for this annotation

Codecov / codecov/patch

system/emergency_goal_manager/src/emergency_goal_manager_node.cpp#L17

Added line #L17 was not covered by tests
{
rclcpp::init(argc, argv);
rclcpp::executors::MultiThreadedExecutor executor;

Check warning on line 20 in system/emergency_goal_manager/src/emergency_goal_manager_node.cpp

View check run for this annotation

Codecov / codecov/patch

system/emergency_goal_manager/src/emergency_goal_manager_node.cpp#L19-L20

Added lines #L19 - L20 were not covered by tests
auto node = std::make_shared<emergency_goal_manager::EmergencyGoalManager>();
executor.add_node(node);
executor.spin();
executor.remove_node(node);
rclcpp::shutdown();

Check warning on line 25 in system/emergency_goal_manager/src/emergency_goal_manager_node.cpp

View check run for this annotation

Codecov / codecov/patch

system/emergency_goal_manager/src/emergency_goal_manager_node.cpp#L22-L25

Added lines #L22 - L25 were not covered by tests

return 0;
}

Check warning on line 28 in system/emergency_goal_manager/src/emergency_goal_manager_node.cpp

View check run for this annotation

Codecov / codecov/patch

system/emergency_goal_manager/src/emergency_goal_manager_node.cpp#L28

Added line #L28 was not covered by tests
15 changes: 15 additions & 0 deletions system/mrm_pull_over_manager/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 3.14)
project(mrm_pull_over_manager)

find_package(autoware_cmake REQUIRED)
autoware_package()

ament_auto_add_executable(mrm_pull_over_manager
src/mrm_pull_over_manager/mrm_pull_over_manager_node.cpp
src/mrm_pull_over_manager/mrm_pull_over_manager_core.cpp
)

ament_auto_package(INSTALL_TO_SHARE
launch
config
)
Loading
Loading