
Building and running nodelets
We will make the entry for the source code files in CMakeLists.txt, so that we can build a nodelet package:
## Declare a cpp library add_library(nodelet_hello_ros src/hello_ros.cpp ) ## Specify libraries to link a library or executable target against target_link_libraries(nodelet_hello_ros ${catkin_LIBRARIES} )
Consequently, we could build the package using catkin_make and, if the build is successful, it would generate a shared object libnodelet_hello_world.so file, which is indeed a plugin.
The following commands can be used to start the nodelet manager:
$ roscore $ rosrun nodelet nodelet manager __name:=nodelet_manager
If nodelet manager runs successfully, we will see a message as shown in the following screenshot:

The nodelet manager
After launching nodelet manager, we have to start nodelet by using the following command:
$ rosrun nodelet nodelet load nodelet_hello_world/Hello nodelet_manager __name:=Hello1
Upon execution of the preceding command, nodelet contacts nodelet manager to spawn an instance of the nodelet_hello_ros/Hello nodelet with a name of Hello1. If the nodelet is instantiated successfully, we will get a message as shown here:

The running nodelet
We can look at the list of topics generated after running this nodelet, such as that shown in the following screenshot:

Nodelet topics
We can also verify the workings of certain nodelets by publishing a message string to the /Hello1/ros_in topic and looking for whether the same message is received at Hello1/ros_out:

Working nodelets
Here, you will notice that a single instance of the Hello() class is created as a node. Moreover, we can also create multiple instances of the Hello() class with different node names inside this nodelet.