BNO085 & IMU
General functionality
The main purpose of the BNO085 or IMU is to get the yaw at where the robot is pointing to. This way, we are able to orient the robot to be facing forward by making use of a PID. The error behind the BNO is around \(\pm 0.02\) degrees while on a regular IMU, it can be up to \(\pm 1.0\) degrees.
Retrieving the angle.
The BNO085 uses quaternions in order to determine where it is. It is powerful enough to calculate pitch, yaw, and roll at the same time. For soccer, we only need to get the yaw. The BNO by itself is able to calculate the values of the four quaternions. Assuming aerospace sequence, the yaw is calculated as:
In case of using an IMU sensor; rather than using quaternions, we use rotational velocity and integrate with respect to velocity, value that we're able to retrieve using any common IMU. In the end, we will get a yaw plus a drift, drift that can be almost entirely avoided by analyzing the rate of change of the drift; autocorrecting them in the process.
Methods
You can get the angle by first initializing the BNO from BNO.h; defining it's constructor, and then running Bno::GetBNOData(). Likewise, the IMU can be initialized from IMU.h and then you can get the angle by running IMU::getAngle(). Both of these functions return the yaw in degrees.