简体   繁体   中英

How to get position in 3D cordinates using mpu 6050?

I am working in a project using MPU6050 with my designed chip to detect object movement. Project is divided into 2 phases:

  • Phase I: visualize object orientation (DONE)
  • Phase II: visualize object position in 3D cordinates with gyroscope and accelerator.I follow instructions from this website: http://www.x-io.co.uk/oscillatory-motion-tracking-with-x-imu/ . The position must be derived from this through 'double integration'; the accelerometer is first integrated to yield a velocity and then again to yield the position.

     void COpenGLControl::Update() { double mX; double mY; double mZ; mX = mXCordinate*9.81; // mXCordinate-> X accelerator mY = mYCordinate*9.81; // mYCordinate-> Y accelerator mZ = mZCordinate*9.81; // mZCordinate-> Z accelerator /* linear velocity*/ curVelX = preVelX + mX *sampleRate; curVelY = preVelY + mY*sampleRate; curVelZ = preVelZ + mZ*sampleRate; /* linear location*/ curLoX = preLoX + curVelX*sampleRate; curLoY = preLoY + curVelY*sampleRate; curLoZ = preLoZ + curVelZ*sampleRate; preVelX = curVelX; preVelY = curVelY; preVelZ = curVelZ; preLoX = curLoX; preLoY = curLoY; preLoZ = curLoZ; } 

Then curLoX, curLoY, curLoZ is used to visualize 3D object with openGL:

glPushMatrix();
glTranslatef(curLoY,curLoX,curLoZ); //-> object moving visualization
glBegin(GL_QUADS);  
........       
glPopMatrix();

My purpose is that when moving object up, down, left, right, the 3D object will have the same movement. But object just only move when I rotate my device not linear movement following in http://www.x-io.co.uk/oscillatory-motion-tracking-with-x-imu/ . How can I solve this problems? 在此处输入图片说明

Accelerometers don't give you the object's position, but the, well it's in their name, acceleration, ie the rate of change of velocity.

You have to double integrate over time the values from the accelerometer to determine the position of the object. But there's a catch: Technically doing this is only valid for bodies in free fall. Down here on Earth (and every other massive body in the universe) there's gravity. The mechanical effect of gravity is acceleration. So down here on Earth you can measure a constant acceleration of about 9.81m/s² towards the Earth's center of gravity (you already have a constant of 9.81 up there but you completely misunderstood what it means).

There is no physically correct way to compensate for that. Acceleration is acceleration and in fact we are all moved in spacetime by it (that's why time is progressing a little slower down here on Earth than in outer space) and if you plotted the movement of the IMU in 4D spacetime it'd be the actual proper movement.

What you probably want to see however is the relative movement in the local accelerated frame of reference. If you assume a constant acceleration, that you can take this acceleration vector and subtract it from the measured values. Of course with every rotation of the IMU the acceleration vector will rotate, so you have to integrate the IMU rotation and apply that on the acceleration offset vector before subtracting. Assuming that relative movements are short and have a rather high frequency you may get away with low-pass filtering the accelerometer signal to determine the gravity offset vector.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM