Skip to content

Commit

Permalink
-added a further condition for the vehicle's current radius in the co…
Browse files Browse the repository at this point in the history
…nsumption calculation, that prevents a division by zero

git-svn-id: file:///home/behr_mi/git/sumo_synched/trunk@19053 afbd958f-9f77-42d5-a016-97a22340ccf4
  • Loading branch information
Tamas Kurczveil committed Oct 8, 2015
1 parent 68a658b commit 6e26340
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions sumo/src/microsim/devices/MSDevice_Battery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,10 +600,13 @@ SUMOReal MSDevice_Battery::getPropEnergy(SUMOVehicle& veh) {
SUMOReal radius = 0;

if (getLastAngle() != veh.getAngle())
{
radius = veh.getSpeed() * 180 / (PI * (
(fabs(getLastAngle() - veh.getAngle()) < fabs(veh.getAngle() - getLastAngle())) ?
fabs(getLastAngle() - veh.getAngle()) :
fabs(veh.getAngle() - getLastAngle())));
radius = 0.0001 > radius ? 0.0001 : radius;
}

// add current rotational energy of internal rotating elements
currentEnergy += getInternalMomentOfInertia() * veh.getSpeed() * veh.getSpeed();
Expand Down

0 comments on commit 6e26340

Please sign in to comment.