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

Heartbeat-bond: being aware of aliveness of other nodes

asked 2018-02-25 17:39:29 -0500

fracchie gravatar image


Situation: running ROS Kinetic on a Ubuntu 16.04 x86 I am working on a project, in which i would create a dynamic network in which a central node can manage all the operations needed to put the others in contact, while having an up-to-date list of the online nodes. It means, since every "user" node, when launched, must call a service of the central one, i want this to keep track of the online users' nodes, adding its references in a structure, and then deleting them once they are out.

Problem: I need something like an heartbeat, so that a node can feel when another one is out.

Attempts: I had a look for it, but i haven't found a "direct" way to do so, like a quick way to see if the topic you were subscribing stopped working. It would be of course the best way: do you know something like that?

-bond: I found the bond package, that seems to do what i want, but i had problems in building it up. Just adding the 2 lines in both the nodes i want to be linked

bond::Bond bond("heartbeat", id); // id is a std::string as required

i receive the following error

undefined reference to `bond::Bond::Bond(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, boost::function<void ()>, boost::function<void ()>)
utm_node.cpp:(.text+0x6d0): undefined reference to `bond::Bond::start()'
utm_node.cpp:(.text+0x6ef): undefined reference to `bond::Bond::~Bond()'
utm_node.cpp:(.text+0x864): undefined reference to `bond::Bond::~Bond()'

Now: the needed page to understand everything would be that, i am trying but i still have to practice swimming in that sea. I have some questione regarding the bond itself:

the bond is defined with a topic and an id, that should coincide with the one of the other node. Is this topic unique (meaning: can i create a single heartbeat topic receiving many heatbeat with different IDs) or i should create a topic for every bond? and if so: should i declare a bond::Bond for every heartbeat? and if so: how can i manage a dynamic network (i am not supposed to know a priori how many nodes will connect and their name) with such a static mechanism?

and, at this point: wishing to create a bond between 2 nodes, and a callback when it breaks, i have doubt on how to do it. looking at the documentation, we have:

bond::Bond bond(const std::string &     topic, 
                const std::string &     id,
                boost::function< void(void)> on_broken boost::function<void(void)>(),
                 boost::function< void(void)>   on_formed = boost::function<void(void)>() 

How should i declare the cb to be called on_broken? maybe...

    bond::Bond bond("example_bond_topic", id, on_broken = callback);

or, thinking on how i build up a subscriber and its callback...

        bond::Bond bond("example_bond_topic", id, &callback);

then creating the cb routine as (don't ... (more)

edit retag flag offensive close merge delete


I was very relieved to have found this question, as it is exactly the question I'm asking. However, there is no answer! Has the OP found a solution, or can some one help both fracchie and I resolve this?

Tav_PG gravatar image Tav_PG  ( 2019-07-18 18:16:10 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2020-04-21 23:12:47 -0500

Kolyamnc gravatar image

To fix your "undefined reference" compile errors, add "bondcpp" in your find_package list in CMakeLists.txt. eg:

find_package(catkin REQUIRED COMPONENTS
edit flag offensive delete link more

Question Tools



Asked: 2018-02-25 17:39:29 -0500

Seen: 879 times

Last updated: Apr 21 '20