Does anybody knows how to get the speed direction of the vehicles? From what I know, the yaw direction of the vehicle is not exactly the speed direction.
I calculate it myself. You just need to know you IMU now, and in the previous moment. IMU, in this case, it's your position on the map ( measurements.player_measurements.transform.location.x , y, z)
imu_diff = imu_now - imu_last
if imu_diff[imu_diff != 0].shape[0] == 1:
for i in range(3):
if imu_diff[i] > 0:
speed[i] = forward_speed
return speed
x, y, z = imu_diff[0], imu_diff[1], imu_diff[2]
# velocity_x
if x != 0:
speed[0] = forward_speed / np.sqrt(1 + np.square(z / x) + np.square(y / x))
#velocity_y
if y != 0:
speed[1] = forward_speed / np.sqrt(1 + np.square(z / y) + np.square(x / y))
# velocity_z
if z != 0:
speed[2] = forward_speed / np.sqrt(1 + np.square(y / z) + np.square(x / z))
Hi @Romanenko-Serhii , yes you are right. It seem's that we can't get this information directly from carla, so maybe using this differential method is the best way. Thank you!