NodeHandle and ROS_DEBUG [closed]
Dear ROS members.
I had a trouble to use ROS_DEBUG macro after destructing a private node handle in a local scope.
As the following codes, when the "priv_nh1" node handle in the 1st local scope was destructed, ROS_DEBUG macro will never say anything at all. it's occurred in ROS::Groovy and ROS::Indigo.
In other words, the 1st and 2nd local scopes are meaning multi-threads or functions.
Is there bettwer way to use private node handles in each scopes?
Thank you.
#include <ros/ros.h>
#include <ros/console.h>
int main( int argc, char** argv )
{
ros::init( argc, argv, "test" );
ROS_INFO("hello");
{ // <1st local scope>
ROS_INFO("local scope : enter");
ros::NodeHandle priv_nh1("~");
/* ... do something ... */
ROS_INFO("local scope : exit");
} // </1st local scope>
// I can not get following ROS_DEBUG messages ...
ROS_INFO("next");
{ // <2nd local scope>
ROS_INFO("local scope : enter");
ros::NodeHandle priv_nh2("~");
int value = 0;
priv_nh2.param( "value", value, 0 );
ROS_INFO("value %d", value);
ROS_INFO("local scope : exit");
} // </2nd local scope>
ROS_INFO("bye");
ros::spin();
return 0;
}
Does ROS_DEBUG work if you use it elsewhere in your program?
Thank you, ahendrix. ROS_DEBUG can work anywhere, if I do not use such a private(disposable) node handle. When I remove such a private node handle and get parameters by ros::param::get directly, there is no problem occurred.
I'm seeing this with all of the rosconsle output macros, including ROS_INFO, not just ROS_DEBUG.