Calculate coordinates from velocity or orientation

371 Views Asked by At

I am trying to picture the car position from a game.

We can assume that the initial position is (0,0)

The API delivers velocity [x,y,z] (meters/sec) and orientation [yaw,pitch,roll] (radians).

Is it possible to calculate the next position, if I know that I retrieve this data at a fixed rate of 100ms? Can you assist me with the calculations?

Edit What I done so far:
x = Math.Cos(wrapper.data.Telemetry.Pitch) * Math.Cos(wrapper.data.Telemetry.Yaw); y = Math.Cos(wrapper.data.Telemetry.Pitch) * Math.Sin(wrapper.data.Telemetry.Yaw);

vec = (x + y) * speed

But im not sure, if this is correct

Edit 2: velocity vectors:
I tried working with velocity vectors, but I seem to be making something wrong. I calculate x,y like this:

updateRate = 10 // every 100 ms

float vX = velocityX / updateRate;
float vY = velocityY / updateRate;

xPos = xPos + vX;
yPos = yPos + vY;

So what I do here is starting at (0,0), i calculate the meters traveled in each direction (vX and vY) and add this to the initial position. However this seems to be wrong, x is groving with an different rate as y - this is probably because the forward velocity is always greater than the Y velocity. It feels like I need to do more.