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 24e42928 authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

trying to avoid short simuation intervals (<0.25s) so that inertia losses...

trying to avoid short simuation intervals (<0.25s) so that inertia losses after engaging gear etc. are kept within limits
parent 75d147df
No related branches found
No related tags found
No related merge requests found
...@@ -71,6 +71,8 @@ namespace TUGraz.VectoCore.Configuration ...@@ -71,6 +71,8 @@ namespace TUGraz.VectoCore.Configuration
/// </summary> /// </summary>
public static readonly Second TargetTimeInterval = 0.5.SI<Second>(); public static readonly Second TargetTimeInterval = 0.5.SI<Second>();
public static readonly Second LowerBoundTimeInterval = 0.25.SI<Second>();
/// <summary> /// <summary>
/// simulation interval if the vehicle stands still /// simulation interval if the vehicle stands still
/// </summary> /// </summary>
......
...@@ -74,8 +74,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -74,8 +74,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
var currentDistance = Driver.DataBus.Distance; var currentDistance = Driver.DataBus.Distance;
UpdateDrivingAction(currentDistance); UpdateDrivingAction(currentDistance);
if (NextDrivingAction != null) { if (NextDrivingAction != null) {
if (currentDistance.IsEqual(NextDrivingAction.ActionDistance, var remainingDistance = NextDrivingAction.ActionDistance - currentDistance;
Constants.SimulationSettings.DriverActionDistanceTolerance)) { var estimatedNextTimestep = remainingDistance / Driver.DataBus.VehicleSpeed;
if (remainingDistance.IsEqual(0.SI<Meter>(), Constants.SimulationSettings.DriverActionDistanceTolerance) ||
estimatedNextTimestep.IsSmaller(Constants.SimulationSettings.LowerBoundTimeInterval) {
CurrentDrivingMode = DrivingMode.DrivingModeBrake; CurrentDrivingMode = DrivingMode.DrivingModeBrake;
DrivingModes[CurrentDrivingMode].ResetMode(); DrivingModes[CurrentDrivingMode].ResetMode();
Log.Debug("Switching to DrivingMode BRAKE"); Log.Debug("Switching to DrivingMode BRAKE");
...@@ -343,9 +345,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -343,9 +345,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
// overload may happen if driver limits acceleration when rolling downhill // overload may happen if driver limits acceleration when rolling downhill
response = Driver.DrivingActionBrake(absTime, ds, velocity, gradient); response = Driver.DrivingActionBrake(absTime, ds, velocity, gradient);
}). }).
Case<ResponseSpeedLimitExceeded>(() => { Case<ResponseSpeedLimitExceeded>(() => { response = Driver.DrivingActionBrake(absTime, ds, velocity, gradient); });
response = Driver.DrivingActionBrake(absTime, ds, velocity, gradient);
});
}). }).
Case<ResponseUnderload>(r => { Case<ResponseUnderload>(r => {
if (DriverStrategy.OverspeedAllowed(gradient, targetVelocity)) { if (DriverStrategy.OverspeedAllowed(gradient, targetVelocity)) {
...@@ -360,11 +360,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -360,11 +360,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
} else { } else {
response = Driver.DrivingActionRoll(absTime, ds, velocity, gradient); response = Driver.DrivingActionRoll(absTime, ds, velocity, gradient);
response.Switch(). response.Switch().
Case<ResponseUnderload>(r => { Case<ResponseUnderload>(r => { response = Driver.DrivingActionBrake(absTime, ds, velocity, gradient, r); })
response = Driver.DrivingActionBrake(absTime, ds, velocity, gradient, r); .Case<ResponseSpeedLimitExceeded>(() => { response = Driver.DrivingActionBrake(absTime, ds, velocity, gradient); });
}).Case<ResponseSpeedLimitExceeded>(() => {
response = Driver.DrivingActionBrake(absTime, ds, velocity, gradient);
});
} }
return response; return response;
} }
...@@ -458,7 +455,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -458,7 +455,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
DefaultDriverStrategy.BrakingSafetyMargin; 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 > var remainingDistanceToBrake = DriverStrategy.BrakeTrigger.TriggerDistance - brakingDistance - currentDistance;
var estimatedTimeInterval = remainingDistanceToBrake / DataBus.VehicleSpeed;
if (estimatedTimeInterval.IsSmaller(Constants.SimulationSettings.LowerBoundTimeInterval) ||
currentDistance + Constants.SimulationSettings.DriverActionDistanceTolerance >
DriverStrategy.BrakeTrigger.TriggerDistance - brakingDistance) { DriverStrategy.BrakeTrigger.TriggerDistance - brakingDistance) {
Phase = BrakingPhase.Brake; Phase = BrakingPhase.Brake;
Log.Debug("Switching to BRAKE Phase. currentDistance: {0}", currentDistance); Log.Debug("Switching to BRAKE Phase. currentDistance: {0}", currentDistance);
...@@ -498,9 +498,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -498,9 +498,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
} }
//Phase = BrakingPhase.Brake; //Phase = BrakingPhase.Brake;
}). }).
Case<ResponseGearShift>(r => { Case<ResponseGearShift>(r => { response = Driver.DrivingActionRoll(absTime, ds, targetVelocity, gradient); }).
response = Driver.DrivingActionRoll(absTime, ds, targetVelocity, gradient);
}).
Case<ResponseSpeedLimitExceeded>(() => { Case<ResponseSpeedLimitExceeded>(() => {
response = Driver.DrivingActionBrake(absTime, ds, DataBus.VehicleSpeed, response = Driver.DrivingActionBrake(absTime, ds, DataBus.VehicleSpeed,
gradient); gradient);
...@@ -530,8 +528,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -530,8 +528,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
Log.Warn("Clutch is open - trying RollAction"); Log.Warn("Clutch is open - trying RollAction");
response = Driver.DrivingActionRoll(absTime, ds, targetVelocity, gradient); response = Driver.DrivingActionRoll(absTime, ds, targetVelocity, gradient);
} else { } else {
Log.Warn("Clutch is open - trying AccelerateAction"); Log.Warn("Clutch is closed - trying AccelerateAction");
response = Driver.DrivingActionAccelerate(absTime, ds, targetVelocity, gradient); response = Driver.DrivingActionAccelerate(absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient);
response.Switch().Case<ResponseGearShift>(
rs => {
Log.Warn("Got GearShift response, performing roll action...");
response = Driver.DrivingActionRoll(absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient);
}
);
} }
}); });
break; break;
......
...@@ -46,6 +46,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -46,6 +46,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
protected IDrivingCycleOutPort NextComponent; protected IDrivingCycleOutPort NextComponent;
protected bool IntervalProlonged;
public DistanceBasedDrivingCycle(IVehicleContainer container, DrivingCycleData cycle) : base(container) public DistanceBasedDrivingCycle(IVehicleContainer container, DrivingCycleData cycle) : base(container)
{ {
Data = cycle; Data = cycle;
...@@ -137,8 +139,23 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -137,8 +139,23 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
var nextSpeedChange = GetSpeedChangeWithinSimulationInterval(ds); var nextSpeedChange = GetSpeedChangeWithinSimulationInterval(ds);
if (nextSpeedChange == null || ds.IsSmallerOrEqual(nextSpeedChange - PreviousState.Distance)) { if (nextSpeedChange == null || ds.IsSmallerOrEqual(nextSpeedChange - PreviousState.Distance)) {
if (nextSpeedChange == null || DataBus.VehicleSpeed.IsEqual(0.SI<MeterPerSecond>())) {
return DriveDistance(absTime, ds);
}
var remainingDistance = nextSpeedChange - PreviousState.Distance - ds;
var estimatedRemainingTime = remainingDistance / DataBus.VehicleSpeed;
if (IntervalProlonged || remainingDistance.IsEqual(0.SI<Meter>()) ||
estimatedRemainingTime.IsGreater(Constants.SimulationSettings.LowerBoundTimeInterval)) {
return DriveDistance(absTime, ds); return DriveDistance(absTime, ds);
} }
Log.Debug("Extending distance by {0} to next sample point. ds: {1} new ds: {2}", remainingDistance, ds,
nextSpeedChange - PreviousState.Distance);
IntervalProlonged = true;
return new ResponseDrivingCycleDistanceExceeded {
Source = this,
MaxDistance = nextSpeedChange - PreviousState.Distance
};
}
// only drive until next sample point in cycle with speed change // only drive until next sample point in cycle with speed change
Log.Debug("Limiting distance to next sample point {0}", Log.Debug("Limiting distance to next sample point {0}",
CycleIntervalIterator.RightSample.Distance - PreviousState.Distance); CycleIntervalIterator.RightSample.Distance - PreviousState.Distance);
...@@ -258,7 +275,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -258,7 +275,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
protected override void DoWriteModalResults(IModalDataContainer container) protected override void DoWriteModalResults(IModalDataContainer container)
{ {
container[ModalResultField.dist] = CurrentState.Distance; container[ModalResultField.dist] = CurrentState.Distance; // (CurrentState.Distance + PreviousState.Distance) / 2.0;
container[ModalResultField.simulationDistance] = CurrentState.SimulationDistance; container[ModalResultField.simulationDistance] = CurrentState.SimulationDistance;
container[ModalResultField.v_targ] = CurrentState.VehicleTargetSpeed; container[ModalResultField.v_targ] = CurrentState.VehicleTargetSpeed;
container[ModalResultField.grad] = (Math.Tan(CurrentState.Gradient.Value()) * 100).SI<Scalar>(); container[ModalResultField.grad] = (Math.Tan(CurrentState.Gradient.Value()) * 100).SI<Scalar>();
...@@ -273,6 +290,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -273,6 +290,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
PreviousState = CurrentState; PreviousState = CurrentState;
CurrentState = CurrentState.Clone(); CurrentState = CurrentState.Clone();
IntervalProlonged = false;
if (!CycleIntervalIterator.LeftSample.StoppingTime.IsEqual(0) && if (!CycleIntervalIterator.LeftSample.StoppingTime.IsEqual(0) &&
CycleIntervalIterator.LeftSample.StoppingTime.IsEqual(PreviousState.WaitTime)) { CycleIntervalIterator.LeftSample.StoppingTime.IsEqual(PreviousState.WaitTime)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment