-
Notifications
You must be signed in to change notification settings - Fork 668
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(interest_objects_marker_interface): add interest objects marker …
…interface Signed-off-by: Fumiya Watanabe <[email protected]>
- Loading branch information
Showing
8 changed files
with
227 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
cmake_minimum_required(VERSION 3.5) | ||
project(interest_objects_marker_interface) | ||
|
||
### Compile options | ||
if(NOT CMAKE_CXX_STANDARD) | ||
set(CMAKE_CXX_STANDARD 17) | ||
endif() | ||
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") | ||
add_compile_options(-Wall -Wextra -Wpedantic -Werror) | ||
endif() | ||
|
||
find_package(ament_cmake_auto REQUIRED) | ||
ament_auto_find_build_dependencies() | ||
|
||
ament_auto_add_library(interest_objects_marker_interface SHARED | ||
src/interest_objects_marker_interface.cpp | ||
) | ||
|
||
# Test | ||
if(BUILD_TESTING) | ||
find_package(ament_lint_auto REQUIRED) | ||
ament_lint_auto_find_test_dependencies() | ||
endif() | ||
|
||
ament_auto_package() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Interest Objects Marker Interface | ||
|
||
## Purpose | ||
|
||
## Inner-workings / Algorithms | ||
|
||
## Inputs / Outputs | ||
|
||
## Assumptions / Known limits | ||
|
||
## Future extensions / Unimplemented parts |
61 changes: 61 additions & 0 deletions
61
...interface/include/interest_objects_marker_interface/interest_objects_marker_interface.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// 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. | ||
|
||
#ifndef INTEREST_OBJECTS_MARKER_INTERFACE__INTEREST_OBJECTS_MARKER_INTERFACE_HPP_ | ||
#define INTEREST_OBJECTS_MARKER_INTERFACE__INTEREST_OBJECTS_MARKER_INTERFACE_HPP_ | ||
#include "rclcpp/rclcpp.hpp" | ||
|
||
#include <tier4_autoware_utils/ros/marker_helper.hpp> | ||
|
||
#include <geometry_msgs/msg/pose.hpp> | ||
#include <visualization_msgs/msg/marker_array.hpp> | ||
|
||
#include <mutex> | ||
#include <string> | ||
#include <vector> | ||
|
||
namespace interest_objects_marker_interface | ||
{ | ||
using geometry_msgs::msg::Pose; | ||
using visualization_msgs::msg::Marker; | ||
using visualization_msgs::msg::MarkerArray; | ||
|
||
struct ObjectStatus | ||
{ | ||
Pose pose{}; | ||
double height{0.0}; | ||
bool safe{false}; | ||
}; | ||
|
||
class InterestObjectsMarkerInterface | ||
{ | ||
public: | ||
InterestObjectsMarkerInterface(rclcpp::Node * node, const std::string & name); | ||
void insertObjectStatus(const Pose & pose, const double obj_height, const bool safe); | ||
void publishMarkerArray(); | ||
|
||
private: | ||
rclcpp::Publisher<MarkerArray>::SharedPtr pub_marker_; | ||
|
||
std::vector<ObjectStatus> obj_status_array_; | ||
|
||
std::string name_; | ||
std::string topic_namespace_ = "/planning/interest_objects_marker"; | ||
|
||
mutable std::mutex mutex_; | ||
}; | ||
|
||
} // namespace interest_objects_marker_interface | ||
|
||
#endif // INTEREST_OBJECTS_MARKER_INTERFACE__INTEREST_OBJECTS_MARKER_INTERFACE_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0"?> | ||
<package format="3"> | ||
<name>interest_objects_marker_interface</name> | ||
<version>0.1.0</version> | ||
<description>The interest_objects_marker_interface package</description> | ||
|
||
<maintainer email="[email protected]">Fumiya Watanabe</maintainer> | ||
|
||
<license>Apache License 2.0</license> | ||
|
||
<author email="[email protected]">Fumiya Watanabe</author> | ||
|
||
<buildtool_depend>ament_cmake_auto</buildtool_depend> | ||
|
||
<depend>geometry_msgs</depend> | ||
<depend>rclcpp</depend> | ||
<depend>tier4_autoware_utils</depend> | ||
<depend>visualization_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> |
85 changes: 85 additions & 0 deletions
85
planning/interest_objects_marker_interface/src/interest_objects_marker_interface.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// 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 "interest_objects_marker_interface/interest_objects_marker_interface.hpp" | ||
namespace | ||
{ | ||
using geometry_msgs::msg::Point; | ||
using geometry_msgs::msg::Pose; | ||
using interest_objects_marker_interface::ObjectStatus; | ||
using visualization_msgs::msg::Marker; | ||
|
||
using tier4_autoware_utils::createDefaultMarker; | ||
using tier4_autoware_utils::createMarkerColor; | ||
using tier4_autoware_utils::createMarkerScale; | ||
|
||
Marker createArrowMarker(const size_t & id, const ObjectStatus & status, const std::string & name) | ||
{ | ||
const float r = status.safe ? 0.0f : 0.75f; | ||
const float g = status.safe ? 0.75f : 0.0f; | ||
const float b = 0.0f; | ||
|
||
Marker marker = createDefaultMarker( | ||
"map", rclcpp::Clock{RCL_ROS_TIME}.now(), name, id, Marker::ARROW, | ||
createMarkerScale(0.25, 0.5, 0.5), createMarkerColor(r, g, b, 0.999)); | ||
|
||
Point src, dst; | ||
src = status.pose.position; | ||
src.z += status.height + 1.0; | ||
dst = status.pose.position; | ||
dst.z += status.height; | ||
|
||
marker.points.push_back(src); | ||
marker.points.push_back(dst); | ||
|
||
return marker; | ||
} | ||
} // namespace | ||
|
||
namespace interest_objects_marker_interface | ||
{ | ||
|
||
InterestObjectsMarkerInterface::InterestObjectsMarkerInterface( | ||
rclcpp::Node * node, const std::string & name) | ||
: name_{name} | ||
{ | ||
// Publisher | ||
pub_marker_ = node->create_publisher<MarkerArray>(topic_namespace_ + "/" + name, 1); | ||
} | ||
|
||
void InterestObjectsMarkerInterface::insertObjectStatus( | ||
const Pose & pose, const double obj_height, const bool safe) | ||
{ | ||
ObjectStatus status; | ||
status.pose = pose; | ||
status.height = obj_height; | ||
status.safe = safe; | ||
|
||
obj_status_array_.push_back(status); | ||
} | ||
|
||
void InterestObjectsMarkerInterface::publishMarkerArray() | ||
{ | ||
MarkerArray marker_array; | ||
for (size_t i = 0; i < obj_status_array_.size(); ++i) { | ||
const auto obj = obj_status_array_.at(i); | ||
const Marker marker = createArrowMarker(i, obj, name_); | ||
marker_array.markers.push_back(marker); | ||
} | ||
|
||
pub_marker_->publish(marker_array); | ||
obj_status_array_.clear(); | ||
} | ||
|
||
} // namespace interest_objects_marker_interface |