How to Publish IMU Data Using ROS and the BNO055 IMU Sensor

2021-06-10-18.14.45

In this tutorial, I will show you how to use the BNO055 sensor (using i2c communication) to generate IMU data for a ROS-based robot. 

I actually prefer the BNO055 over other IMU sensors like the MPU6050. I have found that the BNO055 generates more accurate and less noisy data than the MPU6050.

Real-World Applications

This project has a number of real-world applications: 

  • Indoor Delivery Robots
  • Room Service Robots
  • Mapping of Underground Mines, Caves, and Hard-to-Reach Environments
  • Robot Vacuums
  • Order Fulfillment
  • Factories

Prerequisites

2021-06-10-18.15.05

You Will Need

You will need the following components (#ad).

Disclosure (#ad): As an Amazon Associate I earn from qualifying purchases.

Set Up the Hardware

First, let’s set up the hardware. Remember you need to solder the pins to the BNO055.

Make the following connections between the BNO055 and the NVIDIA Jetson Nano:

  • Connect BNO055 Vin to pin 17 (3.3V) of the Jetson Nano.
  • Connect BNO055 GND to pin 25 (GND) of the Jetson Nano.
  • Connect BNO055 SDA to pin 3 (SDA) of the Jetson Nano.
  • Connect BNO055 SCL to pin 5 (SCL) of the Jetson Nano.
1-pin-diagram-nvidia-jetson-nano

Set Up the Communication Protocol

Our BNO055 will use the I2C serial communication protocol. What this means is that data will be transferred from the IMU to the Jetson Nano one bit at a time.

Turn on your Jetson Nano.

Open a terminal window.

Type the following command to verify that you can see the BNO055.

sudo i2cdetect -r -y 1

Check that the bus of the BNO055 has an address of 0x28.

2021-05-24-13.13.22

Install and Build the BNO055 ROS Package

Let’s get all the software set up.

Turn on your Jetson Nano.

Open a new terminal window.

Install the libi2c-dev library.

sudo apt-get update
sudo apt-get install libi2c-dev

Install the BNO055 ROS package.

cd ~/catkin_ws/src

Remove any existing package named ‘ros_imu_bno055’.

git clone https://github.com/dheera/ros-imu-bno055.git

Build the package.

cd ~/catkin_ws/
catkin_make --only-pkg-with-deps imu_bno055

Open a new terminal window, and see if our package depends on other packages, type these commands. Ignore any error messages you see in the terminal:

rosdep update
rosdep check <package_name>

We will do:

rosdep check imu_bno055

You should see a message that says “All system dependencies have been satisfied.”

Reboot your computer.

sudo reboot

View the IMU Data

Install the ROS IMU plugin so we can visualize the IMU data on rviz.

sudo apt-get install ros-melodic-rviz-imu-plugin

Open a terminal window, and type:

roslaunch imu_bno055 imu.launch

Open a terminal window and see the active topics.

rostopic list
active_topics

Let’s see the imu data on the topic named /imu/data.

rostopic echo /imu/data
rostopic_echo_imu_messages

If rviz has not already launched, open a new terminal and launch rviz.

rviz

Change the fixed frame to imu.

Click the Add button in the bottom left.

Click imu under rviz_imu_plugin

Click OK.

Change the topic of the imu to /imu/data.

Move your BNO055 around, and you will see the axes move. The red line is the x-axis, the green line is the y-axis, and the blue line is the z-axis.

rviz_axes

Press CTRL + C in all terminal windows to close everything down.

Update Your Launch File (Optional)

I have a launch file I created in this post.

I will add the following lines to my launch file (which is in XML format).

  <!-- IMU Data Publisher Using the BNO055 IMU Sensor -->
  <!-- Publish: /imu/data -->
  <node ns="imu" name="imu_node" pkg="imu_bno055" type="bno055_i2c_node" respawn="true" respawn_delay="2">
    <param name="device" type="string" value="/dev/i2c-1"/>
    <param name="address" type="int" value="40"/> <!-- 0x28 == 40 is the default for BNO055 -->
    <param name="frame_id" type="string" value="imu"/>
  </node>

That’s it. Keep building!