arrow left BLOG

NAVIO: Visualizing Mahony AHRS

3DIMU

This document is not updated, please proceed to docs.blog.emlid.com for latest version!

One of examples for Navio demonstrates the work of Mahony AHRS with the data from an onboard MPU9250 sensor. We’ve also made a simple but cool visualizer for it that you can run on your PC\Mac. Here’s the instruction how to run AHRS and visualizer:

Preparing your Mac

Install pip and use it to get required packages:

sudo pip install PyOpenGL PyOpenGL_accelerate
sudo pip install pyserial

You might be asked to install command line developer tools along the way.

On your PC\Mac

Download the archive with Navio utilities.

Extract the archive, enter the directory with 3DIMU utility and run it:

cd Navio/Utilities/3DIMU
python 3Dimu.py
On your Raspberry Pi

Clone Navio repository, navigate to the folder with AHRS example, compile and run it:

git clone https://github.com/emlid/Navio.git
cd Navio/C++/Examples/AHRS
make
./AHRS X.X.X.X 7000

Where X.X.X.X is an ip address of your PC. 7000 is the port number used in 3DIMU.

 

Now try to move your Navio and check how the “brick” on the screen moves along with it.

6 thoughts on “NAVIO: Visualizing Mahony AHRS

  1. Hans Hansen says:

    Hey there, great work. It IS amazing!

    Two comments for beginners using Raspian Debian Wheezy.
    (1) Do
    cd Navio/C++/Examples/AHRS
    g++ -I ../.. AHRS.cpp ../../Navio/MPU9250.cpp -o AHRS -lrt -lpthread
    instead of
    cd Navio/C++/Examples/AHRS
    make
    (2) On a Linux PC: you may not have python and/or python-opengl, hence type:

    miss sudo apt-get install python python-opengl

    Cheers!

    1. Hello Hans,
      1) I’ve removed lpigpio dependency from makefile, so make should work okay with AHRS example on default Raspbian.

  2. Hi guys, I am trying to run this example now from my laptop (linux mint python 2.7)
    I have installed OpenGL with sudo pip install PyOpenGL and also PyOpenGL_accelerate but cannot run the 3Dimu.py code…

    Error:
    hugo@vaio ~/Documents/prive/navio/Navio-master/Utilities/3DIMU $ python 3Dimu.py
    Traceback (most recent call last):
    File “3Dimu.py”, line 107, in
    glutInit(sys.argv)
    File “/usr/local/lib/python2.7/dist-packages/OpenGL/GLUT/special.py”, line 333, in glutInit
    _base_glutInit( ctypes.byref(count), holder )
    File “/usr/local/lib/python2.7/dist-packages/OpenGL/platform/baseplatform.py”, line 407, in __call__
    self.__name__, self.__name__,
    OpenGL.error.NullFunctionError: Attempt to call an undefined function glutInit, check for bool(glutInit) before calling

    any suggestions?

    thx hugo

  3. ok, fixed by installing python-opengl (not using pip)

  4. alvaro says:

    Hello,

    I have a problem. When I run this example all works fine, but the z axis is moving a little bit all the time although my navio is still. Can you help me please? Is it posible to solve it changing some value in the file AHRS.hpp?

    Thank you.

    1. Alvaro, this is due to how this example is written. It only uses gyros and accelerometers, which allow to determine orientation except for rotation around vector of gravity. To solve this you can add magnetometer to the filter.

Leave a Reply

Your email address will not be published. Required fields are marked *