Skip to content

Commit 3b34d39

Browse files
feat: port autoware_perception_rviz_plugin from Autoware Universe (#6)
Signed-off-by: Ryohsuke Mitsudome <ryohsuke.mitsudome@tier4.jp> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 064a21a commit 3b34d39

22 files changed

Lines changed: 3178 additions & 0 deletions
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
cmake_minimum_required(VERSION 3.14)
2+
project(autoware_perception_rviz_plugin)
3+
4+
find_package(autoware_cmake REQUIRED)
5+
autoware_package()
6+
7+
find_package(Qt5 REQUIRED COMPONENTS Widgets)
8+
9+
set(OD_PLUGIN_LIB_SRC
10+
src/object_detection/detected_objects_display.cpp
11+
src/object_detection/tracked_objects_display.cpp
12+
src/object_detection/predicted_objects_display.cpp
13+
)
14+
15+
set(OD_PLUGIN_LIB_HEADERS
16+
include/autoware_perception_rviz_plugin/visibility_control.hpp
17+
)
18+
set(OD_PLUGIN_LIB_HEADERS_TO_WRAP
19+
include/autoware_perception_rviz_plugin/object_detection/detected_objects_display.hpp
20+
include/autoware_perception_rviz_plugin/object_detection/tracked_objects_display.hpp
21+
include/autoware_perception_rviz_plugin/object_detection/predicted_objects_display.hpp
22+
)
23+
24+
set(COMMON_HEADERS
25+
include/autoware_perception_rviz_plugin/common/color_alpha_property.hpp
26+
include/autoware_perception_rviz_plugin/object_detection/object_polygon_detail.hpp
27+
include/autoware_perception_rviz_plugin/object_detection/object_polygon_display_base.hpp
28+
)
29+
30+
set(COMMON_SRC
31+
src/common/color_alpha_property.cpp
32+
src/object_detection/object_polygon_detail.cpp
33+
)
34+
35+
foreach(header "${OD_PLUGIN_LIB_HEADERS_TO_WRAP}")
36+
qt5_wrap_cpp(OD_PLUGIN_LIB_HEADERS_MOC "${header}")
37+
endforeach()
38+
39+
ament_auto_add_library(${PROJECT_NAME} SHARED
40+
${COMMON_HEADERS}
41+
${COMMON_SRC}
42+
${OD_PLUGIN_LIB_HEADERS}
43+
${OD_PLUGIN_LIB_HEADERS_MOC}
44+
${OD_PLUGIN_LIB_SRC}
45+
)
46+
target_link_libraries(${PROJECT_NAME}
47+
rviz_common::rviz_common
48+
Qt5::Widgets
49+
)
50+
target_include_directories(${PROJECT_NAME} PRIVATE include)
51+
52+
# Settings to improve the build as suggested on https://github.com/ros2/rviz/blob/ros2/docs/plugin_development.md
53+
target_compile_definitions(${PROJECT_NAME} PUBLIC "PLUGINLIB__DISABLE_BOOST_FUNCTIONS")
54+
target_compile_definitions(${PROJECT_NAME} PRIVATE "OBJECT_DETECTION_PLUGINS_BUILDING_LIBRARY")
55+
56+
# Export the plugin to be imported by rviz2
57+
pluginlib_export_plugin_description_file(rviz_common plugins_description.xml)
58+
59+
ament_auto_package(
60+
INSTALL_TO_SHARE
61+
icons
62+
)
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# autoware_perception_rviz_plugin
2+
3+
## Purpose
4+
5+
It is an rviz plugin for visualizing the result from perception module. This package is based on the implementation of the rviz plugin developed by Autoware.Auto.
6+
7+
See Autoware.Auto design documentation for the original design philosophy. [[1]](https://gitlab.com/autowarefoundation/autoware.auto/AutowareAuto/-/blob/master/src/tools/visualization/autoware_rviz_plugins)
8+
9+
<!-- Write the purpose of this package and briefly describe the features.
10+
11+
Example:
12+
{package_name} is a package for planning trajectories that can avoid obstacles.
13+
This feature consists of two steps: obstacle filtering and optimizing trajectory.
14+
-->
15+
16+
## Input Types / Visualization Results
17+
18+
### DetectedObjects
19+
20+
#### Input Types
21+
22+
| Name | Type | Description |
23+
| ---- | ------------------------------------------------ | ---------------------- |
24+
| | `autoware_perception_msgs::msg::DetectedObjects` | detection result array |
25+
26+
#### Visualization Result
27+
28+
![detected-object-visualization-description](./images/detected-object-visualization-description.jpg)
29+
30+
### TrackedObjects
31+
32+
#### Input Types
33+
34+
| Name | Type | Description |
35+
| ---- | ----------------------------------------------- | --------------------- |
36+
| | `autoware_perception_msgs::msg::TrackedObjects` | tracking result array |
37+
38+
#### Visualization Result
39+
40+
Overwrite tracking results with detection results.
41+
42+
![tracked-object-visualization-description](./images/tracked-object-visualization-description.jpg)
43+
44+
### PredictedObjects
45+
46+
#### Input Types
47+
48+
| Name | Type | Description |
49+
| ---- | ------------------------------------------------- | ----------------------- |
50+
| | `autoware_perception_msgs::msg::PredictedObjects` | prediction result array |
51+
52+
#### Visualization Result
53+
54+
Overwrite prediction results with tracking results.
55+
56+
![predicted-object-visualization-description](./images/predicted-object-visualization-description.jpg)
57+
58+
## References/External links
59+
60+
[1] <https://gitlab.com/autowarefoundation/autoware.auto/AutowareAuto/-/tree/master/src/tools/visualization/autoware_rviz_plugins>
61+
62+
## Future extensions / Unimplemented parts
18.4 KB
Loading
18.4 KB
Loading
18.4 KB
Loading
15.6 KB
Loading
29.5 KB
Loading
28.4 KB
Loading
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// Copyright 2021 Apex.AI, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
#ifndef AUTOWARE_PERCEPTION_RVIZ_PLUGIN__COMMON__COLOR_ALPHA_PROPERTY_HPP_
15+
#define AUTOWARE_PERCEPTION_RVIZ_PLUGIN__COMMON__COLOR_ALPHA_PROPERTY_HPP_
16+
17+
#include "autoware_perception_rviz_plugin/visibility_control.hpp"
18+
19+
#include <rviz_common/display.hpp>
20+
#include <rviz_common/properties/color_property.hpp>
21+
#include <rviz_common/properties/float_property.hpp>
22+
23+
#include <std_msgs/msg/color_rgba.hpp>
24+
25+
#include <memory>
26+
27+
namespace autoware
28+
{
29+
namespace rviz_plugins
30+
{
31+
namespace common
32+
{
33+
/// \brief Class to define Color and Alpha values as plugin properties
34+
class AUTOWARE_PERCEPTION_RVIZ_PLUGIN_PUBLIC ColorAlphaProperty
35+
{
36+
public:
37+
/// \brief Constructor
38+
/// \param color_default Default value for color property
39+
/// \param alpha_default Default value for alpha property
40+
/// \param parent_property Parent property for the color and alpha properties. Memory managed
41+
/// by the caller
42+
ColorAlphaProperty(
43+
const QColor & color_default, const float alpha_default,
44+
rviz_common::properties::Property * parent_property);
45+
46+
/// \brief Convert color and alpha to ColorRGBA type
47+
/// \return color and alpha values as ColorRGBA type
48+
operator std_msgs::msg::ColorRGBA() const;
49+
50+
private:
51+
rviz_common::properties::ColorProperty m_color_property;
52+
rviz_common::properties::FloatProperty m_alpha_property;
53+
};
54+
55+
} // namespace common
56+
} // namespace rviz_plugins
57+
} // namespace autoware
58+
59+
#endif // AUTOWARE_PERCEPTION_RVIZ_PLUGIN__COMMON__COLOR_ALPHA_PROPERTY_HPP_
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright 2021 Apex.AI, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
#ifndef AUTOWARE_PERCEPTION_RVIZ_PLUGIN__OBJECT_DETECTION__DETECTED_OBJECTS_DISPLAY_HPP_
15+
#define AUTOWARE_PERCEPTION_RVIZ_PLUGIN__OBJECT_DETECTION__DETECTED_OBJECTS_DISPLAY_HPP_
16+
17+
#include "autoware_perception_rviz_plugin/object_detection/object_polygon_display_base.hpp"
18+
19+
#include <autoware_perception_msgs/msg/detected_objects.hpp>
20+
21+
namespace autoware
22+
{
23+
namespace rviz_plugins
24+
{
25+
namespace object_detection
26+
{
27+
/// \brief Class defining rviz plugin to visualize DetectedObjects
28+
class AUTOWARE_PERCEPTION_RVIZ_PLUGIN_PUBLIC DetectedObjectsDisplay
29+
: public ObjectPolygonDisplayBase<autoware_perception_msgs::msg::DetectedObjects>
30+
{
31+
Q_OBJECT
32+
33+
public:
34+
using DetectedObjects = autoware_perception_msgs::msg::DetectedObjects;
35+
36+
DetectedObjectsDisplay();
37+
38+
private:
39+
void processMessage(DetectedObjects::ConstSharedPtr msg) override;
40+
};
41+
42+
} // namespace object_detection
43+
} // namespace rviz_plugins
44+
} // namespace autoware
45+
46+
#endif // AUTOWARE_PERCEPTION_RVIZ_PLUGIN__OBJECT_DETECTION__DETECTED_OBJECTS_DISPLAY_HPP_

0 commit comments

Comments
 (0)