c++ - Calculating quaternions from gyro + accelerometer data -
c++ - Calculating quaternions from gyro + accelerometer data -
i have gyroscope + accelerometer info @ each period of time t.
using c++, want calculate rotation of object @ each time - can rotate on axes. i've read convenient represent rotation of scheme in terms of quaternions (not in euler angles).
how can transform angular velocity (from gyroscope) quaternions representation? think in order need solve differential equation using numerical methods.
i'm not sure language you're looking for, c++ boost library has working quaternion class (quaternion.hpp). i've used library create simple rotation class computing results or rotating points arbitrary vectors little difficulty.
update: based on comment, don't think need utilize quaternion library figure out angular position @ given time, given either constant angular velocity or angular acceleration. need figure out angle is, , utilize quaternion class compute position of vectors when rotated rotation vector angle you've computed.
given constant angular acceleration α, initial angular velocity ω(t0) , initial angular position θ(t0) in range [0, 2π) angular position @ time t > t0, θ(t) given by:
θ(t) = [θ(t0) + ω(t0)*(t-t0) + α*(t-t0)2/2] mod 2πhere mod 2π operation residual when subtracting n2π n integer required ensure residual in range [0, 2π). constant angular velocity (i.e. α=0) lastly term drops out.
that said, need maintain track of angle on interval of time under constant acceleration (or determine average acceleration on time if it's not constant) , update angle. apply resulting rotation rotation vector quaternion you're using accumulate rotations. can implemented c++ class.
still, if you're looking open source tool this, expect of game physics modeling libraries more adequate. couple of open source ones bullet , open dynamics library.
c++ math accelerometer physics quaternions
Comments
Post a Comment