The Arduino-IMU interfacing code

Let's discuss the code from the beginning. The following Arduino headers help us read IMU values using the I2C protocol. The MPU6050_6Axis_MotionApps20.h header has functions to enable DMP and retrieve values from it.

    #include "Wire.h" 
    #include "I2Cdev.h" 
    #include "MPU6050_6Axis_MotionApps20.h" 

The following line of code will create an MPU6050 handle, which can be used for the MPU-9250. We can use this object to initialize and retrieve values from the IMU.

    MPU6050 mpu; 

As you know, we have to include ros.h to access ROS serial client APIs. We are also including Vector3.h, which has the definition of the Vector3 ROS message. This message can carry three values of orientation. The tf/transform_broadcaster.h ...

Get ROS Programming: Building Powerful Robots now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.