ADORe
ADORe is a modular open source software library and toolkit for decision making, planning, control and simulation of automated vehicles
envfactory.h
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2017-2020 German Aerospace Center (DLR).
3  * Eclipse ADORe, Automated Driving Open Research https://eclipse.org/adore
4  *
5  * This program and the accompanying materials are made available under the
6  * terms of the Eclipse Public License 2.0 which is available at
7  * http://www.eclipse.org/legal/epl-2.0.
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  * Daniel Heß - initial API and implementation
13  ********************************************************************************/
14 
15 #pragma once
16 
17 #include <math.h>
18 #include <ros/ros.h>
19 #include <adore/env/afactory.h>
21 
22 #include <adore_if_ros_msg/Border.h>
23 #include <adore_if_ros_msg/LaneGeometry.h>
24 #include <nav_msgs/Odometry.h>
25 
26 #include <tf2/LinearMath/Quaternion.h>
27 #include <tf2/LinearMath/Matrix3x3.h>
28 
47 
48 
49 namespace adore
50 {
51  namespace if_ROS
52  {
57  {
58  ros::NodeHandle* n_;
59  public:
60  ENV_Factory(ros::NodeHandle* n)
61  {
62  n_ = n;
63  }
64  // send updates for borders
66  {
67  return new Writer<adore::env::BorderBased::Border, // native type - msg type - converter
68  adore_if_ros_msg::Border,
69  BorderConverter>(n_,"ENV/Border",1000);
70  }
71  // read current vehicle state
73  {
74  return new Reader<adore::env::VehicleMotionState9d, // native type - msg type ConstPtr - converter
75  nav_msgs::OdometryConstPtr,
76  VehicleMotionStateConverter>(n_,"localization",1);
77  }
78  // read borders as they become visible
80  {
82  adore_if_ros_msg::BorderConstPtr,
83  BorderConverter>(n_,"ENV/Border",1000);
84  }
85  // write border type change tasks
87  {
89  adore_if_ros_msg::BorderTypeChangeProfile,
90  BorderTypeChangeProfileConverter>(n_,"ENV/BorderTypeChangeProfile",100);
91  }
92 
93  // read border type change tasks
95  {
97  adore_if_ros_msg::BorderTypeChangeProfileConstPtr,
98  BorderTypeChangeProfileConverter>(n_,"ENV/BorderTypeChangeProfile",100);
99  }
100  // read a set of traffic participants - provides the current, complete set of tracked objects
101  //extension 20220524: read and combine real and virtual traffic objects
103  {
104  return new TPSetMultiReader(n_,"traffic","virtual_traffic",1);
105  }
106 
107  // send navigation data
109  {
111  adore_if_ros_msg::NavigationData,
112  NavigationDataConverter>(n_,"ENV/NavigationData",1000);
113  }
114  // read navigation goal
116  {
118  adore_if_ros_msg::NavigationGoalConstPtr,
119  NavigationGoalConverter>(n_,"ENV/NavigationGoal",1);
120  }
121  // read navigation data
123  {
125  adore_if_ros_msg::NavigationDataConstPtr,
126  NavigationDataConverter>(n_,"ENV/NavigationData",1000);
127  }
128  // write precedence rules
130  {
132  adore_if_ros_msg::Precedence,
133  PrecedenceRuleConverter>(n_,"ENV/Precedence",100);
134  }
135 
136  // read precedence rules
138  {
139  return new Feed<adore::env::PrecedenceRule,
140  adore_if_ros_msg::PrecedenceConstPtr,
141  PrecedenceRuleConverter>(n_,"ENV/Precedence",100);
142  }
143 
144  // write propositional logic information
146  {
147  return new Writer<adore::env::Proposition,
148  adore_if_ros_msg::Proposition,
149  PropositionConverter>(n_,"ENV/propositions",100);
150  }
151 
152  // read propositional logic information
154  {
155  return new Feed<adore::env::Proposition,
156  adore_if_ros_msg::PropositionConstPtr,
157  PropositionConverter>(n_,"ENV/propositions",100);
158  }
159 
160  // read traffic light information: controlled connection specifies state of a connection, which is controlled by for example a traffic light
162  {
164  adore_if_ros_msg::TCDConnectionStateTraceConstPtr,
165  TCDConnectionConverter>(n_,"ENV/tcd",500);
166  }
167 
168  // read checkpoint information represented as controlled connections
170  {
172  adore_if_ros_msg::TCDConnectionStateTraceConstPtr,
173  TCDConnectionConverter>(n_,"ENV/checkpoints",100);
174  }
175 
176  //write checkpoint information represented as controlled connections
178  {
180  adore_if_ros_msg::TCDConnectionStateTrace,
181  TCDConnectionConverter>(n_,"ENV/checkpoints",100);
182  }
183 
184  // read the latest prediction set for expected behavior
186  {
188  adore_if_ros_msg::OccupancyCylinderPredictionSetConstPtr,
189  OccupancyConverter>(n_,"ENV/Prediction/expected",1);
190  }
191 
192  // read the latest prediction set for worst-case behavior
194  {
196  adore_if_ros_msg::OccupancyCylinderPredictionSetConstPtr,
197  OccupancyConverter>(n_,"ENV/Prediction/worstcase",1);
198  }
199 
200  // read the latest prediction set for expected behavior, unfiltered
202  {
204  adore_if_ros_msg::OccupancyCylinderPredictionSetConstPtr,
205  OccupancyConverter>(n_,"ENV/Prediction/expected_raw",1);
206  }
207 
208  // read the latest prediction set for worst-case behavior, unfiltered
210  {
212  adore_if_ros_msg::OccupancyCylinderPredictionSetConstPtr,
213  OccupancyConverter>(n_,"ENV/Prediction/worstcase_raw",1);
214  }
215 
216  // read the latest prediction set for desired behavior
218  {
220  adore_if_ros_msg::OccupancyCylinderPredictionSetConstPtr,
221  OccupancyConverter>(n_,"ENV/Prediction/desired",1);
222  }
223 
224  // read the latest prediction set for static obstacles
226  {
228  adore_if_ros_msg::OccupancyCylinderPredictionSetConstPtr,
229  OccupancyConverter>(n_,"ENV/Prediction/static",1);
230  }
231 
232  // write the latest prediction set for expected behavior
234  {
237  OccupancyConverter>(n_,"ENV/Prediction/expected",1);
238  }
239 
240  // write the latest prediction set for worst-case behavior
242  {
245  OccupancyConverter>(n_,"ENV/Prediction/worstcase",1);
246  }
247 
248  // write the latest prediction set for expected behavior, unfiltered
250  {
253  OccupancyConverter>(n_,"ENV/Prediction/expected_raw",1);
254  }
255 
256  // write the latest prediction set for worst-case behavior, unfiltered
258  {
261  OccupancyConverter>(n_,"ENV/Prediction/worstcase_raw",1);
262  }
263 
264  // write the latest prediction set for desired behavior
266  {
269  OccupancyConverter>(n_,"ENV/Prediction/desired",1);
270  }
271 
272  // read the latest conflict set
274  {
276  adore_if_ros_msg::OccupancyCylinderPredictionSetConstPtr,
277  OccupancyConverter>(n_,"ENV/ConflictSet",1);
278  }
279 
280  // read the latest conflict set
282  {
285  OccupancyConverter>(n_,"ENV/ConflictSet",1);
286  }
287 
288  // get combined lane geometry feed
290  {
292  adore_if_ros_msg::LaneGeometryConstPtr,
293  LaneGeometryConverter>(n_,"ENV/lanegeometry",100);
294  }
295 
296  // write the combined lane geometry
298  {
300  adore_if_ros_msg::LaneGeometry,
301  LaneGeometryConverter>(n_,"ENV/lanegeometry",100);
302  }
303 
304  // reads reset signal for lane matching
306  {
307  return new Reader<bool,std_msgs::BoolPtr,StdConverter>(n_,"ENV/ResetLaneMatching",1);
308  }
309 
310  // writes reset signal for lane matching
312  {
313  return new Writer<bool,std_msgs::Bool,StdConverter>(n_,"ENV/ResetLaneMatching",1);
314  }
315 
317  {
318  return new Writer<adore::env::SpeedLimit,
319  adore_if_ros_msg::SpeedLimit,
320  SpeedLimitConverter>(n_,"ENV/speedlimits",100);
321  }
322 
323  // feed for speed limit info
325  {
326  return new Feed<adore::env::SpeedLimit,
327  adore_if_ros_msg::SpeedLimitConstPtr,
328  SpeedLimitConverter>(n_,"ENV/speedlimits",100);
329  }
331  {
332  return new Writer<adore::env::AreaOfEffect,
334  AreaOfEffectConverter>(n_,"ENV/areaofeffect",1);
335  }
337  {
338  return new Writer<adore::env::AreaOfEffect,
340  AreaOfEffectConverter>(n_,"ENV/areaofinterest",1);
341  }
343  {
344  return new Reader<adore::env::CooperativeUserPrediction, // native type - msg type ConstPtr - converter
345  adore_if_ros_msg::CooperativePlanningConstPtr ,
346  CooperativeUsersPredictionConverter>(n_,"ENV/Cooperation/cooperativeuser",1);
347  }
348 
350  {
351  return new Writer<adore::env::CooperativeUserPrediction, // native type - msg type ConstPtr - converter
352  adore_if_ros_msg::CooperativePlanning ,
353  CooperativeUsersPredictionConverter>(n_,"ENV/Cooperation/cooperativeuser",1);
354  }
355 
357  {
358  return new Reader<adore::env::CooperativeUsersList, // native type - msg type ConstPtr - converter
359  adore_if_ros_msg::CooperativePlanningSetConstPtr ,
360  CooperativeUsersPredictionConverter>(n_,"ENV/Cooperation/cooperativeuserslist",1);
361  }
362 
364  {
365  return new Writer<adore::env::CooperativeUsersList, // native type - msg type ConstPtr - converter
366  adore_if_ros_msg::CooperativePlanningSet ,
367  CooperativeUsersPredictionConverter>(n_,"ENV/Cooperation/cooperativeuserslist",1);
368  }
369 
370  // write the gap queue on the left lane
372  {
373  return new Writer<adore::env::GapQueue,
375  GapConverter>(n_,"ENV/gaps/leftlane",1);
376  }
377 
378  // write the gap queue on the right lane
380  {
381  return new Writer<adore::env::GapQueue,
383  GapConverter>(n_,"ENV/gaps/rightlane",1);
384  }
385 
386  // read the gap queue on the left lane
388  {
389  return new Reader<adore::env::GapQueue,
390  adore_if_ros_msg::GapQueueConstPtr,
391  GapConverter>(n_,"ENV/gaps/leftlane",1);
392  }
393 
394  // read the gap queue on the right lane
396  {
397  return new Reader<adore::env::GapQueue,
398  adore_if_ros_msg::GapQueueConstPtr,
399  GapConverter>(n_,"ENV/gaps/rightlane",1);
400  }
401 
402  // writer for indicator hints
404  {
406  adore_if_ros_msg::IndicatorHint,
407  IndicatorHintConverter>(n_,"ENV/indicatorhints",100);
408  }
409 
410  // feed for indicator hints
412  {
413  return new Feed<adore::env::IndicatorHint,
414  adore_if_ros_msg::IndicatorHintConstPtr,
415  IndicatorHintConverter>(n_,"ENV/indicatorhints",100);
416  }
417 
418 
419 
420  };
421  }
422 }
abstract factory for adore::env communication
Definition: afactory.h:41
Definition: controlledconnection.h:81
Definition: envfactory.h:57
adore::env::AFactory::TGapQueueReader * getGapQueueReaderRightLane() override
Definition: envfactory.h:395
adore::env::AFactory::TGapQueueWriter * getGapQueueWriterRightLane() override
Definition: envfactory.h:379
adore::env::AFactory::TNavigationDataFeed * getNavigationDataFeed() override
Definition: envfactory.h:122
adore::env::AFactory::TOCPredictionSetWriter * getConflictSetWriter() override
Definition: envfactory.h:281
adore::env::AFactory::TOCPredictionSetReader * getStaticObstaclesPredictionSetReader() override
Definition: envfactory.h:225
adore::env::AFactory::TResetLaneMatchingWriter * getResetLaneMatchingWriter() override
Definition: envfactory.h:311
adore::env::AFactory::TOCPredictionSetWriter * getWorstCasePredictionSetWriter() override
Definition: envfactory.h:241
adore::env::AFactory::TControlledConnectionFeed * getControlledConnectionFeed() override
Definition: envfactory.h:161
adore::env::AFactory::TAreaOfEffectWriter * getAreaOfInterestWriter() override
Definition: envfactory.h:336
adore::env::AFactory::TOCPredictionSetReader * getExpectedPredictionSetReader() override
Definition: envfactory.h:185
virtual adore::mad::AWriter< adore::env::BorderTypeChangeProfile > * getBorderTypeChangeProfileWriter() override
Definition: envfactory.h:86
ros::NodeHandle * n_
Definition: envfactory.h:58
adore::env::AFactory::TOCPredictionSetReader * getWorstCasePredictionSetReader() override
Definition: envfactory.h:193
adore::mad::AWriter< std::pair< adore::env::BorderBased::BorderID, double > > * getNavigationDataWriter() override
Definition: envfactory.h:108
adore::mad::AReader< adore::fun::NavigationGoal > * getNavigationGoalReader() override
Definition: envfactory.h:115
adore::env::AFactory::TOCPredictionSetWriter * getExpectedPredictionSetWriter() override
Definition: envfactory.h:233
adore::env::AFactory::TOCPredictionSetReader * getWorstCaseRawPredictionSetReader() override
Definition: envfactory.h:209
adore::env::AFactory::TAreaOfEffectWriter * getAreaOfEffectWriter() override
Definition: envfactory.h:330
adore::env::AFactory::TControlledConnectionFeed * getCheckPointFeed() override
Definition: envfactory.h:169
TIndicatorHintWriter * getIndicatorHintWriter() override
Definition: envfactory.h:403
adore::mad::AReader< adore::env::VehicleMotionState9d > * getVehicleMotionStateReader() override
Definition: envfactory.h:72
TSpeedLimitFeed * getSpeedLimitFeed() override
Definition: envfactory.h:324
adore::env::AFactory::TControlledConnectionWriter * getCheckPointWriter() override
Definition: envfactory.h:177
TSpeedLimitWriter * getSpeedLimitWriter() override
Definition: envfactory.h:316
adore::env::AFactory::TOCPredictionSetReader * getExpectedRawPredictionSetReader() override
Definition: envfactory.h:201
TPrecedenceRuleFeed * getPrecedenceRuleFeed() override
Definition: envfactory.h:137
TIndicatorHintFeed * getIndicatorHintFeed() override
Definition: envfactory.h:411
adore::env::AFactory::TOCPredictionSetWriter * getWorstCaseRawPredictionSetWriter() override
Definition: envfactory.h:257
adore::mad::AFeed< adore::env::BorderBased::Border > * getBorderFeed() override
Definition: envfactory.h:79
adore::env::AFactory::TOCPredictionSetWriter * getExpectedRawPredictionSetWriter() override
Definition: envfactory.h:249
adore::env::AFactory::TOCPredictionSetWriter * getDesiredPredictionSetWriter() override
Definition: envfactory.h:265
adore::mad::AWriter< adore::env::BorderBased::Border > * getBorderWriter() override
Definition: envfactory.h:65
virtual adore::mad::AFeed< adore::env::BorderTypeChangeProfile > * getBorderTypeChangeProfileFeed() override
Definition: envfactory.h:94
adore::env::AFactory::TGapQueueReader * getGapQueueReaderLeftLane() override
Definition: envfactory.h:387
adore::env::AFactory::TParticipantSetReader * getTrafficParticipantSetReader() override
Definition: envfactory.h:102
virtual adore::mad::AWriter< adore::env::CooperativeUserPrediction > * getCooperativeUserWriter() override
Definition: envfactory.h:349
adore::env::AFactory::TPropositionWriter * getPropositionWriter() override
Definition: envfactory.h:145
virtual adore::mad::AReader< adore::env::CooperativeUserPrediction > * getCooperativeUserReader() override
Definition: envfactory.h:342
adore::env::AFactory::TOCPredictionSetReader * getConflictSetReader() override
Definition: envfactory.h:273
adore::env::AFactory::TResetLaneMatchingReader * getResetLaneMatchingReader() override
Definition: envfactory.h:305
adore::env::AFactory::TPropositionFeed * getPropositionFeed() override
Definition: envfactory.h:153
virtual adore::mad::AWriter< adore::env::CooperativeUsersList > * getCooperativeUsersListWriter() override
Definition: envfactory.h:363
adore::env::AFactory::TOCPredictionSetReader * getDesiredPredictionSetReader() override
Definition: envfactory.h:217
ENV_Factory(ros::NodeHandle *n)
Definition: envfactory.h:60
TPrecedenceRuleWriter * getPrecedenceRuleWriter() override
Definition: envfactory.h:129
adore::env::AFactory::TGapQueueWriter * getGapQueueWriterLeftLane() override
Definition: envfactory.h:371
virtual adore::mad::AReader< adore::env::CooperativeUsersList > * getCooperativeUsersListReader() override
Definition: envfactory.h:356
adore::env::AFactory::TLaneGeometryWriter * getLaneGeometryWriter() override
Definition: envfactory.h:297
adore::env::AFactory::TLaneGeometryFeed * getLaneGeometryFeed() override
Definition: envfactory.h:289
Definition: ros_com_patterns.h:32
Definition: ros_com_patterns.h:113
TPSetMultiReader reads two ros topics and combines data from both.
Definition: trafficparticipantconverter.h:152
Definition: ros_com_patterns.h:153
Definition: com_patterns.h:97
std::vector< OccupancyCylinderPrediction > OccupancyCylinderPredictionSet
Definition: occupancycylinderprediction.h:40
std::vector< CooperativeUserPrediction > CooperativeUsersList
Definition: cooperativeusersprediction.h:70
std::vector< std::pair< double, double > > AreaOfEffect
Definition: areaofeffect.h:20
std::vector< GapData > GapQueue
Definition: gapdata.h:53
Definition: areaofeffectconverter.h:20
The border struct contains data of the smallest.
Definition: border.h:62
Definition: lanecombinedgeometry.h:27
Definition: map_border_management.h:27
Definition: cooperativeusersprediction.h:24
Definition: indicator_hint.h:41
The PrecedenceRule defines a precedence relationship between two routes. Vehicles on the low_ priorit...
Definition: precedence.h:108
A logical proposition, with a possible timeout for the information.
Definition: proposition.h:27
Definition: speedlimit.h:31
This struct holds the motion state of the vehicle in 9d.
Definition: vehiclemotionstate9d.h:39
Definition: navigationgoal.h:26
Definition: areaofeffectconverter.h:27
Definition: borderconverter.h:33
Definition: bordertypechangeprofileconverter.h:27
Definition: cooperativeuserspredictionconverter.h:28
Definition: gapconverter.h:25
Definition: indicatorhintconverter.h:24
Definition: lanegeometryconverter.h:32
Definition: navigationdataconverter.h:25
Definition: navigationgoalconverter.h:39
Definition: occupancyconverter.h:25
Definition: precedenceruleconverter.h:24
Definition: propositionconverter.h:24
Definition: speedlimitconverter.h:25
Definition: tcdconnectionconverter.h:22
Definition: envvehiclemotionstateconverter.h:40