20
20
#include < rosbag2_cpp/reader.hpp>
21
21
#include < tier4_autoware_utils/geometry/geometry.hpp>
22
22
#include < tier4_autoware_utils/math/unit_conversion.hpp>
23
+ #include < topic_publisher.hpp>
23
24
24
25
#include < autoware_adapi_v1_msgs/msg/localization_initialization_state.hpp>
25
26
#include < autoware_adapi_v1_msgs/msg/operation_mode_state.hpp>
29
30
#include < autoware_auto_perception_msgs/msg/detected_objects.hpp>
30
31
#include < autoware_auto_perception_msgs/msg/predicted_objects.hpp>
31
32
#include < autoware_auto_planning_msgs/msg/trajectory.hpp>
32
- #include < autoware_auto_vehicle_msgs/msg/control_mode_report.hpp>
33
- #include < autoware_auto_vehicle_msgs/msg/gear_report.hpp>
34
- #include < autoware_auto_vehicle_msgs/msg/hazard_lights_report.hpp>
35
- #include < autoware_auto_vehicle_msgs/msg/steering_report.hpp>
36
- #include < autoware_auto_vehicle_msgs/msg/turn_indicators_report.hpp>
37
- #include < autoware_auto_vehicle_msgs/msg/velocity_report.hpp>
38
33
#include < geometry_msgs/msg/pose_with_covariance_stamped.hpp>
39
34
#include < nav_msgs/msg/odometry.hpp>
40
- #include < sensor_msgs/msg/camera_info.hpp>
41
- #include < sensor_msgs/msg/image.hpp>
42
- #include < sensor_msgs/msg/imu.hpp>
43
- #include < sensor_msgs/msg/point_cloud2.hpp>
44
35
45
36
#include < pcl/common/distances.h>
46
37
#include < pcl/point_types.h>
@@ -75,6 +66,7 @@ using TrajectoryBuffer = std::optional<Trajectory>;
75
66
using PointCloud2Buffer = std::optional<PointCloud2>;
76
67
using PredictedObjectsBuffer = std::optional<PredictedObjects>;
77
68
using DetectedObjectsBuffer = std::optional<DetectedObjects>;
69
+
78
70
using BufferVariant = std::variant<
79
71
ControlCommandBuffer, TrajectoryBuffer, PointCloud2Buffer, PredictedObjectsBuffer,
80
72
DetectedObjectsBuffer>;
@@ -88,21 +80,6 @@ enum class SubscriberMessageType {
88
80
PredictedObjects = 5 ,
89
81
};
90
82
91
- enum class PublisherMessageType {
92
- Unknown = 0 ,
93
- CameraInfo = 1 ,
94
- Image = 2 ,
95
- PointCloud2 = 3 ,
96
- PoseWithCovarianceStamped = 4 ,
97
- Imu = 5 ,
98
- ControlModeReport = 6 ,
99
- GearReport = 7 ,
100
- HazardLightsReport = 8 ,
101
- SteeringReport = 9 ,
102
- TurnIndicatorsReport = 10 ,
103
- VelocityReport = 11 ,
104
- };
105
-
106
83
enum class RunningMode {
107
84
PerceptionPlanning = 0 ,
108
85
PlanningControl = 1 ,
@@ -140,124 +117,23 @@ struct EntityParams
140
117
double z_l;
141
118
};
142
119
143
- struct GeneralParams
120
+ struct NodeParams
144
121
{
145
122
std::string running_mode;
146
123
double timer_period;
147
124
double object_search_radius_offset;
148
- EntityParams entity_params;
149
- PoseParams goal_pose;
150
- };
151
-
152
- struct PerceptionPlanningModeParams
153
- {
154
- std::string path_bag_without_object;
155
- std::string path_bag_with_object;
156
- bool publish_pointcloud_synchronically;
157
- double synchronic_pointcloud_publishing_period;
158
125
double spawn_time_after_init;
159
- };
160
-
161
- struct PlanningControlModeParams
162
- {
163
126
double spawn_distance_threshold;
164
127
double spawned_pointcloud_sampling_distance;
128
+ double dummy_perception_publisher_period;
165
129
double control_cmd_buffer_time_interval;
166
130
double min_jerk_for_brake_cmd;
167
131
size_t min_number_descending_order_control_cmd;
168
132
PoseParams initial_pose;
133
+ PoseParams goal_pose;
134
+ EntityParams entity_params;
169
135
};
170
136
171
- template <typename MessageType>
172
- struct PublisherVariables
173
- {
174
- double period_ns{0.0 };
175
- typename MessageType::SharedPtr empty_area_message;
176
- typename MessageType::SharedPtr object_spawned_message;
177
- typename rclcpp::Publisher<MessageType>::SharedPtr publisher;
178
- rclcpp::TimerBase::SharedPtr timer;
179
- };
180
-
181
- struct PublisherVarAccessor
182
- {
183
- template <typename T, typename = std::void_t <>>
184
- struct has_header : std::false_type
185
- {
186
- };
187
-
188
- template <typename T>
189
- struct has_header <T, std::void_t <decltype(T::header)>> : std::true_type
190
- {
191
- };
192
- template <typename T, typename = std::void_t <>>
193
- struct has_stamp : std::false_type
194
- {
195
- };
196
-
197
- template <typename T>
198
- struct has_stamp <T, std::void_t <decltype(T::stamp)>> : std::true_type
199
- {
200
- };
201
- template <typename MessageType>
202
- void publishWithCurrentTime (
203
- const PublisherVariables<MessageType> & publisherVar, const rclcpp::Time & current_time,
204
- const bool is_object_spawned) const
205
- {
206
- std::unique_ptr<MessageType> msg_to_be_published = std::make_unique<MessageType>();
207
-
208
- if (is_object_spawned) {
209
- *msg_to_be_published = *publisherVar.object_spawned_message ;
210
- } else {
211
- *msg_to_be_published = *publisherVar.empty_area_message ;
212
- }
213
- if constexpr (has_header<MessageType>::value) {
214
- msg_to_be_published->header .stamp = current_time;
215
- } else if constexpr (has_stamp<MessageType>::value) {
216
- msg_to_be_published->stamp = current_time;
217
- }
218
- publisherVar.publisher ->publish (std::move (msg_to_be_published));
219
- }
220
- // Set Period
221
- template <typename T>
222
- void setPeriod (T & publisherVar, double newPeriod)
223
- {
224
- publisherVar.period_ns = newPeriod;
225
- }
226
-
227
- // Get Period
228
- template <typename T>
229
- double getPeriod (const T & publisherVar) const
230
- {
231
- return publisherVar.period_ns ;
232
- }
233
-
234
- // Get Empty Area Message
235
- template <typename T>
236
- std::shared_ptr<void > getEmptyAreaMessage (const T & publisherVar) const
237
- {
238
- return std::static_pointer_cast<void >(publisherVar.empty_area_message );
239
- }
240
-
241
- // Get Object Spawned Message
242
- template <typename T>
243
- std::shared_ptr<void > getObjectSpawnedMessage (const T & publisherVar) const
244
- {
245
- return std::static_pointer_cast<void >(publisherVar.object_spawned_message );
246
- }
247
- };
248
-
249
- using PublisherVariablesVariant = std::variant<
250
- PublisherVariables<PointCloud2>, PublisherVariables<sensor_msgs::msg::CameraInfo>,
251
- PublisherVariables<sensor_msgs::msg::Image>,
252
- PublisherVariables<geometry_msgs::msg::PoseWithCovarianceStamped>,
253
- PublisherVariables<sensor_msgs::msg::Imu>,
254
- PublisherVariables<autoware_auto_vehicle_msgs::msg::ControlModeReport>,
255
- PublisherVariables<autoware_auto_vehicle_msgs::msg::GearReport>,
256
- PublisherVariables<autoware_auto_vehicle_msgs::msg::HazardLightsReport>,
257
- PublisherVariables<autoware_auto_vehicle_msgs::msg::SteeringReport>,
258
- PublisherVariables<autoware_auto_vehicle_msgs::msg::TurnIndicatorsReport>,
259
- PublisherVariables<autoware_auto_vehicle_msgs::msg::VelocityReport>>;
260
-
261
137
class ReactionAnalyzerNode : public rclcpp ::Node
262
138
{
263
139
public:
@@ -270,17 +146,7 @@ class ReactionAnalyzerNode : public rclcpp::Node
270
146
RunningMode node_running_mode_;
271
147
272
148
// Parameters
273
- GeneralParams general_params_;
274
- PerceptionPlanningModeParams perception_planning_mode_params_;
275
- PlanningControlModeParams planning_control_mode_params_;
276
-
277
- // TEMP
278
- void genericMessagePublisher (const std::string & topic_name);
279
- std::unordered_map<std::string, PublisherVariablesVariant> topic_publisher_map_;
280
- std::vector<PublisherVariables<PointCloud2>> sync_pointcloud_publishers_;
281
- void syncPointcloudPublisher ();
282
- rclcpp::TimerBase::SharedPtr sync_pointcloud_publish_timer_;
283
- void initRosbagPublishers ();
149
+ NodeParams node_params_;
284
150
285
151
// Initialization Variables
286
152
geometry_msgs::msg::Pose entity_pose_;
@@ -324,8 +190,9 @@ class ReactionAnalyzerNode : public rclcpp::Node
324
190
void initPredictedObjects ();
325
191
326
192
void initEgoForTest (
327
- LocalizationInitializationState::ConstSharedPtr initialization_state_ptr,
328
- RouteState::ConstSharedPtr route_state_ptr);
193
+ const LocalizationInitializationState::ConstSharedPtr & initialization_state_ptr,
194
+ const RouteState::ConstSharedPtr & route_state_ptr,
195
+ const OperationModeState::ConstSharedPtr & operation_mode_ptr);
329
196
330
197
void setControlCommandToBuffer (
331
198
std::vector<AckermannControlCommand> & buffer, const AckermannControlCommand & cmd);
@@ -334,13 +201,16 @@ class ReactionAnalyzerNode : public rclcpp::Node
334
201
const std::vector<AckermannControlCommand> & cmd_array,
335
202
const std::optional<rclcpp::Time> & spawn_cmd_time);
336
203
337
- void spawnObstacle (
338
- const geometry_msgs::msg::Point & ego_pose, std::optional<rclcpp::Time> & spawn_cmd_time);
204
+ void spawnObstacle (const geometry_msgs::msg::Point & ego_pose);
339
205
340
206
void printResults (const std::unordered_map<std::string, BufferVariant> & message_buffers);
341
207
342
208
void onTimer ();
343
209
210
+ void dummyPerceptionPublisher ();
211
+
212
+ void reset ();
213
+
344
214
// Callbacks
345
215
void vehiclePoseCallback (Odometry::ConstSharedPtr msg_ptr);
346
216
@@ -350,7 +220,7 @@ class ReactionAnalyzerNode : public rclcpp::Node
350
220
351
221
void operationModeCallback (OperationModeState::ConstSharedPtr msg_ptr);
352
222
353
- // Callbacks for modules are observed
223
+ // Callbacks for modules are subscribed
354
224
void controlCommandOutputCallback (
355
225
const std::string & node_name, const AckermannControlCommand::ConstSharedPtr & msg_ptr);
356
226
@@ -369,23 +239,26 @@ class ReactionAnalyzerNode : public rclcpp::Node
369
239
// Variables
370
240
std::vector<rclcpp::SubscriptionBase::SharedPtr> subscribers_;
371
241
std::unordered_map<std::string, BufferVariant> message_buffers_;
372
- std::optional<rclcpp::Time> last_test_environment_init_time_;
242
+ std::optional<rclcpp::Time> last_test_environment_init_request_time_;
243
+ std::optional<rclcpp::Time> test_environment_init_time_;
373
244
std::optional<rclcpp::Time> spawn_cmd_time_;
374
- std::atomic<bool > is_object_spawned_{false };
375
- bool is_test_environment_created_{false };
376
- bool is_ego_initialized_{false };
377
- bool is_route_set_{false };
245
+ std::atomic<bool > spawn_object_cmd_{false };
246
+ std::atomic<bool > is_object_spawned_message_published_{false };
378
247
bool is_output_printed_{false };
379
-
248
+ bool is_vehicle_initialized_{false };
249
+ bool is_route_set_{false };
380
250
// Timer
381
251
rclcpp::TimerBase::SharedPtr timer_;
252
+ rclcpp::TimerBase::SharedPtr dummy_perception_timer_;
382
253
383
254
// Client
384
255
rclcpp::Client<ChangeOperationMode>::SharedPtr client_change_to_autonomous_;
385
256
386
257
void callOperationModeServiceWithoutResponse ();
387
258
388
259
// Pointers
260
+ std::shared_ptr<topic_publisher::TopicPublisher> topic_publisher_ptr_;
261
+
389
262
PointCloud2::SharedPtr entity_pointcloud_ptr_;
390
263
PredictedObjects::SharedPtr predicted_objects_ptr_;
391
264
Odometry::ConstSharedPtr odometry_;
0 commit comments