Go to the documentation of this file.
20 #ifndef GEOMETRY__BOUNDING_BOX__BOUNDING_BOX_COMMON_HPP_
21 #define GEOMETRY__BOUNDING_BOX__BOUNDING_BOX_COMMON_HPP_
23 #include <autoware_auto_perception_msgs/msg/bounding_box.hpp>
24 #include <autoware_auto_perception_msgs/msg/detected_object.hpp>
25 #include <autoware_auto_perception_msgs/msg/shape.hpp>
28 #include <geometry_msgs/msg/pose.hpp>
41 namespace bounding_box
54 float32_t max_z = -std::numeric_limits<float32_t>::max();
55 float32_t min_z = std::numeric_limits<float32_t>::max();
56 for (
auto it = begin; it !=
end; ++it) {
65 box.centroid.z = (max_z + min_z) * 0.5F;
66 for (
auto & corner : box.corners) {
67 corner.z = box.centroid.z;
69 box.size.z = (max_z - min_z);
79 void compute_height(
const IT begin,
const IT
end, autoware_auto_perception_msgs::msg::Shape & shape)
81 float32_t max_z = -std::numeric_limits<float32_t>::max();
82 float32_t min_z = std::numeric_limits<float32_t>::max();
83 for (
auto it = begin; it !=
end; ++it) {
92 for (
auto & corner : shape.polygon.points) {
95 shape.height = max_z - min_z;
103 using base_type =
typename std::remove_cv<typename std::remove_reference<T>::type>::type;
106 template<
typename Po
intT>
113 template<
typename T, std::
size_t N>
116 static std::size_t
const size = N;
120 "Bounding box does not have the right number of corners");
126 const decltype(BoundingBox::corners) & corners,
127 geometry_msgs::msg::Point32 & ret);
132 const decltype(BoundingBox::corners) & corners,
BoundingBox & box);
141 template<
typename IT,
typename Po
intT>
143 decltype(BoundingBox::corners) & corners,
147 for (uint32_t idx = 0U; idx < corners.size(); ++idx) {
148 const uint32_t jdx = (idx != 3U) ? (idx + 1U) : 0U;
150 intersection_2d(*supports[idx], directions[idx], *supports[jdx], directions[jdx]);
181 const autoware_auto_perception_msgs::msg::Shape & shape_msg,
183 const geometry_msgs::msg::Quaternion & orientation);
191 #endif // GEOMETRY__BOUNDING_BOX__BOUNDING_BOX_COMMON_HPP_
auto x_(const PointT &pt)
Gets the x value for a point.
Definition: common_2d.hpp:50
void compute_corners(decltype(BoundingBox::corners) &corners, const Point4< IT > &supports, const Point4< PointT > &directions)
given support points and two orthogonal directions, compute corners of bounding box
Definition: bounding_box_common.hpp:142
This file includes common functionality for 2D geometry, such as dot products.
autoware_auto_perception_msgs::msg::BoundingBox BoundingBox
Definition: tf2_autoware_auto_msgs.hpp:39
autoware_auto_perception_msgs::msg::Shape GEOMETRY_PUBLIC make_shape(const BoundingBox &box)
Copy vertices of the given box into a Shape type.
Definition: bounding_box.cpp:70
This file defines the lanelet2_map_provider_node class.
Definition: quick_sort.hpp:24
auto & yr_(PointT &pt)
Gets a reference to the y value for a point.
Definition: common_2d.hpp:114
autoware_auto_perception_msgs::msg::DetectedObject GEOMETRY_PUBLIC make_detected_object(const BoundingBox &box)
Fill DetectedObject type with contents from a BoundingBox type.
Definition: bounding_box.cpp:100
float float32_t
Definition: types.hpp:45
auto & xr_(PointT &pt)
Gets a reference to the x value for a point.
Definition: common_2d.hpp:98
std::vector< geometry_msgs::msg::Point32 > GEOMETRY_PUBLIC get_transformed_corners(const autoware_auto_perception_msgs::msg::Shape &shape_msg, const geometry_msgs::msg::Point ¢roid, const geometry_msgs::msg::Quaternion &orientation)
Transform corners from object-local coordinates using the given centroid and orientation.
Definition: bounding_box.cpp:126
T intersection_2d(const T &pt, const T &u, const T &q, const T &v)
solve p + t * u = q + s * v Ref: https://stackoverflow.com/questions/563198/ whats-the-most-efficent-...
Definition: common_2d.hpp:273
Helper struct for compile time introspection of array size from stackoverflow.com/questions/16866033/...
Definition: bounding_box_common.hpp:112
auto y_(const PointT &pt)
Gets the y value for a point.
Definition: common_2d.hpp:66
geometry_msgs::msg::Point32 Point
Definition: cluster2d.cpp:28
typename std::remove_cv< typename std::remove_reference< T >::type >::type base_type
Templated alias for getting a type without CV or reference qualification.
Definition: bounding_box_common.hpp:103
void GEOMETRY_PUBLIC size_2d(const decltype(BoundingBox::corners) &corners, geometry_msgs::msg::Point32 &ret)
Compute length, width, area of bounding box.
Definition: bounding_box.cpp:41
std::array< PointT, 4U > Point4
Templated alias for an array of 4 objects of type PointT.
Definition: bounding_box_common.hpp:107
auto z_(const PointT &pt)
Gets the z value for a point.
Definition: common_2d.hpp:82
void compute_height(const IT begin, const IT end, BoundingBox &box)
Computes height of bounding box given a full list of points.
Definition: bounding_box_common.hpp:52
geometry_msgs::msg::Pose GEOMETRY_PUBLIC make_pose(const BoundingBox &box)
Copy centroid and orientation info of the box into Pose type.
void GEOMETRY_PUBLIC finalize_box(const decltype(BoundingBox::corners) &corners, BoundingBox &box)
Computes centroid and orientation of a box given corners.
Definition: bounding_box.cpp:57
end
Definition: scripts/get_open_port.py:23
autoware_auto_perception_msgs::msg::BoundingBox BoundingBox
Definition: bounding_box_common.hpp:43