Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS will be completely phased out by mid-2025. To see alternatives please check here

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

adapt simulation component's interface:

- introduce dry-run parameter for point of operation search
- add parameters for initialize methods
- add point of operation search in case of engine overload
parent 58d21415
No related branches found
No related tags found
No related merge requests found
Showing
with 242 additions and 98 deletions
......@@ -33,7 +33,13 @@ namespace TUGraz.VectoCore.Configuration
/// threshold for changes in the road gradient. changes below this threshold will be considered to be equal for filtering out the driving cycle.
/// altitude computation is done before filtering!
/// </summary>
public static readonly double DrivingCycleRoadGradientTolerance = VectoMath.InclinationToAngle(0.25 / 100.0).Value();
public static readonly double DrivingCycleRoadGradientTolerance = 0;
//VectoMath.InclinationToAngle(0.25 / 100.0).Value();
public const int DriverSearchLoopThreshold = 100;
public const double EngineFLDPowerTolerance = 0.50; // Watt
}
}
}
\ No newline at end of file
......@@ -53,8 +53,9 @@ namespace TUGraz.VectoCore.Models.Connector.Ports
/// <param name="dt">[s]</param>
/// <param name="acceleration">[m/s^2]</param>
/// <param name="gradient">[rad]</param>
IResponse Request(Second absTime, Second dt, MeterPerSquareSecond acceleration, Radian gradient);
/// <param name="dryRun"></param>
IResponse Request(Second absTime, Second dt, MeterPerSquareSecond acceleration, Radian gradient, bool dryRun = false);
IResponse Initialize();
IResponse Initialize(MeterPerSecond vehicleSpeed, Radian roadGradient);
}
}
\ No newline at end of file
......@@ -66,6 +66,6 @@ namespace TUGraz.VectoCore.Models.Connector.Ports
/// <returns></returns>
IResponse Request(Second absTime, Second dt, MeterPerSecond targetVelocity, Radian gradient);
IResponse Initialize();
IResponse Initialize(MeterPerSecond vehicleSpeed, Radian roadGradient);
}
}
\ No newline at end of file
......@@ -53,8 +53,9 @@ namespace TUGraz.VectoCore.Models.Connector.Ports
/// <param name="dt">[s]</param>
/// <param name="force">[N]</param>
/// <param name="velocity">[m/s]</param>
IResponse Request(Second absTime, Second dt, Newton force, MeterPerSecond velocity);
/// <param name="dryRun"></param>
IResponse Request(Second absTime, Second dt, Newton force, MeterPerSecond velocity, bool dryRun = false);
IResponse Initialize();
IResponse Initialize(Newton vehicleForce, MeterPerSecond vehicleSpeed);
}
}
\ No newline at end of file
......@@ -11,6 +11,7 @@ namespace TUGraz.VectoCore.Models.Connector.Ports
FailOverload,
FailTimeInterval,
DrivingCycleDistanceExceeded,
DryRun,
}
......
......@@ -54,8 +54,9 @@ namespace TUGraz.VectoCore.Models.Connector.Ports
/// <param name="dt">[s]</param>
/// <param name="torque">[Nm]</param>
/// <param name="angularVelocity">[rad/s]</param>
IResponse Request(Second absTime, Second dt, NewtonMeter torque, PerSecond angularVelocity);
/// <param name="dryRun"></param>
IResponse Request(Second absTime, Second dt, NewtonMeter torque, PerSecond angularVelocity, bool dryRun = false);
IResponse Initialize();
IResponse Initialize(NewtonMeter torque, PerSecond angularVelocity);
}
}
\ No newline at end of file
......@@ -68,4 +68,15 @@ namespace TUGraz.VectoCore.Models.Connector.Ports.Impl
get { return ResponseType.DrivingCycleDistanceExceeded; }
}
}
internal class ResponseDryRun : AbstractResponse
{
public double DeltaFullLoad { get; set; }
public double DeltaDragLoad { get; set; }
public override ResponseType ResponseType
{
get { return ResponseType.DryRun; }
}
}
}
\ No newline at end of file
......@@ -32,16 +32,17 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
_nextComponent = other;
}
public IResponse Request(Second absTime, Second dt, NewtonMeter torque, PerSecond angularVelocity)
public IResponse Request(Second absTime, Second dt, NewtonMeter torque, PerSecond angularVelocity, bool dryRun = false)
{
return _nextComponent.Request(absTime, dt,
_gearData.LossMap.GearboxInTorque(angularVelocity * _gearData.Ratio, torque),
angularVelocity * _gearData.Ratio);
angularVelocity * _gearData.Ratio, dryRun);
}
public IResponse Initialize()
public IResponse Initialize(NewtonMeter torque, PerSecond angularVelocity)
{
return _nextComponent.Initialize();
return _nextComponent.Initialize(_gearData.LossMap.GearboxInTorque(angularVelocity * _gearData.Ratio, torque),
angularVelocity * _gearData.Ratio);
}
protected override void DoWriteModalResults(IModalDataWriter writer)
......
......@@ -58,10 +58,34 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
return this;
}
public IResponse Request(Second absTime, Second dt, NewtonMeter torque, PerSecond angularVelocity)
public IResponse Request(Second absTime, Second dt, NewtonMeter torque, PerSecond angularVelocity, bool dryRun = false)
{
var torqueIn = torque;
var engineSpeedIn = angularVelocity;
NewtonMeter torqueIn;
PerSecond engineSpeedIn;
AddClutchLoss(torque, angularVelocity, out torqueIn, out engineSpeedIn);
return _nextComponent.Request(absTime, dt, torqueIn, engineSpeedIn, dryRun);
}
public IResponse Initialize(NewtonMeter torque, PerSecond angularVelocity)
{
NewtonMeter torqueIn;
PerSecond engineSpeedIn;
AddClutchLoss(torque, angularVelocity, out torqueIn, out engineSpeedIn);
return _nextComponent.Initialize(torqueIn, engineSpeedIn);
}
public void Connect(ITnOutPort other)
{
_nextComponent = other;
}
private void AddClutchLoss(NewtonMeter torque, PerSecond angularVelocity, out NewtonMeter torqueIn,
out PerSecond engineSpeedIn)
{
torqueIn = torque;
engineSpeedIn = angularVelocity;
if (DataBus.Gear() == 0) {
_clutchState = ClutchState.ClutchOpened;
......@@ -85,18 +109,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
_clutchState = ClutchState.ClutchClosed;
}
}
return _nextComponent.Request(absTime, dt, torqueIn, engineSpeedIn);
}
public IResponse Initialize()
{
return _nextComponent.Initialize();
}
public void Connect(ITnOutPort other)
{
_nextComponent = other;
}
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using TUGraz.VectoCore.Configuration;
using TUGraz.VectoCore.Exceptions;
using TUGraz.VectoCore.Models.Connector.Ports;
using TUGraz.VectoCore.Models.Connector.Ports.Impl;
......@@ -73,7 +74,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
#region ITnOutPort
IResponse ITnOutPort.Request(Second absTime, Second dt, NewtonMeter torque, PerSecond engineSpeed)
IResponse ITnOutPort.Request(Second absTime, Second dt, NewtonMeter torque, PerSecond engineSpeed, bool dryRun)
{
_currentState.dt = dt;
_currentState.EngineSpeed = engineSpeed;
......@@ -97,8 +98,15 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
_currentState.EnginePower = LimitEnginePower(requestedEnginePower);
if (!_currentState.EnginePower.IsEqual(requestedEnginePower)) {
return new ResponseFailOverload() { Delta = (_currentState.EnginePower - requestedEnginePower).Value() };
if (dryRun) {
return new ResponseDryRun() {
DeltaFullLoad = (requestedEnginePower - _currentState.DynamicFullLoadPower).Value(),
DeltaDragLoad = (requestedEnginePower - _currentState.FullDragPower).Value()
};
}
if (!_currentState.EnginePower.IsEqual(requestedEnginePower, Constants.SimulationSettings.EngineFLDPowerTolerance)) {
return new ResponseFailOverload() { Delta = (requestedEnginePower - _currentState.EnginePower).Value() };
}
UpdateEngineState(_currentState.EnginePower);
......@@ -107,19 +115,27 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
_currentState.EngineTorque = Formulas.PowerToTorque(_currentState.EnginePower,
_currentState.EngineSpeed);
//todo: use ResponseOverloadFail in case of overload
return new ResponseSuccess();
}
public IResponse Initialize()
public IResponse Initialize(NewtonMeter torque, PerSecond engineSpeed)
{
// Todo: @@@quam
_previousState = new EngineState() {
EngineSpeed = _data.IdleSpeed,
EnginePower = 0.SI<Watt>(),
EngineSpeed = engineSpeed,
dt = 1.SI<Second>(),
EnginePowerLoss = InertiaPowerLoss(torque, engineSpeed),
StationaryFullLoadTorque =
_data.FullLoadCurve.FullLoadStationaryTorque(engineSpeed),
StationaryFullLoadPower = Formulas.TorqueToPower(_previousState.StationaryFullLoadTorque,
engineSpeed),
DynamicFullLoadTorque = _previousState.StationaryFullLoadTorque,
DynamicFullLoadPower = _previousState.StationaryFullLoadPower,
FullDragTorque = _data.FullLoadCurve.DragLoadStationaryTorque(engineSpeed),
FullDragPower = Formulas.TorqueToPower(_previousState.FullDragTorque, engineSpeed),
EnginePower = Formulas.TorqueToPower(torque, engineSpeed) + _previousState.EnginePowerLoss,
EngineTorque = Formulas.PowerToTorque(_previousState.EnginePower, _previousState.EngineSpeed)
};
//_currentState
return new ResponseSuccess();
}
......
......@@ -49,7 +49,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
#region ITnOutPort
IResponse ITnOutPort.Request(Second absTime, Second dt, NewtonMeter torque, PerSecond engineSpeed)
IResponse ITnOutPort.Request(Second absTime, Second dt, NewtonMeter torque, PerSecond engineSpeed, bool dryRun)
{
if (_outPort == null) {
Log.ErrorFormat("{0} cannot handle incoming request - no outport available", absTime);
......@@ -60,12 +60,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
_powerDemand = _demand.GetPowerDemand(absTime, dt);
var tq = Formulas.PowerToTorque(_powerDemand, engineSpeed);
return _outPort.Request(absTime, dt, torque + tq, engineSpeed);
return _outPort.Request(absTime, dt, torque + tq, engineSpeed, dryRun);
}
public IResponse Initialize()
public IResponse Initialize(NewtonMeter torque, PerSecond engineSpeed)
{
return _outPort.Initialize();
_powerDemand = _demand.GetPowerDemand(0.SI<Second>(), 0.SI<Second>());
var tq = Formulas.PowerToTorque(_powerDemand, engineSpeed);
return _outPort.Initialize(torque + tq, engineSpeed);
}
#endregion
......
......@@ -158,7 +158,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
};
CurrentState = PreviousState.Clone();
//return new ResponseSuccess();
return _outPort.Initialize();
return _outPort.Initialize(CycleIntervalIterator.LeftSample.VehicleTargetSpeed,
CycleIntervalIterator.LeftSample.RoadGradient);
}
#endregion
......@@ -208,11 +209,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
protected IEnumerator<DrivingCycleData.DrivingCycleEntry> LeftSampleIt;
protected IEnumerator<DrivingCycleData.DrivingCycleEntry> RightSampleIt;
//protected uint currentCycleIndex;
public DrivingCycleEnumerator(DrivingCycleData data)
{
LeftSampleIt = data.Entries.GetEnumerator();
RightSampleIt = data.Entries.GetEnumerator();
RightSampleIt.MoveNext();
//currentCycleIndex = 0;
}
public DrivingCycleData.DrivingCycleEntry Current
......
using System;
using System.CodeDom;
using System.Collections.Generic;
using System.Linq;
using TUGraz.VectoCore.Configuration;
using TUGraz.VectoCore.Exceptions;
using TUGraz.VectoCore.Models.Connector.Ports;
using TUGraz.VectoCore.Models.Connector.Ports.Impl;
......@@ -41,7 +43,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
CurrentState.Response = retVal;
//switch (retVal.ResponseType) {}
switch (retVal.ResponseType) {
case ResponseType.FailOverload:
break;
}
return retVal;
}
......@@ -56,13 +62,73 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
return retVal;
}
public IResponse Initialize()
public IResponse Initialize(MeterPerSecond vehicleSpeed, Radian roadGradient)
{
return Next.Initialize();
return Next.Initialize(vehicleSpeed, roadGradient);
}
protected IResponse DoHandleRequest(Second absTime, Meter ds, MeterPerSecond targetVelocity, Radian gradient)
{
ComputeAcceleration(ds, targetVelocity);
if (CurrentState.dt.IsEqual(0)) {
return new ResponseFailTimeInterval();
}
do {
var retVal = Next.Request(absTime, CurrentState.dt, CurrentState.Acceleration, gradient);
switch (retVal.ResponseType) {
case ResponseType.Success:
retVal.SimulationInterval = CurrentState.dt;
return retVal;
case ResponseType.FailOverload:
SearchOperatingPoint(absTime, ds, targetVelocity, gradient, retVal);
break;
}
} while (CurrentState.RetryCount++ < Constants.SimulationSettings.DriverSearchLoopThreshold);
return new ResponseDrivingCycleDistanceExceeded() { SimulationInterval = CurrentState.dt };
}
private void SearchOperatingPoint(Second absTime, Meter ds, MeterPerSecond targetVelocity, Radian gradient,
IResponse response)
{
var exceeded = new List<double>();
var acceleration = new List<double>();
var searchInterval = CurrentState.Acceleration.Value() / 2.0;
do {
var delta = 0.0;
switch (response.ResponseType) {
case ResponseType.FailOverload:
delta = ((ResponseFailOverload)response).Delta;
break;
case ResponseType.DryRun:
delta = ((ResponseDryRun)response).DeltaFullLoad;
break;
default:
throw new VectoSimulationException("Unknown response type");
}
exceeded.Add(delta);
acceleration.Add(CurrentState.Acceleration.Value());
if (delta.IsEqual(0, Constants.SimulationSettings.EngineFLDPowerTolerance)) {
return;
}
if (delta > 0) {
CurrentState.Acceleration -= searchInterval;
} else {
CurrentState.Acceleration += searchInterval;
}
searchInterval /= 2.0;
CurrentState.dt = ComputeTimeInterval(ds, targetVelocity, CurrentState.Acceleration);
response = Next.Request(absTime, CurrentState.dt, CurrentState.Acceleration, gradient, true);
//factor *= 2;
} while (CurrentState.RetryCount++ < Constants.SimulationSettings.DriverSearchLoopThreshold);
}
private void ComputeAcceleration(Meter ds, MeterPerSecond targetVelocity)
{
var currentSpeed = DataBus.VehicleSpeed();
......@@ -78,30 +144,34 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
requiredAcceleration = maxAcceleration.Deceleration;
}
var dt = (ds / currentSpeed).Cast<Second>();
if (!requiredAcceleration.IsEqual(0)) {
// we need to accelerate / decelerate. solve quadratic equation...
// ds = acceleration / 2 * dt^2 + currentSpeed * dt => solve for dt
var solutions = VectoMath.QuadraticEquationSolver(requiredAcceleration.Value() / 2.0, currentSpeed.Value(),
-ds.Value());
solutions = solutions.Where(x => x >= 0).ToList();
if (solutions.Count == 0) {
Log.WarnFormat(
"Could not find solution for computing required time interval to drive distance {0}. currentSpeed: {1}, targetSpeed: {2}, acceleration: {3}",
ds, currentSpeed, targetVelocity, requiredAcceleration);
return new ResponseFailTimeInterval();
}
// if there are 2 positive solutions (i.e. when decelerating), take the smaller time interval
// (the second solution means that you reach negative speed
solutions.Sort();
dt = solutions.First().SI<Second>();
}
CurrentState.Acceleration = requiredAcceleration;
CurrentState.dt = ComputeTimeInterval(ds, targetVelocity, CurrentState.Acceleration);
}
var retVal = Next.Request(absTime, dt, requiredAcceleration, gradient);
retVal.SimulationInterval = dt;
return retVal;
private Second ComputeTimeInterval(Meter ds, MeterPerSecond targetVelocity, MeterPerSquareSecond acceleration)
{
var currentSpeed = DataBus.VehicleSpeed();
if (acceleration.IsEqual(0)) {
return (ds / currentSpeed).Cast<Second>();
}
// we need to accelerate / decelerate. solve quadratic equation...
// ds = acceleration / 2 * dt^2 + currentSpeed * dt => solve for dt
var solutions = VectoMath.QuadraticEquationSolver(acceleration.Value() / 2.0, currentSpeed.Value(),
-ds.Value());
solutions = solutions.Where(x => x >= 0).ToList();
if (solutions.Count == 0) {
Log.WarnFormat(
"Could not find solution for computing required time interval to drive distance {0}. currentSpeed: {1}, targetSpeed: {2}, acceleration: {3}",
ds, currentSpeed, targetVelocity, acceleration);
return 0.SI<Second>();
}
// if there are 2 positive solutions (i.e. when decelerating), take the smaller time interval
// (the second solution means that you reach negative speed
solutions.Sort();
return solutions.First().SI<Second>();
}
......@@ -136,8 +206,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
public class DriverState
{
public Second dt;
public MeterPerSquareSecond Acceleration;
public IResponse Response;
public int RetryCount;
}
}
}
\ No newline at end of file
......@@ -51,7 +51,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
#region ITnOutPort
IResponse ITnOutPort.Request(Second absTime, Second dt, NewtonMeter torque, PerSecond engineSpeed)
IResponse ITnOutPort.Request(Second absTime, Second dt, NewtonMeter torque, PerSecond engineSpeed, bool dryRun)
{
if (_outPort == null) {
Log.ErrorFormat("{0} cannot handle incoming request - no outport available", absTime);
......@@ -59,12 +59,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
string.Format("{0} cannot handle incoming request - no outport available",
absTime));
}
return _outPort.Request(absTime, dt, torque, engineSpeed);
return _outPort.Request(absTime, dt, torque, engineSpeed, dryRun);
}
public IResponse Initialize()
public IResponse Initialize(NewtonMeter torque, PerSecond engineSpeed)
{
return _outPort.Initialize();
return _outPort.Initialize(torque, engineSpeed);
}
#endregion
......
......@@ -48,14 +48,15 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
#region ITnOutPort
IResponse ITnOutPort.Request(Second absTime, Second dt, NewtonMeter torque, PerSecond engineSpeed)
IResponse ITnOutPort.Request(Second absTime, Second dt, NewtonMeter torque, PerSecond engineSpeed, bool dryRun)
{
throw new NotImplementedException();
}
public IResponse Initialize()
public IResponse Initialize(NewtonMeter torque, PerSecond engineSpeed)
{
return Next.Initialize();
// todo: add gearbox losses
return Next.Initialize(torque, engineSpeed);
}
#endregion
......
......@@ -68,7 +68,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
#region ITnOutPort
IResponse ITnOutPort.Request(Second absTime, Second dt, NewtonMeter torque, PerSecond angularVelocity)
IResponse ITnOutPort.Request(Second absTime, Second dt, NewtonMeter torque, PerSecond angularVelocity, bool dryRun)
{
if (_outPort == null) {
Log.ErrorFormat("{0} cannot handle incoming request - no outport available", absTime);
......@@ -77,23 +77,32 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
absTime));
}
var power_supply = _demand.GetPowerDemand(absTime, dt);
var power_aux_out = power_supply / _data.EfficiencyToSupply;
var torqueAux = GetPowerDemand(absTime, dt, angularVelocity);
var n_auxiliary = angularVelocity * _data.TransitionRatio;
return _outPort.Request(absTime, dt, torque + torqueAux, angularVelocity);
}
private NewtonMeter GetPowerDemand(Second absTime, Second dt, PerSecond angularVelocity)
{
var powerSupply = _demand.GetPowerDemand(absTime, dt);
var powerAuxOut = powerSupply / _data.EfficiencyToSupply;
var power_aux_in = _data.GetPowerDemand(n_auxiliary, power_aux_out);
var power_aux = power_aux_in / _data.EfficiencyToEngine;
var nAuxiliary = angularVelocity * _data.TransitionRatio;
_powerDemand = power_aux;
var powerAuxIn = _data.GetPowerDemand(nAuxiliary, powerAuxOut);
var powerAux = powerAuxIn / _data.EfficiencyToEngine;
var torque_aux = Formulas.PowerToTorque(power_aux, angularVelocity);
return _outPort.Request(absTime, dt, torque + torque_aux, angularVelocity);
_powerDemand = powerAux;
var torqueAux = Formulas.PowerToTorque(powerAux, angularVelocity);
return torqueAux;
}
public IResponse Initialize()
public IResponse Initialize(NewtonMeter torque, PerSecond angularVelocity)
{
return _outPort.Initialize();
var torqueAux = GetPowerDemand(0.SI<Second>(), 0.SI<Second>(), angularVelocity);
return _outPort.Initialize(torque + torqueAux, angularVelocity);
}
#endregion
......
......@@ -43,19 +43,20 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
_nextComponent = other;
}
public IResponse Request(Second absTime, Second dt, NewtonMeter torque, PerSecond angularVelocity)
public IResponse Request(Second absTime, Second dt, NewtonMeter torque, PerSecond angularVelocity, bool dryRun = false)
{
var retarderTorqueLoss = _lossMap.RetarderLoss(angularVelocity);
//_retarderLoss = Formulas.TorqueToPower(torqueLoss, angularVelocity);
//var requestedPower = Formulas.TorqueToPower(torque, angularVelocity);
//requestedPower += _retarderLoss;
return _nextComponent.Request(absTime, dt, torque + retarderTorqueLoss, angularVelocity);
return _nextComponent.Request(absTime, dt, torque + retarderTorqueLoss, angularVelocity, dryRun);
}
public IResponse Initialize()
public IResponse Initialize(NewtonMeter torque, PerSecond angularVelocity)
{
return _nextComponent.Initialize();
var retarderTorqueLoss = _lossMap.RetarderLoss(angularVelocity);
return _nextComponent.Initialize(torque + retarderTorqueLoss, angularVelocity);
}
}
}
\ No newline at end of file
......@@ -56,7 +56,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
_currentState = new VehicleState();
}
public IResponse Request(Second absTime, Second dt, MeterPerSquareSecond accelleration, Radian gradient)
public IResponse Request(Second absTime, Second dt, MeterPerSquareSecond accelleration, Radian gradient, bool dryRun)
{
_currentState.Velocity = (_previousState.Velocity + (accelleration * dt)).Cast<MeterPerSecond>();
_currentState.dt = dt;
......@@ -68,14 +68,16 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
AirDragResistance() +
SlopeResistance(gradient);
return _nextInstance.Request(absTime, dt, vehicleAccelerationForce, _currentState.Velocity);
return _nextInstance.Request(absTime, dt, vehicleAccelerationForce, _currentState.Velocity, dryRun);
}
public IResponse Initialize()
public IResponse Initialize(MeterPerSecond vehicleSpeed, Radian roadGradient)
{
_previousState = new VehicleState() { Distance = 0.SI<Meter>(), Velocity = 0.SI<MeterPerSecond>() };
_currentState = new VehicleState() { Distance = 0.SI<Meter>(), Velocity = 0.SI<MeterPerSecond>() };
return _nextInstance.Initialize();
_previousState = new VehicleState() { Distance = 0.SI<Meter>(), Velocity = vehicleSpeed };
_currentState = new VehicleState() { Distance = 0.SI<Meter>(), Velocity = vehicleSpeed };
var vehicleAccelerationForce = RollingResistance(roadGradient) + AirDragResistance() + SlopeResistance(roadGradient);
return _nextInstance.Initialize(vehicleAccelerationForce, vehicleSpeed);
}
protected Newton RollingResistance(Radian gradient)
......
......@@ -37,16 +37,19 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
#region IFvOutPort
IResponse IFvOutPort.Request(Second absTime, Second dt, Newton force, MeterPerSecond velocity)
IResponse IFvOutPort.Request(Second absTime, Second dt, Newton force, MeterPerSecond velocity, bool dryRun)
{
var torque = force * _dynamicWheelRadius;
var angularVelocity = velocity / _dynamicWheelRadius;
return _outPort.Request(absTime, dt, torque, angularVelocity);
return _outPort.Request(absTime, dt, torque, angularVelocity, dryRun);
}
public IResponse Initialize()
public IResponse Initialize(Newton force, MeterPerSecond velocity)
{
return _outPort.Initialize();
var torque = force * _dynamicWheelRadius;
var angularVelocity = velocity / _dynamicWheelRadius;
return _outPort.Initialize(torque, angularVelocity);
}
#endregion
......
No preview for this file type
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