@@ -79,7 +79,7 @@ using BufferVariant = std::variant<
79
79
ControlCommandBuffer, TrajectoryBuffer, PointCloud2Buffer, PredictedObjectsBuffer,
80
80
DetectedObjectsBuffer>;
81
81
82
- enum class MessageType {
82
+ enum class SubscriberMessageType {
83
83
Unknown = 0 ,
84
84
AckermannControlCommand = 1 ,
85
85
Trajectory = 2 ,
@@ -88,11 +88,31 @@ enum class MessageType {
88
88
PredictedObjects = 5 ,
89
89
};
90
90
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
+ enum class RunningMode {
107
+ PerceptionPlanning = 0 ,
108
+ PlanningControl = 1 ,
109
+ };
110
+
91
111
struct TopicConfig
92
112
{
93
113
std::string node_name;
94
114
std::string topic_address;
95
- MessageType message_type;
115
+ SubscriberMessageType message_type;
96
116
};
97
117
98
118
using ChainModules = std::vector<TopicConfig>;
@@ -120,76 +140,83 @@ struct EntityParams
120
140
double z_l;
121
141
};
122
142
123
- struct NodeParams
143
+ struct GeneralParams
124
144
{
145
+ std::string running_mode;
125
146
double timer_period;
147
+ 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
+ double spawn_time_after_init;
159
+ };
160
+
161
+ struct PlanningControlModeParams
162
+ {
126
163
double spawn_distance_threshold;
164
+ double spawned_pointcloud_sampling_distance;
127
165
double control_cmd_buffer_time_interval;
128
166
double min_jerk_for_brake_cmd;
129
- int min_number_descending_order_control_cmd;
130
- bool run_from_bag;
131
- };
132
-
133
- enum class PublisherMessageType {
134
- Unknown = 0 ,
135
- CameraInfo = 1 ,
136
- Image = 2 ,
137
- PointCloud2 = 3 ,
138
- PoseWithCovarianceStamped = 4 ,
139
- Imu = 5 ,
140
- ControlModeReport = 6 ,
141
- GearReport = 7 ,
142
- HazardLightsReport = 8 ,
143
- SteeringReport = 9 ,
144
- TurnIndicatorsReport = 10 ,
145
- VelocityReport = 11 ,
167
+ size_t min_number_descending_order_control_cmd;
168
+ PoseParams initial_pose;
146
169
};
147
170
148
171
template <typename MessageType>
149
172
struct PublisherVariables
150
173
{
151
- double period_ns;
174
+ double period_ns{ 0.0 } ;
152
175
typename MessageType::SharedPtr empty_area_message;
153
176
typename MessageType::SharedPtr object_spawned_message;
154
177
typename rclcpp::Publisher<MessageType>::SharedPtr publisher;
155
178
rclcpp::TimerBase::SharedPtr timer;
156
179
};
157
180
158
- template <typename T>
159
- struct PublisherVariablesMessageTypeExtractor ;
160
-
161
- template <typename MessageType>
162
- struct PublisherVariablesMessageTypeExtractor <PublisherVariables<MessageType>>
163
- {
164
- using Type = MessageType;
165
- };
166
-
167
- template <typename T, typename = std::void_t <>>
168
- struct has_header : std::false_type
181
+ struct PublisherVarAccessor
169
182
{
170
- };
183
+ template <typename T, typename = std::void_t <>>
184
+ struct has_header : std::false_type
185
+ {
186
+ };
171
187
172
- template <typename T>
173
- struct has_header <T, std::void_t <decltype(T::header)>> : std::true_type
174
- {
175
- };
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
+ };
176
196
177
- struct PublisherVarAccessor
178
- {
179
- // Method to set header time if available
180
197
template <typename T>
181
- void setHeaderTimeIfAvailable (T & publisherVar, const rclcpp::Time & time)
198
+ struct has_stamp <T, std:: void_t <decltype(T::stamp)>> : std::true_type
182
199
{
183
- if constexpr (has_header<typename T::MessageType>::value) {
184
- if (publisherVar.empty_area_message ) {
185
- publisherVar.empty_area_message ->header .stamp = time ;
186
- }
187
- if (publisherVar.object_spawned_message ) {
188
- publisherVar.object_spawned_message ->header .stamp = time ;
189
- }
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 ;
190
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));
191
219
}
192
-
193
220
// Set Period
194
221
template <typename T>
195
222
void setPeriod (T & publisherVar, double newPeriod)
@@ -204,62 +231,19 @@ struct PublisherVarAccessor
204
231
return publisherVar.period_ns ;
205
232
}
206
233
207
- // Set Empty Area Message
208
- template <typename T, typename Message>
209
- void setEmptyAreaMessage (T & publisherVar, typename Message::SharedPtr message)
210
- {
211
- publisherVar.empty_area_message = message;
212
- }
213
-
214
234
// Get Empty Area Message
215
235
template <typename T>
216
236
std::shared_ptr<void > getEmptyAreaMessage (const T & publisherVar) const
217
237
{
218
238
return std::static_pointer_cast<void >(publisherVar.empty_area_message );
219
239
}
220
240
221
- // Set Object Spawned Message
222
- template <typename T, typename Message>
223
- void setObjectSpawnedMessage (T & publisherVar, typename Message::SharedPtr message)
224
- {
225
- publisherVar.object_spawned_message = message;
226
- }
227
-
228
241
// Get Object Spawned Message
229
242
template <typename T>
230
243
std::shared_ptr<void > getObjectSpawnedMessage (const T & publisherVar) const
231
244
{
232
245
return std::static_pointer_cast<void >(publisherVar.object_spawned_message );
233
246
}
234
-
235
- // Set Publisher
236
- template <typename T, typename PublisherType>
237
- void setPublisher (
238
- T & publisherVar, typename rclcpp::Publisher<PublisherType>::SharedPtr publisher)
239
- {
240
- publisherVar.publisher = publisher;
241
- }
242
-
243
- // Get Publisher
244
- template <typename T>
245
- std::shared_ptr<void > getPublisher (const T & publisherVar) const
246
- {
247
- return std::static_pointer_cast<void >(publisherVar.publisher );
248
- }
249
-
250
- // Set Timer
251
- template <typename T>
252
- void setTimer (T & publisherVar, rclcpp::TimerBase::SharedPtr newTimer)
253
- {
254
- publisherVar.timer = newTimer;
255
- }
256
-
257
- // Get Timer
258
- template <typename T>
259
- std::shared_ptr<void > getTimer (const T & publisherVar) const
260
- {
261
- return std::static_pointer_cast<void >(publisherVar.timer );
262
- }
263
247
};
264
248
265
249
using PublisherVariablesVariant = std::variant<
@@ -283,26 +267,26 @@ class ReactionAnalyzerNode : public rclcpp::Node
283
267
284
268
private:
285
269
std::mutex mutex_;
270
+ RunningMode node_running_mode_;
286
271
287
272
// Parameters
288
- EntityParams entity_params_;
289
- PoseParams initial_pose_params_;
290
- PoseParams goal_pose_params_;
291
- NodeParams node_params_;
292
- double entity_search_radius_;
273
+ GeneralParams general_params_;
274
+ PerceptionPlanningModeParams perception_planning_mode_params_;
275
+ PlanningControlModeParams planning_control_mode_params_;
293
276
294
277
// TEMP
295
- void genericMessagePublisherTimer (const std::string & topic_name);
278
+ void genericMessagePublisher (const std::string & topic_name);
296
279
std::unordered_map<std::string, PublisherVariablesVariant> topic_publisher_map_;
297
280
std::vector<PublisherVariables<PointCloud2>> sync_pointcloud_publishers_;
298
- bool publish_pointcloud_sync_{true };
299
- void publishAllPointClouds ();
281
+ void syncPointcloudPublisher ();
300
282
rclcpp::TimerBase::SharedPtr sync_pointcloud_publish_timer_;
283
+ void initRosbagPublishers ();
301
284
302
285
// Initialization Variables
303
286
geometry_msgs::msg::Pose entity_pose_;
304
287
geometry_msgs::msg::PoseWithCovarianceStamped init_pose_;
305
288
geometry_msgs::msg::PoseStamped goal_pose_;
289
+ double entity_search_radius_;
306
290
307
291
// Subscribers
308
292
rclcpp::Subscription<Odometry>::SharedPtr sub_kinematics_;
@@ -331,7 +315,7 @@ class ReactionAnalyzerNode : public rclcpp::Node
331
315
332
316
bool loadChainModules ();
333
317
334
- bool initObservers (const ChainModules & modules);
318
+ bool initSubscribers (const reaction_analyzer:: ChainModules & modules);
335
319
336
320
void initAnalyzerVariables ();
337
321
@@ -358,35 +342,36 @@ class ReactionAnalyzerNode : public rclcpp::Node
358
342
void onTimer ();
359
343
360
344
// Callbacks
361
- void vehiclePoseCallback (const Odometry::ConstSharedPtr msg_ptr);
345
+ void vehiclePoseCallback (Odometry::ConstSharedPtr msg_ptr);
362
346
363
- void initializationStateCallback (const LocalizationInitializationState::ConstSharedPtr msg_ptr);
347
+ void initializationStateCallback (LocalizationInitializationState::ConstSharedPtr msg_ptr);
364
348
365
- void routeStateCallback (const RouteState::ConstSharedPtr msg);
349
+ void routeStateCallback (RouteState::ConstSharedPtr msg);
366
350
367
- void operationModeCallback (const OperationModeState::ConstSharedPtr msg_ptr);
351
+ void operationModeCallback (OperationModeState::ConstSharedPtr msg_ptr);
368
352
369
353
// Callbacks for modules are observed
370
354
void controlCommandOutputCallback (
371
- const std::string & node_name, const AckermannControlCommand::ConstSharedPtr msg_ptr);
355
+ const std::string & node_name, const AckermannControlCommand::ConstSharedPtr & msg_ptr);
372
356
373
357
void trajectoryOutputCallback (
374
- const std::string & node_name, const Trajectory::ConstSharedPtr msg_ptr);
358
+ const std::string & node_name, const Trajectory::ConstSharedPtr & msg_ptr);
375
359
376
360
void pointcloud2OutputCallback (
377
- const std::string & node_name, const PointCloud2::ConstSharedPtr msg_ptr);
361
+ const std::string & node_name, const PointCloud2::ConstSharedPtr & msg_ptr);
378
362
379
363
void predictedObjectsOutputCallback (
380
- const std::string & node_name, const PredictedObjects::ConstSharedPtr msg_ptr);
364
+ const std::string & node_name, const PredictedObjects::ConstSharedPtr & msg_ptr);
381
365
382
366
void detectedObjectsOutputCallback (
383
- const std::string & node_name, const DetectedObjects::ConstSharedPtr msg_ptr);
367
+ const std::string & node_name, const DetectedObjects::ConstSharedPtr & msg_ptr);
384
368
385
369
// Variables
386
370
std::vector<rclcpp::SubscriptionBase::SharedPtr> subscribers_;
387
371
std::unordered_map<std::string, BufferVariant> message_buffers_;
388
372
std::optional<rclcpp::Time> last_test_environment_init_time_;
389
373
std::optional<rclcpp::Time> spawn_cmd_time_;
374
+ std::atomic<bool > is_object_spawned_{false };
390
375
bool is_test_environment_created_{false };
391
376
bool is_ego_initialized_{false };
392
377
bool is_route_set_{false };
0 commit comments