ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

What is the second case of ros::ok() return false?

asked 2011-09-23 20:19:53 -0500

sam gravatar image

In topic programmoing tutorials

Here says that

ros::ok() will return false if:

1. a SIGINT is received (Ctrl-C)
2. we have been kicked off the network by another node with the same name
3. ros::shutdown() has been called by another part of the application.

I understand 1 and 3,but what is the second situation?

How to kicked off the network by another node with the same name?

Thank you~

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
3

answered 2011-09-23 22:20:46 -0500

sam gravatar image

I figure out 'we have been kicked off the network by another node with the same name' by tring two sample code:

node_test.cpp:

 #include "ros/ros.h"

 int main(int argc, char **argv)
 {
    //ROS的初始化
    ros::init(argc, argv, "basic_node");
    ROS_INFO("%s","Hello 1!");
    //讓ROS進入無窮迴圈,但能進行事件處理
    ros::spin();
    return 0;
 }

node_test2.cpp

 #include "ros/ros.h"

 int main(int argc, char **argv)
 {
    //ROS的初始化
    ros::init(argc, argv, "basic_node");
    ROS_INFO("%s","Hello 2!");
    //讓ROS進入無窮迴圈,但能進行事件處理
    ros::spin();
    return 0;
 }

When I run the first,and second.

The first will crash on following messages:

 sam@/home/sam/code/ros/node/basic_node$ ./bin/basicNode
 [ INFO] [1316859193.830963744]: Hello 1!
 [ WARN] [1316859279.686228002]: Shutdown request received.
 [ WARN] [1316859279.686357767]: Reason given for shutdown: [new node      registered with same name]

 sam@/home/sam/code/ros/node/basic_node$

Thank you~

edit flag offensive delete link more

Comments

Right. This provides a way to restart a node if it seems to have stopped working.
joq gravatar image joq  ( 2011-09-24 03:07:58 -0500 )edit

Question Tools

Stats

Asked: 2011-09-23 20:19:53 -0500

Seen: 7,734 times

Last updated: Sep 23 '11