26
26
#include < tf2/utils.h>
27
27
28
28
#include < algorithm>
29
+ #include < limits>
29
30
#include < string>
30
31
#include < vector>
31
32
@@ -92,17 +93,20 @@ bool convertConvexHullToBoundingBox(
92
93
}
93
94
94
95
// 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
+
100
103
for (const auto & point : input_object.shape .footprint .points ) {
101
104
max_x = std::max (max_x, point.x );
102
105
max_y = std::max (max_y, point.y );
103
106
min_x = std::min (min_x, point.x );
104
107
min_y = std::min (min_y, point.y );
105
108
max_z = std::max (max_z, point.z );
109
+ min_z = std::min (min_z, point.z );
106
110
}
107
111
108
112
// calc new center
@@ -120,7 +124,7 @@ bool convertConvexHullToBoundingBox(
120
124
output_object.shape .type = autoware_perception_msgs::msg::Shape::BOUNDING_BOX;
121
125
output_object.shape .dimensions .x = max_x - min_x;
122
126
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 ;
124
128
125
129
return true ;
126
130
}
0 commit comments