-
Notifications
You must be signed in to change notification settings - Fork 1
Sensor Testing
Assuming you installed the BeagleSat package on your BeagleBone Black and connected a supported sensor device, we can move on to some actual tests.
Before we go forward, change to the python/examples folder:
# pwd
/root/git-BeagleSat/python
# cd examples
The most basic example is getting a single set of unprocessed 3-axis magnetometer data from the sensor.
Run:
# python singleReadExample.py
As output, BeagleSat will inform you that it initializes PyBBIO and the internal magnetometer on the MPU9250 successfully, on which bus was the sensor registered, under what name and the actual values measured on the magnetometer.
If it looks similar to this:
Magnetometer initialization complete.
MPU9250 sensor initialized via SPI0, sensor registered on ID = MPU_1
Corrected magnetometer data:
MagX: 4768.508 uT | MagY: -4178.678 uT | MagZ: -3633.204 uT
Your setup is correct and ready for more advanced stuff.
For a more complete demonstration of some usual functionality you would need to get/store/process data, run the code for the data pipeline example.
In the terminal, run:
# dataPipelineExample.py
Follow the instructions in the program, specifically when prompted to rotate your device around all three axes, spin the device at a moderate rate to as many positions of a sphere as possible. Having a varied set of positions is crucial for the ellipsoid fitting algorithm to be able to determine the best possible fit for the correction parameters.
Once the fitting is complete, a different set of data will be collected and corrected using the previously computed parameters.
After a successful run of the example, the script will generate output data in a set of space separated CSV files in the ./data folder. One file for each of fitting, test and corrected test data.
Looking in the folder we get:
# ls ./data
correctedTestData fittingData testData
If you haven't already, it's a good idea to take a look at the code in the examples to get an idea what the BeagleSat API can do and how it does it.
For a more detailed rundown of the API functionality and available methods, take a look at the API Documentation.
Optionally, after you have generated a test dataset, you can run the visualize.py script to get a graphic representation of the processed data.
Before running this script make sure you have a display (or virtual display) connected to your device and the matplotlib package installed on your system.
To install matplotlib (as root):
# apt-get install python-matplotlib
After all is set, run the script:
# python visualize.py -f ./data/testData -c ./data/correctedTestData
You can use the script using only raw data as well. It will compute the fitting parameters based on the raw dataset and correct the set as well.
# python visualize.py -f ../data/referenceData
Using the reference data, you should see a 3D plot similar to:

Congratulations, you've went through the crash course on how to use magnetic sensors using the BeagleSat platform. For further reading refer to the API Documentation.