Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS has been phased out. To see alternatives please check here

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

changes in driverstrategy: perform updates for drive action when switching from brake to drive

parent 0ccd7713
Branches
Tags
No related merge requests found
...@@ -10,6 +10,8 @@ namespace TUGraz.VectoCore.Models.Simulation ...@@ -10,6 +10,8 @@ namespace TUGraz.VectoCore.Models.Simulation
/// </summary> /// </summary>
void Run(); void Run();
string Name { get; }
/// <summary> /// <summary>
/// Return the vehicle container. /// Return the vehicle container.
/// </summary> /// </summary>
......
...@@ -9,8 +9,6 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl ...@@ -9,8 +9,6 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
{ {
public class DistanceRun : VectoRun public class DistanceRun : VectoRun
{ {
public string Name { get; protected set; }
public DistanceRun(string name, IVehicleContainer container) : base(container) public DistanceRun(string name, IVehicleContainer container) : base(container)
{ {
Name = name; Name = name;
......
...@@ -12,6 +12,8 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl ...@@ -12,6 +12,8 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
/// </summary> /// </summary>
public abstract class VectoRun : LoggingObject, IVectoRun public abstract class VectoRun : LoggingObject, IVectoRun
{ {
public string Name { get; protected set; }
protected Second AbsTime = 0.SI<Second>(); protected Second AbsTime = 0.SI<Second>();
protected Second dt = 1.SI<Second>(); protected Second dt = 1.SI<Second>();
protected SummaryFileWriter SumWriter { get; set; } protected SummaryFileWriter SumWriter { get; set; }
...@@ -49,16 +51,16 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl ...@@ -49,16 +51,16 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
} while (response is ResponseSuccess); } while (response is ResponseSuccess);
} catch (VectoSimulationException vse) { } catch (VectoSimulationException vse) {
Container.FinishSimulation(); Container.FinishSimulation();
throw new VectoSimulationException("absTime: {0}, distance: {1}, dt: {2}, v: {3}, Gear: {4}", vse, AbsTime, throw new VectoSimulationException("{6} - absTime: {0}, distance: {1}, dt: {2}, v: {3}, Gear: {4} | {5}", vse,
Container.Distance, dt, Container.VehicleSpeed, Container.Gear, vse.Message); AbsTime, Container.Distance, dt, Container.VehicleSpeed, Container.Gear, vse.Message, Name);
} catch (VectoException ve) { } catch (VectoException ve) {
Container.FinishSimulation(); Container.FinishSimulation();
throw new VectoSimulationException("absTime: {0}, distance: {1}, dt: {2}, v: {3}, Gear: {4}", ve, AbsTime, throw new VectoSimulationException("{6} - absTime: {0}, distance: {1}, dt: {2}, v: {3}, Gear: {4} | {5}", ve,
Container.Distance, dt, Container.VehicleSpeed, Container.Gear, ve.Message); AbsTime, Container.Distance, dt, Container.VehicleSpeed, Container.Gear, ve.Message, Name);
} catch (Exception e) { } catch (Exception e) {
Container.FinishSimulation(); Container.FinishSimulation();
throw new VectoSimulationException("absTime: {0}, distance: {1}, dt: {2}, v: {3}, Gear: {4}", 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); Container.Distance, dt, Container.VehicleSpeed, Container.Gear, e.Message, Name);
} }
Container.FinishSimulation(); Container.FinishSimulation();
Log.Info("VectoJob finished."); Log.Info("VectoJob finished.");
......
...@@ -42,9 +42,15 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -42,9 +42,15 @@ 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)
{ {
//DrivingBehaviorEntry nextAction = null; if (CurrentDrivingMode == DrivingMode.DrivingModeBrake) {
switch (CurrentDrivingMode) { if (Driver.DataBus.Distance.IsGreaterOrEqual(BrakeTrigger.TriggerDistance)) {
case DrivingMode.DrivingModeDrive: CurrentDrivingMode = DrivingMode.DrivingModeDrive;
NextDrivingAction = null;
DrivingModes[CurrentDrivingMode].ResetMode();
Log.Debug("Switching to DrivingMode DRIVE");
}
}
if (CurrentDrivingMode == DrivingMode.DrivingModeDrive) {
var currentDistance = Driver.DataBus.Distance; var currentDistance = Driver.DataBus.Distance;
UpdateDrivingAction(currentDistance); UpdateDrivingAction(currentDistance);
if (NextDrivingAction != null) { if (NextDrivingAction != null) {
...@@ -55,9 +61,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -55,9 +61,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
Log.Debug("Switching to DrivingMode BRAKE"); Log.Debug("Switching to DrivingMode BRAKE");
BrakeTrigger = NextDrivingAction; BrakeTrigger = NextDrivingAction;
break; //break;
} } else if ((currentDistance + ds).IsGreater(NextDrivingAction.ActionDistance)) {
if ((currentDistance + ds).IsGreater(NextDrivingAction.ActionDistance)) {
Log.Debug("Current simulation interval exceeds next action distance at {0}. reducing maxDistance to {1}", Log.Debug("Current simulation interval exceeds next action distance at {0}. reducing maxDistance to {1}",
NextDrivingAction.ActionDistance, NextDrivingAction.ActionDistance - currentDistance); NextDrivingAction.ActionDistance, NextDrivingAction.ActionDistance - currentDistance);
return new ResponseDrivingCycleDistanceExceeded() { return new ResponseDrivingCycleDistanceExceeded() {
...@@ -66,14 +71,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -66,14 +71,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
}; };
} }
} }
break;
case DrivingMode.DrivingModeBrake:
if (Driver.DataBus.Distance.IsGreaterOrEqual(BrakeTrigger.TriggerDistance)) {
CurrentDrivingMode = DrivingMode.DrivingModeDrive;
DrivingModes[CurrentDrivingMode].ResetMode();
Log.Debug("Switching to DrivingMode DRIVE");
}
break;
} }
var retVal = DrivingModes[CurrentDrivingMode].Request(absTime, ds, targetVelocity, gradient); var retVal = DrivingModes[CurrentDrivingMode].Request(absTime, ds, targetVelocity, gradient);
...@@ -142,6 +139,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -142,6 +139,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
} }
} else { } else {
// update action distance for current 'next action' // update action distance for current 'next action'
if (Driver.DataBus.VehicleSpeed > NextDrivingAction.NextTargetSpeed) {
switch (NextDrivingAction.Action) { switch (NextDrivingAction.Action) {
case DrivingBehavior.Coasting: case DrivingBehavior.Coasting:
var coastingDistance = Formulas.DecelerationDistance(Driver.DataBus.VehicleSpeed, var coastingDistance = Formulas.DecelerationDistance(Driver.DataBus.VehicleSpeed,
...@@ -156,6 +154,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -156,6 +154,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
default: default:
throw new ArgumentOutOfRangeException(); throw new ArgumentOutOfRangeException();
} }
}
if (nextAction != null) { if (nextAction != null) {
if (nextAction.HasEqualTrigger(NextDrivingAction)) { if (nextAction.HasEqualTrigger(NextDrivingAction)) {
...@@ -457,7 +456,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -457,7 +456,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
}). }).
Case<ResponseOverload>(r => { Case<ResponseOverload>(r => {
// limiting deceleration while coast may result in an overload => issue brakes to decelerate with driver's max deceleration // limiting deceleration while coast may result in an overload => issue brakes to decelerate with driver's max deceleration
if (DataBus.ClutchClosed(absTime)) {
response = Driver.DrivingActionAccelerate(absTime, ds, targetVelocity, gradient); response = Driver.DrivingActionAccelerate(absTime, ds, targetVelocity, gradient);
} else {
response = Driver.DrivingActionRoll(absTime, ds, targetVelocity, gradient);
}
//Phase = BrakingPhase.Brake; //Phase = BrakingPhase.Brake;
}). }).
Case<ResponseGearShift>(r => { Case<ResponseGearShift>(r => {
......
...@@ -854,8 +854,8 @@ namespace TUGraz.VectoCore.Tests.Integration.DriverStrategy ...@@ -854,8 +854,8 @@ namespace TUGraz.VectoCore.Tests.Integration.DriverStrategy
var cycleData = new string[] { var cycleData = new string[] {
// <s>,<v>,<grad>,<stop> // <s>,<v>,<grad>,<stop>
" 0, 60, -1.4, 0", " 0, 60, -1.4, 0",
"198, 60, -1.7, 0", "298, 60, -1.7, 0",
"200, 0, -1.7, 4", "300, 0, -1.7, 4",
}; };
var cycle = SimpleDrivingCycles.CreateCycleData(cycleData); var cycle = SimpleDrivingCycles.CreateCycleData(cycleData);
......
...@@ -120,7 +120,6 @@ namespace TUGraz.VectoCore.Tests.Utils ...@@ -120,7 +120,6 @@ namespace TUGraz.VectoCore.Tests.Utils
IsDockedInsideChartArea = false, IsDockedInsideChartArea = false,
DockedToChartArea = yfield.ToString(), DockedToChartArea = yfield.ToString(),
Font = new Font("Verdana", 14), Font = new Font("Verdana", 14),
}; };
chart.Legends.Add(legend); chart.Legends.Add(legend);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment