Skip to content

Commit da5646b

Browse files
committed
feat(autoware_auto_perception_rviz_plugin): bounding box orientation indication
Signed-off-by: Taekjin LEE <taekjin.lee@tier4.jp>
1 parent 5338c42 commit da5646b

File tree

2 files changed

+61
-1
lines changed

2 files changed

+61
-1
lines changed

common/autoware_auto_perception_rviz_plugin/include/autoware_auto_perception_rviz_plugin/object_detection/object_polygon_detail.hpp

+8
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,10 @@ AUTOWARE_AUTO_PERCEPTION_RVIZ_PLUGIN_PUBLIC void calc_bounding_box_direction_lin
186186
const autoware_auto_perception_msgs::msg::Shape & shape,
187187
std::vector<geometry_msgs::msg::Point> & points);
188188

189+
AUTOWARE_AUTO_PERCEPTION_RVIZ_PLUGIN_PUBLIC void calc_bounding_box_orientation_line_list(
190+
const autoware_auto_perception_msgs::msg::Shape & shape,
191+
std::vector<geometry_msgs::msg::Point> & points);
192+
189193
AUTOWARE_AUTO_PERCEPTION_RVIZ_PLUGIN_PUBLIC void calc_2d_bounding_box_bottom_line_list(
190194
const autoware_auto_perception_msgs::msg::Shape & shape,
191195
std::vector<geometry_msgs::msg::Point> & points);
@@ -194,6 +198,10 @@ AUTOWARE_AUTO_PERCEPTION_RVIZ_PLUGIN_PUBLIC void calc_2d_bounding_box_bottom_dir
194198
const autoware_auto_perception_msgs::msg::Shape & shape,
195199
std::vector<geometry_msgs::msg::Point> & points);
196200

201+
AUTOWARE_AUTO_PERCEPTION_RVIZ_PLUGIN_PUBLIC void calc_2d_bounding_box_bottom_orientation_line_list(
202+
const autoware_auto_perception_msgs::msg::Shape & shape,
203+
std::vector<geometry_msgs::msg::Point> & points);
204+
197205
AUTOWARE_AUTO_PERCEPTION_RVIZ_PLUGIN_PUBLIC void calc_cylinder_line_list(
198206
const autoware_auto_perception_msgs::msg::Shape & shape,
199207
std::vector<geometry_msgs::msg::Point> & points);

common/autoware_auto_perception_rviz_plugin/src/object_detection/object_polygon_detail.cpp

+53-1
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,8 @@ visualization_msgs::msg::Marker::SharedPtr get_shape_marker_ptr(
506506
calc_bounding_box_line_list(shape_msg, marker_ptr->points);
507507
if (is_orientation_available) {
508508
calc_bounding_box_direction_line_list(shape_msg, marker_ptr->points);
509+
} else {
510+
calc_bounding_box_orientation_line_list(shape_msg, marker_ptr->points);
509511
}
510512
} else if (shape_msg.type == Shape::CYLINDER) {
511513
marker_ptr->type = visualization_msgs::msg::Marker::LINE_LIST;
@@ -542,6 +544,8 @@ visualization_msgs::msg::Marker::SharedPtr get_2d_shape_marker_ptr(
542544
calc_2d_bounding_box_bottom_line_list(shape_msg, marker_ptr->points);
543545
if (is_orientation_available) {
544546
calc_2d_bounding_box_bottom_direction_line_list(shape_msg, marker_ptr->points);
547+
} else {
548+
calc_2d_bounding_box_bottom_orientation_line_list(shape_msg, marker_ptr->points);
545549
}
546550
} else if (shape_msg.type == Shape::CYLINDER) {
547551
marker_ptr->type = visualization_msgs::msg::Marker::LINE_LIST;
@@ -629,6 +633,30 @@ void calc_bounding_box_direction_line_list(
629633
calc_line_list_from_points(point_list, point_pairs, 5, points);
630634
}
631635

636+
void calc_bounding_box_orientation_line_list(
637+
const autoware_auto_perception_msgs::msg::Shape & shape,
638+
std::vector<geometry_msgs::msg::Point> & points)
639+
{
640+
const double length_half = shape.dimensions.x / 2.0;
641+
const double width_half = shape.dimensions.y / 2.0;
642+
const double height_half = shape.dimensions.z / 2.0;
643+
const double tick_width = width_half * 0.4;
644+
const double tick_length = std::min(tick_width * 1.4, length_half);
645+
geometry_msgs::msg::Point point;
646+
647+
// triangle-shaped direction indicator
648+
const double point_list[3][3] = {
649+
{length_half, 0, height_half},
650+
{length_half - tick_length, tick_width, height_half},
651+
{length_half - tick_length, -tick_width, height_half},
652+
};
653+
const int point_pairs[2][2] = {
654+
{0, 1},
655+
{0, 2},
656+
};
657+
calc_line_list_from_points(point_list, point_pairs, 2, points);
658+
}
659+
632660
void calc_2d_bounding_box_bottom_line_list(
633661
const autoware_auto_perception_msgs::msg::Shape & shape,
634662
std::vector<geometry_msgs::msg::Point> & points)
@@ -662,7 +690,7 @@ void calc_2d_bounding_box_bottom_direction_line_list(
662690
const double length_half = shape.dimensions.x / 2.0;
663691
const double width_half = shape.dimensions.y / 2.0;
664692
const double height_half = shape.dimensions.z / 2.0;
665-
const double triangle_size_half = shape.dimensions.y / 1.4;
693+
const double triangle_size_half = std::min(width_half * 1.4, shape.dimensions.x);
666694
geometry_msgs::msg::Point point;
667695

668696
// triangle-shaped direction indicator
@@ -679,6 +707,30 @@ void calc_2d_bounding_box_bottom_direction_line_list(
679707
calc_line_list_from_points(point_list, point_pairs, 3, points);
680708
}
681709

710+
void calc_2d_bounding_box_bottom_orientation_line_list(
711+
const autoware_auto_perception_msgs::msg::Shape & shape,
712+
std::vector<geometry_msgs::msg::Point> & points)
713+
{
714+
const double length_half = shape.dimensions.x / 2.0;
715+
const double width_half = shape.dimensions.y / 2.0;
716+
const double height_half = shape.dimensions.z / 2.0;
717+
const double tick_width = width_half * 0.4;
718+
const double tick_length = std::min(tick_width * 1.4, length_half);
719+
geometry_msgs::msg::Point point;
720+
721+
// triangle-shaped direction indicator
722+
const double point_list[3][3] = {
723+
{length_half, 0, -height_half},
724+
{length_half - tick_length, tick_width, -height_half},
725+
{length_half - tick_length, -tick_width, -height_half},
726+
};
727+
const int point_pairs[2][2] = {
728+
{0, 1},
729+
{0, 2},
730+
};
731+
calc_line_list_from_points(point_list, point_pairs, 2, points);
732+
}
733+
682734
void calc_cylinder_line_list(
683735
const autoware_auto_perception_msgs::msg::Shape & shape,
684736
std::vector<geometry_msgs::msg::Point> & points)

0 commit comments

Comments
 (0)