Skip to Content
ROS Programming: Building Powerful Robots
book

ROS Programming: Building Powerful Robots

by Anil Mahtani, Luis Sanchez, Enrique Fernandez, Aaron Martinez, Lentin Joseph
March 2018
Intermediate to advanced content levelIntermediate to advanced
1396 pages
42h 14m
English
Packt Publishing
Content preview from ROS Programming: Building Powerful Robots

Creating an ROS node to use data from the 9DoF sensor in our robot

Now that we have our low-cost IMU working in ROS, we are going to create a new node that subscribes to the imu/data topics from the Razor IMU. For example, we can see in our robot model the pitch, roll, and heading depending on the IMU data. So, let's create a new node based on our c8_odom.cpp. We will name this file c8_odom_with_imu.cpp.

Now, we are going to make some modifications. First, we will include sensor_msgs/Imu to be able to subscribe to IMU topics:

#include <sensor_msgs/Imu.h&gt; 

Also, we need a global variable to store IMU data:

sensor_msgs::Imu imu; 

Then, we are going to create a callback function to obtain IMU data:

void imuCallback(const sensor_msgs::Imu ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Programming Robots with ROS

Programming Robots with ROS

Morgan Quigley, Brian Gerkey, William D. Smart
Machine Learning Design Patterns

Machine Learning Design Patterns

Valliappa Lakshmanan, Sara Robinson, Michael Munn

Publisher Resources

ISBN: 9781788627436Supplemental Content