Skip to content

Vehicle behaviour

Turning speed control

Vehicles control their speed while turning, using a custom Traffic3D algorithm. The algorithm uses the following steps to calculate the target speed of the vehicle:

  1. The vehicle scans ahead along the road for a specific amount of meters and calculates a position on the road.

  2. Using the position, the vehicle calculates the angle (degrees) between the current vehicle direction and the direction of the position.

  3. Steps 1 - 2 repeat, using multiple distances of 10, 30, 60, 150 meters.

  4. The mean of the angles is calculated.

  5. The mean angle is used in the following formula:

    • Where:
      • m = Sensitivity Modifier (Default value of 50).
      • a = Average Angle Difference (Degrees).
      • t = Corner Threshold (Default value of 90 Degrees)
    • target_speed = (m^(-a/t)) * maxSpeed
    • Where:
      • m is a sensitivity modifier (no units, default is 50).
      • a is the average angle difference (in degrees).
      • t is the corner threshold (in degrees, default is 90deg)
  6. The speed output is then set as the target speed.

Collision sensors

By placing multiple rays from the vehicle, the vehicle can detect whether there is an obstacle with a collider in front of its self. These can be made more sensitive by increasing the Number of Sensor Rays attribute on the vehicle object, although this may decrease performance. If the vehicle is turning, the rays will move with the vehicle, which helps to detect obstacles around a corner.

Stop lines and merging

When a vehicle first spawns into the scene, all intersections (where paths of other vehicles overlap with the current vehicle's path) are calculated and stored in a list.

Once a vehicle pulls up to a Stop Line, the vehicle evaluates whether the path is clear by:

  1. Finding the intersections in a certain radius around the vehicle, this is mergeRadiusCheck in the VehicleEngine class, and defaults to 100m.
  2. Then for each of the intersections, the vehicle:
    1. Calculates the current distance to the intersection.
    2. Calculates the other vehicle's distance to the intersections.
    3. Calculates the relative distance from each other.
    4. Applies the ramps algorithm from Nagel and Rasmussen (1994) to the values above, to generate a target speed.

The speed of the vehicle is then set to the minimum of the target speeds calculated by the algorithm above.

Vehicles behave slightly differently, depending on whether the stop line is a MERGE or JUNCTION, but the algorithm above applies to both cases. Find out more on the assets page.

Notes

  • All intersections are currently calculated on a 2D plane (meaning that any roads that are above another road would class as an intersection) but will later support the 3D Environment.
  • Traffic3D uses flat coordinates - i.e. it assumes that the earth is flat. This should not affect most scenes.

Further reading

  • Nagel, K., & Rasmussen, S. (1994). Traffic at the edge of chaos (No. LA-UR-94-2681). Los Alamos National Laboratory.