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

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

Merge branch 'feature/VECTO-125-comparison-of-vecto2.2-and-vecto3' of...

Merge branch 'feature/VECTO-125-comparison-of-vecto2.2-and-vecto3' of https://webgate.ec.europa.eu/CITnet/stash/scm/~emquarima/vecto-sim into feature/VECTO-125-comparison-of-vecto2.2-and-vecto3
parents 93308eae aa88b4e4
No related branches found
No related tags found
No related merge requests found
Showing
with 698 additions and 192 deletions
...@@ -271,6 +271,8 @@ namespace TUGraz.VectoCore.Models.Simulation.Data ...@@ -271,6 +271,8 @@ namespace TUGraz.VectoCore.Models.Simulation.Data
/// [m] Altitude /// [m] Altitude
/// </summary> /// </summary>
[ModalResultField(typeof(SI))] altitude, [ModalResultField(typeof(SI))] altitude,
[ModalResultField(typeof(SI), name: "ds [m]")] simulationDistance
} }
......
...@@ -17,5 +17,7 @@ namespace TUGraz.VectoCore.Models.Simulation ...@@ -17,5 +17,7 @@ namespace TUGraz.VectoCore.Models.Simulation
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
IVehicleContainer GetContainer(); IVehicleContainer GetContainer();
bool FinishedWithoutErrors { get; }
} }
} }
\ No newline at end of file
...@@ -36,6 +36,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl ...@@ -36,6 +36,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
ds = r.MaxDistance; ds = r.MaxDistance;
}). }).
Case<ResponseCycleFinished>(r => { Case<ResponseCycleFinished>(r => {
FinishedWithoutErrors = true;
Log.Info("========= Driving Cycle Finished"); Log.Info("========= Driving Cycle Finished");
}). }).
Default(r => { Default(r => {
......
...@@ -23,6 +23,8 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl ...@@ -23,6 +23,8 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
//protected IModalDataWriter DataWriter { get; set; } //protected IModalDataWriter DataWriter { get; set; }
protected IVehicleContainer Container { get; set; } protected IVehicleContainer Container { get; set; }
public bool FinishedWithoutErrors { get; protected set; }
protected VectoRun(IVehicleContainer container) protected VectoRun(IVehicleContainer container)
{ {
Container = container; Container = container;
...@@ -50,14 +52,20 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl ...@@ -50,14 +52,20 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
} }
} while (response is ResponseSuccess); } while (response is ResponseSuccess);
} catch (VectoSimulationException vse) { } catch (VectoSimulationException vse) {
Log.Error("SIMULATION RUN ABORTED! ========================");
Log.Error(vse);
Container.FinishSimulation(); Container.FinishSimulation();
throw new VectoSimulationException("{6} - absTime: {0}, distance: {1}, dt: {2}, v: {3}, Gear: {4} | {5}", vse, throw new VectoSimulationException("{6} - absTime: {0}, distance: {1}, dt: {2}, v: {3}, Gear: {4} | {5}", vse,
AbsTime, Container.Distance, dt, Container.VehicleSpeed, Container.Gear, vse.Message, Name); AbsTime, Container.Distance, dt, Container.VehicleSpeed, Container.Gear, vse.Message, Name);
} catch (VectoException ve) { } catch (VectoException ve) {
Log.Error("SIMULATION RUN ABORTED! ========================");
Log.Error(ve);
Container.FinishSimulation(); Container.FinishSimulation();
throw new VectoSimulationException("{6} - absTime: {0}, distance: {1}, dt: {2}, v: {3}, Gear: {4} | {5}", ve, throw new VectoSimulationException("{6} - absTime: {0}, distance: {1}, dt: {2}, v: {3}, Gear: {4} | {5}", ve,
AbsTime, Container.Distance, dt, Container.VehicleSpeed, Container.Gear, ve.Message, Name); AbsTime, Container.Distance, dt, Container.VehicleSpeed, Container.Gear, ve.Message, Name);
} catch (Exception e) { } catch (Exception e) {
Log.Error("SIMULATION RUN ABORTED! ========================");
Log.Error(e);
Container.FinishSimulation(); Container.FinishSimulation();
throw new VectoSimulationException("{6} - absTime: {0}, distance: {1}, dt: {2}, v: {3}, Gear: {4} | {5}", e, AbsTime, throw new VectoSimulationException("{6} - absTime: {0}, distance: {1}, dt: {2}, v: {3}, Gear: {4} | {5}", e, AbsTime,
Container.Distance, dt, Container.VehicleSpeed, Container.Gear, e.Message, Name); Container.Distance, dt, Container.VehicleSpeed, Container.Gear, e.Message, Name);
......
...@@ -17,6 +17,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -17,6 +17,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
{ {
public class DefaultDriverStrategy : LoggingObject, IDriverStrategy public class DefaultDriverStrategy : LoggingObject, IDriverStrategy
{ {
public static readonly SIBase<Meter> BrakingSafetyMargin = 0.1.SI<Meter>();
protected internal DrivingBehaviorEntry NextDrivingAction; protected internal DrivingBehaviorEntry NextDrivingAction;
public enum DrivingMode public enum DrivingMode
...@@ -43,7 +45,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -43,7 +45,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
public IResponse Request(Second absTime, Meter ds, MeterPerSecond targetVelocity, Radian gradient) public IResponse Request(Second absTime, Meter ds, MeterPerSecond targetVelocity, Radian gradient)
{ {
if (CurrentDrivingMode == DrivingMode.DrivingModeBrake) { if (CurrentDrivingMode == DrivingMode.DrivingModeBrake) {
if (Driver.DataBus.Distance.IsGreaterOrEqual(BrakeTrigger.TriggerDistance)) { if (Driver.DataBus.Distance.IsGreaterOrEqual(BrakeTrigger.TriggerDistance, 1e-3.SI<Meter>())) {
CurrentDrivingMode = DrivingMode.DrivingModeDrive; CurrentDrivingMode = DrivingMode.DrivingModeDrive;
NextDrivingAction = null; NextDrivingAction = null;
DrivingModes[CurrentDrivingMode].ResetMode(); DrivingModes[CurrentDrivingMode].ResetMode();
...@@ -107,7 +109,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -107,7 +109,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
NextDrivingAction.ActionDistance = NextDrivingAction.TriggerDistance - coastingDistance; NextDrivingAction.ActionDistance = NextDrivingAction.TriggerDistance - coastingDistance;
break; break;
case DrivingBehavior.Braking: case DrivingBehavior.Braking:
var brakingDistance = Driver.ComputeDecelerationDistance(NextDrivingAction.NextTargetSpeed); var brakingDistance = Driver.ComputeDecelerationDistance(NextDrivingAction.NextTargetSpeed) + BrakingSafetyMargin;
NextDrivingAction.ActionDistance = NextDrivingAction.TriggerDistance - brakingDistance; NextDrivingAction.ActionDistance = NextDrivingAction.TriggerDistance - brakingDistance;
break; break;
default: default:
...@@ -155,7 +157,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -155,7 +157,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
if (nextTargetSpeed < currentSpeed) { if (nextTargetSpeed < currentSpeed) {
if (!Driver.DriverData.LookAheadCoasting.Enabled || if (!Driver.DriverData.LookAheadCoasting.Enabled ||
currentSpeed < Driver.DriverData.LookAheadCoasting.MinSpeed) { currentSpeed < Driver.DriverData.LookAheadCoasting.MinSpeed) {
var brakingDistance = Driver.ComputeDecelerationDistance(nextTargetSpeed); var brakingDistance = Driver.ComputeDecelerationDistance(nextTargetSpeed) + BrakingSafetyMargin;
Log.Debug("adding 'Braking' starting at distance {0}. brakingDistance: {1}, triggerDistance: {2}", Log.Debug("adding 'Braking' starting at distance {0}. brakingDistance: {1}, triggerDistance: {2}",
entry.Distance - brakingDistance, brakingDistance, entry.Distance); entry.Distance - brakingDistance, brakingDistance, entry.Distance);
nextActions.Add(new DrivingBehaviorEntry { nextActions.Add(new DrivingBehaviorEntry {
...@@ -381,7 +383,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -381,7 +383,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
default: default:
return response; return response;
} }
return null; return response;
} }
public override void ResetMode() {} public override void ResetMode() {}
...@@ -433,7 +435,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -433,7 +435,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
var currentDistance = DataBus.Distance; var currentDistance = DataBus.Distance;
if (Phase == BrakingPhase.Coast) { if (Phase == BrakingPhase.Coast) {
var brakingDistance = Driver.ComputeDecelerationDistance(DriverStrategy.BrakeTrigger.NextTargetSpeed); var brakingDistance = Driver.ComputeDecelerationDistance(DriverStrategy.BrakeTrigger.NextTargetSpeed) +
DefaultDriverStrategy.BrakingSafetyMargin;
Log.Debug("breaking distance: {0}, start braking @ {1}", brakingDistance, Log.Debug("breaking distance: {0}, start braking @ {1}", brakingDistance,
DriverStrategy.BrakeTrigger.TriggerDistance - brakingDistance); DriverStrategy.BrakeTrigger.TriggerDistance - brakingDistance);
if (currentDistance + Constants.SimulationSettings.DriverActionDistanceTolerance > if (currentDistance + Constants.SimulationSettings.DriverActionDistanceTolerance >
...@@ -485,7 +488,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -485,7 +488,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
}); });
break; break;
case BrakingPhase.Brake: case BrakingPhase.Brake:
var brakingDistance = Driver.ComputeDecelerationDistance(DriverStrategy.BrakeTrigger.NextTargetSpeed); var brakingDistance = Driver.ComputeDecelerationDistance(DriverStrategy.BrakeTrigger.NextTargetSpeed) +
DefaultDriverStrategy.BrakingSafetyMargin;
Log.Debug("Phase: BRAKE. breaking distance: {0} start braking @ {1}", brakingDistance, Log.Debug("Phase: BRAKE. breaking distance: {0} start braking @ {1}", brakingDistance,
DriverStrategy.BrakeTrigger.TriggerDistance - brakingDistance); DriverStrategy.BrakeTrigger.TriggerDistance - brakingDistance);
if (DriverStrategy.BrakeTrigger.TriggerDistance - brakingDistance < currentDistance) { if (DriverStrategy.BrakeTrigger.TriggerDistance - brakingDistance < currentDistance) {
...@@ -533,7 +537,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -533,7 +537,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
default: default:
return response; return response;
} }
return null; return response;
} }
public override void ResetMode() public override void ResetMode()
......
...@@ -148,6 +148,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -148,6 +148,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
} }
CurrentState.Distance = PreviousState.Distance + ds; CurrentState.Distance = PreviousState.Distance + ds;
CurrentState.SimulationDistance = ds;
CurrentState.VehicleTargetSpeed = CycleIntervalIterator.LeftSample.VehicleTargetSpeed; CurrentState.VehicleTargetSpeed = CycleIntervalIterator.LeftSample.VehicleTargetSpeed;
CurrentState.Gradient = ComputeGradient(ds); CurrentState.Gradient = ComputeGradient(ds);
...@@ -240,6 +241,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -240,6 +241,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
protected override void DoWriteModalResults(IModalDataWriter writer) protected override void DoWriteModalResults(IModalDataWriter writer)
{ {
writer[ModalResultField.dist] = CurrentState.Distance; writer[ModalResultField.dist] = CurrentState.Distance;
writer[ModalResultField.simulationDistance] = CurrentState.SimulationDistance;
writer[ModalResultField.v_targ] = CurrentState.VehicleTargetSpeed; writer[ModalResultField.v_targ] = CurrentState.VehicleTargetSpeed;
writer[ModalResultField.grad] = (Math.Tan(CurrentState.Gradient.Value()) * 100).SI<Scalar>(); writer[ModalResultField.grad] = (Math.Tan(CurrentState.Gradient.Value()) * 100).SI<Scalar>();
writer[ModalResultField.altitude] = CurrentState.Altitude; writer[ModalResultField.altitude] = CurrentState.Altitude;
...@@ -413,6 +415,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -413,6 +415,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
public IResponse Response; public IResponse Response;
public bool RequestToNextSamplePointDone = false; public bool RequestToNextSamplePointDone = false;
public Meter SimulationDistance;
} }
} }
} }
\ No newline at end of file
...@@ -492,7 +492,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -492,7 +492,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
// braking power is in the range of the exceeding delta. set searching range to 2/3 so that // braking power is in the range of the exceeding delta. set searching range to 2/3 so that
// the target point is approximately in the center of the second interval // the target point is approximately in the center of the second interval
var searchInterval = origDelta.Abs() * 2 / 3; var searchInterval = origDelta.Abs() * 2 / 3;
debug.Add(new { brakePower = 0.SI<Watt>(), searchInterval, delta = origDelta, operatingPoint }); debug.Add(new { brakePower = 0.SI<Watt>(), searchInterval, delta = origDelta, operatingPoint });
var brakePower = searchInterval * -origDelta.Sign(); var brakePower = searchInterval * -origDelta.Sign();
...@@ -728,9 +728,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -728,9 +728,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
retVal.SimulationInterval = ds / currentSpeed; retVal.SimulationInterval = ds / currentSpeed;
return retVal; return retVal;
} }
Log.Error("vehicle speed is {0}, acceleration is {1}", currentSpeed, acceleration); Log.Error("vehicle speed is {0}, acceleration is {1}", currentSpeed.Value(), acceleration.Value());
throw new VectoSimulationException( throw new VectoSimulationException(
"vehicle speed has to be > 0 if acceleration = 0! v: {0}", currentSpeed); "vehicle speed has to be > 0 if acceleration = 0! v: {0}, a: {1}", currentSpeed.Value(), acceleration.Value());
} }
// we need to accelerate / decelerate. solve quadratic equation... // we need to accelerate / decelerate. solve quadratic equation...
...@@ -777,7 +777,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -777,7 +777,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
public IResponse DrivingActionHalt(Second absTime, Second dt, MeterPerSecond targetVelocity, Radian gradient) public IResponse DrivingActionHalt(Second absTime, Second dt, MeterPerSecond targetVelocity, Radian gradient)
{ {
if (!targetVelocity.IsEqual(0) || !DataBus.VehicleSpeed.IsEqual(0, 1e-3)) { if (!targetVelocity.IsEqual(0) || !DataBus.VehicleSpeed.IsEqual(0, 1e-3)) {
throw new NotImplementedException("TargetVelocity or VehicleVelocity is not zero!"); throw new NotImplementedException(string.Format(
"TargetVelocity or VehicleVelocity is not zero! v: {0} target: {1}", DataBus.VehicleSpeed.Value(),
targetVelocity.Value()));
} }
DataBus.BreakPower = Double.PositiveInfinity.SI<Watt>(); DataBus.BreakPower = Double.PositiveInfinity.SI<Watt>();
var retVal = NextComponent.Request(absTime, dt, 0.SI<MeterPerSquareSecond>(), gradient); var retVal = NextComponent.Request(absTime, dt, 0.SI<MeterPerSquareSecond>(), gradient);
......
...@@ -24,10 +24,10 @@ namespace TUGraz.VectoCore.Utils ...@@ -24,10 +24,10 @@ namespace TUGraz.VectoCore.Utils
MeterPerSquareSecond deceleration) MeterPerSquareSecond deceleration)
{ {
if (deceleration >= 0) { if (deceleration >= 0) {
throw new VectoException("Deceleration must be negative!"); throw new VectoException("Deceleration must be negative! a: {0}", deceleration);
} }
if (v2 > v1) { if (v2 > v1) {
throw new VectoException("v2 must not be greater than v1"); throw new VectoException("v2 must not be greater than v1 v1: {0} v2: {1}", v1.Value(), v2.Value());
} }
return ((v2 - v1) * (v1 + v2) / deceleration / 2.0).Cast<Meter>(); return ((v2 - v1) * (v1 + v2) / deceleration / 2.0).Cast<Meter>();
......
...@@ -16,7 +16,7 @@ namespace TUGraz.VectoCore.Tests.Integration ...@@ -16,7 +16,7 @@ namespace TUGraz.VectoCore.Tests.Integration
[TestMethod] [TestMethod]
public void Truck40tDeclarationTest() public void Truck40tDeclarationTest()
{ {
//LogManager.DisableLogging(); LogManager.DisableLogging();
var factory = new SimulatorFactory(SimulatorFactory.FactoryMode.DeclarationMode, TruckDeclarationJob); var factory = new SimulatorFactory(SimulatorFactory.FactoryMode.DeclarationMode, TruckDeclarationJob);
var sumFileName = Path.GetFileNameWithoutExtension(TruckDeclarationJob) + Constants.FileExtensions.SumFile; var sumFileName = Path.GetFileNameWithoutExtension(TruckDeclarationJob) + Constants.FileExtensions.SumFile;
...@@ -26,6 +26,10 @@ namespace TUGraz.VectoCore.Tests.Integration ...@@ -26,6 +26,10 @@ namespace TUGraz.VectoCore.Tests.Integration
jobContainer.AddRuns(factory); jobContainer.AddRuns(factory);
jobContainer.Execute(); jobContainer.Execute();
foreach (var run in jobContainer._runs) {
Assert.IsTrue(run.FinishedWithoutErrors);
}
} }
} }
} }
\ No newline at end of file
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