This project uses the NuttX RTOS process accelerometer data using the Attitude And Heading Reference System (AHRS) algorithm Fusion and transmits yaw, pitch and roll information through MQTT. On the other side, a Python scripts allows you to visualize this information using a 3D application, based on PyTeapot.
To compile on NuttX through menuconfig, add the nuttx
directory as a symbolic link on nuttx-apps
.
$ cd ~/nuttxspace/nuttx-apps
$ ln -s ~/imu-nuttx-fusion-demo/nuttx FusionDemo
Run make clean
and it should appear on Application Configuration under Fusion DEMO.
The important configuration options are:
- Accelerometer sensitivity (it was tested using MPU6050)
- Sample rate in milliseconds (defaults to 10 Hz)
- MQTT Broker IP, port and topic
On the computer side, the best option to run the 3D visualizer or the MQTT dump script is to create a Python virtual environment and install the required packages:
$ cd ~/imu-nuttx-fusion-demo
$ python3 -m venv venv
$ source venv/bin/activate
$ pip3 install -r requirements.txt
$ python3 scripts/view_3d.py
$ python3 scripts/dump_mqtt.py
NOTE: A MQTT broker is required to run this application. I recommend to use Mosquitto, simple to install and to start running.