I just received my SparkFun OTOS sensor and started testing immediately. Something I noticed is the abnormal drift of the imu, specifically, ignoring the x and y. If I were to let it calibrate and then wait a few seconds, it would seem normal and stay at 0 degrees. If I were to turn it 90 degrees, it would turn to 90 degrees, then start drifting at random amounts(e.x, 90.2, 90.4, 90.6, …). I’m not sure if there is something I can do to fix this, or if anyone else has experienced this and has any links on how to solve it.
Sounds like you haven’t completed the required calibration of the IMU, or if you did, something went wrong. Have you worked through the getting started guide?
Attention
The IMU on the Optical Tracking Odometry Sensor includes a gyroscope
and accelerometer, which could have an offset. The OTOS performs a
quick calibration when it powers up, but it is recommended to perform
a more thorough calibration at the start of all your programs.
From my understanding, all that’s required in terms of calibration is setting the offset(spin 10 times and see the error). However, this wouldn’t solve the drifting issue, as it drifts in random amounts. Is there some other calibration I’m missing?
I’m not even sure how to compute the gyro offset. If I spin it 10 times and check the value, it’s already drifting like 1 degree every few seconds, whereas at the beginning of the program, it wasn’t. I’m also not sure what accelerometer calibrations are needed. This is the link I used:Calibrating Your Odometry Sensor - SparkFun Learn
The accel/gyro offset is evidently determined in this section of code:
Serial.println("Calibrating IMU...");
// Calibrate the IMU, which removes the accelerometer and gyroscope offsets
myOtos.calibrateImu();
That seems to be a firmware black box, and may not be working properly or at all. I haven’t looked further, but will add that those corrections are very important and required of all IMUs.
Yikes, that’s a lot! It should be more like 1 degrees every few minutes. Some things to check:
Does this happen with the sample OpMode? Do not make any modifications to the OpMode.
Is the robot completely stationary when myOtos.calibrateImu(); is called? I assume so, but want to sanity check.
How have you mounted the OTOS? Is it completely flat without any tilt angle?
Are you touching the sensor with your hand at all? Are there any heat sources near the OTOS? The gyro offset rotation rate changes with temperature (even a couple degrees makes a pretty substantial difference), so ensure the sensor temperature is not changing at all.
Firstly, I assume the sample OpMode is an FRC/FTC thing; however, it is just hooked up to an Arduino with the default project provided. Yes, the robot is stationary and perfectly flat, and right now it’s just the sensor with an Arduino, no additional heat sources are near the OTOS.
Oops! Yes, my apologies, I had just posted on another thread with an FTC team and was still thinking in that context
In that case, replace “sample OpMode” with “Example 1”.
Hmm, hard to say what the problem is, I’ve not seen that kind of behavior before where the angle starts drifting dramatically after rotating 90 degrees. It’s possible the IMU on your particular board is defective.
Just for completeness, could you perhaps share a photo of how you’ve mounted the sensor?
Also, are you turning the robot by hand, or having it drive itself?
Unfortunately, I don’t have the base right now. But I’ve just been turning the robot by hand, as there are no other motors/electronics on the base. I’ve ensured that it stayed flat with the ground, however, and I didn’t think that would be an issue for the IMU portion at least.
Ok, no worries. The heading angle measured by the IMU is simply the integrated z-axis rotation rate, it doesn’t use “proper” quaternion integration as a performance optimization. So if you were to pick up the robot and rotate it around in a funky way, the measured heading would be wrong. But as long as you’re keeping it flat, that shouldn’t be a problem. Nor should that cause the heading to drift like that.
Only thing I can conclude at the moment is that your OTOS may just have a defective IMU. If you’d like an RMA, please work with @TS-Russell or @TS-John. They’ll need your order number.