Skip to content

Commit

Permalink
feat(detected_object_validation): add BOUNDING_BOX interface to lanel…
Browse files Browse the repository at this point in the history
…et filter (autowarefoundation#3957)

* feature(detected_object_validation): add BOUNDING_BOX interface to lanelet filter

Signed-off-by: scepter914 <scepter914@gmail.com>

* update README

Signed-off-by: scepter914 <scepter914@gmail.com>

* avoid reuse msg data

Signed-off-by: scepter914 <scepter914@gmail.com>

---------

Signed-off-by: scepter914 <scepter914@gmail.com>
  • Loading branch information
scepter914 authored and zulfaqar-azmi-t4 committed Jun 21, 2023
1 parent d1c905c commit 5eb7602
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class ObjectLaneletFilterNode : public rclcpp::Node
lanelet::ConstLanelets getIntersectedLanelets(
const LinearRing2d &, const lanelet::ConstLanelets &);
bool isPolygonOverlapLanelets(const Polygon2d &, const lanelet::ConstLanelets &);
geometry_msgs::msg::Polygon setFootprint(
const autoware_auto_perception_msgs::msg::DetectedObject &);
};

} // namespace object_lanelet_filter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Purpose

The `object_lanelet_filter` is a node that filters detected object by using vector map.
The `object_lanelet_filter` is a node that filters detected object by using vector map.
The objects only inside of the vector map will be published.

## Inner-workings / Algorithms
Expand Down Expand Up @@ -39,7 +39,7 @@ The objects only inside of the vector map will be published.

## Assumptions / Known limits

Filtering is performed based on the shape polygon of the object.
The lanelet filter is performed based on the shape polygon and bounding box of the objects.

## (Optional) Error detection and handling

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void ObjectLaneletFilterNode::objectCallback(

int index = 0;
for (const auto & object : transformed_objects.objects) {
const auto & footprint = object.shape.footprint;
const auto footprint = setFootprint(object);
const auto & label = object.classification.front().label;
if (filter_target_.isTarget(label)) {
Polygon2d polygon;
Expand All @@ -110,13 +110,39 @@ void ObjectLaneletFilterNode::objectCallback(
object_pub_->publish(output_object_msg);
}

geometry_msgs::msg::Polygon ObjectLaneletFilterNode::setFootprint(
const autoware_auto_perception_msgs::msg::DetectedObject & detected_object)
{
geometry_msgs::msg::Polygon footprint;
if (detected_object.shape.type == autoware_auto_perception_msgs::msg::Shape::BOUNDING_BOX) {
const auto object_size = detected_object.shape.dimensions;
const double x_front = object_size.x / 2.0;
const double x_rear = -object_size.x / 2.0;
const double y_left = object_size.y / 2.0;
const double y_right = -object_size.y / 2.0;

footprint.points.push_back(
geometry_msgs::build<geometry_msgs::msg::Point32>().x(x_front).y(y_left).z(0.0));
footprint.points.push_back(
geometry_msgs::build<geometry_msgs::msg::Point32>().x(x_front).y(y_right).z(0.0));
footprint.points.push_back(
geometry_msgs::build<geometry_msgs::msg::Point32>().x(x_rear).y(y_right).z(0.0));
footprint.points.push_back(
geometry_msgs::build<geometry_msgs::msg::Point32>().x(x_rear).y(y_left).z(0.0));
} else {
footprint = detected_object.shape.footprint;
}
return footprint;
}

LinearRing2d ObjectLaneletFilterNode::getConvexHull(
const autoware_auto_perception_msgs::msg::DetectedObjects & detected_objects)
{
MultiPoint2d candidate_points;
for (const auto & object : detected_objects.objects) {
const auto & pos = object.kinematics.pose_with_covariance.pose.position;
for (const auto & p : object.shape.footprint.points) {
const auto footprint = setFootprint(object);
for (const auto & p : footprint.points) {
candidate_points.emplace_back(p.x + pos.x, p.y + pos.y);
}
}
Expand Down

0 comments on commit 5eb7602

Please sign in to comment.