As Patrick said, you should be using the timestamp parameter to calculate the time between measurements. The timestamp is in milliseconds.
Also, to ensure your sensor is set up correctly every time you run the program, I recommend making use of the attach message to automatically set your parameters once the device is attached, as depicted in the attached image.
Attachments
Attach_Handling.png (23.81 KiB) Viewed 64424 times
have incorporated a way of calibrating the gyros using switches and bangs then automatically feed this result back to my gyros.
I have the complimentary filter in place but was still getting significant drift from the gyro - mainly from pitch it never returned to 0 would be usually 5-10 degrees out and this would accumulate each rotation.
so I put a split and if / or / else type thing - seems complicated but essentially my thought was if the gyro was not actively moving it would take reading from accels and transfer this as the input as a way of resetting the gyro numbers?
or is there a better way?
I can't get my head round programming quaternions and kalman filters.
also I haven't used the magnetometer as I'm not worried about yaw movements as its not common for what I want.
but I will switch the formulae for roll and pitch as really I 180 degrees of roll and on 90 of pitch. I know that's not aeronautically standard notation but is the reality of hand movements.
Ian
If you are able to look at my patch now would be great - but only if I'm not being too frustrating -
I'm actually really enjoying the challenge and loving the "programming"
If your gyro is rotating in multiple axes at once, and your want to accumulate rates over time to track orientation, then you MUST do the required math (quaternions or rotation matrices) - there really isn't any choice, because rotation in one axis can affect degree of rotation in another axis.
What I don't understand with quaternions is what value do I take from the raw gyro for the angles for quaternions?
I've read lots of forums etc about it.
I have the atan2 formula for the accelerometer calculation - but I use this as my correction for they gyro when its not moving.
I can't work out rotation matrices from the gyro data.
I have a pretty complete program at present.
It gives me out the angles and results I need, Have tested it extensively and everything performs as expected. I'm not requiring super uptodate exact position sensing, just the idea of extent of movement. But would love to get my head round the maths.
I'll keep looking - do you know of good guides for gyros and quaternions?
We have a C# example which uses rotation matrices to calculate orientation. I'm not really experienced with Quaternions, but I do know they are preferable to rotation matrices. At some point, I'd like to have some app notes on IMUs, including kalman filters, etc. but just don't know when we'll get to it.
Do you think it would work with the jit.axisquat obj? If I plug gyro data into it with an expr $f1*timestamp to create a degree rotation? That obj is supposed to convert 3axis rotation into a quaternion? My numbers at present work completely fine accept if I rotate the pitch >60degrees then try to roll. It can't register the roll. But pitch works completely normally