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(rerouting-static-obstacle): rerouting static obstacle using a selected point by the user #4524

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
ea20186
feat(rerouting-static-obstacle): proposed solution for rerouting stat…
ahmeddesokyebrahim Aug 7, 2023
a432f80
feat(rerouting-static-obstacle): fixing cpp lint errors
ahmeddesokyebrahim Aug 8, 2023
7c29ef2
feat(rerouting-static-obstacle): fixing cpp lint errors
ahmeddesokyebrahim Aug 8, 2023
7acd51d
feat(rerouting-static-obstacle): adding dedicated plugin for publish …
ahmeddesokyebrahim Aug 10, 2023
e531834
style(pre-commit): autofix
pre-commit-ci[bot] Aug 10, 2023
a81dbaf
feat(reroute-static-obstacle): refactoring and cleaning-up
ahmeddesokyebrahim Aug 10, 2023
3092be6
feat(reroute-static-obstacle): fixing review comments
ahmeddesokyebrahim Aug 15, 2023
4d3fac5
style(pre-commit): autofix
pre-commit-ci[bot] Aug 15, 2023
997b056
feat(reroute-static-obstacle): fixing review comments
ahmeddesokyebrahim Aug 15, 2023
dc3a6bd
feat(rerouting-static-obstacle): fixing review comments
ahmeddesokyebrahim Aug 15, 2023
8958519
feat(rerout-static-obstacle): fixing review comments - adding descrip…
ahmeddesokyebrahim Aug 15, 2023
b0382b1
style(pre-commit): autofix
pre-commit-ci[bot] Aug 15, 2023
984a0f4
feat(reroute-static-obstacle): fixing typo
ahmeddesokyebrahim Aug 15, 2023
5f16546
feat(rerouting-static-obstacle): add steps for using the plugin in re…
ahmeddesokyebrahim Aug 16, 2023
f512dfb
feat(rerouting-static-obstacle): adding a note for rerouting limitation
ahmeddesokyebrahim Aug 16, 2023
521b75c
style(pre-commit): autofix
pre-commit-ci[bot] Aug 16, 2023
c181feb
feat(rerouting-static-obstacle): fixing review comments
Aug 23, 2023
53a1f3e
feat(rerouting-static-obstacle): fixing review comment - using select…
Sep 1, 2023
e072fa1
feat(rerouting-static-obstacle): adding header for point stamped
Sep 14, 2023
84f2607
style(pre-commit): autofix
pre-commit-ci[bot] Sep 14, 2023
ab38caa
feat(reroute-static-obstacle): fixing compilation issues after branch…
Dec 8, 2023
ec92fc4
style(pre-commit): autofix
pre-commit-ci[bot] Dec 8, 2023
69f7c33
feat(reroute-static-obstacle): fixing compilation issue after api cha…
Mar 8, 2024
aca5be2
style(pre-commit): autofix
pre-commit-ci[bot] Mar 8, 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
5 changes: 3 additions & 2 deletions common/tier4_planning_rviz_plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ project(tier4_planning_rviz_plugin)

find_package(autoware_cmake REQUIRED)
autoware_package()

find_package(Qt5 REQUIRED Core Widgets)
set(QT_LIBRARIES Qt5::Widgets)
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_definitions(-DQT_NO_KEYWORDS)
find_package(Eigen3 REQUIRED)

include_directories(
Comment on lines 7 to 12

Choose a reason for hiding this comment

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

Image description CodeRabbit

The add_definitions(-DQT_NO_KEYWORDS) line is missing in the new hunk. Please add it back to the CMakeLists.txt file.

+add_definitions(-DQT_NO_KEYWORDS)

Copy link
Contributor Author

@ahmeddesokyebrahim ahmeddesokyebrahim Aug 15, 2023

Choose a reason for hiding this comment

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

The removal of this line is intended and needed as this definition leads to the usage of QSLOTS instead of slots and the file <rviz_rendering/render_window.hpp> is using slots. With using this definition, the new plugin is not compiling.

Expand All @@ -28,6 +26,9 @@ ament_auto_add_library(tier4_planning_rviz_plugin SHARED
src/mission_checkpoint/mission_checkpoint.cpp
src/tools/jsk_overlay_utils.cpp
src/tools/max_velocity.cpp
# reroute static obstacle
include/reroute_static_obstacle/reroute_static_obstacle_plugin.hpp
src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp
Comment on lines +30 to +31

Choose a reason for hiding this comment

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

Image description CodeRabbit

A new section for the "reroute static obstacle" feature has been added. Please ensure that the paths to the header and source files are correct.

+   # reroute static obstacle
+   include/reroute_static_obstacle/reroute_static_obstacle_plugin.hpp
+   src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp

)

target_link_libraries(tier4_planning_rviz_plugin
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
// 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.
/*
* Software License Agreement (BSD License)
*
* Copyright (c) 2012, Willow Garage, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Willow Garage, Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef REROUTE_STATIC_OBSTACLE__REROUTE_STATIC_OBSTACLE_PLUGIN_HPP_
#define REROUTE_STATIC_OBSTACLE__REROUTE_STATIC_OBSTACLE_PLUGIN_HPP_

#include "rclcpp/qos.hpp"
#include "rviz_common/interaction/view_picker_iface.hpp"
#include "rviz_common/load_resource.hpp"
#include "rviz_common/msg_conversions.hpp"
#include "rviz_common/properties/bool_property.hpp"
#include "rviz_common/properties/qos_profile_property.hpp"
#include "rviz_common/properties/string_property.hpp"
#include "rviz_common/render_panel.hpp"
#include "rviz_common/view_controller.hpp"
#include "rviz_common/viewport_mouse_event.hpp"
#include "rviz_default_plugins/tools/point/point_tool.hpp"

#include <rviz_common/display_context.hpp>

#include <OgreVector.h>
#include <OgreVector3.h>

#include <algorithm>
#include <memory>
#include <optional>
#include <sstream>
#include <vector>

namespace rviz_plugins
{

class RerouteStaticObstaclePointPublish : public rviz_default_plugins::tools::PointTool
{
public:
RerouteStaticObstaclePointPublish();
void onInitialize() override;

void activate() override;
void deactivate() override;

int processMouseEvent(rviz_common::ViewportMouseEvent & event) override;

public Q_SLOTS:
void updateTopic();
void updateAutoDeactivate();

protected:
void publishPosition(const Ogre::Vector3 & position) const;
void setStatusForPosition(const Ogre::Vector3 & position);

rclcpp::QoS qos_profile_;

private:
std::optional<Ogre::Vector3> get_point_from_mouse(rviz_common::ViewportMouseEvent & event);
};
} // namespace rviz_plugins
#endif // REROUTE_STATIC_OBSTACLE__REROUTE_STATIC_OBSTACLE_PLUGIN_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,8 @@
type="rviz_plugins::MissionCheckpointTool"
base_class_type="rviz_common::Tool">
</class>
<class name="rviz_plugins/RerouteStaticObstaclePointPublish"
type="rviz_plugins::RerouteStaticObstaclePointPublish"
base_class_type="rviz_common::Tool">
</class>
</library>
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
// 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.
/*
* Copyright (c) 2013, Willow Garage, Inc.
* Copyright (c) 2018, Bosch Software Innovations GmbH.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the Willow Garage, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <reroute_static_obstacle/reroute_static_obstacle_plugin.hpp>
#include <rviz_common/render_panel.hpp>
#include <rviz_rendering/render_window.hpp>

#include <geometry_msgs/msg/point_stamped.hpp>

#include <OgreCamera.h>
#include <OgreRay.h>
#include <OgreViewport.h>

namespace rviz_plugins
{

RerouteStaticObstaclePointPublish::RerouteStaticObstaclePointPublish() : qos_profile_(5)

Check warning on line 56 in common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp#L56

Added line #L56 was not covered by tests
{
topic_property_ = new rviz_common::properties::StringProperty(

Check warning on line 58 in common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp#L58

Added line #L58 was not covered by tests
"Topic", "/simulation/planning/reroute_static_obstacle_point_publisher/point",
"The topic on which to publish points.", getPropertyContainer(), SLOT(updateTopic()), this);

Check warning on line 60 in common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp#L60

Added line #L60 was not covered by tests
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like this plugin can be used on the actual device as well as simulation. If so, it would be better to change the namespace.

for exmale, we have topic name whose name space is /rviz like /rviz/routing/pose.

https://github.com/autowarefoundation/autoware.universe/blob/main/common/tier4_adapi_rviz_plugin/README.md#L6


auto_deactivate_property_ = new rviz_common::properties::BoolProperty(
"Single click", true, "Switch away from this tool after one click.", getPropertyContainer(),
SLOT(updateAutoDeactivate()), this);

Check warning on line 64 in common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp#L62-L64

Added lines #L62 - L64 were not covered by tests

qos_profile_property_ =
new rviz_common::properties::QosProfileProperty(topic_property_, qos_profile_);
}

Check warning on line 68 in common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp#L66-L68

Added lines #L66 - L68 were not covered by tests

void RerouteStaticObstaclePointPublish::onInitialize()

Check warning on line 70 in common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp#L70

Added line #L70 was not covered by tests
{
qos_profile_property_->initialize([this](rclcpp::QoS profile) { this->qos_profile_ = profile; });
updateTopic();
}

Check warning on line 74 in common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp#L72-L74

Added lines #L72 - L74 were not covered by tests

void RerouteStaticObstaclePointPublish::activate()

Check warning on line 76 in common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp#L76

Added line #L76 was not covered by tests
{
}

Check warning on line 78 in common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp#L78

Added line #L78 was not covered by tests

void RerouteStaticObstaclePointPublish::deactivate()

Check warning on line 80 in common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp#L80

Added line #L80 was not covered by tests
{
}

Check warning on line 82 in common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp#L82

Added line #L82 was not covered by tests

void RerouteStaticObstaclePointPublish::updateTopic()

Check warning on line 84 in common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp#L84

Added line #L84 was not covered by tests
{
rclcpp::Node::SharedPtr raw_node = context_->getRosNodeAbstraction().lock()->get_raw_node();
publisher_ = raw_node->template create_publisher<geometry_msgs::msg::PointStamped>(
topic_property_->getStdString(), qos_profile_);
clock_ = raw_node->get_clock();
}

Check warning on line 90 in common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp#L86-L90

Added lines #L86 - L90 were not covered by tests

void RerouteStaticObstaclePointPublish::updateAutoDeactivate()

Check warning on line 92 in common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp#L92

Added line #L92 was not covered by tests
{
}

Check warning on line 94 in common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp#L94

Added line #L94 was not covered by tests

int RerouteStaticObstaclePointPublish::processMouseEvent(rviz_common::ViewportMouseEvent & event)

Check warning on line 96 in common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp#L96

Added line #L96 was not covered by tests
{
int flags = 0;
if (event.leftUp()) {
const auto point = get_point_from_mouse(event);
if (point) {
setStatusForPosition(point.value());
publishPosition(point.value());
if (auto_deactivate_property_->getBool()) {

Check warning on line 104 in common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp#L99-L104

Added lines #L99 - L104 were not covered by tests
flags |= Finished;
}
}
}

return flags;

Check warning on line 110 in common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp#L110

Added line #L110 was not covered by tests
}

void RerouteStaticObstaclePointPublish::setStatusForPosition(const Ogre::Vector3 & position)

Check warning on line 113 in common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp#L113

Added line #L113 was not covered by tests
{
std::ostringstream s;
s << "<b>Left-Click:</b> Select this point.";

Check warning on line 116 in common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp#L115-L116

Added lines #L115 - L116 were not covered by tests
s.precision(3);
s << " [" << position.x << "," << position.y << "," << position.z << "]";
setStatus(s.str().c_str());
}

Check warning on line 120 in common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp#L118-L120

Added lines #L118 - L120 were not covered by tests

void RerouteStaticObstaclePointPublish::publishPosition(const Ogre::Vector3 & position) const

Check warning on line 122 in common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp#L122

Added line #L122 was not covered by tests
{
auto point = rviz_common::pointOgreToMsg(position);
geometry_msgs::msg::PointStamped point_stamped;
point_stamped.point = point;
point_stamped.header.frame_id = context_->getFixedFrame().toStdString();
point_stamped.header.stamp = clock_->now();
publisher_->publish(point_stamped);
}

Check warning on line 130 in common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp#L126-L130

Added lines #L126 - L130 were not covered by tests

std::optional<Ogre::Vector3> RerouteStaticObstaclePointPublish::get_point_from_mouse(

Check warning on line 132 in common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp#L132

Added line #L132 was not covered by tests
rviz_common::ViewportMouseEvent & event)
{
using rviz_rendering::RenderWindowOgreAdapter;
const auto viewport = RenderWindowOgreAdapter::getOgreViewport(event.panel->getRenderWindow());
const auto w = viewport->getActualWidth();
const auto h = viewport->getActualHeight();
const auto x = static_cast<Ogre::Real>(event.x) / static_cast<Ogre::Real>(w);
const auto y = static_cast<Ogre::Real>(event.y) / static_cast<Ogre::Real>(h);

Check warning on line 140 in common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp#L136-L140

Added lines #L136 - L140 were not covered by tests

const auto plane = Ogre::Plane(Ogre::Vector3::UNIT_Z, 0.0);
const auto ray = viewport->getCamera()->getCameraToViewportRay(x, y);
const auto intersect = ray.intersects(plane);
return intersect.first ? std::optional(ray.getPoint(intersect.second)) : std::nullopt;

Check warning on line 145 in common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp#L143-L145

Added lines #L143 - L145 were not covered by tests
}

} // namespace rviz_plugins

#include <pluginlib/class_list_macros.hpp> // NOLINT
PLUGINLIB_EXPORT_CLASS(rviz_plugins::RerouteStaticObstaclePointPublish, rviz_common::Tool)

Check warning on line 151 in common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_planning_rviz_plugin/src/reroute_static_obstacle/reroute_static_obstacle_plugin.cpp#L151

Added line #L151 was not covered by tests
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@
<group>
<include file="$(find-pkg-share mission_planner)/launch/goal_pose_visualizer.launch.xml"/>
</group>

<group>
<include file="$(find-pkg-share mission_planner)/launch/rerouting_static_obstacle.launch.xml"/>
</group>
</launch>
9 changes: 9 additions & 0 deletions planning/mission_planner/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ rclcpp_components_register_node(goal_pose_visualizer_component
EXECUTABLE goal_pose_visualizer
)

ament_auto_add_library(rerouting_static_obstacle_component SHARED
src/rerouting_static_obstacle/rerouting_static_obstacle.cpp
)

rclcpp_components_register_node(rerouting_static_obstacle_component
PLUGIN "mission_planner::ReroutingStaticObstacle"
EXECUTABLE rerouting_static_obstacle
)
Comment on lines +16 to +23

Choose a reason for hiding this comment

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

Image description CodeRabbit

The rerouting_static_obstacle_component is added without any error handling or validation. It's important to handle potential errors during component registration. Additionally, it would be beneficial to add comments explaining the purpose of each added component and executable.

+ament_auto_add_library(rerouting_static_obstacle_component SHARED
+  src/rerouting_static_obstacle/rerouting_static_obstacle.cpp
+)
+
+rclcpp_components_register_node(rerouting_static_obstacle_component
+  PLUGIN "mission_planner::ReroutingStaticObstacle"
+  EXECUTABLE rerouting_static_obstacle
+)


ament_auto_add_library(${PROJECT_NAME}_component SHARED
src/mission_planner/arrival_checker.cpp
src/mission_planner/service_utils.cpp
Expand Down
24 changes: 24 additions & 0 deletions planning/mission_planner/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,30 @@ This interface for the MRM that pulls over the road shoulder. It has to be stopp
This is a goal change to pull over, avoid parked vehicles, and so on by a planning component. If the modified goal is outside the calculated route, a reroute is required. This goal modification is executed by checking the local environment and path safety as the vehicle actually approaches the destination. And this modification is allowed for both normal_route and mrm_route.
The new route generated here is sent to the AD API so that it can also be referenced by the application. Note, however, that the specifications here are subject to change in the future.

#### Rerouting Static Obstacle

`Rerouting Static Obstacle` is a node under `Mission Planner` that aims to change the planned route of the current already set route by finding an alternative route to the shortest planned one.
The `Rerouting Static Obstacle` use-cases can be rerouting for a vehicle that is blocking the road, road construction that blocks some lanes, or any other similar scenarios of dynamic map information.

The way that `Rerouting Static Obstacle` node is working currently is that, when the human driver/operator notices a blockage during the planned route of the mission, s/he points in the map (using a dedicated plugin in rviz) where the blockage is. Then `Rerouting Static Obstacle` searches for alternative routes and if successfully found it calls `change_route` API.
Copy link
Contributor

Choose a reason for hiding this comment

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

I apologize very much for the very late review.
The change_route api will be removed as it has the same message type as set_route.

This rerouting node needs to be updated as well.
We will need to coordinate whether to merge the PRs first for both. cc @isamu-takagi


The following diagram shows how `Rerouting Static Obstacle` node works in high level :

<p align="center">
<img src=./media/rerouting-static-obstacle_flowchart.svg />
</p>

Reference implementation for `Rerouting Static Obstacle` node is under `src/rerouting_static_obstacle`

##### How to enable rerouting static obstacle plugin ?

1. In rviz using the add plugin sign, then under `tier4_planning_rviz_plugin`, add the `RerouteStaticObstaclePointPublish` plugin
2. Make the plugin visible for ease of use
3. Select a point through the route of the vehicle (where you see a blockage for example)
4. If an alternative route can be found, the vehicle will to change route and will not go through the selected point.

> Make sure that you select the point for rerouting with enough distance ahead the vehicle, otherwise the rerouting will be considered unsafe. For more information, please check the Rerouting Limitations section below and `mission_planner.param.yaml` config file.

#### Rerouting Limitations

- The safety judgment of rerouting is not guaranteed to the level of trajectory or control. Therefore, the distance to the reroute change must be large for the safety.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<launch>
<arg name="odometry_topic_name" default="/localization/kinematic_state"/>
<arg name="route_topic_name" default="/planning/mission_planning/route"/>
<arg name="map_topic_name" default="/map/vector_map"/>
<arg name="reroute_point_topic_name" default="/simulation/planning/reroute_static_obstacle_point_publisher/point"/>

<node pkg="mission_planner" exec="rerouting_static_obstacle" name="rerouting_static_obstacle" output="screen">
<remap from="input/odometry" to="$(var odometry_topic_name)"/>
<remap from="input/route" to="$(var route_topic_name)"/>
<remap from="input/vector_map" to="$(var map_topic_name)"/>
<remap from="input/reroute_point" to="$(var reroute_point_topic_name)"/>
</node>
</launch>
Loading
Loading