Gyroscope -> Arduino -> RoboRIO

We’re trying to use a Gyroscope on our robot this year. The gyroscope we’re trying to use is the Adafruit BNO055. So far, the way we’re found to get information from it is with an Arduino Driver that adafruit provides. So naturally we are trying to get the data from the gyroscope with an arduino, and then trying to pipe it to the RoboRIO.

We got the arduino to read the Gyroscope no problem. But now we’re trying to get the arduino to pipe the data to the RoboRIO via the I2C bus. We threw some code together, for both the RoboRIO side of things, and the Arduino side of things.

So the trouble is, we don’t know how to use the Wire library on the Arduino to send the gyroscope values back to the RoboRIO when it asks for them. We got the RoboRIO to send over data to the Arduino, telling it what to send, but we can’t get the arduino to send anything back.

When sending data back to the RoboRIO(the master) device, do we need to specify the address of the device? Asking since the Arduino acts as the master device to the Gyroscope, but a Slave device to the RoboRIO.

We’ve tried the I2C address scanner code to try and find the address for the roborRIO that way. But then we found that there was a board from Rev robotics called the RIODuino, which has example code using the I2C bus. So we found that the examples used the address of 84. We tried telling the Wire library to begin a Transmission with device 84, but that made the Arduino sketch crash.

Is it worth it to try and write our own Driver for the Gyroscope and remove the Arduino middle man altogether?

Buy a NavX, avoid the headache altogether. One of the best controls investments your team can make.

This year we tried to use an Arduino to send gyroscope and acrostic pinger values to the roboRIO. Using a formatted serial.out() we could pull the separate values out using a VISA read. If you’re using LabVIEW, I can post some sample code we are using for autonomous when I get home.

I’ve used the BNO055 on some personal projects involving a cRIO - here’s the “driver” I wrote for talking to it (mostly based on Adafruit’s python library): https://github.com/4ndr3w/BallBot/blob/master/BNO055.cpp

Some notes if you move forward with something based on this:

  • Since this wasn’t a competition robot and just a fun project, I just used while loops to structure the init process. You DO NOT
    want to copy-paste this as-is in your code - it will lock up if the gyro doesn’t finish initializing - getYaw() assumes big endian
  • If I remember correctly shift-left by one is an artifact of the cRIO addressing and not required on the roboRIO

EDIT:

Just wanted to tack on that there are a ton of COTS gyro solutions that let you avoid headache, like Oblarg said:

  • WCP’s Spartan board with the ADXRS450 gyro (we use)
  • CTRE’s Pigeon IMU
  • NavX
  • If you’re just looking to do some simple gyro turns/drive straight in auto, you could use an analog gyro and be pretty safe

I’m curious, if you are already using i2c, why not interface to the sensor directly?

Looks like you’re using java…

Last year I ported the Adafruit BNO055 Arduino library to Java and released the sources.
There’s example code and lots of instructions in the repo: https://github.com/jcorcoran/BNO055_FRC

It’s tested code and was used by a number of team last season.
Communications with the sensor are performed in a separate thread from main robot comms, so you won’t affect communications with your motor controllers or the FMS.

This will let you wire the BNO055 directly to the roboRIO. Check the repo for wiring instructions.

Thank you very much, this is amazing.