Commit 9b30eee7 authored by Uwe Woessner's avatar Uwe Woessner
Browse files

compute max deceleration


Signed-off-by: Uwe Woessner's avatarhpcwoess <woessner@hlrs.de>
parent b13c88d2
......@@ -89,8 +89,6 @@ struct ParametrizedVehicleModelParameters
VehicleAxle rearAxle;
openScenario::ParameterizedAttribute<double> distanceReferencePointToLeadingEdge = -999.0;
openScenario::ParameterizedAttribute<double> maxVelocity = -999.0;
openScenario::ParameterizedAttribute<double> maxAcceleration = -999.0;
openScenario::ParameterizedAttribute<double> maxDeceleration = -999.0;
openScenario::ParameterizedAttribute<double> weight = -999.0;
openScenario::ParameterizedAttribute<double> heightCOG = -999.0;
openScenario::ParameterizedAttribute<double> momentInertiaRoll = -999.0;
......
......@@ -44,6 +44,7 @@
#include "common/parametersVehicleSignal.h"
#include <list>
#include "include/parameterInterface.h"
#include "include/worldInterface.h"
#include <cassert>
#include <memory>
......@@ -51,35 +52,36 @@
AlgorithmModularDriverImplementation::AlgorithmModularDriverImplementation(
std::string componentName,
bool isInit,
int priority,
int offsetTime,
int responseTime,
int cycleTime,
StochasticsInterface *stochastics,
WorldInterface *world,
const ParameterInterface *parameters,
PublisherInterface *const publisher,
const CallbackInterface *callbacks,
AgentInterface *agent) :
AlgorithmInterface(
componentName,
isInit,
priority,
offsetTime,
responseTime,
cycleTime,
stochastics,
parameters,
publisher,
callbacks,
agent),
informationacquisition(stochastics, /*GetObservations()->at(0)*/nullptr),
mentalmodel(stochastics),
situationassessment(stochastics, cycleTime, /*GetObservations()->at(0)*/nullptr),
actiondeduction(cycleTime, stochastics, /*GetObservations()->at(0)*/nullptr),
actionexecution(stochastics)
std::string componentName,
bool isInit,
int priority,
int offsetTime,
int responseTime,
int cycleTime,
StochasticsInterface *stochastics,
WorldInterface *world,
const ParameterInterface *parameters,
PublisherInterface *const publisher,
const CallbackInterface *callbacks,
AgentInterface *agent) :
AlgorithmInterface(
componentName,
isInit,
priority,
offsetTime,
responseTime,
cycleTime,
stochastics,
parameters,
publisher,
callbacks,
agent),
informationacquisition(stochastics, /*GetObservations()->at(0)*/ nullptr),
mentalmodel(stochastics),
situationassessment(stochastics, cycleTime, /*GetObservations()->at(0)*/ nullptr),
actiondeduction(cycleTime, stochastics, /*GetObservations()->at(0)*/ nullptr),
actionexecution(stochastics),
world(world)
{
//!!!
// try
......@@ -383,8 +385,10 @@ void AlgorithmModularDriverImplementation::UpdateInput(int localLinkId, const st
throw std::runtime_error(msg);
}
vehicleParameters = signal->vehicleParameters;
vehicleParameters.maxDeceleration = vehicleParameters.maxDeceleration > 0 ? vehicleParameters.maxDeceleration*-1 : vehicleParameters.maxDeceleration; //GetAgent()->GetMaxDeceleration() * -1; // TODO Adjust to deceleration as absolute value
//vehicleParameters.maxAcceleration = GetAgent()->GetMaxAcceleration();
vehicleParameters.maxDeceleration = -9.81 * GetWorld()->GetFriction() * signal->vehicleParameters.frictionCoeff;
GetAgent()->SetMaxDeceleration(vehicleParameters.maxDeceleration);
; // TODO Adjust to deceleration as absolute value
vehicleParameters.maxAcceleration = GetAgent()->GetMaxAcceleration();
situationassessment.SetVehicleParameters(&vehicleParameters);
actiondeduction.SetVehicleParameters(&vehicleParameters);
actionexecution.SetVehicleParameters(&vehicleParameters);
......
......@@ -248,6 +248,11 @@ public:
//----------------------------------------------------------------
WorldInterface *GetWorld()
{
return world;
};
private:
bool initializedVehicleModelParameters = false;
......@@ -320,4 +325,6 @@ private:
ObservationInterface* observer = nullptr; ///!< Observer containing the eventnetwork into which (de-)activation events are inserted
WorldInterface *world=nullptr;
};
......@@ -103,28 +103,35 @@ void AgentRepresentation::ExtrapolateAlongLane(const std::vector<MentalModelLane
std::tuple<double,double,double,double> nexttuple;
std::tuple<double,double,double,double> neighbortuple;
for (std::vector<MentalModelLane>::const_iterator lanesection = lane->begin(); lanesection != lane->end(); lanesection++)
for (const auto &lanesection:*lane)
{
std::vector<std::tuple<double,double,double,double>> Points = lanesection->GetPoints();
for(std::vector<std::tuple<double,double,double,double>>::iterator tuple = Points.begin(); tuple < Points.end(); tuple++)
auto Points = lanesection.GetPoints();
for (auto tuple = Points.begin(); tuple != Points.end(); tuple++)
{
double deltas = std::abs(s-std::get<3>(*tuple));
double deltas = std::abs(s - std::get<3>(*tuple));
if (dslast < deltas)
break;
if (deltas<dsmin)
if (deltas < dsmin)
{
dsmin = deltas;
s_near = std::get<3>(*tuple);
x_near = std::get<0>(*tuple);
y_near = std::get<1>(*tuple);
yaw_near = std::get<2>(*tuple);
nexttuple = *(tuple++);
nexttuple = *(tuple);
tuple++;
if (tuple != Points.end())
{
nexttuple = *(tuple);
}
tuple--;
if (tuple == Points.begin())
previoustuple = *(tuple);
else
{
previoustuple = *(tuple--);
tuple++;
tuple++;
}
}
dslast = deltas;
}
......
......@@ -212,8 +212,6 @@ void VehicleModelsImporter::ImportVehicleModelPerformance(QDomElement& vehicleEl
vehicleElement, "Tag " + std::string(TAG::performance) + " is missing.");
modelParameters.maxVelocity = ParseParametrizedAttribute<double>(performanceElement, ATTRIBUTE::maxSpeed, parameters);
modelParameters.maxAcceleration = ParseParametrizedAttribute<double>(performanceElement, ATTRIBUTE::maxAcceleration, parameters);
modelParameters.maxDeceleration = ParseParametrizedAttribute<double>(performanceElement, ATTRIBUTE::maxDeceleration, parameters);
}
void VehicleModelsImporter::ImportVehicleModelGears(ParametrizedVehicleModelParameters& modelParameters,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment