Skip to content

Commit 1110c2f

Browse files
author
beyza
committed
Revert "feat(aeb): replace InterProcessPollingSubscriber (autowarefoundation#6997)"
This reverts commit 74da4c1.
1 parent d10921b commit 1110c2f

File tree

3 files changed

+49
-29
lines changed

3 files changed

+49
-29
lines changed

control/autonomous_emergency_braking/include/autonomous_emergency_braking/node.hpp

+10-18
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include <pcl_ros/transforms.hpp>
2121
#include <rclcpp/rclcpp.hpp>
2222
#include <tier4_autoware_utils/geometry/geometry.hpp>
23-
#include <tier4_autoware_utils/ros/polling_subscriber.hpp>
2423
#include <vehicle_info_util/vehicle_info_util.hpp>
2524

2625
#include <autoware_auto_planning_msgs/msg/trajectory.hpp>
@@ -225,28 +224,18 @@ class CollisionDataKeeper
225224
rclcpp::Clock::SharedPtr clock_;
226225
};
227226

228-
static rclcpp::SensorDataQoS SingleDepthSensorQoS()
229-
{
230-
rclcpp::SensorDataQoS qos;
231-
qos.get_rmw_qos_profile().depth = 1;
232-
return qos;
233-
}
234-
235227
class AEB : public rclcpp::Node
236228
{
237229
public:
238230
explicit AEB(const rclcpp::NodeOptions & node_options);
239231

240232
// subscriber
241-
tier4_autoware_utils::InterProcessPollingSubscriber<PointCloud2> sub_point_cloud_{
242-
this, "~/input/pointcloud", SingleDepthSensorQoS()};
243-
tier4_autoware_utils::InterProcessPollingSubscriber<VelocityReport> sub_velocity_{
244-
this, "~/input/velocity"};
245-
tier4_autoware_utils::InterProcessPollingSubscriber<Imu> sub_imu_{this, "~/input/imu"};
246-
tier4_autoware_utils::InterProcessPollingSubscriber<Trajectory> sub_predicted_traj_{
247-
this, "~/input/predicted_trajectory"};
248-
tier4_autoware_utils::InterProcessPollingSubscriber<AutowareState> sub_autoware_state_{
249-
this, "/autoware/state"};
233+
rclcpp::Subscription<PointCloud2>::SharedPtr sub_point_cloud_;
234+
rclcpp::Subscription<VelocityReport>::SharedPtr sub_velocity_;
235+
rclcpp::Subscription<Imu>::SharedPtr sub_imu_;
236+
rclcpp::Subscription<Trajectory>::SharedPtr sub_predicted_traj_;
237+
rclcpp::Subscription<AutowareState>::SharedPtr sub_autoware_state_;
238+
250239
// publisher
251240
rclcpp::Publisher<sensor_msgs::msg::PointCloud2>::SharedPtr pub_obstacle_pointcloud_;
252241
rclcpp::Publisher<MarkerArray>::SharedPtr debug_ego_path_publisher_; // debug
@@ -256,12 +245,15 @@ class AEB : public rclcpp::Node
256245

257246
// callback
258247
void onPointCloud(const PointCloud2::ConstSharedPtr input_msg);
248+
void onVelocity(const VelocityReport::ConstSharedPtr input_msg);
259249
void onImu(const Imu::ConstSharedPtr input_msg);
260250
void onTimer();
251+
void onPredictedTrajectory(const Trajectory::ConstSharedPtr input_msg);
252+
void onAutowareState(const AutowareState::ConstSharedPtr input_msg);
261253
rcl_interfaces::msg::SetParametersResult onParameter(
262254
const std::vector<rclcpp::Parameter> & parameters);
263255

264-
bool fetchLatestData();
256+
bool isDataReady();
265257

266258
// main function
267259
void onCheckCollision(DiagnosticStatusWrapper & stat);

control/autonomous_emergency_braking/package.xml

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
<maintainer email="takamasa.horibe@tier4.jp">Takamasa Horibe</maintainer>
88
<maintainer email="tomoya.kimura@tier4.jp">Tomoya Kimura</maintainer>
99
<maintainer email="mamoru.sobue@tier4.jp">Mamoru Sobue</maintainer>
10-
<maintainer email="daniel.sanchez@tier4.jp">Daniel Sanchez</maintainer>
1110

1211
<license>Apache License 2.0</license>
1312

control/autonomous_emergency_braking/src/node.cpp

+39-10
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,27 @@ AEB::AEB(const rclcpp::NodeOptions & node_options)
105105
vehicle_info_(vehicle_info_util::VehicleInfoUtil(*this).getVehicleInfo()),
106106
collision_data_keeper_(this->get_clock())
107107
{
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+
108129
// Publisher
109130
{
110131
pub_obstacle_pointcloud_ =
@@ -208,6 +229,11 @@ void AEB::onTimer()
208229
updater_.force_update();
209230
}
210231

232+
void AEB::onVelocity(const VelocityReport::ConstSharedPtr input_msg)
233+
{
234+
current_velocity_ptr_ = input_msg;
235+
}
236+
211237
void AEB::onImu(const Imu::ConstSharedPtr input_msg)
212238
{
213239
// transform imu
@@ -227,6 +253,17 @@ void AEB::onImu(const Imu::ConstSharedPtr input_msg)
227253
tf2::doTransform(input_msg->angular_velocity, *angular_velocity_ptr_, transform_stamped);
228254
}
229255

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+
230267
void AEB::onPointCloud(const PointCloud2::ConstSharedPtr input_msg)
231268
{
232269
PointCloud::Ptr pointcloud_ptr(new PointCloud);
@@ -279,23 +316,17 @@ void AEB::onPointCloud(const PointCloud2::ConstSharedPtr input_msg)
279316
obstacle_ros_pointcloud_ptr_->header = input_msg->header;
280317
}
281318

282-
bool AEB::fetchLatestData()
319+
bool AEB::isDataReady()
283320
{
284321
const auto missing = [this](const auto & name) {
285322
RCLCPP_INFO_SKIPFIRST_THROTTLE(get_logger(), *get_clock(), 5000, "[AEB] waiting for %s", name);
286323
return false;
287324
};
288325

289-
current_velocity_ptr_ = sub_velocity_.takeData();
290326
if (!current_velocity_ptr_) {
291327
return missing("ego velocity");
292328
}
293329

294-
const auto pointcloud_ptr = sub_point_cloud_.takeData();
295-
if (!pointcloud_ptr) {
296-
return missing("object pointcloud message");
297-
}
298-
onPointCloud(pointcloud_ptr);
299330
if (!obstacle_ros_pointcloud_ptr_) {
300331
return missing("object pointcloud");
301332
}
@@ -312,12 +343,10 @@ bool AEB::fetchLatestData()
312343
return missing("imu");
313344
}
314345

315-
predicted_traj_ptr_ = sub_predicted_traj_.takeData();
316346
if (use_predicted_trajectory_ && !predicted_traj_ptr_) {
317347
return missing("control predicted trajectory");
318348
}
319349

320-
autoware_state_ = sub_autoware_state_.takeData();
321350
if (!autoware_state_) {
322351
return missing("autoware_state");
323352
}
@@ -354,7 +383,7 @@ bool AEB::checkCollision(MarkerArray & debug_markers)
354383
using colorTuple = std::tuple<double, double, double, double>;
355384

356385
// step1. check data
357-
if (!fetchLatestData()) {
386+
if (!isDataReady()) {
358387
return false;
359388
}
360389

0 commit comments

Comments
 (0)