Branch data Line data Source code
1 : : // ----------------- BEGIN LICENSE BLOCK ---------------------------------
2 : : //
3 : : // Copyright (C) 2019-2021 Intel Corporation
4 : : //
5 : : // SPDX-License-Identifier: LGPL-2.1-only
6 : : //
7 : : // ----------------- END LICENSE BLOCK -----------------------------------
8 : : /**
9 : : * @file
10 : : */
11 : :
12 : : #pragma once
13 : :
14 : : #include <ad/map/match/AdMapMatching.hpp>
15 : : #include <ad/rss/map/RssObjectAdapterData.hpp>
16 : : #include <ad/rss/map/RssObjectData.hpp>
17 : : #include <ad/rss/map/RssObjectInstance.hpp>
18 : : #include "ad/rss/map/RssAppendRoadBoundariesMode.hpp"
19 : : #include "ad/rss/map/RssConstellationConfiguration.hpp"
20 : : #include "ad/rss/map/RssRouteList.hpp"
21 : :
22 : : /*!
23 : : * @brief namespace rss
24 : : */
25 : : namespace ad {
26 : : /*!
27 : : * @brief namespace rss
28 : : */
29 : : namespace rss {
30 : : /*!
31 : : * @brief namespace map
32 : : */
33 : : namespace map {
34 : :
35 : : /*! @brief Base class to access basic object information required to perform the RSS checks in conjunction with the
36 : : * RssRouteChecker class.
37 : : *
38 : : * Derived from this class virtually to allows for a similar class layout
39 : : * on side of the concrete implementations of this to be able to handle common functionality of
40 : : * vehicles and pedestrians at one place. E.g.:
41 : : *
42 : : * class RssObjectAdapterCustom: public virtual RssObjectAdapter {};
43 : : * class RssPedestrianAdapterCustom: public RssObjectAdapterCustom, public RssPedestrianAdapter {};
44 : : * class RssVehicleAdapterCustom: public RssObjectAdapterCustom, public virtual RssVehicleAdapter {};
45 : : * class RssEgoVehicleAdapterCustom: public RssVehicleAdapterCustom, public RssEgoVehicleAdapter {};
46 : : *
47 : : * Where RssArtificialObjectAdapter plays a special role to be used to inject additional artificial
48 : : * objects to be considered in addition by the RSS calculation.
49 : : *
50 : : * The pure virtual Getter-functions of this class have to be provided by some derived class.
51 : : * This not necessarily has to be the direct child class (e.g. RssObjectAdapterCustom), since RssObjectAdapter is not
52 : : * used directly.
53 : : * Other virtual functions might be implemented by derived classed to take care on the required steps on their own
54 : : * instead of letting the default implementation handle these (see details on in the function descriptions).
55 : : */
56 : : template <class OBJECT_INSTANCE_TYPE> class RssObjectAdapter : public RssObjectAdapterData
57 : : {
58 : : public:
59 : : /*!
60 : : * \brief Smart pointer on RssObjectAdapter
61 : : */
62 : : typedef std::shared_ptr<RssObjectAdapter> Ptr;
63 : :
64 : : /*!
65 : : * \brief Smart pointer on constant RssObjectAdapter
66 : : */
67 : : typedef std::shared_ptr<RssObjectAdapter const> ConstPtr;
68 : :
69 : : typedef typename RssObjectInstance<OBJECT_INSTANCE_TYPE>::Ptr ObjectInstancePtr;
70 : : typedef typename RssObjectInstance<OBJECT_INSTANCE_TYPE>::ConstPtr ObjectInstanceConstPtr;
71 : :
72 : : /*! @brief default constructor
73 : : */
74 : 441 : explicit RssObjectAdapter(ObjectInstancePtr const objectInstance)
75 : 441 : : mObjectInstance(objectInstance)
76 : : {
77 [ + - ]: 441 : RssObjectAdapterData::object_type = mObjectInstance->getObjectType();
78 : 441 : }
79 : :
80 : : /*! @brief default destructor
81 : : */
82 : 441 : virtual ~RssObjectAdapter() = default;
83 : :
84 : : /*! @returns the object type of this.
85 : : *
86 : : * This function is not virtual by intension. If a derived class (e.g. RssEgoVehicleAdapter) is not used as
87 : : * ego-vehicle, but e.g. as other vehicle, the object type should reflect this.
88 : : */
89 : 438 : ::ad::rss::world::ObjectType getObjectType() const
90 : : {
91 : 438 : return object_type;
92 : : }
93 : :
94 : : /*! @brief get the checker control instance
95 : : */
96 : 1510 : typename RssRouteCheckerControl<OBJECT_INSTANCE_TYPE>::Ptr getCheckerControl() const
97 : : {
98 : 1510 : return getObjectInstance()->getCheckerControl();
99 : : }
100 : :
101 : : /*! @brief get the underlying object instance type
102 : : */
103 : 2057 : ObjectInstancePtr getObjectInstance() const
104 : : {
105 : 2057 : return mObjectInstance;
106 : : }
107 : :
108 : : /*! @brief get the underlying object instance type.
109 : : */
110 : : OBJECT_INSTANCE_TYPE &getObjectInstanceType()
111 : : {
112 : : return getObjectInstance()->getObjectInstanceType();
113 : : }
114 : :
115 : : /*! @brief get the underlying object instance type
116 : : */
117 : 547 : OBJECT_INSTANCE_TYPE const &getObjectInstanceType() const
118 : : {
119 : 547 : return getObjectInstance()->getObjectInstanceType();
120 : : }
121 : :
122 : : /*! @brief get the default RSS dynamics to be used for the object.
123 : : *
124 : : * Default implementation deploys RssRouteCheckerControl in conjunction with the object_type to gather results.
125 : : */
126 : 224 : virtual ::ad::rss::world::RssDynamics getDefaultRssDynamics() const
127 : : {
128 [ + - + - ]: 224 : return getCheckerControl()->getDefaultRssDynamics(object_type, getObjectInstanceType());
129 : : }
130 : :
131 : : /*! @brief get the dimensions of the object to be considered:
132 : : * the stored (estimated) dimensions are expanded by the position confidence
133 : : */
134 : 481 : ::ad::physics::Dimension3D getDimensions() const override
135 : : {
136 : 481 : ::ad::physics::Dimension3D expanded_dimension = dimension;
137 [ + - ]: 481 : if (getCheckerControl()->getConsiderPositionConfidence())
138 : : {
139 [ + - + - ]: 481 : expanded_dimension.length += 2.0 * position_confidence_ellipse_half_axis_dimension.length;
140 [ + - + - ]: 481 : expanded_dimension.width += 2.0 * position_confidence_ellipse_half_axis_dimension.width;
141 : : }
142 : 481 : return expanded_dimension;
143 : : }
144 : :
145 : : /*! @brief Perform actual map matching of the object
146 : : *
147 : : * This function is called each time step ONCE to get the latest map matching results.
148 : : * The default implementation mainly calls into ::ad::map::match::AdMapMatching::getMapMatchedBoundingBox()
149 : : *
150 : : * Can be reimplemented if the map matched position of the object is already available by other means.
151 : : *
152 : : * @param[in] mapMatching the map matching object used for map matching
153 : : * @param[in] sampling_distance the sampling_distance parameter for the mapMatching.getMapMatchedBoundingBox() call.
154 : : *
155 : : * If there is specific user implementation available for this, this can be overridden.
156 : : */
157 : 455 : virtual ::ad::map::match::Object getMatchedObject(::ad::map::match::AdMapMatching const &mapMatching,
158 : : physics::Distance const sampling_distance) const
159 : : {
160 : 455 : ::ad::map::match::Object matchedObject;
161 : 455 : matchedObject.enu_position.center_point = getCenterPoint();
162 : 455 : matchedObject.enu_position.heading = getHeading();
163 [ + - ]: 455 : matchedObject.enu_position.dimension = getDimensions();
164 [ + - ]: 455 : matchedObject.enu_position.enu_reference_point = ::ad::map::access::getENUReferencePoint();
165 : : matchedObject.map_matched_bounding_box
166 [ + - ]: 455 : = mapMatching.getMapMatchedBoundingBox(matchedObject.enu_position, sampling_distance);
167 : 455 : return matchedObject;
168 : 0 : }
169 : :
170 : : /*!
171 : : * @brief Indicate if the object id of this remains unique over time
172 : : *
173 : : * If the object is re-associated over time e.g. the object is tracked, this is \c true.
174 : : * In that case it is assumed that the same real/artificial object keeps the same object id in the next time step,
175 : : * so the RSS state of the previous time step can be taken into account for deriving the proper response.
176 : : * But if the object data is delivered by lower level object detectors where IDs are not re-associated to the last
177 : : * time step objects, this should return \c false.
178 : : *
179 : : * @returns \c true by default implementation.
180 : : */
181 : 28 : virtual bool isObjectIdUniqueOverTime() const
182 : : {
183 : 28 : return true;
184 : : }
185 : :
186 : : protected:
187 : : ObjectInstancePtr mObjectInstance;
188 : : };
189 : :
190 : : template <class OBJECT_INSTANCE_TYPE> class RssPedestrianAdapter : public virtual RssObjectAdapter<OBJECT_INSTANCE_TYPE>
191 : : {
192 : : public:
193 : : /*!
194 : : * \brief Smart pointer on RssPedestrianAdapter
195 : : */
196 : : typedef std::shared_ptr<RssPedestrianAdapter> Ptr;
197 : :
198 : : /*!
199 : : * \brief Smart pointer on constant RssPedestrianAdapter
200 : : */
201 : : typedef std::shared_ptr<RssPedestrianAdapter const> ConstPtr;
202 : :
203 : : using typename RssObjectAdapter<OBJECT_INSTANCE_TYPE>::ObjectInstancePtr;
204 : :
205 : : /*! @brief constructor
206 : : */
207 : 1 : explicit RssPedestrianAdapter(ObjectInstancePtr const objectInstance)
208 : 1 : : RssObjectAdapter<OBJECT_INSTANCE_TYPE>(objectInstance)
209 : : {
210 : 1 : }
211 : :
212 : : /*! @brief default destructor
213 : : */
214 : 1 : virtual ~RssPedestrianAdapter() = default;
215 : : };
216 : :
217 : : /*!
218 : : * \brief typedef for a list of RssPedestrianAdapter smart pointers
219 : : */
220 : : template <class OBJECT_INSTANCE_TYPE>
221 : : using RssPedestrianAdapterList = std::vector<typename RssPedestrianAdapter<OBJECT_INSTANCE_TYPE>::Ptr>;
222 : :
223 : : /*! @brief Base class to access artificialObject information required to perform the RSS checks in conjunction with the
224 : : * RssRouteChecker class.
225 : : *
226 : : * This class specializes the RssObjectAdapter by functionality required specifically for artificialObjects.
227 : : * This class derives virtually from the RssObjectAdapter which allows for a similar class layout
228 : : * on side of the concrete implementations of this to be able to handle common functionality of
229 : : * vehicles, pedestrians and artificialObjects at one place. E.g.:
230 : : *
231 : : * class RssObjectAdapterCustom: public virtual RssObjectAdapter {};
232 : : * class RssPedestrianAdapterCustom: public RssObjectAdapterCustom, public RssPedestrianAdapter {};
233 : : * class RssVehicleAdapterCustom: public RssObjectAdapterCustom, public virtual RssVehicleAdapter {};
234 : : *
235 : : * Where RssArtificialObjectAdapter plays a special role to be used to inject additional artificial
236 : : * objects to be considered in addition by the RSS calculation.
237 : : *
238 : : * Since this class is already constructed with all information required, all virtual functions of the base class
239 : : * RssObjectAdapter are already handled. There is no need to derive from this.
240 : : *
241 : : * Artificial objects are already used to inject road boundaries within RssWorldModelCreation as virtual borders at the
242 : : * border of the lanes. But one is able to make use of this in may ways, since these are considered RSS internally just
243 : : * as everything else. You can inject a duplicate of a real vehicle to enforce a different RSS operation mode or to
244 : : * have two
245 : : * sets of RSS parameters of one vehicle considered at once
246 : : * (you have to ensure that the object id of this is different from all duplicates for sure).
247 : : * Or, if you want to enforce a vehicle to stop in front of a red light, you might be able to inject an artificial
248 : : * object
249 : : * in the middle of the lane at the Stopline to achieve such (and remove the virtual object when it becomes green).
250 : : * Especially for research tasks this provides some freedom to the user.
251 : : */
252 : : template <class OBJECT_INSTANCE_TYPE>
253 : : class RssArtificialObjectAdapter : public virtual RssObjectAdapter<OBJECT_INSTANCE_TYPE>
254 : : {
255 : : public:
256 : : /*!
257 : : * \brief Smart pointer on RssArtificialObjectAdapter
258 : : */
259 : : typedef std::shared_ptr<RssArtificialObjectAdapter> Ptr;
260 : :
261 : : /*!
262 : : * \brief Smart pointer on constant RssArtificialObjectAdapter
263 : : */
264 : : typedef std::shared_ptr<RssArtificialObjectAdapter const> ConstPtr;
265 : :
266 : : using typename RssObjectAdapter<OBJECT_INSTANCE_TYPE>::ObjectInstancePtr;
267 : :
268 : : /*! @brief constructor
269 : : *
270 : : * @param[in] objectAdapterData the RSS relevant data for the artificial object to be considered
271 : : * which describes all required field for RssObjectAdapter to operate on this.
272 : : */
273 : 2 : explicit RssArtificialObjectAdapter(RssObjectAdapterData const &objectAdapterData,
274 : : ::ad::rss::world::RssDynamics rssDynamics,
275 : : typename RssRouteCheckerControl<OBJECT_INSTANCE_TYPE>::Ptr checkerControl)
276 : : : RssObjectAdapter<OBJECT_INSTANCE_TYPE>(
277 : : std::make_shared<RssObjectInstanceDummy<OBJECT_INSTANCE_TYPE>>(objectAdapterData, checkerControl))
278 [ + - ]: 2 : , mRssDynamics(rssDynamics)
279 : : {
280 : : // directly fill the objectAdapterData
281 : 2 : *static_cast<RssObjectAdapterData *>(this) = objectAdapterData;
282 : 2 : }
283 : :
284 : : /*! @brief default destructor
285 : : */
286 : 2 : virtual ~RssArtificialObjectAdapter() = default;
287 : :
288 : : /*! @brief get the default RSS dynamics to be used for the object.
289 : : *
290 : : * Reimplementation returns respective data from RssObjectAdapterData passed at construction time.
291 : : */
292 : 2 : ::ad::rss::world::RssDynamics getDefaultRssDynamics() const override
293 : : {
294 : 2 : return mRssDynamics;
295 : : }
296 : :
297 : : protected:
298 : : ::ad::rss::world::RssDynamics const mRssDynamics;
299 : :
300 : : template <class OBJECT_INSTANCE_TYPE_INNER>
301 : : class RssObjectInstanceDummy : public RssObjectInstance<OBJECT_INSTANCE_TYPE_INNER>
302 : : {
303 : : public:
304 : 2 : RssObjectInstanceDummy(RssObjectAdapterData const &objectAdapterData,
305 : : typename RssRouteCheckerControl<OBJECT_INSTANCE_TYPE_INNER>::Ptr checkerControl)
306 : 2 : : RssObjectInstance<OBJECT_INSTANCE_TYPE_INNER>(mDummyObjectInstanceType, checkerControl)
307 : 2 : , mObjectAdapterData(objectAdapterData)
308 : : {
309 : 2 : }
310 : :
311 : 2 : virtual ~RssObjectInstanceDummy() = default;
312 : :
313 : : /*! @brief get the object type
314 : : *
315 : : * Reimplemented from RssObjectInstance.
316 : : */
317 : 2 : ::ad::rss::world::ObjectType getObjectType() const override
318 : : {
319 : : // fallback to the standard RssObjectAdapter function
320 : 2 : return mObjectAdapterData.object_type;
321 : : }
322 : :
323 : : RssObjectAdapterData const &mObjectAdapterData;
324 : : OBJECT_INSTANCE_TYPE_INNER mDummyObjectInstanceType{};
325 : : };
326 : : };
327 : :
328 : : /*!
329 : : * \brief typedef for a list of RssArtificialObjectAdapter smart pointers
330 : : */
331 : : template <class OBJECT_INSTANCE_TYPE>
332 : : using RssArtificialObjectAdapterList = std::vector<typename RssArtificialObjectAdapter<OBJECT_INSTANCE_TYPE>::Ptr>;
333 : :
334 : : /*! @brief Base class to access vehicle information required to perform the RSS checks in conjunction with the
335 : : * RssRouteChecker class.
336 : : *
337 : : * This class specializes the RssObjectAdapter by functionality required specifically for vehicles.
338 : : * This class derives virtually from the RssObjectAdapter which allows for a similar class layout
339 : : * on side of the concrete implementations of this to be able to handle common functionality of
340 : : * vehicles and pedestrians at one place. E.g.:
341 : : *
342 : : * class RssObjectAdapterCustom: public virtual RssObjectAdapter {};
343 : : * class RssPedestrianAdapterCustom: public RssObjectAdapterCustom, public RssPedestrianAdapter {};
344 : : * class RssVehicleAdapterCustom: public RssObjectAdapterCustom, public virtual RssVehicleAdapter {};
345 : : * class RssEgoVehicleAdapterCustom: public RssVehicleAdapterCustom, public RssEgoVehicleAdapter {};
346 : : *
347 : : * Where RssArtificialObjectAdapter plays a special role to be used to inject additional artificial
348 : : * objects to be considered in addition by the RSS calculation.
349 : : *
350 : : * The pure virtual Getter-functions of this class have to be provided by some derived class.
351 : : * Other virtual functions might be implemented by derived classed to take care on the required steps on their own
352 : : * instead of letting the default implementation handle these (see details on in the function descriptions).
353 : : *
354 : : * The main aspect of RssVehicleAdapter class are the route predictions of the vehicle.
355 : : * These are used by RSS to evaluate the potential route constellations between a
356 : : * RssEgoVehicleAdapter and a RssVehicleAdapter.
357 : : * The default functionality for route prediction is actually implemented by the RssRouteChecker class.
358 : : * Therefore, it is not required to provide any information on those by this class.
359 : : *
360 : : */
361 : : template <class OBJECT_INSTANCE_TYPE> class RssVehicleAdapter : public virtual RssObjectAdapter<OBJECT_INSTANCE_TYPE>
362 : : {
363 : : public:
364 : : /*!
365 : : * \brief Smart pointer on RssVehicleAdapter
366 : : */
367 : : typedef std::shared_ptr<RssVehicleAdapter> Ptr;
368 : :
369 : : /*!
370 : : * \brief Smart pointer on constant RssVehicleAdapter
371 : : */
372 : : typedef std::shared_ptr<RssVehicleAdapter const> ConstPtr;
373 : :
374 : : using typename RssObjectAdapter<OBJECT_INSTANCE_TYPE>::ObjectInstancePtr;
375 : : using RssObjectAdapter<OBJECT_INSTANCE_TYPE>::getCheckerControl;
376 : : using RssObjectAdapter<OBJECT_INSTANCE_TYPE>::getObjectInstance;
377 : : using RssObjectAdapter<OBJECT_INSTANCE_TYPE>::getObjectInstanceType;
378 : : using RssObjectAdapterData::getObjectId;
379 : :
380 : : /*! @brief default constructor
381 : : */
382 : 438 : RssVehicleAdapter(ObjectInstancePtr const objectInstance)
383 : 438 : : RssObjectAdapter<OBJECT_INSTANCE_TYPE>(objectInstance)
384 : : {
385 : 438 : }
386 : :
387 : : /*! @brief default destructor
388 : : */
389 : 438 : virtual ~RssVehicleAdapter() = default;
390 : :
391 : : /*!
392 : : * @brief Return the list of route predictions of the object (optionally).
393 : : *
394 : : * The default implementation returns an empty list.
395 : : *
396 : : * If the specialized function RssVehicleAdapter::getRoutePredictions() returns anything else than an empty list,
397 : : * the returned routes are used for further RSS calculations.
398 : : * In this case only the field RssRoute::vehicle_dynamics_on_route is updated for ego vehicles by RssRouteChecker.
399 : : * All other fields have to be taken care on, including Route::route_id and Route::likelihood (normalization is taken
400 : : * care by RssRouteChecker).
401 : : *
402 : : * Otherwise, RssRouteChecker will take care on calculating the route predictions.
403 : : *
404 : : * Another possibility to influence the route predictions is overriding the routing targets functionality (see
405 : : * below).
406 : : */
407 : 26 : virtual ::ad::rss::map::RssRouteList getRoutePredictions() const
408 : : {
409 : 26 : return ::ad::rss::map::RssRouteList();
410 : : }
411 : :
412 : : /*! @name Routing targets specific functions
413 : : *
414 : : * The following group of functions are used to handle routing targets of the vehicle.
415 : : *
416 : : * The default implementation returns an empty list, which disables the routing target functionality
417 : : * and RssRouteChecker will take care on calculating the route predictions.
418 : : *
419 : : * Be aware: if the getRoutePredictions() function returns anything else than an empty list,
420 : : * the routing target functionality is not used/called at all!
421 : : */
422 : : ///@{
423 : : /*!
424 : : * @brief The mode to be applied on routing target operation
425 : : */
426 : : enum class RssRoutingTargetCommand
427 : : {
428 : : None, //!< no operation (default)
429 : : AppendTargets, //!< append the provided routing targets to the current routing targets and extend the route(s)
430 : : //! accordingly
431 : : ReplaceTargets //!< clear the current route and replace the current routing targets by the new ones;
432 : : //!< in case the new routing targets are empty, route is created using predictions
433 : : };
434 : :
435 : : /*!
436 : : * @brief The mode to be applied on routing target operation
437 : : */
438 : : struct RssRoutingTargetOperation
439 : : {
440 : : RssRoutingTargetCommand command{RssRoutingTargetCommand::None};
441 : : ::ad::map::point::ENUPointList routingTargets{};
442 : : };
443 : :
444 : : /*! @brief Return a routing target operation to be applied (optional)
445 : : *
446 : : * In case getRoutePredictions() returns an empty list, RssRouteChecker will query for
447 : : * routing target operations via this function. If this returns anything else than RoutingTargetCommand::None,
448 : : * the route for the vehicle is created/extended according to the routing target operation;
449 : : * further route prediction operations are only performed in case the resulting route is empty.
450 : : *
451 : : * Default implementation deploys RssRouteCheckerControl to gather results.
452 : : */
453 : 26 : virtual RssRoutingTargetOperation getRoutingTargetOperation()
454 : : {
455 [ + - ]: 26 : return getCheckerControl()->getCurrentRoutingTargetOperation(getObjectId());
456 : : }
457 : :
458 : : /*! @brief Defines the distance at which a given routing target is interpreted to be reached
459 : : *
460 : : * The default implementation returns 3 meters.
461 : : *
462 : : * Be aware: only relevant if routing target functionality is active.
463 : : */
464 : 26 : virtual ad::physics::Distance getRoutingTargetReachedDistance() const
465 : : {
466 : 26 : return ad::physics::Distance(3.);
467 : : }
468 : :
469 : : /*! @brief Provides information on the currently active routing targets
470 : : *
471 : : * Default implementation deploys RssRouteCheckerControl to collect results.
472 : : *
473 : : * Be aware: only relevant if routing target functionality is active.
474 : : */
475 : 26 : virtual void activeRoutingTargets(::ad::map::point::ENUPointList const &activeRoutingTargets)
476 : : {
477 [ + - ]: 26 : getCheckerControl()->setActiveRoutingTargets(getObjectId(), activeRoutingTargets);
478 : 26 : }
479 : : ///@}
480 : :
481 : : /*! @brief Defines the distance at which a delta in vehicle position is considered as
482 : : * unexpected jump. A jump in the position (can occur in simulation on resetting a vehicle's position)
483 : : * triggers automatically the clearing of the current routes and enforces a re-creation of them.
484 : : *
485 : : * Default implementation deploys RssRouteCheckerControl to gather results.
486 : : */
487 : 16 : virtual ad::physics::Distance getPositionJumpTraveledDistance() const
488 : : {
489 : 16 : return getCheckerControl()->getPositionJumpTraveledDistance();
490 : : }
491 : :
492 : : /*! @brief Defines the distance below which a detailed analysis becomes necessary regardless of the objects stopping
493 : : * distance estimates.
494 : : *
495 : : * Far away object might not be analyzed in detail, if the stopping distances allow it
496 : : *
497 : : * Default implementation deploys RssRouteCheckerControl to gather results.
498 : : */
499 : 28 : virtual ad::physics::Distance getMinimumDistanceToObjectsThatHaveToBeAnalyzed() const
500 : : {
501 : 28 : return getCheckerControl()->getMinimumDistanceToObjectsThatHaveToBeAnalyzed();
502 : : }
503 : : };
504 : :
505 : : /*!
506 : : * \brief typedef for a list of RssEgoVehicleAdapter smart pointers
507 : : */
508 : : template <class OBJECT_INSTANCE_TYPE>
509 : : using RssVehicleAdapterList = std::vector<typename RssVehicleAdapter<OBJECT_INSTANCE_TYPE>::Ptr>;
510 : :
511 : : /*! @brief Base class to access ego vehicle information required to perform the RSS checks in conjunction with the
512 : : * RssRouteChecker class.
513 : : *
514 : : * This class specializes the RssVehicleAdapter by functionality required specifically for ego vehicles.
515 : : * This class derives virtually from the RssVehicleAdapter which allows for a similar class layout
516 : : * on side of the concrete implementations of this to be able to handle common functionality of
517 : : * vehicles and pedestrians at one place. E.g.:
518 : : *
519 : : * class RssObjectAdapterCustom: public virtual RssObjectAdapter {};
520 : : * class RssPedestrianAdapterCustom: public RssObjectAdapterCustom, public RssPedestrianAdapter {};
521 : : * class RssVehicleAdapterCustom: public RssObjectAdapterCustom, public virtual RssVehicleAdapter {};
522 : : * class RssEgoVehicleAdapterCustom: public RssVehicleAdapterCustom, public RssEgoVehicleAdapter {};
523 : : * class RssArtificialObjectAdapterCustom: public RssObjectAdapterCustom, public RssArtificialObjectAdapter {};
524 : : *
525 : : * The pure virtual Getter-functions of this class have to be provided by some derived class.
526 : : * The virtual Update-functions might be implemented by derived classed to take care on the required steps on their own
527 : : * instead of letting the default implementation handle these (see details on in the function descriptions).
528 : : */
529 : : template <class OBJECT_INSTANCE_TYPE>
530 : : class RssEgoVehicleAdapter : public virtual RssVehicleAdapter<OBJECT_INSTANCE_TYPE>
531 : : {
532 : : public:
533 : : /*!
534 : : * \brief Smart pointer on RssEgoVehicleAdapter
535 : : */
536 : : typedef std::shared_ptr<RssEgoVehicleAdapter> Ptr;
537 : :
538 : : /*!
539 : : * \brief Smart pointer on constant RssEgoVehicleAdapter
540 : : */
541 : : typedef std::shared_ptr<RssEgoVehicleAdapter const> ConstPtr;
542 : :
543 : : using typename RssObjectAdapter<OBJECT_INSTANCE_TYPE>::ObjectInstancePtr;
544 : : using RssObjectAdapter<OBJECT_INSTANCE_TYPE>::getCheckerControl;
545 : : using RssObjectAdapter<OBJECT_INSTANCE_TYPE>::getObjectInstance;
546 : : using RssObjectAdapter<OBJECT_INSTANCE_TYPE>::getObjectInstanceType;
547 : :
548 : : /*! @brief default constructor
549 : : */
550 : 221 : RssEgoVehicleAdapter(ObjectInstancePtr const objectInstance)
551 : : : RssObjectAdapter<OBJECT_INSTANCE_TYPE>(objectInstance)
552 : 221 : , RssVehicleAdapter<OBJECT_INSTANCE_TYPE>(objectInstance)
553 : : {
554 : 221 : }
555 : :
556 : : /*! @brief default destructor
557 : : */
558 : 221 : virtual ~RssEgoVehicleAdapter() = default;
559 : : /*! @brief get the green traffic lights along the investigated route
560 : : *
561 : : * Virtual function. Default implementation deploys RssRouteCheckerControl to gather results.
562 : : */
563 : : virtual ::ad::map::landmark::LandmarkIdSet
564 : 28 : getGreenTrafficLightsOnRoute(::ad::map::route::FullRoute const &route) const
565 : : {
566 : : // the default implementation is independent from route...
567 : : (void)route;
568 [ + - ]: 28 : return getCheckerControl()->getCurrentGreenTrafficLights();
569 : : }
570 : :
571 : : /*! @brief get the road boundaries mode on the investigated route
572 : : *
573 : : * Virtual function. Default implementation deploys RssRouteCheckerControl to gather results.
574 : : */
575 : 28 : virtual RssAppendRoadBoundariesMode getRoadBoundariesMode(::ad::map::route::FullRoute const &route) const
576 : : {
577 : : // the default implementation is independent from route...
578 : : (void)route;
579 : 28 : return getCheckerControl()->getRoadBoundariesMode();
580 : : }
581 : :
582 : : /*! @brief get the parameters to be used for the vehicle constellation on the route.
583 : : *
584 : : * Virtual function. Default implementation deploys RssRouteCheckerControl to gather results.
585 : : *
586 : : * @param[in] route the ego-route of this constellation
587 : : * @param[in] egoVehicleObject the ego vehicle object data of this constellation
588 : : * @param[in] otherVehicle the other vehicle of this constellation
589 : : * @param[in] otherVehicleObject the other vehicle object data of this constellation
590 : : *
591 : : */
592 : : virtual RssConstellationConfiguration
593 : 44 : getVehicleConstellationOnRoute(RssRoute const &route,
594 : : RssObjectData const &egoVehicleObject,
595 : : typename RssVehicleAdapter<OBJECT_INSTANCE_TYPE>::ConstPtr otherVehicle,
596 : : RssObjectData const &otherVehicleObject) const
597 : : {
598 : 88 : return getCheckerControl()->getVehicleConstellation(
599 [ + - + - : 88 : route, egoVehicleObject, getObjectInstanceType(), otherVehicleObject, otherVehicle->getObjectInstanceType());
+ - ]
600 : : }
601 : :
602 : : /*! @brief get the parameters to be used for the pedestrian constellation on the route.
603 : : *
604 : : * Virtual function. Default implementation deploys RssRouteCheckerControl to gather results.
605 : : *
606 : : * @param[in] route the ego-route of this constellation
607 : : * @param[in] egoVehicleObject the ego vehicle object data of this constellation
608 : : * @param[in] pedestrian the pedestrian of this constellation
609 : : * @param[in] pedestrianObject the pedestrian object data of this constellation
610 : : *
611 : : */
612 : : virtual RssConstellationConfiguration
613 : 0 : getPedestrianConstellationOnRoute(RssRoute const &route,
614 : : RssObjectData const &egoVehicleObject,
615 : : typename RssPedestrianAdapter<OBJECT_INSTANCE_TYPE>::ConstPtr pedestrian,
616 : : RssObjectData const &pedestrianObject) const
617 : : {
618 : 0 : return getCheckerControl()->getPedestrianConstellation(
619 [ # # # # : 0 : route, egoVehicleObject, getObjectInstanceType(), pedestrianObject, pedestrian->getObjectInstanceType());
# # ]
620 : : }
621 : :
622 : : /*! @brief get the parameters to be used for the artificialObject constellation on the route.
623 : : *
624 : : * Virtual function. Default implementation deploys RssRouteCheckerControl to gather results.
625 : : *
626 : : * @param[in] route the ego-route of this constellation
627 : : * @param[in] egoVehicleObject the ego vehicle object data of this constellation
628 : : * @param[in] artificialObject the artificialObject of this constellation
629 : : * @param[in] artificialObjectObject the artificialObject object data of this constellation
630 : : *
631 : : */
632 : 4 : virtual RssConstellationConfiguration getArtificialObjectConstellationOnRoute(
633 : : RssRoute const &route,
634 : : RssObjectData const &egoVehicleObject,
635 : : typename RssArtificialObjectAdapter<OBJECT_INSTANCE_TYPE>::ConstPtr artificialObjectAdapter,
636 : : RssObjectData const &artificialObject) const
637 : : {
638 : : (void)artificialObjectAdapter;
639 : 8 : return getCheckerControl()->getArtificialObjectConstellation(
640 [ + - + - ]: 8 : route, egoVehicleObject, getObjectInstanceType(), artificialObject);
641 : : }
642 : :
643 : : /*! @returns ::ad::rss::world::ObjectType::EgoVehicle as type of this.
644 : : *
645 : : * This overloaded function is not virtual by intension. If this class is not used as ego-vehicle,
646 : : * but other vehicle, the object type of the base class RssVehicleAdapter should be returned.
647 : : */
648 : 17 : ::ad::rss::world::ObjectType getObjectType() const
649 : : {
650 : 17 : return ::ad::rss::world::ObjectType::EgoVehicle;
651 : : }
652 : :
653 : : /*! @brief get the default RSS dynamics to be used for the object.
654 : : *
655 : : * Reimplemented from RssObjectAdapter.
656 : : * Default implementation deploys RssRouteCheckerControl to gather results.
657 : : */
658 : 231 : ::ad::rss::world::RssDynamics getDefaultRssDynamics() const override
659 : : {
660 : 462 : return getCheckerControl()->getDefaultRssDynamics(::ad::rss::world::ObjectType::EgoVehicle,
661 [ + - + - ]: 462 : getObjectInstanceType());
662 : : }
663 : : };
664 : :
665 : : /*!
666 : : * \brief typedef for a list of RssEgoVehicleAdapter smart pointers
667 : : */
668 : : template <class OBJECT_INSTANCE_TYPE>
669 : : using RssEgoVehicleAdapterList = std::vector<typename RssEgoVehicleAdapter<OBJECT_INSTANCE_TYPE>::Ptr>;
670 : :
671 : : } // namespace map
672 : : } // namespace rss
673 : : } // namespace ad
|