I am using an Oak-d on a robotic rover platform and would like to use the IMU to be able to get roll, pitch, and yaw/heading. I've read the documentation and saw the several different methods for getting different types of data from the IMU but these are typically conveyed in a quaternion. Is there a straightforward method for converting the quaternion into roll, pitch, and yaw? I'm not looking for somebody to write a full implementation for me, but some proper equations would be greatly appreciated.
Additionally, how would I go about correcting the quaternion for something like magnetic declination. The IMU will return a quaternion that is referenced to magnetic north (depending on which method is being used), but most of the time there is a small difference between magnetic north and geographic north. The system I'm using has an RTK on board. I am able to drive the rover in a straight line for a short distance and then use the positioning data to calculate what the true heading is in reference to geographic north. But how would I use that to correct the orientation data from the IMU?