LCOV - code coverage report
Current view: top level - include/ad/rss/map - RssObjectConversion.hpp (source / functions) Hit Total Coverage
Test: ad_rss_map_integration Lines: 4 6 66.7 %
Date: 2024-04-16 14:13:14 Functions: 3 4 75.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : // ----------------- BEGIN LICENSE BLOCK ---------------------------------
       2                 :            : //
       3                 :            : // Copyright (C) 2018-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/rss/map/RssObjectData.hpp>
      15                 :            : 
      16                 :            : #include <ad/map/route/FullRoute.hpp>
      17                 :            : #include <memory>
      18                 :            : 
      19                 :            : /*!
      20                 :            :  * @brief namespace ad
      21                 :            :  */
      22                 :            : namespace ad {
      23                 :            : /*!
      24                 :            :  * @brief namespace rss
      25                 :            :  */
      26                 :            : namespace rss {
      27                 :            : /*!
      28                 :            :  * @brief namespace map
      29                 :            :  */
      30                 :            : namespace map {
      31                 :            : 
      32                 :            : /*!
      33                 :            :  * @brief class providing support to convert ad::map objects into ad::rss objects
      34                 :            :  */
      35                 :            : class RssObjectConversion
      36                 :            : {
      37                 :            : public:
      38                 :            :   /*!
      39                 :            :    * \brief Smart pointer on RssObjectConversion
      40                 :            :    */
      41                 :            :   using Ptr = std::shared_ptr<RssObjectConversion>;
      42                 :            : 
      43                 :            :   /*!
      44                 :            :    * \brief Smart pointer on constant RssObjectConversion
      45                 :            :    */
      46                 :            :   using ConstPtr = std::shared_ptr<RssObjectConversion const>;
      47                 :            : 
      48                 :            :   /*!
      49                 :            :    * @brief constructor
      50                 :            :    *
      51                 :            :    * @param[in] objectData the object data
      52                 :            :    */
      53                 :            :   explicit RssObjectConversion(RssObjectData const &objectData);
      54                 :            : 
      55                 :            :   /*!
      56                 :            :    * @brief constructor with explicit occupied regions
      57                 :            :    *
      58                 :            :    * @param[in] objectData the object data
      59                 :            :    * @param[in] objectOccupiedRegions the object's occupied regions explicitly
      60                 :            :    */
      61                 :            :   RssObjectConversion(RssObjectData const &objectData,
      62                 :            :                       ::ad::rss::world::OccupiedRegionVector const &objectOccupiedRegions);
      63                 :            : 
      64                 :            :   /*!
      65                 :            :    * \brief standard copy constructor
      66                 :            :    */
      67                 :        555 :   RssObjectConversion(const RssObjectConversion &other) = default;
      68                 :            : 
      69                 :            :   /*!
      70                 :            :    * \brief standard move constructor
      71                 :            :    */
      72                 :            :   RssObjectConversion(RssObjectConversion &&other) = default;
      73                 :            : 
      74                 :            :   /*!
      75                 :            :    * \brief standard destructor
      76                 :            :    */
      77                 :        990 :   ~RssObjectConversion() = default;
      78                 :            : 
      79                 :            :   /*!
      80                 :            :    * \brief delete standard assignment operator
      81                 :            :    */
      82                 :            :   RssObjectConversion &operator=(const RssObjectConversion &other) = delete;
      83                 :            : 
      84                 :            :   /*!
      85                 :            :    * \brief delete standard move assignment operator
      86                 :            :    */
      87                 :            :   RssObjectConversion &operator=(RssObjectConversion &&other) = delete;
      88                 :            : 
      89                 :            :   /** @returns RssDynamics of the object
      90                 :            :    *
      91                 :            :    * If updateSpeedLimit() was called in between the maxSpeedOnAcceleration value of the dynamics will be adapted to
      92                 :            :    * these.
      93                 :            :    */
      94                 :            :   ::ad::rss::world::RssDynamics getRssDynamics() const;
      95                 :            : 
      96                 :            :   /** @returns RSS Object description
      97                 :            :    *
      98                 :            :    * If laneIntervalAdded() or fillNotRelevantSceneBoundingBox() was called in between the
      99                 :            :    * occupied regions have been filled accordingly. If not, these are empty (which is an invalid object!)
     100                 :            :    */
     101                 :            :   ::ad::rss::world::Object const &getRssObject() const;
     102                 :            : 
     103                 :            :   /** @returns Object id */
     104                 :            :   ::ad::rss::world::ObjectId getId() const;
     105                 :            : 
     106                 :            :   /** @returns the minimum distance for the object to stop
     107                 :            :    *  This is an estimate, that can be used to calculate the connecting route calculation distance to be taken into
     108                 :            :    * account.
     109                 :            :    */
     110                 :            :   bool calculateMinStoppingDistance(::ad::physics::Distance &minStoppingDistance) const;
     111                 :            : 
     112                 :            :   /** @brief update the max speed content
     113                 :            :    */
     114                 :            :   void updateSpeedLimit(::ad::physics::Speed const &maxSpeedOnAcceleration);
     115                 :            : 
     116                 :            :   /** @brief lane interval was added to the object route, so append relevant occupied regions
     117                 :            :    */
     118                 :            :   void laneIntervalAdded(::ad::map::route::LaneInterval const &laneInterval);
     119                 :            : 
     120                 :            :   /** @brief update the objects current velocity on the route
     121                 :            :    */
     122                 :            :   void updateVelocityOnRoute(::ad::map::route::FullRoute const &route);
     123                 :            : 
     124                 :            :   /** @brief return the map matched position object this was created with (might be nullptr)
     125                 :            :    */
     126                 :        852 :   ::ad::map::match::Object const *getObjectMapMatchedPosition() const
     127                 :            :   {
     128                 :        852 :     return mObjectMapMatchedPosition;
     129                 :            :   }
     130                 :            : 
     131                 :            :   /** @brief check if the original input speed is in acceptable range
     132                 :            :    *
     133                 :            :    *  Negative speed is not supported by the RSS implementation; therefore negative input speeds are mapped to zero
     134                 :            :    * speed by this class.
     135                 :            :    *
     136                 :            :    *  But up to a certain small negative speed value, negative speeds still might want to be accepted to account for
     137                 :            :    * slowly backward drifting vehicles.
     138                 :            :    *  Therefore, the constructor of this class maps all negative speeds to zero, but stores the original provided speed
     139                 :            :    * for later analysis.
     140                 :            :    *  This function can be used to check for an acceptable speed.
     141                 :            :    *
     142                 :            :    * @param[in] acceptableNegativeSpeed a small negative speed value that should be allowed to be mapped to zero
     143                 :            :    * without error (default -0.5m/s).
     144                 :            :    *
     145                 :            :    * @returns \c true if the original speed equals the current internal object speed.
     146                 :            :    *  It also returns \c true if the original speed is equal or larger than the provided acceptableNegativeSpeed.
     147                 :            :    */
     148                 :            :   bool isOriginalSpeedAcceptable(::ad::physics::Speed const acceptableNegativeSpeed = ::ad::physics::Speed(-0.5)) const;
     149                 :            : 
     150                 :            :   /**
     151                 :            :    * @returns the original object speed provided as input
     152                 :            :    */
     153                 :          0 :   ::ad::physics::Speed const &getOriginalObjectSpeed() const
     154                 :            :   {
     155                 :          0 :     return mOriginalObjectSpeed;
     156                 :            :   }
     157                 :            : 
     158                 :            : private:
     159                 :            :   ::ad::rss::world::Object mRssObject;
     160                 :            :   ::ad::map::match::Object const *mObjectMapMatchedPosition;
     161                 :            :   ::ad::physics::Speed mMaxSpeedOnAcceleration;
     162                 :            :   ::ad::physics::Speed const mOriginalObjectSpeed;
     163                 :            :   ::ad::rss::world::RssDynamics const &mRssDynamics;
     164                 :            : 
     165                 :            :   void initializeRssObject(::ad::rss::world::ObjectId const &objectId,
     166                 :            :                            ::ad::rss::world::ObjectType const &objectType,
     167                 :            :                            ::ad::rss::world::OccupiedRegionVector const &objectOccupiedRegions,
     168                 :            :                            ::ad::map::match::ENUObjectPosition const &objectEnuPosition,
     169                 :            :                            ::ad::physics::Speed const &objectSpeed,
     170                 :            :                            ::ad::physics::AngularVelocity const &objectYawRate,
     171                 :            :                            ::ad::physics::Angle const &objectSteeringAngle);
     172                 :            : 
     173                 :            :   void addRestrictedOccupiedRegion(::ad::map::match::LaneOccupiedRegion const &laneOccupiedRegion,
     174                 :            :                                    ::ad::map::route::LaneInterval const &laneInterval);
     175                 :            : };
     176                 :            : 
     177                 :            : } // namespace map
     178                 :            : } // namespace rss
     179                 :            : } // namespace ad

Generated by: LCOV version 1.14