WJSchakel / ots-fosim

Extension of OTS which can be used as a simulation core within FOSIM.
0 stars 0 forks source link

Vehicle lane change information #15

Closed WJSchakel closed 3 months ago

WJSchakel commented 3 months ago

The information that is sent to FOSIM makes the vehicles jump lane sometimes. The following information is for example sent (one line per time step):

GTU 9 is at lane 0 GTU 9 changes right at 0.16666666666666666 and is at lane 1 GTU 9 changes right at 0.3333333333333333 and is at lane 1 GTU 9 changes right at 0.5 and is at lane 1 GTU 9 changes right at 0.6666666666666666 and is at lane 1 GTU 9 changes right at 0.8333333333333333 and is at lane 1 GTU 9 is at lane 0 GTU 9 is at lane 1

Clearly the before-last line is wrong.

WJSchakel commented 3 months ago

There are two issues:

  1. For issue #13 all positions of the vehicle were looped, and the most downstream was taken. Usually this will get an exact location of the vehicle nose, but during a lane change it is arbitrary whether the left-hand or right-hand lane is eventually used. The same loop over vehicle positions is used to derive the lane, which then becomes arbitrary. It should however always be the target lane during a lane change.
  2. The LaneChange object of the model is consulted to figure out whether vehicles are changing lane, and the lane change fraction. In the last step of the lane change, the model already finalizes the lane change in this object. However, finalizeLaneChange() on the vehicle, which deals with registration on the lanes, is not yet called. As a consequence, whatever fixes were in place that happened to correctly adjust the lane during a lane change given issue 1, were not active during the last step of the lane change.
WJSchakel commented 3 months ago

As a solution, two matters are changed:

  1. The lane is taken from the reference lane of the vehicle. During a lane change this is the from lane. This is corrected to the target lane using the LaneChange object. For the vehicle position, the distance from the reference of the vehicle to the nose is simply added, regardless of slight rotation of the vehicle.
  2. During a lane change, the correct target lane is stored in a Map for the vehicle. In the last step of the lane change, LaneChange indicated no lane change. However, as the vehicle is still in the Map, it is known that this is the final step of the lane change. The target lane is taken and removed from the Map. For this time step, the target lane is given as the lane. For following time steps, the normal in-lane procedure will follow as the vehicle is no longer present in the Map (until a new lane change is initiated).