Skip to content

Commit 959de0c

Browse files
JonasKrugJonas Krugpre-commit-ci[bot]mitsudome-r
authored
feat(autoware_perception_rviz_plugin): object mesh marker visualization (#32)
* Add meshes with license Signed-off-by: Jonas Krug <jonas.krug@dai-labor.de> * Modify cmake Signed-off-by: Jonas Krug <jonas.krug@dai-labor.de> * Modify code for mesh, vehicle light and prediction with offset visualization Signed-off-by: Jonas Krug <jonas.krug@dai-labor.de> * Update license and readme Signed-off-by: Jonas Krug <jonas.krug@dai-labor.de> * Update license reference in readme Signed-off-by: Jonas Krug <jonas.krug@dai-labor.de> * Update license in package.xml Signed-off-by: Jonas Krug <jonas.krug@dai-labor.de> * Fix casting style Signed-off-by: Jonas Krug <jonas.krug@dai-labor.de> * Add missing import Signed-off-by: Jonas Krug <jonas.krug@dai-labor.de> * style(pre-commit): autofix Signed-off-by: Jonas Krug <jonas.krug@dai-labor.de> * style(pre-commit): autofix Signed-off-by: Jonas Krug <jonas.krug@dai-labor.de> * style(pre-commit): autofix * Ignore certain spell checks Signed-off-by: Jonas Krug <jonas.krug@dai-labor.de> * fix skipping of cspell check for LICENSE file Signed-off-by: Ryohsuke Mitsudome <ryohsuke.mitsudome@tier4.jp> --------- Signed-off-by: Jonas Krug <jonas.krug@dai-labor.de> Signed-off-by: Ryohsuke Mitsudome <ryohsuke.mitsudome@tier4.jp> Co-authored-by: Jonas Krug <jonas.krug@dai-labor.de> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Ryohsuke Mitsudome <ryohsuke.mitsudome@tier4.jp>
1 parent df40247 commit 959de0c

35 files changed

Lines changed: 5246 additions & 20 deletions

autoware_perception_rviz_plugin/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,5 @@ pluginlib_export_plugin_description_file(rviz_common plugins_description.xml)
6767
ament_auto_package(
6868
INSTALL_TO_SHARE
6969
icons
70+
meshes
7071
)

autoware_perception_rviz_plugin/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,22 @@ Overwrite prediction results with tracking results.
5555

5656
![predicted-object-visualization-description](./images/predicted-object-visualization-description.jpg)
5757

58+
### Mesh Visualization
59+
60+
For all object types mentioned above it is possible to additionally visualize a mesh file for each object based on its class. For this the mesh namespace can be activated in RViz.
61+
For cars the visualization dynamically switches between a sedan and SUV model, based on the ratio between height and length.
62+
63+
#### Visualization Result
64+
65+
Visualization of only the mesh files for different vehicle types, pedestrians and cyclists.
66+
67+
![predicted-object-visualization-description](./images/mesh-object-visualization-description.jpg)
68+
69+
##### Customizable Features
70+
71+
- Set visualization offset for predicted objects (n steps in to the future)
72+
- Visualize vehicle lights (brake, left indicator, right indicator)
73+
5874
### TrafficLight
5975

6076
#### Input Types
@@ -83,6 +99,12 @@ The plugin visualizes traffic light states in two ways:
8399
- Timeout for stale data
84100
- Topic names for both input types
85101

102+
## Resources / License
103+
104+
<!-- cspell:ignore Preuße sebastianpreusse -->
105+
106+
The 3D models in the 'meshes' directory are provided by Sebastian Preuße ([LinkedIn](https://www.linkedin.com/in/sebastianpreusse), [sebastianpreusse.com](sebastianpreusse.com)) and are licensed under [Creative Commons Attribution-ShareAlike 4.0 International License](https://creativecommons.org/licenses/by-sa/4.0/legalcode.en).
107+
86108
## References/External links
87109

88110
[1] <https://gitlab.com/autowarefoundation/autoware.auto/AutowareAuto/-/tree/master/src/tools/visualization/autoware_rviz_plugins>
120 KB
Loading

autoware_perception_rviz_plugin/include/autoware_perception_rviz_plugin/object_detection/object_polygon_detail.hpp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <geometry_msgs/msg/twist.hpp>
3232
#include <geometry_msgs/msg/twist_with_covariance.hpp>
3333
#include <visualization_msgs/msg/marker.hpp>
34+
#include <visualization_msgs/msg/marker_array.hpp>
3435

3536
#include <algorithm>
3637
#include <map>
@@ -98,6 +99,18 @@ get_2d_shape_marker_ptr(
9899
const std_msgs::msg::ColorRGBA & color_rgba, const double & line_width,
99100
const bool & is_orientation_available = true);
100101

102+
AUTOWARE_PERCEPTION_RVIZ_PLUGIN_PUBLIC visualization_msgs::msg::Marker::SharedPtr
103+
get_mesh_marker_ptr(
104+
const autoware_perception_msgs::msg::Shape & shape_msg,
105+
const geometry_msgs::msg::Point & centroid, const geometry_msgs::msg::Quaternion & orientation,
106+
const std::vector<autoware_perception_msgs::msg::ObjectClassification> & classification);
107+
108+
AUTOWARE_PERCEPTION_RVIZ_PLUGIN_PUBLIC visualization_msgs::msg::MarkerArray::SharedPtr
109+
get_indicator_marker_ptr(
110+
const autoware_perception_msgs::msg::Shape & shape_msg,
111+
const geometry_msgs::msg::Point & centroid, const geometry_msgs::msg::Quaternion & orientation,
112+
const std::vector<autoware_perception_msgs::msg::ObjectClassification> & classification);
113+
101114
/// \brief Convert the given polygon into a marker representing the shape in 3d
102115
/// \param centroid Centroid position of the shape in Object.header.frame_id frame
103116
/// \return Marker ptr. Id and header will have to be set by the caller
@@ -277,9 +290,10 @@ AUTOWARE_PERCEPTION_RVIZ_PLUGIN_PUBLIC
277290
autoware_perception_msgs::msg::ObjectClassification::_label_type
278291
get_best_label(ClassificationContainerT labels, const std::string & logger_name)
279292
{
280-
const auto best_class_label = std::max_element(
281-
labels.begin(), labels.end(),
282-
[](const auto & a, const auto & b) -> bool { return a.probability < b.probability; });
293+
const auto best_class_label =
294+
std::max_element(labels.begin(), labels.end(), [](const auto & a, const auto & b) -> bool {
295+
return a.label >= 100 || (a.probability < b.probability && b.label < 100);
296+
}); // label > 100 is reserved for status labels
283297
if (best_class_label == labels.end()) {
284298
RCLCPP_WARN(
285299
rclcpp::get_logger(logger_name),

autoware_perception_rviz_plugin/include/autoware_perception_rviz_plugin/object_detection/object_polygon_display_base.hpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class AUTOWARE_PERCEPTION_RVIZ_PLUGIN_PUBLIC ObjectPolygonDisplayBase
5252
public:
5353
using Color = std::array<float, 3U>;
5454
using Marker = visualization_msgs::msg::Marker;
55+
using MarkerArray = visualization_msgs::msg::MarkerArray;
5556
using MarkerCommon = rviz_default_plugins::displays::MarkerCommon;
5657
using ObjectClassificationMsg = autoware_perception_msgs::msg::ObjectClassification;
5758
using RosTopicDisplay = rviz_common::RosTopicDisplay<MsgT>;
@@ -62,6 +63,10 @@ class AUTOWARE_PERCEPTION_RVIZ_PLUGIN_PUBLIC ObjectPolygonDisplayBase
6263
explicit ObjectPolygonDisplayBase(const std::string & default_topic)
6364
: m_marker_common(this),
6465
// m_display_type_property{"Polygon Type", "3d", "Type of the polygon to display object", this},
66+
m_display_mesh_property{
67+
"Display Mesh", false, "Enable/disable mesh visualization of the object", this},
68+
m_display_indicator_property{
69+
"Display Indicator", false, "Enable/disable indicator visualization of the object", this},
6570
m_display_label_property{"Display Label", true, "Enable/disable label visualization", this},
6671
m_display_uuid_property{"Display UUID", true, "Enable/disable uuid visualization", this},
6772
m_display_velocity_text_property{
@@ -217,6 +222,37 @@ class AUTOWARE_PERCEPTION_RVIZ_PLUGIN_PUBLIC ObjectPolygonDisplayBase
217222
const std_msgs::msg::ColorRGBA & color_rgba, const double & line_width,
218223
const bool & is_orientation_available);
219224

225+
template <typename ClassificationContainerT>
226+
std::optional<Marker::SharedPtr> get_mesh_marker_ptr(
227+
const autoware_perception_msgs::msg::Shape & shape_msg,
228+
const geometry_msgs::msg::Point & centroid, const geometry_msgs::msg::Quaternion & orientation,
229+
const ClassificationContainerT & labels) const
230+
{
231+
if (m_display_mesh_property.getBool()) {
232+
auto marker_ptr = detail::get_mesh_marker_ptr(shape_msg, centroid, orientation, labels);
233+
if (marker_ptr) {
234+
return marker_ptr;
235+
}
236+
}
237+
return std::nullopt;
238+
}
239+
240+
template <typename ClassificationContainerT>
241+
std::optional<MarkerArray::SharedPtr> get_indicator_marker_ptr(
242+
const autoware_perception_msgs::msg::Shape & shape_msg,
243+
const geometry_msgs::msg::Point & centroid, const geometry_msgs::msg::Quaternion & orientation,
244+
const ClassificationContainerT & labels) const
245+
{
246+
if (m_display_indicator_property.getBool()) {
247+
static const std::string kLoggerName("ObjectPolygonDisplayBase");
248+
auto marker_ptr = detail::get_indicator_marker_ptr(shape_msg, centroid, orientation, labels);
249+
if (marker_ptr) {
250+
return marker_ptr;
251+
}
252+
}
253+
return std::nullopt;
254+
}
255+
220256
/// \brief Convert given shape msg into a Marker to visualize label name
221257
/// \tparam ClassificationContainerT List type with ObjectClassificationMsg
222258
/// \param centroid Centroid position of the shape in Object.header.frame_id frame
@@ -534,6 +570,10 @@ class AUTOWARE_PERCEPTION_RVIZ_PLUGIN_PUBLIC ObjectPolygonDisplayBase
534570
rviz_common::properties::EnumProperty * m_display_type_property;
535571
// Property to choose simplicity of visualization polygon
536572
rviz_common::properties::EnumProperty * m_simple_visualize_mode_property;
573+
// Property to enable/disable mesh visualization of the object
574+
rviz_common::properties::BoolProperty m_display_mesh_property;
575+
// Property to enable/disable mesh visualization of the object
576+
rviz_common::properties::BoolProperty m_display_indicator_property;
537577
// Property to set confidence interval of state estimations
538578
rviz_common::properties::EnumProperty * m_confidence_interval_property;
539579
// Property to set visualization type

autoware_perception_rviz_plugin/include/autoware_perception_rviz_plugin/object_detection/predicted_objects_display.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
#include "autoware_perception_rviz_plugin/object_detection/object_polygon_display_base.hpp"
1818

19+
#include <rviz_common/properties/int_property.hpp>
20+
1921
#include <autoware_perception_msgs/msg/predicted_objects.hpp>
2022

2123
#include <boost/functional/hash.hpp>
@@ -127,6 +129,8 @@ class AUTOWARE_PERCEPTION_RVIZ_PLUGIN_PUBLIC PredictedObjectsDisplay
127129

128130
void update(float wall_dt, float ros_dt) override;
129131

132+
rviz_common::properties::IntProperty m_offset_property;
133+
130134
std::unordered_map<boost::uuids::uuid, int32_t, boost::hash<boost::uuids::uuid>> id_map;
131135
// std::unordered_map<boost::uuids::uuid, int32_t> id_map;
132136
std::list<int32_t> unused_marker_ids;

0 commit comments

Comments
 (0)