March 2018
Intermediate to advanced
1396 pages
42h 14m
English
Following is a basic structure ROS Arduino node. We can see the function of each line of code:
#include <ros.h>
ros::NodeHandle nh;
void setup()
{
nh.initNode();
}
void loop()
{
nh.spinOnce();
}
Creating of NodeHandle in Arduino is done using the following line of code:
ros::NodeHandle nh;
Note that Nodehandle should be declared before the setup() function, which will give a global scope to the NodeHandle instance called nh. The initialization of this node is done inside the setup() function.
nh.initNode();
The Arduino setup() function will execute only once when the device starts, and note that we can only create one node from a serial device.
Inside the loop() function, we have to use the following ...