Autoware.Auto
euclidean_cluster_node.hpp
Go to the documentation of this file.
1 // Copyright 2019-2021 the Autoware Foundation
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //    http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 //
15 // Co-developed by Tier IV, Inc. and Apex.AI, Inc.
18 
19 #ifndef EUCLIDEAN_CLUSTER_NODES__EUCLIDEAN_CLUSTER_NODE_HPP_
20 #define EUCLIDEAN_CLUSTER_NODES__EUCLIDEAN_CLUSTER_NODE_HPP_
21 
22 #include <tf2_ros/transform_listener.h>
23 #include <tf2_ros/buffer.h>
24 #include <rclcpp/rclcpp.hpp>
25 #include <autoware_auto_perception_msgs/msg/point_clusters.hpp>
26 #include <geometry_msgs/msg/transform_stamped.hpp>
28 #include <autoware_auto_perception_msgs/msg/bounding_box_array.hpp>
29 #include <autoware_auto_perception_msgs/msg/detected_objects.hpp>
31 #include <visualization_msgs/msg/marker_array.hpp>
33 #include <common/types.hpp>
34 #include <memory>
35 #include <string>
36 
37 namespace autoware
38 {
39 namespace perception
40 {
41 namespace segmentation
42 {
44 namespace euclidean_cluster_nodes
45 {
53 
56 class EUCLIDEAN_CLUSTER_NODES_PUBLIC EuclideanClusterNode : public rclcpp::Node
57 {
58  using PointCloud2 = sensor_msgs::msg::PointCloud2;
60 
61 public:
64  explicit EuclideanClusterNode(
65  const rclcpp::NodeOptions & node_options);
66 
67 private:
68  enum class DetectedObjectsShape : uint8_t { POLYGON_PRISM = 1u, BOUNDING_BOX = 2u, };
70  void EUCLIDEAN_CLUSTER_NODES_LOCAL handle(const PointCloud2::SharedPtr msg_ptr);
72  void EUCLIDEAN_CLUSTER_NODES_LOCAL insert_plain(const PointCloud2 & cloud);
74  void EUCLIDEAN_CLUSTER_NODES_LOCAL insert_voxel(const PointCloud2 & cloud);
76  void EUCLIDEAN_CLUSTER_NODES_LOCAL insert(const PointCloud2 & cloud);
78  void EUCLIDEAN_CLUSTER_NODES_LOCAL publish_clusters(
79  Clusters & clusters,
80  const std_msgs::msg::Header & header);
82  void EUCLIDEAN_CLUSTER_NODES_LOCAL handle_clusters(
83  Clusters & clusters,
84  const std_msgs::msg::Header & header);
86  DetectedObjectsShape get_detected_object_type_from_string(
87  const std::string & detected_object_type_string)
88  {
89  if (detected_object_type_string == "polygon") {
90  return DetectedObjectsShape::POLYGON_PRISM;
91  } else if (detected_object_type_string == "bounding_box") {
92  return DetectedObjectsShape::BOUNDING_BOX;
93  } else {
94  throw std::invalid_argument{"Unknown detected object type"};
95  }
96  }
97 
98  // pub/sub
99  const rclcpp::Subscription<PointCloud2>::SharedPtr m_cloud_sub_ptr;
100  const rclcpp::Publisher<Clusters>::SharedPtr m_cluster_pub_ptr;
101  const rclcpp::Publisher<BoundingBoxArray>::SharedPtr m_box_pub_ptr;
102  const rclcpp::Publisher<MarkerArray>::SharedPtr m_marker_pub_ptr;
103  rclcpp::Publisher<DetectedObjects>::SharedPtr m_detected_objects_pub_ptr;
104  std::shared_ptr<tf2_ros::Buffer> tf_buffer_;
105  std::shared_ptr<tf2_ros::TransformListener> tf_listener_;
106 
107  // algorithms
109  Clusters m_clusters;
110  std::unique_ptr<VoxelAlgorithm> m_voxel_ptr;
111  DetectedObjectsShape detected_objects_shape_type;
112  const bool8_t m_use_lfit;
113  const bool8_t m_use_z;
114  const bool8_t m_filter_output_by_size;
115 }; // class EuclideanClusterNode
116 } // namespace euclidean_cluster_nodes
117 } // namespace segmentation
118 } // namespace perception
119 } // namespace autoware
120 #endif // EUCLIDEAN_CLUSTER_NODES__EUCLIDEAN_CLUSTER_NODE_HPP_
autoware::rviz_plugins::object_detection::detail::Marker
visualization_msgs::msg::Marker Marker
Definition: object_polygon_detail.cpp:31
autoware::off_map_obstacles_filter_nodes::MarkerArray
visualization_msgs::msg::MarkerArray MarkerArray
Definition: off_map_obstacles_filter_node.cpp:39
autoware::perception::segmentation::euclidean_cluster::EuclideanCluster
implementation of euclidean clustering for point cloud segmentation This clas implicitly projects poi...
Definition: euclidean_cluster.hpp:196
autoware::perception::segmentation::euclidean_cluster_nodes::DetectedObjects
autoware_auto_perception_msgs::msg::DetectedObjects DetectedObjects
Definition: euclidean_cluster_node.hpp:52
types.hpp
This file includes common type definition.
u
DifferentialState u
Definition: kinematic_bicycle.snippet.hpp:29
autoware::perception::segmentation::euclidean_cluster_nodes::BoundingBoxArray
autoware_auto_perception_msgs::msg::BoundingBoxArray BoundingBoxArray
Definition: euclidean_cluster_node.hpp:51
euclidean_cluster.hpp
This file defines the euclidean cluster algorithm for object detection.
autoware::perception::segmentation::euclidean_cluster_nodes::BoundingBox
autoware_auto_perception_msgs::msg::BoundingBox BoundingBox
Definition: euclidean_cluster_node.hpp:50
BoundingBox
autoware_auto_perception_msgs::msg::BoundingBox BoundingBox
Definition: tf2_autoware_auto_msgs.hpp:39
autoware::common::types::bool8_t
bool bool8_t
Definition: types.hpp:39
autoware
This file defines the lanelet2_map_provider_node class.
Definition: quick_sort.hpp:24
autoware::perception::segmentation::euclidean_cluster_nodes::Clusters
euclidean_cluster::Clusters Clusters
Definition: euclidean_cluster_node.hpp:47
autoware::perception::segmentation::euclidean_cluster_nodes::EuclideanClusterNode
Combined object detection node, primarily does clustering, can also do in-place downsampling and boun...
Definition: euclidean_cluster_node.hpp:56
autoware::perception::filters::voxel_grid_nodes::algorithm::VoxelCloudApproximate
Instantiation of PointCloud2 VoxelCloudBase for ApproximateVoxels.
Definition: voxel_cloud_approximate.hpp:35
visibility_control.hpp
voxel_cloud_approximate.hpp
This file defines an instance of the VoxelCloudBase interface.
autoware::perception::filters::filter_node_base::PointCloud2
sensor_msgs::msg::PointCloud2 PointCloud2
Definition: filter_node_base.cpp:32
autoware::perception::segmentation::euclidean_cluster::Clusters
autoware_auto_perception_msgs::msg::PointClusters Clusters
Definition: euclidean_cluster.hpp:89
DetectedObjects
autoware_auto_perception_msgs::msg::DetectedObjects DetectedObjects
Definition: euclidean_cluster_node.cpp:39