Skip to content

Commit a64d444

Browse files
committed
fix(object_model): correct bounding box calculation by initializing limits and including min_z
Signed-off-by: Taekjin LEE <taekjin.lee@tier4.jp>
1 parent f978993 commit a64d444

File tree

1 file changed

+10
-6
lines changed
  • perception/autoware_multi_object_tracker/lib/object_model

1 file changed

+10
-6
lines changed

perception/autoware_multi_object_tracker/lib/object_model/shapes.cpp

+10-6
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <tf2/utils.h>
2727

2828
#include <algorithm>
29+
#include <limits>
2930
#include <string>
3031
#include <vector>
3132

@@ -92,17 +93,20 @@ bool convertConvexHullToBoundingBox(
9293
}
9394

9495
// look for bounding box boundary
95-
float max_x = 0;
96-
float max_y = 0;
97-
float min_x = 0;
98-
float min_y = 0;
99-
float max_z = 0;
96+
float max_x = -std::numeric_limits<float>::infinity();
97+
float max_y = -std::numeric_limits<float>::infinity();
98+
float min_x = std::numeric_limits<float>::infinity();
99+
float min_y = std::numeric_limits<float>::infinity();
100+
float max_z = -std::numeric_limits<float>::infinity();
101+
float min_z = std::numeric_limits<float>::infinity();
102+
100103
for (const auto & point : input_object.shape.footprint.points) {
101104
max_x = std::max(max_x, point.x);
102105
max_y = std::max(max_y, point.y);
103106
min_x = std::min(min_x, point.x);
104107
min_y = std::min(min_y, point.y);
105108
max_z = std::max(max_z, point.z);
109+
min_z = std::min(min_z, point.z);
106110
}
107111

108112
// calc new center
@@ -120,7 +124,7 @@ bool convertConvexHullToBoundingBox(
120124
output_object.shape.type = autoware_perception_msgs::msg::Shape::BOUNDING_BOX;
121125
output_object.shape.dimensions.x = max_x - min_x;
122126
output_object.shape.dimensions.y = max_y - min_y;
123-
output_object.shape.dimensions.z = max_z;
127+
output_object.shape.dimensions.z = max_z - min_z;
124128

125129
return true;
126130
}

0 commit comments

Comments
 (0)