@@ -105,6 +105,27 @@ AEB::AEB(const rclcpp::NodeOptions & node_options)
105
105
vehicle_info_ (vehicle_info_util::VehicleInfoUtil(*this ).getVehicleInfo()),
106
106
collision_data_keeper_(this ->get_clock ())
107
107
{
108
+ // Subscribers
109
+ {
110
+ sub_point_cloud_ = this ->create_subscription <PointCloud2>(
111
+ " ~/input/pointcloud" , rclcpp::SensorDataQoS (),
112
+ std::bind (&AEB::onPointCloud, this , std::placeholders::_1));
113
+
114
+ sub_velocity_ = this ->create_subscription <VelocityReport>(
115
+ " ~/input/velocity" , rclcpp::QoS{1 }, std::bind (&AEB::onVelocity, this , std::placeholders::_1));
116
+
117
+ sub_imu_ = this ->create_subscription <Imu>(
118
+ " ~/input/imu" , rclcpp::QoS{1 }, std::bind (&AEB::onImu, this , std::placeholders::_1));
119
+
120
+ sub_predicted_traj_ = this ->create_subscription <Trajectory>(
121
+ " ~/input/predicted_trajectory" , rclcpp::QoS{1 },
122
+ std::bind (&AEB::onPredictedTrajectory, this , std::placeholders::_1));
123
+
124
+ sub_autoware_state_ = this ->create_subscription <AutowareState>(
125
+ " /autoware/state" , rclcpp::QoS{1 },
126
+ std::bind (&AEB::onAutowareState, this , std::placeholders::_1));
127
+ }
128
+
108
129
// Publisher
109
130
{
110
131
pub_obstacle_pointcloud_ =
@@ -208,6 +229,11 @@ void AEB::onTimer()
208
229
updater_.force_update ();
209
230
}
210
231
232
+ void AEB::onVelocity (const VelocityReport::ConstSharedPtr input_msg)
233
+ {
234
+ current_velocity_ptr_ = input_msg;
235
+ }
236
+
211
237
void AEB::onImu (const Imu::ConstSharedPtr input_msg)
212
238
{
213
239
// transform imu
@@ -227,6 +253,17 @@ void AEB::onImu(const Imu::ConstSharedPtr input_msg)
227
253
tf2::doTransform (input_msg->angular_velocity , *angular_velocity_ptr_, transform_stamped);
228
254
}
229
255
256
+ void AEB::onPredictedTrajectory (
257
+ const autoware_auto_planning_msgs::msg::Trajectory::ConstSharedPtr input_msg)
258
+ {
259
+ predicted_traj_ptr_ = input_msg;
260
+ }
261
+
262
+ void AEB::onAutowareState (const AutowareState::ConstSharedPtr input_msg)
263
+ {
264
+ autoware_state_ = input_msg;
265
+ }
266
+
230
267
void AEB::onPointCloud (const PointCloud2::ConstSharedPtr input_msg)
231
268
{
232
269
PointCloud::Ptr pointcloud_ptr (new PointCloud);
@@ -279,23 +316,17 @@ void AEB::onPointCloud(const PointCloud2::ConstSharedPtr input_msg)
279
316
obstacle_ros_pointcloud_ptr_->header = input_msg->header ;
280
317
}
281
318
282
- bool AEB::fetchLatestData ()
319
+ bool AEB::isDataReady ()
283
320
{
284
321
const auto missing = [this ](const auto & name) {
285
322
RCLCPP_INFO_SKIPFIRST_THROTTLE (get_logger (), *get_clock (), 5000 , " [AEB] waiting for %s" , name);
286
323
return false ;
287
324
};
288
325
289
- current_velocity_ptr_ = sub_velocity_.takeData ();
290
326
if (!current_velocity_ptr_) {
291
327
return missing (" ego velocity" );
292
328
}
293
329
294
- const auto pointcloud_ptr = sub_point_cloud_.takeData ();
295
- if (!pointcloud_ptr) {
296
- return missing (" object pointcloud message" );
297
- }
298
- onPointCloud (pointcloud_ptr);
299
330
if (!obstacle_ros_pointcloud_ptr_) {
300
331
return missing (" object pointcloud" );
301
332
}
@@ -312,12 +343,10 @@ bool AEB::fetchLatestData()
312
343
return missing (" imu" );
313
344
}
314
345
315
- predicted_traj_ptr_ = sub_predicted_traj_.takeData ();
316
346
if (use_predicted_trajectory_ && !predicted_traj_ptr_) {
317
347
return missing (" control predicted trajectory" );
318
348
}
319
349
320
- autoware_state_ = sub_autoware_state_.takeData ();
321
350
if (!autoware_state_) {
322
351
return missing (" autoware_state" );
323
352
}
@@ -354,7 +383,7 @@ bool AEB::checkCollision(MarkerArray & debug_markers)
354
383
using colorTuple = std::tuple<double , double , double , double >;
355
384
356
385
// step1. check data
357
- if (!fetchLatestData ()) {
386
+ if (!isDataReady ()) {
358
387
return false ;
359
388
}
360
389
0 commit comments