Correcting roll on IMU


Hi all,
I am trying to correct the Roll in the HUD for the IMU with -5 degrees, but i am unable to figure out where (what file), and how (exact text) to change the value. I have been playing around with the
NDataManager::m_navData.ROLL = MPU.m_fusedEulerPose[VEC3_X] * -5;

I have also been looking at NDataManager::m_navData.ROLL = -euler.y();
from the CBNO055.CPP file, with no luck.

but it does not seem to work… when booting, roll starts at zero, but after 2-5 sec, it goes back to the standard +5 degrees error…

Any help out there?


The roll (and all other IMU data fields) appear to start at 0 degrees, as that is their default value until the IMU produces a reading. Typically, the second you move, shake, or otherwise change the state of the IMU, it starts to calibrate itself into a nominally working state. What you are likely seeing with the 5 degree error is that you haven’t mounted the sensor perfectly horizontally with respect to the roll axis.

Back in October, I wrote a small plugin/command that allowed you to zero the roll and pitch from the cockpit, but I don’t think I ever merged it into the current release. I’ll find that code and merge it into the 30.0.4 release that we are currently working on and that will allow you to hit a key on the keyboard to zero your IMU at will. In the new feature release that we are working on (30.1.x), we will also be adding a way to save these settings for your vehicle so those offsets are by default loaded at runtime. I’ll provide instructions here soon for getting those updates.

In the mean time, if you want to manually adjust for that error, you can do this at lines 300-303 in CMPU9150.cpp:

NDataManager::m_navData.PITC = ( MPU.m_fusedEulerPose[VEC3_Y] * RAD_TO_DEGREE ) + <pitchErrorOffset>;
NDataManager::m_navData.ROLL = ( MPU.m_fusedEulerPose[VEC3_X] * RAD_TO_DEGREE ) + <rollErrorOffset>;

In your case, with an error of 5.0 degrees:

NDataManager::m_navData.ROLL = ( MPU.m_fusedEulerPose[VEC3_X] * RAD_TO_DEGREE ) + (-5.0f);

If you are using the BNO055 (OpenROV’s IMU2), your change would be at the bottom of CBNO055.cpp as such:

NDataManager::m_navData.PITC    = euler.z() + <pitchErrorOffset>;
NDataManager::m_navData.ROLL    = -euler.y() + <rollErrorOffset>;

Let me know if you have any further issues and look out for the updates.


Thanks - that worked perfectly!


These files are in the firmware, so after you update them you need to upload your firmware again in order for the changes to take effect.