Slow down in curves/turns in route simulation
Open, NormalPublic

Description

Plan a route somewhere, and in the Location panel set "Position Tracking" to "Current Route". You now have a GPS simulation where the position is reported along the planned route. Note how the speed stays at exactly 90 km/h. In this task assume that the position is taken from a car driving along the route which slows down as needed in curves and turns. Implement this slow-down by changing the speed according to the shape of the route.

Find a way to determine whether a section of the route is a straight section, a curve or a turn. One possible approach is to assume that the current point, the next one and the one after lie on a circle and determine its radius. A circle with a low radius corresponds to a turn, one with a large radius to a curve and one with infinite radius to a straight section.

The slow-down should have the following characteristics:

  • the speed never gets zero
  • the speed never exceeds the maximum speed (currently 90 km/h)
  • in (longer) straight sections the speed reaches the maximum speed
  • the sharper a curve, the slower the speed
  • the slow-down behavior does not have to be realistic with regard to the kinematic behavior of a car or the steering behavior of a human

To implement the slow-down, change the line fraction = 25*time / ... in RouteSimulationPositionProviderPlugin.cpp and replace 25 with your calculation of an appropriate speed. Test your implementation and create a review request using Differential here in phabricator.kde.org