# Speed between two cars

#### Kcaem

Hi,
I found a programming problem that calculated the speed between two cars as below and I would like to know how the calculation is done.
it is about determining the speed of two cars. The coordinate reference system (y,x) is attached to the ego vehicle (as shown in the attached figure).
The speed of the lead car is estimated with the radar of the ego vehicle.
As mentioned in the program reference: The true ground speed of a radar-reported object from the relative speed and the ego vehicle speed is calculated as follows:

Code:
(Vxi,Vyi) : relative object speed
egoSpeed : ego vehicle speed
[Vx,Vy] : ground object speed

Vx = Vxi + egoSpeed :Calculate longitudinal ground speed
theta = atan2(Vyi,Vxi) :Calculate heading angle
Vy = Vx * tan(theta) :Calculate lateral ground speed
Is there anyone who can explain how Vx and Vy are calculated? and why he uses the term "ground"?
Thank you.

#### Attachments

• 6.6 KB Views: 0

#### Woody

VXi and VYi are reported by the radar which is mounted on the Ego Car,
They are the components of velocity of the object car relative to the Ego car.
They must be the relative velocities because the radar gun is traveling with the Ego car.

However the Ground speed of the Object Car is available (from the cars speedometer).
This is just the speed of the car relative to some stationary point on the ground.

However we need to know the Ground speed of the Object Car (are they breaking the speed limit for example).

This is simply gained by adding the radar reported velocity of the object car relative to the Ego Car
to the actual speed (Ground speed) of the Ego Car (reported by its speedometer).

There is also just a little simple trigonometry to allow for the two cars to not be traveling in exactly the same direction.

1 person