Skip to Content
Mastering ROS for Robotics Programming - Second Edition
book

Mastering ROS for Robotics Programming - Second Edition

by Lentin Joseph, Jonathan Cacace
February 2018
Beginner
580 pages
13h 20m
English
Packt Publishing
Content preview from Mastering ROS for Robotics Programming - Second Edition

Step 3 - Explanation of hello_world.cpp

Here is the explanation of the code:

#include <pluginlib/class_list_macros.h> 
#include <nodelet/nodelet.h> 
#include <ros/ros.h> 
#include <std_msgs/String.h> 
#include <stdio.h> 

These are the header files of this code. We should include class_list_macro.h and nodelet.h to access the pluginlib APIs and nodelets APIs:

namespace nodelet_hello_world 
{ 
  class Hello : public nodelet::Nodelet 
  { 

Here, we create a nodelet class called Hello, which inherits a standard nodelet base class. All nodelet classes should inherit from the nodelet base class and be dynamically loadable using pluginlib. Here, the Hello class is going to be used for dynamic loading:

 virtual void onInit() { ros::NodeHandle& private_nh = ...
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

Mastering ROS for Robotics Programming - Third Edition

Mastering ROS for Robotics Programming - Third Edition

Lentin Joseph, Jonathan Cacace
Effective Robotics Programming with ROS - Third Edition

Effective Robotics Programming with ROS - Third Edition

Luis Sanchez, Enrique Fernandez Perdomo, Anil Mahtani

Publisher Resources

ISBN: 9781788478953Supplemental Content