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

Skip to content
Snippets Groups Projects
Commit 65e9e8ec authored by Markus QUARITSCH's avatar Markus QUARITSCH
Browse files

Merge pull request #543 in VECTO/vecto-sim from...

Merge pull request #543 in VECTO/vecto-sim from ~EMQUARIMA/vecto-sim:bugfix/VECTO-599-vecto-crash-when-retardation-is to master

* commit 'cd1417a8':
  bugfix: correct calculation of acceleration in case simulation intervals are split up
  add condition in measured speed cycle: if the remaining interval to the next sampling point is too low, reduce the current simulation interval and thus prolong the next one
parents 622a4201 cd1417a8
No related branches found
No related tags found
No related merge requests found
......@@ -38,6 +38,7 @@ using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.Configuration;
using TUGraz.VectoCore.Models.Connector.Ports;
using TUGraz.VectoCore.Models.Connector.Ports.Impl;
using TUGraz.VectoCore.Models.Declaration;
using TUGraz.VectoCore.Models.Simulation;
using TUGraz.VectoCore.Models.Simulation.Data;
using TUGraz.VectoCore.Models.Simulation.DataBus;
......@@ -134,6 +135,18 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
DeltaT = CycleIterator.RightSample.Time - absTime
};
}
if (Constants.SimulationSettings.MeasuredSpeedTargetTimeInterval.IsEqual(dt)) {
if ((CycleIterator.RightSample.Time - (absTime + dt)) > 0 && (CycleIterator.RightSample.Time - (absTime + dt)) /
Constants.SimulationSettings.MeasuredSpeedTargetTimeInterval < 0.5) {
// the remaining simulation interval would be below 0.5 seconds (i.e., half of MeasuredSpeedTargetTimeInterval)
// reduce the current simulation interval to extend the remaining interval
return new ResponseFailTimeInterval {
AbsTime = absTime,
Source = this,
DeltaT = (CycleIterator.RightSample.Time - absTime)/2
};
}
}
// calc acceleration from speed diff vehicle to cycle
var targetSpeed = CycleIterator.RightSample.VehicleTargetSpeed;
......@@ -141,7 +154,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
targetSpeed = 0.KMPHtoMeterPerSecond();
}
var deltaV = targetSpeed - DataBus.VehicleSpeed;
var deltaT = CycleIterator.RightSample.Time - CycleIterator.LeftSample.Time;
var deltaT = CycleIterator.RightSample.Time - absTime;
if (DataBus.VehicleSpeed.IsSmaller(0)) {
throw new VectoSimulationException("vehicle velocity is smaller than zero");
......
......@@ -32,6 +32,7 @@
using NUnit.Framework;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using TUGraz.VectoCommon.Exceptions;
using TUGraz.VectoCommon.Models;
......@@ -60,6 +61,13 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation
[TestFixture]
public class MeasuredSpeedModeTest
{
[OneTimeSetUp]
public void Init()
{
Directory.SetCurrentDirectory(TestContext.CurrentContext.TestDirectory);
}
/// <summary>
/// Test if the cycle file can be read.
/// </summary>
......
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