[rclpy] node having many services is not responding [closed]
This question has been cross-posted as I feel that it is more suited to ROS Answers. Please see here. My apologies. I am sharing a reference to this post on GitHub as well. Sorry for the trouble.
One of my nodes has many services, publishers, subscribers, and action servers. To be precise, there are 17 service servers, 1 publisher, 1 subscriber, and 1 action sever. This node is not responding. However, the node works when I remove any one item: publisher, subscriber, service server, or action server.
Required Info
- Operating System:
- Ubuntu 20.04.4 LTS
- Installation type:
- binaries
- Version or commit hash:
- ROS Foxy
- DDS implementation:
- Default
- Client library:
- rclpy
Steps to reproduce issue
publisher_member_function.py:
from action_tutorials_interfaces.action import Fibonacci
import rclpy
from rclpy.action import ActionServer
from rclpy.node import Node
from std_msgs.msg import String
from std_srvs.srv import SetBool, Trigger
class MinimalPublisher(Node):
def __init__(self):
super().__init__('minimal_publisher')
self.pub = self.create_publisher(String, 'pub', 10)
self.sub = self.create_subscription(String, 'sub', self.listener_cb, 10)
self.srv_1 = self.create_service(SetBool, 'srv_1', self.set_bool_cb)
self.srv_2 = self.create_service(SetBool, 'srv_2', self.set_bool_cb)
self.srv_3 = self.create_service(SetBool, 'srv_3', self.set_bool_cb)
self.srv_4 = self.create_service(SetBool, 'srv_4', self.set_bool_cb)
self.srv_5 = self.create_service(SetBool, 'srv_5', self.set_bool_cb)
self.srv_6 = self.create_service(SetBool, 'srv_6', self.set_bool_cb)
self.srv_7 = self.create_service(SetBool, 'srv_7', self.set_bool_cb)
self.srv_8 = self.create_service(SetBool, 'srv_8', self.set_bool_cb)
self.srv_9 = self.create_service(SetBool, 'srv_9', self.set_bool_cb)
self.srv_10 = self.create_service(Trigger, 'srv_10', self.trigger_cb)
self.srv_11 = self.create_service(Trigger, 'srv_11', self.trigger_cb)
self.srv_12 = self.create_service(Trigger, 'srv_12', self.trigger_cb)
self.srv_13 = self.create_service(Trigger, 'srv_13', self.trigger_cb)
self.srv_14 = self.create_service(Trigger, 'srv_14', self.trigger_cb)
self.srv_15 = self.create_service(Trigger, 'srv_15', self.trigger_cb)
self.srv_16 = self.create_service(Trigger, 'srv_16', self.trigger_cb)
self.srv_17 = self.create_service(Trigger, 'srv_17', self.trigger_cb)
self.ac_srv = ActionServer(self, Fibonacci, 'fib', self.execute_cb)
self.timer = self.create_timer(1, self.timer_cb)
def listener_cb(self, msg):
self.get_logger().info(msg.data)
def execute_cb(self, goal_handle):
fb = Fibonacci.Feedback()
fb.partial_sequence = [0, 1]
for i in range(1, goal_handle.request.order):
fb.partial_sequence.append(fb.partial_sequence[i] + fb.partial_sequence[i - 1])
goal_handle.publish_feedback(fb)
goal_handle.succeed()
return Fibonacci.Result(sequence=fb.partial_sequence)
def timer_cb(self):
msg = String(data='Hello from Publisher')
self.pub.publish(msg)
def set_bool_cb(self, req, res):
res.message = 'Hello from SetBool Service'
return res
def trigger_cb(self, req, res):
res.message = 'Hello from Trigger Service'
return res
def main(args=None):
rclpy.init(args=args)
minimal_publisher = MinimalPublisher()
rclpy.spin(minimal_publisher)
rclpy.shutdown()
if __name__ == '__main__':
main()
Actual behavior
Upon calling services or echoing on topic, the node is not saying anything, as shown below:
ravi@dell:~/ros_ws$ ros2 service call /srv_1 std_srvs/srv/SetBool "{data: True}"
waiting for service to become available...
^C
ravi@dell:~/ros_ws$ ros2 topic echo /pub
^Cravi@dell:~/ros_ws$
Node Info
$ ros2 node info /minimal_publisher
/minimal_publisher
Subscribers:
/sub: std_msgs/msg/String
Publishers:
/parameter_events: rcl_interfaces/msg/ParameterEvent
/pub: std_msgs/msg/String
/rosout: rcl_interfaces/msg/Log ...
I'm closing this as your issue on GH has had quite a few comments posted on it already.
Let's not distribute diagnostic efforts.
@gvdhoorn: Yeah. For future readers, please check the following link: https://github.com/ros2/ros2/issues/1301