LCOV - code coverage report
Current view: top level - src/microsim/cfmodels - MSCFModel_ACC.h (source / functions) Hit Total Coverage
Test: lcov.info Lines: 7 7 100.0 %
Date: 2024-05-04 15:27:10 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /****************************************************************************/
       2             : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3             : // Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
       4             : // This program and the accompanying materials are made available under the
       5             : // terms of the Eclipse Public License 2.0 which is available at
       6             : // https://www.eclipse.org/legal/epl-2.0/
       7             : // This Source Code may also be made available under the following Secondary
       8             : // Licenses when the conditions for such availability set forth in the Eclipse
       9             : // Public License 2.0 are satisfied: GNU General Public License, version 2
      10             : // or later which is available at
      11             : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
      12             : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
      13             : /****************************************************************************/
      14             : /// @file    MSCFModel_ACC.h
      15             : /// @author  Kallirroi Porfyri
      16             : /// @date    Feb 2018
      17             : ///
      18             : // ACC car-following model based on [1], [2].
      19             : // [1] Milanes, V., and S. E. Shladover. Handling Cut-In Vehicles in Strings
      20             : //    of Cooperative Adaptive Cruise Control Vehicles. Journal of Intelligent
      21             : //     Transportation Systems, Vol. 20, No. 2, 2015, pp. 178-191.
      22             : // [2] Xiao, L., M. Wang and B. van Arem. Realistic Car-Following Models for
      23             : //    Microscopic Simulation of Adaptive and Cooperative Adaptive Cruise
      24             : //     Control Vehicles. Transportation Research Record: Journal of the
      25             : //     Transportation Research Board, No. 2623, 2017. (DOI: 10.3141/2623-01).
      26             : /****************************************************************************/
      27             : #pragma once
      28             : #include <config.h>
      29             : 
      30             : #include "MSCFModel.h"
      31             : #include <utils/xml/SUMOXMLDefinitions.h>
      32             : 
      33             : // ===========================================================================
      34             : // class declarations
      35             : // ===========================================================================
      36             : class MSVehicle;
      37             : class MSVehicleType;
      38             : class MSCFModel_CACC;
      39             : 
      40             : // ===========================================================================
      41             : // class definitions
      42             : // ===========================================================================
      43             : /** @class MSCFModel_ACC
      44             : * @brief The ACC car-following model
      45             : * @see MSCFModel
      46             : */
      47             : class MSCFModel_ACC : public MSCFModel {
      48             : public:
      49             :     /** @brief Constructor
      50             :      *  @param[in] vtype the type for which this model is built and also the parameter object to configure this model
      51             :      */
      52             :     MSCFModel_ACC(const MSVehicleType* vtype);
      53             : 
      54             :     /// @brief Destructor
      55             :     ~MSCFModel_ACC();
      56             : 
      57             : 
      58             :     /// @name Implementations of the MSCFModel interface
      59             :     /// @{
      60             : 
      61             :     /** @brief Computes the vehicle's safe speed (no dawdling)
      62             :     * @param[in] veh The vehicle (EGO)
      63             :     * @param[in] speed The vehicle's speed
      64             :     * @param[in] gap2pred The (netto) distance to the LEADER
      65             :     * @param[in] predSpeed The speed of LEADER
      66             :     * @return EGO's safe speed
      67             :     * @see MSCFModel::ffeV
      68             :     */
      69             :     double followSpeed(const MSVehicle* const veh, double speed, double gap2pred, double predSpeed,
      70             :                        double predMaxDecel, const MSVehicle* const pred = 0, const CalcReason usage = CalcReason::CURRENT) const;
      71             : 
      72             : 
      73             :     /** @brief Computes the vehicle's safe speed for approaching a non-moving obstacle (no dawdling)
      74             :     * @param[in] veh The vehicle (EGO)
      75             :     * @param[in] gap2pred The (netto) distance to the the obstacle
      76             :     * @return EGO's safe speed for approaching a non-moving obstacle
      77             :     * @see MSCFModel::ffeS
      78             :     * @todo generic Interface, models can call for the values they need
      79             :     */
      80             :     double stopSpeed(const MSVehicle* const veh, const double speed, double gap2pred, double decel, const CalcReason usage = CalcReason::CURRENT) const;
      81             : 
      82             :     /** @brief Returns the a gap such that the gap mode acceleration of the follower is zero
      83             :      * @param[in] veh The vehicle itself, for obtaining other values
      84             :      * @param[in] speed EGO's speed
      85             :      * @param[in] leaderSpeed LEADER's speed
      86             :      * @param[in] leaderMaxDecel LEADER's max. deceleration rate
      87             :      */
      88             :     double getSecureGap(const MSVehicle* const veh, const MSVehicle* const pred, const double speed, const double leaderSpeed, const double leaderMaxDecel) const;
      89             : 
      90             :     /** @brief Computes the vehicle's acceptable speed at insertion
      91             :      * @param[in] veh The vehicle (EGO)
      92             :      * @param[in] pred The leader vehicle, for obtaining other values
      93             :      * @param[in] speed The vehicle's speed
      94             :      * @param[in] gap2pred The (netto) distance to the LEADER
      95             :      * @param[in] predSpeed The speed of LEADER
      96             :      * @return EGO's safe speed
      97             :      */
      98             :     double insertionFollowSpeed(const MSVehicle* const v, double speed, double gap2pred, double predSpeed, double predMaxDecel, const MSVehicle* const pred = 0) const;
      99             : 
     100             : 
     101             :     /** @brief Returns the maximum gap at which an interaction between both vehicles occurs
     102             :     *
     103             :     * "interaction" means that the LEADER influences EGO's speed.
     104             :     * @param[in] veh The EGO vehicle
     105             :     * @param[in] vL LEADER's speed
     106             :     * @return The interaction gap
     107             :     * @todo evaluate signature
     108             :     * @see MSCFModel::interactionGap
     109             :     */
     110             :     double interactionGap(const MSVehicle* const, double vL) const;
     111             : 
     112             : 
     113             :     /** @brief Returns the model's name
     114             :     * @return The model's name
     115             :     * @see MSCFModel::getModelName
     116             :     */
     117        7391 :     int getModelID() const {
     118        7391 :         return SUMO_TAG_CF_ACC;
     119             :     }
     120             :     /// @}
     121             : 
     122             : 
     123             : 
     124             :     /** @brief Duplicates the car-following model
     125             :     * @param[in] vtype The vehicle type this model belongs to (1:1)
     126             :     * @return A duplicate of this car-following model
     127             :     */
     128             :     MSCFModel* duplicate(const MSVehicleType* vtype) const;
     129             : 
     130        6995 :     VehicleVariables* createVehicleVariables() const {
     131        6995 :         ACCVehicleVariables* ret = new ACCVehicleVariables();
     132             :         ret->ACC_ControlMode = 0;
     133        6995 :         ret->lastUpdateTime = 0;
     134        6995 :         return ret;
     135             :     }
     136             : 
     137             :     friend class MSCFModel_CACC;
     138             : 
     139             : private:
     140             :     class ACCVehicleVariables : public MSCFModel::VehicleVariables {
     141             :     public:
     142       14122 :         ACCVehicleVariables() : ACC_ControlMode(0) {}
     143             :         /// @brief The vehicle's ACC control mode. 0 for speed control and 1 for gap control
     144             :         int ACC_ControlMode;
     145             :         SUMOTime lastUpdateTime;
     146             :     };
     147             : 
     148             : 
     149             : private:
     150             :     double _v(const MSVehicle* const veh, const double gap2pred, const double mySpeed,
     151             :               const double predSpeed, const double desSpeed, const bool respectMinGap = true) const;
     152             : 
     153             :     double accelSpeedControl(double vErr) const;
     154             :     double accelGapControl(const MSVehicle* const veh, const double gap2pred, const double speed, const double predSpeed, double vErr) const;
     155             : 
     156             : 
     157             : private:
     158             :     double mySpeedControlGain;
     159             :     double myGapClosingControlGainSpeed;
     160             :     double myGapClosingControlGainSpace;
     161             :     double myGapControlGainSpeed;
     162             :     double myGapControlGainSpace;
     163             :     double myCollisionAvoidanceGainSpeed;
     164             :     double myCollisionAvoidanceGainSpace;
     165             :     double myEmergencyThreshold;
     166             : 
     167             : private:
     168             :     /// @brief Invalidated assignment operator
     169             :     MSCFModel_ACC& operator=(const MSCFModel_ACC& s);
     170             : };

Generated by: LCOV version 1.14