Hi guys, I'm currently working on a robot project. I install an accelerometer ADXL335 and a gyroscope on the robot, and want to use both of them to measure the moving direction of the robot.
For gyroscope it's very easy as it's capable of measuring the degree change.
So how can I measure the moving direction with the accelerometer?
So how can I measure the moving direction with the accelerometer?
What does the accelerometer measure? It measures the rate of change of velocity. And velocity is? The rate of change of direction. So, it you integrate acceleration over time, you get velocity. And, if you integrate velocity over time, you get direction. Trivial? Not in the slightest.
PaulS:
So, it you integrate acceleration over time, you get velocity. And, if you integrate velocity over time, you get direction. Trivial? Not in the slightest.
*distance, not direction
Double-integrating acceleration is not much more difficult than integrating rate of rotation from the rate gyro. One problem is that gravity is always pulling so your accelerometer will always say you are accelerating toward the center of the earth at 1G. If your accelerometer is absolutely horizontal you can ignore the Z axis and just measure X and Y.
You will find that the gyroscope and accelerometer integrations drift fairly quickly. In an hour your robot will think it's three towns over and spinning like a top.
Assuming the acceleration's direction is static, it is more simple than that. The vector that is created by the acceleration is in line with the direction as the speed and distance traveled. That vector shows your direction already.
Assuming you account for gravity.
Acceleration in that direction will give you your distance traveled in that direction when integrated twice.
If the vector is constantly changing direction, then it may become a little more complicated.
Without having searched for a solution to this already, I think the mass of your system will want resist any
changes to rotational acceleration, and your systems direction will not be reflected in the vector anymore.
If your system moves slow enough, you might be able to assume linearity and neglect this.
E: now that I think of it more, you accelerometer only measures in respect to it's own axes. It won't know anything about a world axes. It's more tricky than that. Seems that's where the gyro comes in handy.
You absolutely need a full IMU to do this sensibly. 9 degrees of freedom (unless your robot is
steel in which case the magnetometer isn't going to work well). With a full IMU the acceleration
signal can be meaningfully integrated (it will drift a lot though, but you should be able to
identify still moments in the gait that allow drift correction).