Drone compass calibration: Difference between revisions

From Rsewiki
 
(4 intermediate revisions by the same user not shown)
Line 51: Line 51:


Arduino with sensor calibration code. Sending raw data to app and receive the calibration data when send is pressed on the calibration app.
Arduino with sensor calibration code. Sending raw data to app and receive the calibration data when send is pressed on the calibration app.
The calibration is saved in the Teensy EE-prom and will be loaded by the sensor library.


== Rotate drone and save result ==
== Rotate drone and save result ==
Line 57: Line 56:
In the Calibration app, clear the buffer when you are ready to rotate the drome in all directions.
In the Calibration app, clear the buffer when you are ready to rotate the drome in all directions.


Rotate the drone in all directions, until you get a sphere or an ellipsoide as in the figure above.
* press 'clear'
 
Rotate the drone in all directions, until you get a sphere or an ellipsoid as in the figure above.
 
I got a 'Fit error' of 2.3% and gaps of just 1.1% - seems to be OK, in the above figure it is even lower.


When it looks good, upload to the Teensy by "Send Cal"
When it looks good, upload to the Teensy by "Send Cal"
* press 'send Cal'
And the reply should be a green tick-mark as shown.


It is then saved in the Teensy flash (addresses below the first 512 bytes, that is not used by the drone firmware).
It is then saved in the Teensy flash (addresses below the first 512 bytes, that is not used by the drone firmware).

Latest revision as of 13:17, 2 December 2020

back to Drone control

Calibration setup

Once the controller is mounted on the drone, it is time to calibrate the compass.

Upload the calibration firmware to the Teensy (using the Arduino GUI)

Run the calibration app - in the bin directory for Linux, or here for other platforms https://www.pjrc.com/store/prop_shield.html

Compass calibration app

If on Linux go to

cd mobotware/drone_ctrl/trunk/CalibrateSensors
./MotionCal

Calibration app - with a fair set of values. Runs directly on Ubuntu 18.04, for Ubuntu 20.04 see below

Ubuntu 20.04

The calibration app is rather old, so it asks for libpng12.so.0.

I managed to install it through package nsight-systems

sudo apt install nsight-systems
cd /usr/lib/x86_64-linux-gnu
sudo ln -s ../nsight-systems/Host-x86_64/libpng12.so.0

Another option is to get the source code, but the Makefile asks for wxwidgets/3.0.2.gtk2-opengl/bin/wx-config, which I couldn't find.

Arduino code for compas calibration

In arduino open the calibration firmware in mobotware/drone_ctrl/trunk/CalibrateSensors

Run the arduino version, where you have installed the Teensyduino and open the CalibrateSensors.ino

In my case

cd mobotware/drone_ctrl/trunk/CalibrateSensors
/home/chr/Downloads/arduino-1.8.13/arduino 
  • Select board Teensy3.5
  • Compile
  • upload (to /dev/ttyACM0 or the port to which the Teensy is connected)

Arduino with sensor calibration code. Sending raw data to app and receive the calibration data when send is pressed on the calibration app.

Rotate drone and save result

In the Calibration app, clear the buffer when you are ready to rotate the drome in all directions.

  • press 'clear'

Rotate the drone in all directions, until you get a sphere or an ellipsoid as in the figure above.

I got a 'Fit error' of 2.3% and gaps of just 1.1% - seems to be OK, in the above figure it is even lower.

When it looks good, upload to the Teensy by "Send Cal"

  • press 'send Cal'

And the reply should be a green tick-mark as shown.

It is then saved in the Teensy flash (addresses below the first 512 bytes, that is not used by the drone firmware).

Reload drone control firmware

Go back to the drone_ctrl directory and reload

cd mobotware/drone_ctrl/trunk/drone_ctrl
make
make upload

The new compas calibration should be in effect.