LCOV - code coverage report
Current view: top level - src/unstructured - TrajectoryVehicle.hpp (source / functions) Hit Total Coverage
Test: ad_rss Lines: 2 2 100.0 %
Date: 2024-10-01 15:08:14 Functions: 1 1 100.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : // ----------------- BEGIN LICENSE BLOCK ---------------------------------
       2                 :            : //
       3                 :            : // Copyright (C) 2020-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/physics/RatioValue.hpp>
      15                 :            : #include <algorithm>
      16                 :            : #include <vector>
      17                 :            : #include "TrajectoryCommon.hpp"
      18                 :            : #include "ad/rss/situation/Physics.hpp"
      19                 :            : #include "ad/rss/situation/VehicleState.hpp"
      20                 :            : #include "ad/rss/unstructured/Geometry.hpp"
      21                 :            : 
      22                 :            : /*!
      23                 :            :  * @brief namespace ad
      24                 :            :  */
      25                 :            : namespace ad {
      26                 :            : /*!
      27                 :            :  * @brief namespace rss
      28                 :            :  */
      29                 :            : namespace rss {
      30                 :            : /*!
      31                 :            :  * @brief namespace unstructured
      32                 :            :  */
      33                 :            : namespace unstructured {
      34                 :            : 
      35                 :            : /**
      36                 :            :  * @brief Calculates the trajectory sets of a vehicle
      37                 :            :  */
      38                 :            : class TrajectoryVehicle
      39                 :            : {
      40                 :            : public:
      41                 :         20 :   TrajectoryVehicle()
      42                 :            :   {
      43                 :         20 :   }
      44                 :            : 
      45                 :            :   /**
      46                 :            :    * @brief Calculate the trajectory sets for braking and continue forward behavior
      47                 :            :    *
      48                 :            :    * @param[in]  vehicleState current state of the vehicle
      49                 :            :    * @param[out] brakePolygon the trajectory set for braking behavior
      50                 :            :    * @param[out] continueForwardPolygon the trajectory set for continue-forward behavior
      51                 :            :    *
      52                 :            :    * @returns false if a failure occurred during calculations, true otherwise
      53                 :            :    */
      54                 :            :   bool calculateTrajectorySets(situation::VehicleState const &vehicleState,
      55                 :            :                                Polygon &brakePolygon,
      56                 :            :                                Polygon &continueForwardPolygon);
      57                 :            : 
      58                 :            : private:
      59                 :            :   /**
      60                 :            :    * @brief Calculate the yaw rate after a duration
      61                 :            :    *
      62                 :            :    * @param[in] yawRate     current yaw rate
      63                 :            :    * @param[in] timeInMovementUntilResponseTime         duration of yaw rate change
      64                 :            :    * @param[in] maxYawRateChange maximum yaw rate change per second
      65                 :            :    * @param[in] ratio            yaw rate change ratio
      66                 :            :    *
      67                 :            :    * @returns yaw rate
      68                 :            :    */
      69                 :            :   ad::physics::AngularVelocity calculateYawRate(ad::physics::AngularVelocity const &yawRate,
      70                 :            :                                                 ad::physics::Duration const &timeInMovementUntilResponseTime,
      71                 :            :                                                 ad::physics::AngularAcceleration const &maxYawRateChange,
      72                 :            :                                                 ad::physics::RatioValue const &ratio) const;
      73                 :            : 
      74                 :            :   /**
      75                 :            :    * @brief Calculate all trajectory points at response time
      76                 :            :    *
      77                 :            :    * @param[in]  vehicleState current state of the vehicle
      78                 :            :    * @param[out] frontSide the trajectory points defining the front
      79                 :            :    * @param[out] backSide the trajectory points defining the back
      80                 :            :    *
      81                 :            :    * @returns false if a failure occurred during calculations, true otherwise
      82                 :            :    */
      83                 :            :   bool getResponseTimeTrajectoryPoints(situation::VehicleState const &vehicleState,
      84                 :            :                                        TrajectorySetStep &frontSide,
      85                 :            :                                        TrajectorySetStep &backSide) const;
      86                 :            : 
      87                 :            :   /**
      88                 :            :    * @brief Calculate all trajectory points at response time
      89                 :            :    *
      90                 :            :    * @param[in]  vehicleState current state of the vehicle
      91                 :            :    * @param[in]  acceleration acceleration to use
      92                 :            :    * @param[in]  ratioDiff    yaw rate change ratio
      93                 :            :    * @param[in]  step         resulting trajectory set step
      94                 :            :    *
      95                 :            :    * @returns false if a failure occurred during calculations, true otherwise
      96                 :            :    */
      97                 :            :   bool getResponseTimeTrajectoryPoints(situation::VehicleState const &vehicleState,
      98                 :            :                                        physics::Acceleration const &acceleration,
      99                 :            :                                        physics::RatioValue const &ratioDiff,
     100                 :            :                                        TrajectorySetStep &step) const;
     101                 :            : 
     102                 :            :   /**
     103                 :            :    * @brief Calculate a single trajectory point with changing radius
     104                 :            :    *
     105                 :            :    * @param[in] currentPoint           trajectory point to use for calculation
     106                 :            :    * @param[in]  dynamics              dynamics to use
     107                 :            :    * @param[in]  duration              time
     108                 :            :    * @param[in]  acceleration          acceleration to use
     109                 :            :    * @param[in]  yawRateChangeRatio    yaw rate change ratio
     110                 :            :    * @param[out] resultTrajectoryPoint resulting trajectory point
     111                 :            :    *
     112                 :            :    * @returns false if a failure occurred during calculations, true otherwise
     113                 :            :    */
     114                 :            :   bool calculateTrajectoryPoint(TrajectoryPoint const &currentPoint,
     115                 :            :                                 world::RssDynamics const &dynamics,
     116                 :            :                                 ad::physics::Duration const &duration,
     117                 :            :                                 ad::physics::Acceleration const &acceleration,
     118                 :            :                                 ad::physics::RatioValue const &yawRateChangeRatio,
     119                 :            :                                 TrajectoryPoint &resultTrajectoryPoint) const;
     120                 :            : 
     121                 :            :   /**
     122                 :            :    * @brief Calculate a next trajectory point on a circle
     123                 :            :    *
     124                 :            :    * @param[inout] currentPoint        trajectory point to use for calculation
     125                 :            :    * @param[in]  acceleration          acceleration to use
     126                 :            :    * @param[in]  duration              duration of accelerated movement
     127                 :            :    * @param[in]  dynamics              dynamics to use
     128                 :            :    *
     129                 :            :    * @returns false if a failure occurred during calculations, true otherwise
     130                 :            :    */
     131                 :            :   bool calculateTrajectoryPointOnCircle(TrajectoryPoint &currentPoint,
     132                 :            :                                         physics::Acceleration const &acceleration,
     133                 :            :                                         physics::Duration const &duration,
     134                 :            :                                         ::ad::rss::world::RssDynamics const &dynamics) const;
     135                 :            : 
     136                 :            :   /**
     137                 :            :    * @brief Calculate a time in movement until response time
     138                 :            :    *
     139                 :            :    * @param[in]  speed                      speed of the vehicle
     140                 :            :    * @param[in]  acceleration          acceleration to use
     141                 :            :    * @param[inout]  timeInMovement   resulting time in movement
     142                 :            :    *
     143                 :            :    * @returns false if a failure occurred during calculations, true otherwise
     144                 :            :    */
     145                 :            :   bool getTimeInMovement(ad::physics::Speed const &speed,
     146                 :            :                          ad::physics::Acceleration const &acceleration,
     147                 :            :                          ad::physics::Duration &timeInMovement) const;
     148                 :            : 
     149                 :            :   /**
     150                 :            :    * @brief Calculate the brake trajectory set
     151                 :            :    *
     152                 :            :    * @param[in]  vehicleState                      current state of the vehicle
     153                 :            :    * @param[in]  timeAfterResponseTime             time after the response time to move
     154                 :            :    * @param[in]  responseTimeFrontSide             the trajectory points defining the front
     155                 :            :    * @param[in]  responseTimeBackSide              the trajectory points defining the back
     156                 :            :    * @param[out] resultPolygon                     the resulting brake polygon
     157                 :            :    * @param[out] brakeMinStepVehicleLocation       the vehicle locations for brakeMin after response time
     158                 :            :    *
     159                 :            :    * @returns false if a failure occurred during calculations, true otherwise
     160                 :            :    */
     161                 :            :   bool calculateBrake(situation::VehicleState const &vehicleState,
     162                 :            :                       ad::physics::Duration const &timeAfterResponseTime,
     163                 :            :                       TrajectorySetStep const &responseTimeFrontSide,
     164                 :            :                       TrajectorySetStep const &responseTimeBackSide,
     165                 :            :                       Polygon &resultPolygon,
     166                 :            :                       TrajectorySetStepVehicleLocation &brakeMinStepVehicleLocation) const;
     167                 :            : 
     168                 :            :   /**
     169                 :            :    * @brief Calculate the continue forward trajectory set
     170                 :            :    *
     171                 :            :    * @param[in]  vehicleState                      current state of the vehicle
     172                 :            :    * @param[in]  timeAfterResponseTime             time after the response time to move
     173                 :            :    * @param[in]  responseTimeFrontSide             the trajectory points defining the front
     174                 :            :    * @param[in]  brakePolygon                      the polygon defining the brake trajectory set
     175                 :            :    * @param[in]  brakeMinStepVehicleLocation       the vehicle locations for brakeMin after response time
     176                 :            :    * @param[out] resultPolygon                     the resulting continue forward polygon
     177                 :            :    *
     178                 :            :    * @returns false if a failure occurred during calculations, true otherwise
     179                 :            :    */
     180                 :            :   bool calculateContinueForward(situation::VehicleState const &vehicleState,
     181                 :            :                                 physics::Duration const &timeAfterResponseTime,
     182                 :            :                                 TrajectorySetStep const &responseTimeFrontSide,
     183                 :            :                                 Polygon const &brakePolygon,
     184                 :            :                                 TrajectorySetStepVehicleLocation const &brakeMinStepVehicleLocation,
     185                 :            :                                 Polygon &resultPolygon) const;
     186                 :            : 
     187                 :            :   /**
     188                 :            :    * @brief Calculate the trajectory set step for a movement on a circle
     189                 :            :    *
     190                 :            :    * @param[in]  vehicleState                      current state of the vehicle
     191                 :            :    * @param[in]  timeAfterResponseTime             time after the response time to move
     192                 :            :    * @param[in]  acceleration                      acceleration to apply
     193                 :            :    * @param[in]  step                              resulting trajectory set step
     194                 :            :    *
     195                 :            :    * @returns false if a failure occurred during calculations, true otherwise
     196                 :            :    */
     197                 :            :   bool calculateTrajectorySetStepOnCircle(situation::VehicleState const &vehicleState,
     198                 :            :                                           physics::Duration const &timeAfterResponseTime,
     199                 :            :                                           physics::Acceleration const &acceleration,
     200                 :            :                                           TrajectorySetStep &step) const;
     201                 :            : };
     202                 :            : 
     203                 :            : } // namespace unstructured
     204                 :            : } // namespace rss
     205                 :            : } // namespace ad

Generated by: LCOV version 1.14