From acd965344563564fd55132caaab7ddfe4f4a9715 Mon Sep 17 00:00:00 2001 From: P0064KB <konstantin.blenz@tu-dresden.de> Date: Tue, 20 Dec 2022 14:10:38 +0100 Subject: [PATCH] addition of a spawn lc-offset, change in acceleration extrapolation --- .../50_action_deduction.rst | 1 + .../src/ActionDeductionMethods/LaneChangeModel.cpp | 8 +++++--- .../src/ActionDeductionMethods/LaneChangeModel.h | 13 ++++++++++++- .../src/AlgorithmActionDeduction.cpp | 3 ++- .../src/AlgorithmActionDeduction.h | 13 ++++++++++--- .../Algorithm_ActionDeduction_implementation.cpp | 5 +++++ .../src/Container/agent_representation.cpp | 2 ++ 7 files changed, 37 insertions(+), 8 deletions(-) diff --git a/doc/source/user_guide/sim_user_guide/components/components_modular_driver/50_action_deduction.rst b/doc/source/user_guide/sim_user_guide/components/components_modular_driver/50_action_deduction.rst index 0ece4a8a1..9cc90bb76 100644 --- a/doc/source/user_guide/sim_user_guide/components/components_modular_driver/50_action_deduction.rst +++ b/doc/source/user_guide/sim_user_guide/components/components_modular_driver/50_action_deduction.rst @@ -60,6 +60,7 @@ If the module doesn't get the assessed information from the module :ref:`situati ReactionTimeMean Integer ms 34 Mean reaction time on suddenly hard braking leader ReactionTimeStd Integer ms 35 Standard deviation of the reaction time MinReactionTime Integer ms 36 Min reaction time on suddenly hard braking leader + spawnLCOffset Integer ms 37 Time offset in which the lane-change is blocked after the spawning 10000 ================================ ========== ====== ==== =============================================================================================================================== ============================ The module *action-deduction* needs for the decision process the following components: diff --git a/sim/src/components/Algorithm_ActionDeduction/src/ActionDeductionMethods/LaneChangeModel.cpp b/sim/src/components/Algorithm_ActionDeduction/src/ActionDeductionMethods/LaneChangeModel.cpp index 834c7c860..7e0f43c51 100644 --- a/sim/src/components/Algorithm_ActionDeduction/src/ActionDeductionMethods/LaneChangeModel.cpp +++ b/sim/src/components/Algorithm_ActionDeduction/src/ActionDeductionMethods/LaneChangeModel.cpp @@ -34,7 +34,8 @@ LaneChangeModel::LaneChangeModel(int CycleTime, double LeftFactor, double RightFactor, double CooperativeFactor, - PublisherInterface * publisher) : + PublisherInterface * publisher, + int spawnLCOffset) : vehicleParameters(vehicleParameters), Ego(Ego), DriverInformation(DriverInformation), @@ -52,7 +53,8 @@ LaneChangeModel::LaneChangeModel(int CycleTime, StayLeftFactor(LeftFactor), NoOvertakeRightFactor(LeftFactor), CooperativeFactor(CooperativeFactor), - publisher(publisher) + publisher(publisher), + spawnLCOffset(spawnLCOffset) { InitLCReasons(); } @@ -60,7 +62,7 @@ LaneChangeModel::LaneChangeModel(int CycleTime, LaneChangeState LaneChangeModel::CheckForLaneChange(const int *time, const int *spawnTime) { - int spawnoffset = 10000; + int spawnoffset = spawnLCOffset; // to avoid lane-changes directly after spawning if (*time == *spawnTime + spawnoffset) diff --git a/sim/src/components/Algorithm_ActionDeduction/src/ActionDeductionMethods/LaneChangeModel.h b/sim/src/components/Algorithm_ActionDeduction/src/ActionDeductionMethods/LaneChangeModel.h index 429b822f5..4ca38d350 100644 --- a/sim/src/components/Algorithm_ActionDeduction/src/ActionDeductionMethods/LaneChangeModel.h +++ b/sim/src/components/Algorithm_ActionDeduction/src/ActionDeductionMethods/LaneChangeModel.h @@ -51,7 +51,8 @@ public: double LeftFactor, double RightFactor, double CooperativeFactor, - PublisherInterface *publisher); + PublisherInterface *publisher, + int spawnLCOffset); void prepareStep() { @@ -351,6 +352,12 @@ private: return (surroundingvehicles & Relation) != 0; } + double GetDistanceTraveled() + { + distanceTraveled += Ego.absoluteVelocity*CycleTime_s; + return distanceTraveled; + } + void InitLCReasons() { overtakeRight = new OvertakeRight(CycleTime, carFollowingModel, Ego, DriverInformation, NearTraffic, vehicleParameters, surroundingvehicles, publisher, OvertakeFactor); @@ -423,6 +430,8 @@ private: int leftLCstatusSet = 0; int rightLCstatusSet = 0; + double distanceTraveled = 0.0; + const CarFollowingModel &carFollowingModel; int lastLaneId = -999; @@ -468,6 +477,8 @@ private: const int CycleTime; + int spawnLCOffset; + bool print = false; PublisherInterface * publisher; diff --git a/sim/src/components/Algorithm_ActionDeduction/src/AlgorithmActionDeduction.cpp b/sim/src/components/Algorithm_ActionDeduction/src/AlgorithmActionDeduction.cpp index ace1692ee..a48217cb3 100644 --- a/sim/src/components/Algorithm_ActionDeduction/src/AlgorithmActionDeduction.cpp +++ b/sim/src/components/Algorithm_ActionDeduction/src/AlgorithmActionDeduction.cpp @@ -363,7 +363,8 @@ void ActionDeduction::Initialize(driverInformation *DriverInformation, int time) SpeedGain, KeepRight, Cooperative, - publisher); + publisher, + spawnLCOffset); targetBraking = new TargetBraking(CycleTime, stochastics, carFollowingModel); diff --git a/sim/src/components/Algorithm_ActionDeduction/src/AlgorithmActionDeduction.h b/sim/src/components/Algorithm_ActionDeduction/src/AlgorithmActionDeduction.h index 25989e6b3..f95eb2423 100644 --- a/sim/src/components/Algorithm_ActionDeduction/src/AlgorithmActionDeduction.h +++ b/sim/src/components/Algorithm_ActionDeduction/src/AlgorithmActionDeduction.h @@ -452,21 +452,26 @@ public: void CheckTDGazeRequest(); - void SetReactionTimeMean(double reactionTimeMean) + void SetReactionTimeMean(int reactionTimeMean) { this->reactionTime.meanTime = reactionTimeMean; } - void SetReactionTimeStd(double reactionTimeStd) + void SetReactionTimeStd(int reactionTimeStd) { this->reactionTime.stdTime = reactionTimeStd; } - void SetMinReactionTime(double minReactionTime) + void SetMinReactionTime(int minReactionTime) { this->reactionTime.minTime = minReactionTime; } + void SetSpawnLCOffset(int spawnLCOffset) + { + this->spawnLCOffset = spawnLCOffset; + } + void PublishLCTrigger(); ~ActionDeduction() @@ -562,6 +567,8 @@ private: double velocity_next = 0; + int spawnLCOffset = 10000; + //! Current Lane-change wish status LaneChangeState LaneChangeWish = LaneChangeState::NoLaneChange; //! The agents Car-following-model diff --git a/sim/src/components/Algorithm_ActionDeduction/src/Algorithm_ActionDeduction_implementation.cpp b/sim/src/components/Algorithm_ActionDeduction/src/Algorithm_ActionDeduction_implementation.cpp index 5cdc42883..fcfde3677 100644 --- a/sim/src/components/Algorithm_ActionDeduction/src/Algorithm_ActionDeduction_implementation.cpp +++ b/sim/src/components/Algorithm_ActionDeduction/src/Algorithm_ActionDeduction_implementation.cpp @@ -189,6 +189,11 @@ AlgorithmActionDeductionImplementation::AlgorithmActionDeductionImplementation( { int minReactionTime = (parameters->GetParametersInt().count("MinReactionTime") > 0 ? parameters->GetParametersInt().at("MinReactionTime") : parameters->GetParametersInt().at("36"));; actiondeduction.SetMinReactionTime(minReactionTime); + } + if (parameters->GetParametersInt().count("SpawnLCOffset") > 0 || parameters->GetParametersInt().count("37") > 0) + { + int spawnLCOffset = (parameters->GetParametersInt().count("SpawnLCOffset") > 0 ? parameters->GetParametersInt().at("SpawnLCOffset") : parameters->GetParametersInt().at("37"));; + actiondeduction.SetSpawnLCOffset(spawnLCOffset); } initialisationAD = true; diff --git a/sim/src/components/Algorithm_ActionDeduction/src/Container/agent_representation.cpp b/sim/src/components/Algorithm_ActionDeduction/src/Container/agent_representation.cpp index a00fe3acf..7b322ffa2 100644 --- a/sim/src/components/Algorithm_ActionDeduction/src/Container/agent_representation.cpp +++ b/sim/src/components/Algorithm_ActionDeduction/src/Container/agent_representation.cpp @@ -73,6 +73,8 @@ void AgentRepresentation::Extrapolate (double EgoVelocity) void AgentRepresentation::ExtrapolateKinematic(double EgoVelocity) { + acceleration = acceleration * 1/(std::max(100,lifetime)/100); + absoluteVelocity = std::max(0.0, absoluteVelocity + acceleration * cycletime / 1000) ; relativeLongitudinalDistance += (absoluteVelocity * cycletime/1000.0) - (EgoVelocity * cycletime/1000.0); -- GitLab