bike ETA: more ele-filter, energy-correction

This commit is contained in:
Arndt Brenschede 2018-11-25 20:11:50 +01:00
parent 0faae6dea7
commit 17be3653ae
2 changed files with 37 additions and 18 deletions

View file

@ -174,18 +174,16 @@ public final class RoutingContext
turnInstructionRoundabouts = expctxGlobal.getVariableValue( "turnInstructionRoundabouts", 1.f ) != 0.f; turnInstructionRoundabouts = expctxGlobal.getVariableValue( "turnInstructionRoundabouts", 1.f ) != 0.f;
// Speed computation model (for bikes) // Speed computation model (for bikes)
if (bikeMode) { // Mass of the biker + bike + luggages, in kg
// Mass of the biker + bike + luggages, in kg bikeMass = expctxGlobal.getVariableValue( "bikeMass", 90.f );
bikeMass = expctxGlobal.getVariableValue( "bikeMass", 90.f ); // Max speed (before braking), in km/h in profile and m/s in code
// Max speed (before braking), in km/h in profile and m/s in code maxSpeed = expctxGlobal.getVariableValue( "maxSpeed", 45.f ) / 3.6;
maxSpeed = expctxGlobal.getVariableValue( "maxSpeed", 45.f ) / 3.6; // Equivalent surface for wind, S * C_x, F = -1/2 * S * C_x * v^2 = - S_C_x * v^2
// Equivalent surface for wind, S * C_x, F = -1/2 * S * C_x * v^2 = - S_C_x * v^2 S_C_x = expctxGlobal.getVariableValue( "S_C_x", 0.5f * 0.45f );
S_C_x = expctxGlobal.getVariableValue( "S_C_x", 0.5f * 0.45f ); // Default resistance of the road, F = - m * g * C_r (for good quality road)
// Default resistance of the road, F = - m * g * C_r (for good quality road) defaultC_r = expctxGlobal.getVariableValue( "C_r", 0.01f );
defaultC_r = expctxGlobal.getVariableValue( "C_r", 0.01f ); // Constant power of the biker (in W)
// Constant power of the biker (in W) bikerPower = expctxGlobal.getVariableValue( "bikerPower", 100.f );
bikerPower = expctxGlobal.getVariableValue( "bikerPower", 100.f );
}
} }
public List<OsmNodeNamed> nogopoints = null; public List<OsmNodeNamed> nogopoints = null;

View file

@ -606,6 +606,29 @@ final class StdPath extends OsmPath
return cost > c; return cost > c;
} }
private double calcIncline( double dist )
{
double min_delta = 3.;
double shift;
if ( elevation_buffer > min_delta )
{
shift = -min_delta;
}
else if ( elevation_buffer < min_delta )
{
shift = -min_delta;
}
else
{
return 0.;
}
double decayFactor = exp( - dist / 100. );
float new_elevation_buffer = (float)( (elevation_buffer+shift) * decayFactor - shift);
double incline = ( elevation_buffer - new_elevation_buffer ) / dist;
elevation_buffer = new_elevation_buffer;
return incline;
}
@Override @Override
protected void computeKinematic( RoutingContext rc, double dist, double delta_h, boolean detailMode ) protected void computeKinematic( RoutingContext rc, double dist, double delta_h, boolean detailMode )
{ {
@ -615,13 +638,11 @@ final class StdPath extends OsmPath
} }
// compute incline // compute incline
double decayFactor = exp( - dist / 100. );
elevation_buffer += delta_h; elevation_buffer += delta_h;
float new_elevation_buffer = (float)( elevation_buffer * decayFactor ); double incline = calcIncline( dist );
double incline = ( elevation_buffer - new_elevation_buffer ) / dist;
elevation_buffer = new_elevation_buffer;
double speed; // Travel speed double speed; // Travel speed
double f_roll = rc.bikeMass * GRAVITY * ( rc.defaultC_r + incline );
if (rc.footMode ) if (rc.footMode )
{ {
// Use Tobler's hiking function for walking sections // Use Tobler's hiking function for walking sections
@ -629,7 +650,7 @@ final class StdPath extends OsmPath
} }
else if (rc.bikeMode) else if (rc.bikeMode)
{ {
speed = solveCubic( rc.S_C_x, rc.bikeMass * GRAVITY * ( rc.defaultC_r + incline ), rc.bikerPower ); speed = solveCubic( f_air, f_roll, rc.bikerPower );
speed = Math.min(speed, rc.maxSpeed); speed = Math.min(speed, rc.maxSpeed);
} }
else else
@ -638,7 +659,7 @@ final class StdPath extends OsmPath
} }
float dt = (float) ( dist / speed ); float dt = (float) ( dist / speed );
totalTime += dt; totalTime += dt;
totalEnergy += dt*rc.bikerPower; totalEnergy += dist*(rc.S_C_x*speed*speed + f_roll);
} }
private static double solveCubic( double a, double c, double d ) private static double solveCubic( double a, double c, double d )