ROS2: subscription/service/timer callbacks not being called
TL;DR:
rclcpp::Node
-inheriting class registers some subscribers, services and a timer in its constructor; not a single callback is being called (apparently).
Details
I've recently refactored a working (4 nodes, C++) but non-composable code [1] (global function callbacks etc) into rclcpp::Node
-inheriting classes, so that they can be run together.
The code structure is just like in demos/examples - nodes pass their names to super constructors, initialize whathever they're responsible for (e.g. sensors) and register subscriptions, services and timers. For running them separately I've created simple entry points just like in the examples - auto node = std::make_shared<NodeClass>(args...)
and then rclcpp::spin(node)
.
Now, while one of the nodes [2] that only publishes data works as intended, the other one [3] that listens for data/requests does not (note that both register a timer!). As you can see in the code, I've added cout
s in the beggining of every callback function.
The expected behaviour would be some outputs from the node's constructor and at least one output from the timer callback (Loop!
), however, the latter does not happen. There's no output from any subscription/service callback either (they're called from a separate control app/node [4]).
I've tried disabling most callbacks to reduce the case to the simplest one, but it didn't solve the issue.
More info
C++ nodes are being run on a BeagleBone Green Wireless, Python node is being run on a x86_64 laptop, both connected to the same WiFi.
In both cases I'm using ROS2 Beta 3 compiled from source.
Entry points
They're located in main.cpp
files of their respective packages, right next to the Node class files.
- Working node [5] (
rclcpp::shutdown()
was disabled for testing only) - Not working node [6]
Refs
- https://github.com/GroupOfRobots/RysR...
- https://github.com/GroupOfRobots/RysR...
- https://github.com/GroupOfRobots/RysR...
- https://github.com/GroupOfRobots/RysR...
- https://github.com/GroupOfRobots/RysR...
- https://github.com/GroupOfRobots/RysR...
Edit1: added 'Entry points' section and links
It sounds like you're not spinning the nodes, do you have a link to the main function for one of your executables or are you using our composition demo perhaps?
They're right next to their respective
*Node
class files - I've updated the question to include links to them.