1

i have been trying to get speed of the vehicle using MPU-6050 but couldn't find my way to do it so, in the end i am stuck here

def stateCondition():
while True:
    acc_x = read_raw_data(ACCEL_XOUT_H)
    acc_y = read_raw_data(ACCEL_YOUT_H)
    acc_z = read_raw_data(ACCEL_ZOUT_H)
    gyro_x = read_raw_data(GYRO_XOUT_H)
    gyro_y = read_raw_data(GYRO_YOUT_H)
    gyro_z = read_raw_data(GYRO_ZOUT_H)
    # Full scale range +/- 250 degree/C as per sensitivity scale factor
    Ax = acc_x/16384.0
    Ay = acc_y/16384.0
    Az = acc_z/16384.0
    Gx = gyro_x/131.0
    Gy = gyro_y/131.0
    Gz = gyro_z/131.0

can some one please write the rest of it so that it returns the speed of the vehicle in km/hr or whatever it is!!!!!

Thank you

  • Suggest their [developers corner](https://invensense.tdk.com/developers/). – jarmod Feb 13 '23 at 16:47
  • Hi and welcome to StackOverflow! We will not write your code for you. We will help you solve your problems if you have specific questions, though. – erip Feb 13 '23 at 16:48
  • [Show us](https://stackoverflow.com/help/minimal-reproducible-example) the X input training data for {A, G}, and the Y training output in kph. Plus, this code will need at least one more input, a way of learning when the vehicle is parked. The errors accumulate: https://en.wikipedia.org/wiki/Inertial_measurement_unit#Disadvantages – J_H Feb 13 '23 at 16:49

1 Answers1

1

An MPU6050 will provide you with information about changes in motion (acceleration or decelleration mostly, but also curves). It will not provide you with absolute values. That can only be achieved by integrating over time, but this requires a known start position/speed. Also, it is very inexact, particularly with cheap motion sensors such as this one.

To get the speed of a vehicle, it is much easier to use a GNSS module instead.

PMF
  • 14,535
  • 3
  • 23
  • 49