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

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

set vehicle speed to zero if below certain threshold

parent ce4bc3fe
No related branches found
No related tags found
No related merge requests found
......@@ -78,6 +78,16 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
return retVal;
}
public IResponse Request(Second absTime, Second dt, MeterPerSecond targetVelocity, Radian gradient)
{
DriverBehavior = DrivingBehavior.Halted;
return Driver.DrivingActionHalt(absTime, dt, targetVelocity, gradient);
}
public DrivingBehavior DriverBehavior { get; internal set; }
private void UpdateDrivingAction(Meter currentDistance)
{
var nextAction = GetNextDrivingAction(currentDistance);
......@@ -126,15 +136,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
}
public IResponse Request(Second absTime, Second dt, MeterPerSecond targetVelocity, Radian gradient)
{
DriverBehavior = DrivingBehavior.Halted;
return Driver.DrivingActionHalt(absTime, dt, targetVelocity, gradient);
}
public DrivingBehavior DriverBehavior { get; internal set; }
protected DrivingBehaviorEntry GetNextDrivingAction(Meter minDistance)
{
var currentSpeed = Driver.DataBus.VehicleSpeed;
......@@ -152,7 +153,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
? entry.VehicleTargetSpeed + Driver.DriverData.OverSpeedEcoRoll.OverSpeed
: entry.VehicleTargetSpeed;
if (nextTargetSpeed < currentSpeed) {
// TODO @@@quam currentSpeed ? targetSpeed? nextTargetSpeed?
if (!Driver.DriverData.LookAheadCoasting.Enabled ||
currentSpeed < Driver.DriverData.LookAheadCoasting.MinSpeed) {
var brakingDistance = Driver.ComputeDecelerationDistance(nextTargetSpeed);
......@@ -178,14 +178,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
});
}
}
//if (nextTargetSpeed > currentSpeed) {
// nextActions.Add(new DrivingBehaviorEntry {
// Action = DefaultDriverStrategy.DrivingBehavior.Accelerating,
// NextTargetSpeed = entry.VehicleTargetSpeed,
// TriggerDistance = entry.Distance,
// ActionDistance = entry.Distance
// });
//}
}
return nextActions.Count == 0 ? null : nextActions.OrderBy(x => x.ActionDistance).First();
......
......@@ -125,6 +125,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
_currentState.dt = dt;
_currentState.Acceleration = acceleration;
_currentState.Velocity = _previousState.Velocity + acceleration * dt;
if (_currentState.Velocity.IsEqual(0, 1e-4)) {
_currentState.Velocity = 0.SI<MeterPerSecond>();
}
_currentState.Distance = _previousState.Distance + dt * (_previousState.Velocity + _currentState.Velocity) / 2;
_currentState.DriverAcceleration = DriverAcceleration(acceleration);
......
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