29
29
#include < autoware_auto_perception_msgs/msg/detected_objects.hpp>
30
30
#include < autoware_auto_perception_msgs/msg/predicted_objects.hpp>
31
31
#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
+ #include < geometry_msgs/msg/pose_with_covariance_stamped.hpp>
32
39
#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>
33
43
#include < sensor_msgs/msg/point_cloud2.hpp>
34
44
35
45
#include < pcl/common/distances.h>
@@ -120,15 +130,107 @@ struct NodeParams
120
130
bool run_from_bag;
121
131
};
122
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 ,
146
+ };
123
147
124
- struct ConjugatePointclouds
148
+ template <typename MessageType>
149
+ struct PublisherVariables
125
150
{
126
- PointCloud2::SharedPtr empty_area_pointcloud;
127
- PointCloud2::SharedPtr object_spawned_pointcloud;
128
- rclcpp::Publisher<PointCloud2>::SharedPtr publisher;
151
+ double period_ns;
152
+ typename MessageType::SharedPtr empty_area_message;
153
+ typename MessageType::SharedPtr object_spawned_message;
154
+ typename rclcpp::Publisher<MessageType>::SharedPtr publisher;
129
155
rclcpp::TimerBase::SharedPtr timer;
130
156
};
131
157
158
+ struct PublisherVarAccessor {
159
+
160
+ // Set Period
161
+ template <typename T>
162
+ void setPeriod (T& publisherVar, double newPeriod) {
163
+ publisherVar.period_ns = newPeriod;
164
+ }
165
+
166
+ // Get Period
167
+ template <typename T>
168
+ double getPeriod (const T& publisherVar) const {
169
+ return publisherVar.period_ns ;
170
+ }
171
+
172
+ // Set Empty Area Message
173
+ template <typename T, typename Message>
174
+ void setEmptyAreaMessage (T& publisherVar, typename Message::SharedPtr message) {
175
+ publisherVar.empty_area_message = message;
176
+ }
177
+
178
+ // Get Empty Area Message
179
+ template <typename T>
180
+ std::shared_ptr<void > getEmptyAreaMessage (const T& publisherVar) const {
181
+ return std::static_pointer_cast<void >(publisherVar.empty_area_message );
182
+ }
183
+
184
+ // Set Object Spawned Message
185
+ template <typename T, typename Message>
186
+ void setObjectSpawnedMessage (T& publisherVar, typename Message::SharedPtr message) {
187
+ publisherVar.object_spawned_message = message;
188
+ }
189
+
190
+ // Get Object Spawned Message
191
+ template <typename T>
192
+ std::shared_ptr<void > getObjectSpawnedMessage (const T& publisherVar) const {
193
+ return std::static_pointer_cast<void >(publisherVar.object_spawned_message );
194
+ }
195
+
196
+ // Set Publisher
197
+ template <typename T, typename PublisherType>
198
+ void setPublisher (T& publisherVar, typename rclcpp::Publisher<PublisherType>::SharedPtr publisher) {
199
+ publisherVar.publisher = publisher;
200
+ }
201
+
202
+ // Get Publisher
203
+ template <typename T>
204
+ std::shared_ptr<void > getPublisher (const T& publisherVar) const {
205
+ return std::static_pointer_cast<void >(publisherVar.publisher );
206
+ }
207
+
208
+ // Set Timer
209
+ template <typename T>
210
+ void setTimer (T& publisherVar, rclcpp::TimerBase::SharedPtr newTimer) {
211
+ publisherVar.timer = newTimer;
212
+ }
213
+
214
+ // Get Timer
215
+ template <typename T>
216
+ std::shared_ptr<void > getTimer (const T& publisherVar) const {
217
+ return std::static_pointer_cast<void >(publisherVar.timer );
218
+ }
219
+ };
220
+
221
+
222
+ using PublisherVariablesVariant = std::variant<
223
+ PublisherVariables<PointCloud2>, PublisherVariables<sensor_msgs::msg::CameraInfo>,
224
+ PublisherVariables<sensor_msgs::msg::Image>,
225
+ PublisherVariables<geometry_msgs::msg::PoseWithCovarianceStamped>,
226
+ PublisherVariables<sensor_msgs::msg::Imu>,
227
+ PublisherVariables<autoware_auto_vehicle_msgs::msg::ControlModeReport>,
228
+ PublisherVariables<autoware_auto_vehicle_msgs::msg::GearReport>,
229
+ PublisherVariables<autoware_auto_vehicle_msgs::msg::HazardLightsReport>,
230
+ PublisherVariables<autoware_auto_vehicle_msgs::msg::SteeringReport>,
231
+ PublisherVariables<autoware_auto_vehicle_msgs::msg::TurnIndicatorsReport>,
232
+ PublisherVariables<autoware_auto_vehicle_msgs::msg::VelocityReport>>;
233
+
132
234
class ReactionAnalyzerNode : public rclcpp ::Node
133
235
{
134
236
public:
@@ -147,11 +249,8 @@ class ReactionAnalyzerNode : public rclcpp::Node
147
249
double entity_search_radius_;
148
250
149
251
// TEMP
150
- void genericPointcloudPublisherTimer (const std::string & topic_name);
151
- std::vector<rclcpp::TimerBase::SharedPtr> pointcloud_pub_timers_;
152
- std::unordered_map<std::string, ConjugatePointclouds> pointclouds_map_;
153
-
154
-
252
+ void genericMessagePublisherTimer (const std::string & topic_name);
253
+ std::unordered_map<std::string, PublisherVariablesVariant> topic_publisher_map_;
155
254
156
255
// Initialization Variables
157
256
geometry_msgs::msg::Pose entity_pose_;
0 commit comments