@@ -86,89 +86,89 @@ void DetectedObjectsDisplay::processMessage(DetectedObjects::ConstSharedPtr msg)
86
86
}
87
87
}
88
88
89
- void DetectedObjectsDisplay::onInitialize ()
90
- {
91
- ObjectPolygonDisplayBase::onInitialize ();
92
- // get access to rviz node to sub and to pub to topics
93
- rclcpp::Node::SharedPtr raw_node = this ->context_ ->getRosNodeAbstraction ().lock ()->get_raw_node ();
94
-
95
- sync_ptr = std::make_shared<Sync>(
96
- SyncPolicy (10 ), perception_objects_subscription, pointcloud_subscription);
97
- sync_ptr->registerCallback (&DetectedObjectsDisplay::onObjectsAndObstaclePointCloud, this );
98
- perception_objects_subscription.subscribe (
99
- raw_node, " /perception/object_recognition/detection/objects" ,
100
- rclcpp::QoS{1 }.get_rmw_qos_profile ());
101
- pointcloud_subscription.subscribe (
102
- raw_node, m_default_pointcloud_topic->getTopic ().toStdString (),
103
- rclcpp::SensorDataQoS{}.keep_last (1 ).get_rmw_qos_profile ());
104
- }
105
-
106
- void DetectedObjectsDisplay::onObjectsAndObstaclePointCloud (
107
- const DetectedObjects::ConstSharedPtr & input_objs_msg,
108
- const sensor_msgs::msg::PointCloud2::ConstSharedPtr & input_pointcloud_msg)
109
- {
110
- if (!m_publish_objs_pointcloud->getBool ()) {
111
- return ;
112
- }
113
- // Transform to pointcloud frame
114
- autoware_auto_perception_msgs::msg::DetectedObjects transformed_objects;
115
- if (!transformObjects (
116
- *input_objs_msg, input_pointcloud_msg->header .frame_id , *tf_buffer, transformed_objects)) {
117
- return ;
118
- }
119
-
120
- objs_buffer.clear ();
121
- for (const auto & object : transformed_objects.objects ) {
122
- std::vector<autoware_auto_perception_msgs::msg::ObjectClassification> labels =
123
- object.classification ;
124
- object_info info = {
125
- object.shape , object.kinematics .pose_with_covariance .pose , object.classification };
126
- objs_buffer.push_back (info);
127
- }
128
-
129
- // convert to pcl pointcloud
130
- pcl::PointCloud<pcl::PointXYZ>::Ptr temp_cloud (new pcl::PointCloud<pcl::PointXYZ>);
131
- pcl::fromROSMsg (*input_pointcloud_msg, *temp_cloud);
132
-
133
- // Create a new point cloud with RGB color information and copy data from input cloud
134
- pcl::PointCloud<pcl::PointXYZRGB>::Ptr colored_cloud (new pcl::PointCloud<pcl::PointXYZRGB>());
135
- pcl::copyPointCloud (*temp_cloud, *colored_cloud);
136
-
137
- // Create Kd-tree to search neighbor pointcloud to reduce cost.
138
- pcl::search::Search<pcl::PointXYZRGB>::Ptr kdtree =
139
- pcl::make_shared<pcl::search::KdTree<pcl::PointXYZRGB>>(false );
140
- kdtree->setInputCloud (colored_cloud);
141
-
142
- pcl::PointCloud<pcl::PointXYZRGB>::Ptr out_cloud (new pcl::PointCloud<pcl::PointXYZRGB>());
143
-
144
- if (objs_buffer.size () > 0 ) {
145
- for (auto object : objs_buffer) {
146
- const auto search_radius = getMaxRadius (object);
147
- // Search neighbor pointcloud to reduce cost.
148
- pcl::PointCloud<pcl::PointXYZRGB>::Ptr neighbor_pointcloud (
149
- new pcl::PointCloud<pcl::PointXYZRGB>);
150
- std::vector<int > indices;
151
- std::vector<float > distances;
152
- kdtree->radiusSearch (
153
- toPCL (object.position .position ), search_radius.value (), indices, distances);
154
- for (const auto & index : indices) {
155
- neighbor_pointcloud->push_back (colored_cloud->at (index ));
156
- }
157
-
158
- filterPolygon (neighbor_pointcloud, out_cloud, object);
159
- }
160
- } else {
161
- return ;
162
- }
163
-
164
- sensor_msgs::msg::PointCloud2::SharedPtr output_pointcloud_msg_ptr (
165
- new sensor_msgs::msg::PointCloud2);
166
- pcl::toROSMsg (*out_cloud, *output_pointcloud_msg_ptr);
167
-
168
- output_pointcloud_msg_ptr->header = input_pointcloud_msg->header ;
169
-
170
- add_pointcloud (output_pointcloud_msg_ptr);
171
- }
89
+ // void DetectedObjectsDisplay::onInitialize()
90
+ // {
91
+ // ObjectPolygonDisplayBase::onInitialize();
92
+ // // get access to rviz node to sub and to pub to topics
93
+ // rclcpp::Node::SharedPtr raw_node = this->context_->getRosNodeAbstraction().lock()->get_raw_node();
94
+
95
+ // sync_ptr = std::make_shared<Sync>(
96
+ // SyncPolicy(10), perception_objects_subscription, pointcloud_subscription);
97
+ // sync_ptr->registerCallback(&DetectedObjectsDisplay::onObjectsAndObstaclePointCloud, this);
98
+ // perception_objects_subscription.subscribe(
99
+ // raw_node, "/perception/object_recognition/detection/objects",
100
+ // rclcpp::QoS{1}.get_rmw_qos_profile());
101
+ // pointcloud_subscription.subscribe(
102
+ // raw_node, m_default_pointcloud_topic->getTopic().toStdString(),
103
+ // rclcpp::SensorDataQoS{}.keep_last(1).get_rmw_qos_profile());
104
+ // }
105
+
106
+ // void DetectedObjectsDisplay::onObjectsAndObstaclePointCloud(
107
+ // const DetectedObjects::ConstSharedPtr & input_objs_msg,
108
+ // const sensor_msgs::msg::PointCloud2::ConstSharedPtr & input_pointcloud_msg)
109
+ // {
110
+ // if (!m_publish_objs_pointcloud->getBool()) {
111
+ // return;
112
+ // }
113
+ // // Transform to pointcloud frame
114
+ // autoware_auto_perception_msgs::msg::DetectedObjects transformed_objects;
115
+ // if (!transformObjects(
116
+ // *input_objs_msg, input_pointcloud_msg->header.frame_id, *tf_buffer, transformed_objects)) {
117
+ // return;
118
+ // }
119
+
120
+ // objs_buffer.clear();
121
+ // for (const auto & object : transformed_objects.objects) {
122
+ // std::vector<autoware_auto_perception_msgs::msg::ObjectClassification> labels =
123
+ // object.classification;
124
+ // object_info info = {
125
+ // object.shape, object.kinematics.pose_with_covariance.pose, object.classification};
126
+ // objs_buffer.push_back(info);
127
+ // }
128
+
129
+ // // convert to pcl pointcloud
130
+ // pcl::PointCloud<pcl::PointXYZ>::Ptr temp_cloud(new pcl::PointCloud<pcl::PointXYZ>);
131
+ // pcl::fromROSMsg(*input_pointcloud_msg, *temp_cloud);
132
+
133
+ // // Create a new point cloud with RGB color information and copy data from input cloud
134
+ // pcl::PointCloud<pcl::PointXYZRGB>::Ptr colored_cloud(new pcl::PointCloud<pcl::PointXYZRGB>());
135
+ // pcl::copyPointCloud(*temp_cloud, *colored_cloud);
136
+
137
+ // // Create Kd-tree to search neighbor pointcloud to reduce cost.
138
+ // pcl::search::Search<pcl::PointXYZRGB>::Ptr kdtree =
139
+ // pcl::make_shared<pcl::search::KdTree<pcl::PointXYZRGB>>(false);
140
+ // kdtree->setInputCloud(colored_cloud);
141
+
142
+ // pcl::PointCloud<pcl::PointXYZRGB>::Ptr out_cloud(new pcl::PointCloud<pcl::PointXYZRGB>());
143
+
144
+ // if (objs_buffer.size() > 0) {
145
+ // for (auto object : objs_buffer) {
146
+ // const auto search_radius = getMaxRadius(object);
147
+ // // Search neighbor pointcloud to reduce cost.
148
+ // pcl::PointCloud<pcl::PointXYZRGB>::Ptr neighbor_pointcloud(
149
+ // new pcl::PointCloud<pcl::PointXYZRGB>);
150
+ // std::vector<int> indices;
151
+ // std::vector<float> distances;
152
+ // kdtree->radiusSearch(
153
+ // toPCL(object.position.position), search_radius.value(), indices, distances);
154
+ // for (const auto & index : indices) {
155
+ // neighbor_pointcloud->push_back(colored_cloud->at(index));
156
+ // }
157
+
158
+ // filterPolygon(neighbor_pointcloud, out_cloud, object);
159
+ // }
160
+ // } else {
161
+ // return;
162
+ // }
163
+
164
+ // sensor_msgs::msg::PointCloud2::SharedPtr output_pointcloud_msg_ptr(
165
+ // new sensor_msgs::msg::PointCloud2);
166
+ // pcl::toROSMsg(*out_cloud, *output_pointcloud_msg_ptr);
167
+
168
+ // output_pointcloud_msg_ptr->header = input_pointcloud_msg->header;
169
+
170
+ // add_pointcloud(output_pointcloud_msg_ptr);
171
+ // }
172
172
173
173
} // namespace object_detection
174
174
} // namespace rviz_plugins
0 commit comments