Main Site Documentation

Project - BNO055 Absolute Orientation Sensor


#1

I just posted BNO055 Absolute Orientation Sensor on Codeshare. Feel free to discuss and make suggestions here.


#2

@ charlieHustle:
That code looks great. Thanks for posting it.
Before getting the Bosch sensor and testing it, can you relate your experiences with its stability?
I am particularly interested in the heading vector stability if the board is static. In some other systems I have tried, the heading will drift many degrees while static, particularly if there is any change in temperature.
Rockybooth


#3

I’m using the sensor for my autonomous rc car. So far the heading seems very stable. It doesn’t move at all when the car is still. I’m only calculating heading to within a degree. The sensor is mounted on a vibration damper. I have not used it in any temperature extremes.


#4

@ CharlieHustle - Thanks for the info. I will check it out!


#5

Do you have a blog or other place where you have photos/videos of your autonomous car?


#6

+1. I just looked into this sensor and think it may be a great addition to my robot.


#7

$35 each is just over the parts-drawer-filler line and into the because-I-need-one zone.


#8

@ mcalsyn - Yeah, but only ~$10 @ mouser, so look for one on a IoT Labs Earth daughter board. I am sure that @ justin will add one to your offerings.


#9

Considering I paid over double that for a similar device (CK Mongoose) back in 2011, I’d say its a great price! But definitely not something you buy just to throw in the parts bin. It’s amazing how they’ve basically taken that entire device and crammed it into a single chip. And added steroids!


#10

The accelerometer on the BNO055 has a maximum range of ±16g

So it wouldn’t be a good fit for my rocket.


#11

Or @ Justin’s motorcycle…


#12

@ charliehustle:
I have your code running and it looks great.
I have gone a little farther and am using the get/set sensor offsets. The seems to work fine except the magnetometer offset not seem to have an effect. The read back correctly, as written, but the heading remains set at the power up position.
Have you had similar results? It seems that a compass needs to be useful at powerup.
In my application, I cannot pick up and wave the package around to initialize.
Rocky


#13

@ ianlee74 - Too much Titanium holding me together to continue with the crotch rockets…

@ Rocky - I can do it without waving and over BLE no less :slight_smile:


#14

Here you go, loading and saving of the BNO calibration offsets to STM flash :slight_smile:

And lots of thanks to @ charlieHustle for his driver


using System.Threading;
using BNO055;
using Microsoft.SPOT;

namespace BioSnapper
{
    public class Program
    {
        private static IngenuityMicro.Sensors.BNO055 _bno;
        private static IngenuityMicro.Sensors.BNO055.Vector _myVector;
        private static SimpleSerial _ble;
        private static string[] _dataIn;
        private static readonly string Delimiter = string.Empty;
        private static Mode _mode = Mode.Ndof;
        public static void Main()
        {
            _bno = new IngenuityMicro.Sensors.BNO055();
            _bno.IsAlive();
            SetBnoCalibration();
            _ble = new SimpleSerial("COM2", 57600);
            _ble.DataReceived += _ble_DataReceived;
            _ble.Open();
            new Thread(LoopDeLoop).Start();
            Thread.Sleep(Timeout.Infinite);
        }

        static void LoopDeLoop()
        {
            for (;;)
            {
                switch (_mode)
                {
                    case Mode.Ndof:
                        SendData();
                        Thread.Sleep(100);
                        break;
                    case Mode.Config:
                        SetConfigVals();
                        break;
                }
            }
        }
        static void SetBnoCalibration()
        {
            ConfigData configs = SettingsHelper.ReadConfigSettings() ?? new ConfigData();
            _bno.SetMode(0x00); // config mode
            Thread.Sleep(25);
            _bno.setCalvalMRL((byte)configs.CalMrl);
            _bno.setCalvalMRM((byte)configs.CalMrm);
            _bno.setCalvalMOXL((byte)configs.CalMoxl);
            _bno.setCalvalMOXM((byte)configs.CalMoxm);
            _bno.setCalvalMOYL((byte)configs.CalMoyl);
            _bno.setCalvalMOYM((byte)configs.CalMoym);
            _bno.setCalvalMOZL((byte)configs.CalMozl);
            _bno.setCalvalMOZM((byte)configs.CalMozm);
            _bno.SetMode(0x0C);    // NDOF Mode
            Thread.Sleep(50);
            _mode = Mode.Ndof;

        }
        static bool SetConfigVals()
        {
            _bno.SetMode(0x00); // config mode
            ConfigData config = new ConfigData();
            config.CalMrl = _bno.getCalvalMRL();
            config.CalMrm = _bno.getCalvalMRM();
            config.CalMoxl = _bno.getCalvalMOXL();
            config.CalMoxm = _bno.getCalvalMOXM();
            config.CalMoyl = _bno.getCalvalMOYL();
            config.CalMoym = _bno.getCalvalMOYM();
            config.CalMozl = _bno.getCalvalMOZL();
            config.CalMozm = _bno.getCalvalMOZM();
            var res = SettingsHelper.SaveConfigSettings(config);
            _bno.SetMode(0x0C);    // NDOF Mode
            Thread.Sleep(50);
            _mode = Mode.Ndof;
            return res;
        }
        private static void _ble_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
        {
            _dataIn = Delimiter != string.Empty ? _ble.Deserialize(Delimiter) : _ble.Deserialize();
            for (int index = 0; index < _dataIn.Length; index++)
            {
                Debug.Print(_dataIn[index]);
                switch (_dataIn[index])
                {
                    case "N":
                        _mode = Mode.Ndof;
                        break;
                    case "C":
                        _mode = Mode.Config;
                        break;
                }
            }
        }
        static void SendData()
        {
            _myVector = _bno.getVector(IngenuityMicro.Sensors.BNO055.adafruit_vector_type_t.VECTOR_EULER);
            _ble.WriteLine("x:" + _myVector.x.ToString("F1"));
        }
    }
}



#15

@ rockybooth - I added a method called saveSensorOffsets and uploaded revised code to Codeshare. Enjoy!


#16

Also FYI, from my reading of the BNO manual you need to save any settings to your “host” micro non-volatile memory, and write them to the BNO at startup. The BNO does not have memory.