ad_rss
RssUnstructuredConstellationChecker.hpp
Go to the documentation of this file.
1 // ----------------- BEGIN LICENSE BLOCK ---------------------------------
2 //
3 // Copyright (C) 2020-2022 Intel Corporation
4 //
5 // SPDX-License-Identifier: LGPL-2.1-only
6 //
7 // ----------------- END LICENSE BLOCK -----------------------------------
8 
13 #pragma once
14 
15 #include <ad/geometry/GeometryOperation.hpp>
16 #include <cstdint>
17 #include <map>
22 
26 namespace ad {
30 namespace rss {
34 namespace unstructured {
35 
46 {
47 public:
48  enum class SafeState
49  {
50  safe,
51  unsafeBrakeOtherHasPrio,
52  unsafeBrakeEgoHasPrio,
53  unsafeBrakeBoth
54  };
55 
56  enum class DrivingMode
57  {
58  DriveAway,
59  ContinueForward,
60  Brake,
61  Invalid
62  };
63 
68 
73 
78 
83 
95  core::RelativeConstellation const &constellation,
97  state::RssState &rssState);
98 
112  = std::function<bool(::ad::rss::core::RelativeConstellation const &constellation,
113  ::ad::rss::world::ObjectId const &objectId,
114  ::ad::rss::core::RelativeObjectState const &vehicleState,
115  ::ad::geometry::Polygon &brakePolygon,
116  ::ad::geometry::Polygon &continueForwardPolygon)>;
117 
124  void
126  CalculateTrajectorySetsCallbackFunctionType calculateTrajectorySetsCallback)
127  {
128  std::lock_guard<std::shared_timed_mutex> const lock(mCallbackRwLock);
129  mCalculateTrajectorySetsCallbackMap[objectType] = calculateTrajectorySetsCallback;
130  }
131 
132 private:
143  bool calculateUnstructuredConstellationStateInfo(::ad::rss::core::RelativeConstellation const &constellation,
144  ::ad::rss::world::ObjectId const &objectId,
145  core::RelativeObjectState const &objectState,
147 
158  bool calculateState(core::RelativeConstellation const &constellation,
162 
173  bool calculateDriveAwayAngle(::ad::geometry::Point const &egoVehicleLocation,
174  ::ad::geometry::Point const &otherVehicleLocation,
175  physics::Angle const &maxAllowedAngleWhenBothStopped,
176  ::ad::geometry::HeadingRange &range) const;
177 
182  typedef std::map<core::RelativeConstellationId, bool> OtherMustBrakeStateBeforeDangerThresholdTimeMap;
183 
189  OtherMustBrakeStateBeforeDangerThresholdTimeMap mOtherMustBrakeStatesBeforeDangerThresholdTime;
190 
194  OtherMustBrakeStateBeforeDangerThresholdTimeMap mNewOtherMustBrakeStatesBeforeDangerThresholdTime;
195 
200  world::TimeIndex mCurrentTimeIndex{0u};
201 
205  struct DriveAwayState
206  {
207  ::ad::geometry::HeadingRange allowedHeadingRange;
208  physics::Distance2D otherPosition;
209  };
210 
214  std::map<core::RelativeConstellationId, DriveAwayState> mDriveAwayStateMap;
215 
216  // one writer mutex for the callbacks of the class should be sufficient
217  // vast majority of concurrent access is of shared nature
218  mutable std::shared_timed_mutex mCallbackRwLock;
219 
220  std::map<world::ObjectType, CalculateTrajectorySetsCallbackFunctionType> mCalculateTrajectorySetsCallbackMap;
221 };
222 
223 } // namespace unstructured
224 } // namespace rss
225 } // namespace ad
Class to check whether an unstructured constellation is safe and to determine the proper response for...
Definition: RssUnstructuredConstellationChecker.hpp:46
bool calculateRssStateUnstructured(world::TimeIndex const &time_index, core::RelativeConstellation const &constellation, state::UnstructuredConstellationStateInformation &egoStateInfo, state::RssState &rssState)
Calculate safety checks and determine required rssState for unstructured constellations.
std::function< bool(::ad::rss::core::RelativeConstellation const &constellation, ::ad::rss::world::ObjectId const &objectId, ::ad::rss::core::RelativeObjectState const &vehicleState, ::ad::geometry::Polygon &brakePolygon, ::ad::geometry::Polygon &continueForwardPolygon)> CalculateTrajectorySetsCallbackFunctionType
Function callback type for unstructured trajectory set calculation.
Definition: RssUnstructuredConstellationChecker.hpp:116
RssUnstructuredConstellationChecker(RssUnstructuredConstellationChecker const &other)
Copy constructor.
void registerCalculateTrajectorySetsCallback(world::ObjectType objectType, CalculateTrajectorySetsCallbackFunctionType calculateTrajectorySetsCallback)
Register a callback for unstructured trajectory set calculation.
Definition: RssUnstructuredConstellationChecker.hpp:125
RssUnstructuredConstellationChecker & operator=(RssUnstructuredConstellationChecker const &other)
Assignment operator.
ObjectType
DataType ObjectType.
Definition: ObjectType.hpp:44
uint64_t ObjectId
DataType ObjectId.
Definition: ObjectId.hpp:39
uint64_t TimeIndex
DataType TimeIndex.
Definition: TimeIndex.hpp:39
namespace ad
Definition: LateralRelativePosition.hpp:28
DataType RelativeConstellation.
Definition: RelativeConstellation.hpp:56
DataType RelativeObjectState.
Definition: RelativeObjectState.hpp:48
DataType RssState.
Definition: RssState.hpp:49
DataType UnstructuredConstellationRssState.
Definition: UnstructuredConstellationRssState.hpp:46
DataType UnstructuredConstellationStateInformation.
Definition: UnstructuredConstellationStateInformation.hpp:45