C++ sample code that access both GPS and IMU data?

I am new to Raspberry Pi and Navio2. I have successfully built and run most of the sample code documented here:


My project requires that I send both GPS data (Lat, Long, Altitude, Velocity, Track angle, etc…) and IMU data (pitch, roll, heading) over TCP to another piece of hardware on the network. The AHRS example sends IMU data over TCP, and the GPS w/uCenter example sends GPS data over TCP. Is it possible to access both sets of data from the same C++ code? It’s not obvious to me how the two sets of code could be combined to put everything I need into a single executable. If anybody has done something similar, I would love to see some sample code.

Hi John,

Yes, you surely can rewrite these examples to transmit both GNSS and IMU data over TCP. However, we don’t have a ready solution for what you’re trying to accomplish, so the implementation requires some research and programming skills from you.

Maybe somebody from our users will share the ready code.

Thank you for the encouraging comment. I am currently trying to merge the AHRS and GPS examples. I am not very confident that I will be successful, but if it actually works, I will post the results here on the forum.


I was able to merge the two pieces of code (AHRS and GPS examples) and have the GPS and IMU data updating at around 5 Hz. Now I just need to figure out how to calibrate the magnetometer so the yaw will stop drifting.

Hi John,

You can examine calibration algorithms, such as soft-iron or hard-iron, and implement something. It’s also possible you can find ready examples in ROS.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.