# Simulating a car in an intersection

I'm somewhat confused. I want to simulate in real-time an intersection where cars have to turn left, right or go straight. What I have are 2 way points: One at the beginning of the intersection on the incoming street and the other at the end of the intersection on the outgoing street. As I know the next way point on the outgoing street, I know which direction the car should be pointing.

How would I slow the car down to the optimal speed, calculate its steering angle and correct it in a time interval so that the car drives an optimal curve?

A resource I have found, that seems quite good for this is the following paper.

I just don't really understand the first part of the paper where the Circular track is calculated. At which point is the steering angle applied?

-
It is not clear to me that this is a physics question. Could you say a little more about exactly what you are trying to model here and why? – dmckee Sep 13 '12 at 13:49
I do not agree with the paper in that people are not proportional controllers in adjusting their speed. I think a more reasonable assumption is a) constant (fractional) power acceleration and b) constant value deceleration. – ja72 Sep 13 '12 at 15:30
I think you need a diagram or a sketch in order to define the problem as you have it. – ja72 Sep 13 '12 at 16:40

Consider a steady corner shown below:

The coordinates of any point along the curve are $x = r - r \cos \varphi$ and $y = r \sin \varphi$. The angle $\varphi$ is computed from the distance traveled $s = r \varphi$ where $r$ is the cornering radius.

If the final point $B$, and orientation $\theta$ are given, then the radius is

$$r = \frac{x_B-x_A}{1-\cos\theta}$$

and

$$y_B-y_A = r \sin \theta$$

The velocity and acceleration vectors at $P$ are:

$$\vec{v} = v(t) (\sin \frac{s(t)}{r}, \cos \frac{s(t)}{r})$$ $$\vec{a} =( \dot{v} \sin \frac{s(t)}{r}+\frac{{v(t)}^2}{r} \cos \frac{s(t)}{r}, \dot{v} \cos \frac{s(t)}{r}-\frac{{v(t)}^2}{r} \sin \frac{s(t)}{r} )$$

Now since most people don't corner with more than $a_N =\frac{{v(t)}^2}{r}= 0.2g$ then the target cornering speed is

$$v(t) = \sqrt{ a_N \; r }$$

If you are accelerating $\dot v > 0$ or decelerating $\dot v <0$ to reach the target speed, the make sure you do not exceed the desired cornering acceleration $a_N$ by checking

$$\left(\frac{v^2}{r}\right)^2 + \left(\dot{v}\right)^2 \le a_N^2$$

-
Most people corner under 0.2g? That explains a lot. – Colin K Oct 13 '12 at 20:50
@ColinK: If you have a smartphone and can see the accelerometer values, take a ride with your friends and make some observations of your own. – ja72 Oct 14 '12 at 0:16
I've gotten up to 0.5 on streets. But I think 0.2 is probably right for normal people. I max out at 0.96 steady state, >1 peak, on street tires in competition. So my standards are not normal :) – Colin K Oct 14 '12 at 3:24

Other answers and the referenced paper assume a constant radius turn. This path would require a discontinuous steering angle, which is not only non-physical but a somewhat poor approximation for how human drivers drive. The reason drivers don't approximate this technique (besides that it would take very rapid steering wheel movement) is that it would incite very high jerk.

To properly answer this question the criteria of optimization need to be established. Now, some criteria to be considered, mentioned by other answers, include maximum acceleration and time to complete the turn.

If this is meant for racing, then these are indeed probably the only important criteria as the tires will limit the safe acceleration and the time should be minimized. However, if deviation from the center of the lane is allowed then the time can be reduced while maintaining maximum acceleration. Thus, one must establish a trade-off for the optimization to have a single solution.

If this is meant for passenger comfort, then not only would the maximum acceleration be significantly be reduced, but criteria like jerk, become important factors. I would also note that people are more comfortable with forward and rearward accelerations than lateral acceleration, so those should probably be given different weights in the optimization criteria.

This problem could be modeled as a three dimensional problem with two spacial dimensions and one time dimension. The desired route would be a curved surface the was constant across the time dimension. The car trajectory could be given an initial position (and speed) and final spacial position (and speed). The trajectory could be modeled with splines and then the reward function could be evaluated to allow optimization.

-