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:
The vehicle scans ahead along the road for a specific amount of meters and calculates a position on the road.
Using the position, the vehicle calculates the angle (degrees) between the current vehicle direction and the direction of the position.
Steps 1 - 2 repeat, using multiple distances of 10, 30, 60, 150 meters.
The mean of the angles is calculated.
The mean angle is used in the following formula:
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
mis a sensitivity modifier (no units, default is 50).
ais the average angle difference (in degrees).
tis the corner threshold (in degrees, default is 90deg)
The speed output is then set as the target speed.
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:
- Finding the intersections in a certain radius around the vehicle, this is
VehicleEngineclass, and defaults to 100m.
- Then for each of the intersections, the vehicle:
- Calculates the current distance to the intersection.
- Calculates the other vehicle's distance to the intersections.
- Calculates the relative distance from each other.
- 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
JUNCTION, but the algorithm above applies to both cases.
Find out more on the assets page.
- 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.
- Nagel, K., & Rasmussen, S. (1994). Traffic at the edge of chaos (No. LA-UR-94-2681). Los Alamos National Laboratory.