Node is not shutting down on ros::ok()
Hi all,
Mine is just a noob question about the expected behaviour of ros::ok() function. I've written this very simple piece of code :
int main(int argc, char **argv)
{
ros::init(argc, argv, "bot");
ros::NodeHandle nh("~");
ros::Publisher odo_pub = nh.advertise<sensor_msgs::JointState>("odometry", 1000);
ros::Subscriber cmd_sub = nh.subscribe(sub.c_str(), 1000, chatterCallback);
// Define the odometry msg
sensor_msgs::JointState msg;
msg.header.frame_id="bot";
msg.position.resize(4);
msg.velocity.resize(4);
msg.effort.resize(4);
while( ros::ok())
{
ROS_INFO("In loop %d",ros::ok());
msg.header.stamp=ros::Time::now();
odo_pub.publish(msg);
ros::spinOnce();
}
ROS_INFO("Exit");
return 0;
}
Should the node exit when I Ctrl-c the ros framework (by killing the terminal on which roscore has been started)? Thanks!
P.S. I'm running ROS hydro on Ubuntu 12.04.2 LTS