Quote:
Originally Posted by Joshua Sicz
I have been helping out our student programmers on our team and we haven't found a good why to calculate velocity. We have a accelerometer that gives us reading in g's. So we just convert it to ft/s^2 and then take the timedifference between that last time the code was ran to calculate velocity. But what we are finding is the accelerometer doesn't give us consistent values.
Does any team have experience in this? Anything would help thanks! 
|
In order to even have a chance at making this work, you would also need a gyroscope. At each time step, you would have to rotate the previous time step's x and y by the amount of angle you've turned (theta),
then add the change in speed. Assuming x is to the right and y is forward, and theta is rotation to the right, you'd have to do:
- ynew = yold*cos(theta) + xold*sin(theta) + yacc*rdelta
- xnew = xold*cos(theta) - yold*sin(theta) + xacc*tdelta
This is known as
inertial navigation, and you can very quickly get lost in the intricacies if you're actually trying to use it for more than a few seconds, or in more than two dimensions, or across more than an area the size of, say, an FRC arena. Even staying in a 27-foot square box and limiting yourself to 2 minutes and 30 seconds, it would probably be a good idea to have a "reset" button that you can hit when the robot is actually stopped that sets both values to zero.