Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 165a6b3b authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

read coasting parameters in vecto 3

parent 078765a0
No related branches found
No related tags found
No related merge requests found
......@@ -275,7 +275,16 @@ namespace TUGraz.VectoCommon.InputData
/// P021
/// cf. VECTO Input Parameters.xlsx
/// </summary>
MeterPerSecond MinSpeed { get; }
//MeterPerSecond MinSpeed { get; }
double CoastingDecisionFactorOffset { get; }
double CoastingDecisionFactorScaling { get; }
double LookaheadDistanceFactor { get; }
DataTable CoastingDecisionFactorTargetSpeedLookup { get; }
DataTable CoastingDecisionFactorVelocityDropLookup { get; }
}
public interface IAuxiliaryEngineeringInputData : IAuxiliaryDeclarationInputData
......
......@@ -109,6 +109,11 @@ namespace TUGraz.VectoCore.Utils
return c1.CompareTo(c2) >= 0 ? c1 : c2;
}
public static T Max<T>(T c1, T c2, T c3) where T : IComparable
{
return Max(Max(c1, c2), c3);
}
public static T Limit<T>(this T value, T lowerBound, T upperBound) where T : IComparable
{
if (lowerBound.CompareTo(upperBound) > 0) {
......
......@@ -265,7 +265,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
public virtual IVehicleEngineeringInputData VehicleInputData
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design",
"CA1065:DoNotRaiseExceptionsInUnexpectedLocations")]
get
{
if (VehicleData == null) {
......@@ -277,7 +278,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
public virtual IGearboxEngineeringInputData GearboxInputData
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design",
"CA1065:DoNotRaiseExceptionsInUnexpectedLocations")]
get
{
if (Gearbox == null) {
......@@ -289,7 +291,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
public virtual IAxleGearInputData AxleGearInputData
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design",
"CA1065:DoNotRaiseExceptionsInUnexpectedLocations")]
get
{
if (AxleGear == null) {
......@@ -306,7 +309,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
public virtual IEngineEngineeringInputData EngineInputData
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design",
"CA1065:DoNotRaiseExceptionsInUnexpectedLocations")]
get
{
if (Engine == null) {
......@@ -333,7 +337,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
public virtual IRetarderInputData RetarderInputData
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design",
"CA1065:DoNotRaiseExceptionsInUnexpectedLocations")]
get
{
if (Retarder == null) {
......@@ -359,7 +364,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
public virtual IList<ICycleData> Cycles
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design",
"CA1065:DoNotRaiseExceptionsInUnexpectedLocations")]
get
{
var retVal = new List<ICycleData>();
......@@ -441,6 +447,14 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
Enabled = lac.GetEx<bool>(JsonKeys.DriverData_Lookahead_Enabled),
Deceleration = lac.GetEx<double>(JsonKeys.DriverData_Lookahead_Deceleration).SI<MeterPerSquareSecond>(),
MinSpeed = lac.GetEx<double>(JsonKeys.DriverData_Lookahead_MinSpeed).KMPHtoMeterPerSecond(),
LookaheadDistanceFactor = lac.GetEx<double>("PreviewDistanceFactor"),
CoastingDecisionFactorOffset = lac.GetEx<double>("DF_offset"),
CoastingDecisionFactorScaling = lac.GetEx<double>("DF_scaling"),
CoastingDecisionFactorTargetSpeedLookup =
ReadTableData(lac.GetEx<string>("DF_targetSpeedLookup"), "Lookahead Coasting Decisionfactor - Target speed", false),
CoastingDecisionFactorVelocityDropLookup = ReadTableData(lac.GetEx<string>("Df_velocityDropLookup"),
"Lookahead Coasting Decisionfactor - Velocity drop",
false)
};
}
}
......@@ -467,7 +481,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
public virtual DataTable AccelerationCurve
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design",
"CA1065:DoNotRaiseExceptionsInUnexpectedLocations")]
get
{
var acceleration = Body[JsonKeys.DriverData_AccelerationCurve];
......
......@@ -62,6 +62,12 @@ namespace TUGraz.VectoCore.InputData.Impl
public MeterPerSquareSecond Deceleration { get; internal set; }
public MeterPerSecond MinSpeed { get; internal set; }
public double CoastingDecisionFactorOffset { get; internal set; }
public double CoastingDecisionFactorScaling { get; internal set; }
public double LookaheadDistanceFactor { get; internal set; }
public DataTable CoastingDecisionFactorTargetSpeedLookup { get; internal set; }
public DataTable CoastingDecisionFactorVelocityDropLookup { get; internal set; }
}
public class OverSpeedEcoRollInputData : IOverSpeedEcoRollEngineeringInputData
......@@ -92,10 +98,11 @@ namespace TUGraz.VectoCore.InputData.Impl
public class AxleInputData : IAxleEngineeringInputData
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design",
"CA1065:DoNotRaiseExceptionsInUnexpectedLocations")]
public bool SavedInDeclarationMode
{
get {throw new System.NotImplementedException(); }
get { throw new System.NotImplementedException(); }
}
public string Vendor { get; internal set; }
......
......@@ -58,7 +58,9 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdaper
var lookAheadData = new DriverData.LACData {
Enabled = DeclarationData.Driver.LookAhead.Enabled,
//Deceleration = DeclarationData.Driver.LookAhead.Deceleration,
MinSpeed = DeclarationData.Driver.LookAhead.MinimumSpeed
MinSpeed = DeclarationData.Driver.LookAhead.MinimumSpeed,
LookAheadDecisionFactor = new LACDecisionFactor(),
LookAheadDistanceFactor = 10,
};
var overspeedData = new DriverData.OverSpeedEcoRollData {
Mode = data.OverSpeedEcoRoll.Mode,
......
......@@ -196,7 +196,12 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdaper
var lookAheadData = new DriverData.LACData {
Enabled = driver.Lookahead.Enabled,
//Deceleration = driver.Lookahead.Deceleration,
MinSpeed = driver.Lookahead.MinSpeed,
//MinSpeed = driver.Lookahead.MinSpeed,
LookAheadDecisionFactor =
new LACDecisionFactor(driver.Lookahead.CoastingDecisionFactorOffset, driver.Lookahead.CoastingDecisionFactorScaling,
driver.Lookahead.CoastingDecisionFactorTargetSpeedLookup,
driver.Lookahead.CoastingDecisionFactorVelocityDropLookup),
LookAheadDistanceFactor = driver.Lookahead.LookaheadDistanceFactor
};
var overspeedData = new DriverData.OverSpeedEcoRollData {
Mode = driver.OverSpeedEcoRoll.Mode,
......
......@@ -6,11 +6,21 @@ using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.Declaration
{
public static class LACDecisionFactor
public class LACDecisionFactor
{
private static readonly DecisionFactor LAC = new DecisionFactor();
private readonly DecisionFactor LAC;
public static double Lookup(MeterPerSecond targetVelocity, MeterPerSecond velocityDrop)
public LACDecisionFactor()
{
LAC = new DecisionFactor();
}
public LACDecisionFactor(double offset, double scaling, DataTable vTargetLookup, DataTable vDropLookup)
{
LAC = new DecisionFactor(offset, scaling, vTargetLookup, vDropLookup);
}
public double Lookup(MeterPerSecond targetVelocity, MeterPerSecond velocityDrop)
{
return LAC.Lookup(targetVelocity, velocityDrop);
}
......@@ -20,13 +30,32 @@ namespace TUGraz.VectoCore.Models.Declaration
/// </summary>
private sealed class DecisionFactor : LookupData<MeterPerSecond, MeterPerSecond, double>
{
private readonly LACDecisionFactorVTarget _vTarget = new LACDecisionFactorVTarget();
private readonly LACDecisionFactorVdrop _vDrop = new LACDecisionFactorVdrop();
private readonly LACDecisionFactorVTarget _vTarget;
private readonly LACDecisionFactorVdrop _vDrop;
private readonly double _offset;
private readonly double _scaling;
public DecisionFactor(double offset, double scaling, DataTable vTargetLookup, DataTable vDropLookup)
{
_offset = offset;
_scaling = scaling;
_vTarget = new LACDecisionFactorVTarget(vTargetLookup);
_vDrop = new LACDecisionFactorVdrop(vDropLookup);
}
public DecisionFactor()
{
_offset = 2.5;
_scaling = 1.5;
_vTarget = new LACDecisionFactorVTarget();
_vDrop = new LACDecisionFactorVdrop();
}
public override double Lookup(MeterPerSecond targetVelocity, MeterPerSecond velocityDrop)
{
// normalize values inverse from [0 .. 1] to [2.5 .. 1]
return 2.5 - 1.5 * _vTarget.Lookup(targetVelocity) * _vDrop.Lookup(velocityDrop);
return _offset - _scaling * _vTarget.Lookup(targetVelocity) * _vDrop.Lookup(velocityDrop);
}
protected override void ParseData(DataTable table) {}
......@@ -40,6 +69,11 @@ namespace TUGraz.VectoCore.Models.Declaration
ParseData(ReadCsvResource(ResourceId));
}
public LACDecisionFactorVdrop(DataTable vDrop)
{
ParseData(vDrop ?? ReadCsvResource(ResourceId));
}
public override double Lookup(MeterPerSecond targetVelocity)
{
var section = Data.GetSection(kv => kv.Key < targetVelocity);
......@@ -77,6 +111,11 @@ namespace TUGraz.VectoCore.Models.Declaration
ParseData(ReadCsvResource(ResourceId));
}
public LACDecisionFactorVTarget(DataTable vTargetLookup)
{
ParseData(vTargetLookup ?? ReadCsvResource(ResourceId));
}
public override double Lookup(MeterPerSecond targetVelocity)
{
var section = Data.GetSection(kv => kv.Key < targetVelocity);
......
......@@ -31,6 +31,7 @@
using TUGraz.VectoCommon.Models;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.Models.Declaration;
using TUGraz.VectoCore.Models.Simulation.Data;
namespace TUGraz.VectoCore.Models.SimulationComponent.Data
......@@ -60,6 +61,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
public bool Enabled;
//public MeterPerSquareSecond Deceleration;
public MeterPerSecond MinSpeed;
public double LookAheadDistanceFactor;
public LACDecisionFactor LookAheadDecisionFactor;
}
}
}
\ No newline at end of file
......@@ -277,8 +277,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
var currentSpeed = Driver.DataBus.VehicleSpeed;
// distance until halt
var lookaheadDistance = (currentSpeed.Value() * 3.6 * 10).SI<Meter>();
lookaheadDistance = VectoMath.Max(2 * ds, 1.2 * lookaheadDistance);
var lookaheadDistance =
(currentSpeed.Value() * 3.6 * Driver.DriverData.LookAheadCoasting.LookAheadDistanceFactor).SI<Meter>();
var stopDistance = Driver.ComputeDecelerationDistance(0.SI<MeterPerSecond>());
lookaheadDistance = VectoMath.Max(2 * ds, lookaheadDistance, 1.2 * stopDistance);
var lookaheadData = Driver.DataBus.LookAhead(lookaheadDistance);
Log.Debug("Lookahead distance: {0} @ current speed {1}", lookaheadDistance, currentSpeed);
......@@ -364,7 +366,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
//var CDP = F_dec_average / -F_coasting;
var DF_coasting = LACDecisionFactor.Lookup(v_target, v_veh - v_target);
var DF_coasting = Driver.DriverData.LookAheadCoasting.LookAheadDecisionFactor.Lookup(v_target, v_veh - v_target);
var delta_x = (delta_E / (DF_coasting * F_coasting)).Cast<Meter>();
......@@ -446,7 +448,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
//DriverStrategy.BrakeTrigger = DriverStrategy.NextDrivingAction;
}
var newOperatingPoint = VectoMath.ComputeTimeInterval(DataBus.VehicleSpeed, response.Acceleration, DataBus.Distance, ds);
var newOperatingPoint = VectoMath.ComputeTimeInterval(DataBus.VehicleSpeed, response.Acceleration, DataBus.Distance,
ds);
if (newOperatingPoint.SimulationInterval.IsSmaller(Constants.SimulationSettings.LowerBoundTimeInterval)) {
// the next time interval will be too short, this may lead to issues with inertia etc.
// instead of accelerating, drive at constant speed.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment