At the begining of your code, you need to initialize the node in order for it to be registered in the ROS network.
<argc> (int)
The number of terminal inputs.
<argv> (char**)
The list of terminal input. Remapping arguments are processed here.
<node_name> (std::string)
Name of the node.
<options> (uint32_t)
Additional operations for initialisation.
ros::init_options::NoSigninHandler
This prevents the installation of the SIGNINT handler which makes sure the node gets shutdown properly.
ros::init_options::AnonymousName
This adds a randomly generated number at the end of the node name for anonymity.
ros::init_options::NoRosout
Prevents broadcast to the rosconsole output on the /rosout topic.
ros::NodeHandle <handle_name>(<namespace>)
After initialising the node, create a node handler which will manage an internal reference count for starting and shutting down a node.
<handle_name>
The object name of the handler.
<namespace>
Specifies the namespace the handler is located in, this can be a literal string or a node handler followed by a string.
E.g.
ros::NodeHandle nh1("handle1"); //This creates a handle at <node_name>/handle1 ros::NodeHandle nh2(nh1, "handle2"); //This creates a handle at <node_name>/handle1/handle2