-1

System Configuration: OS - Ubuntu 18.04 (Bionic Beaver) ROS - ROS2 Bouncy Language - Python

Problem - So I have a program that should only run and return values whenever a request is sent to the program. How can I create such a package using ROS2 py

I tried modifying the demo_node_cpp but it didn't work out the way intended.

Amrit Das
  • 474
  • 1
  • 6
  • 13

1 Answers1

0

Instead of using publish-subscribe type method, you may use the service-client concept in ROS if you need to run the code when requested.

Although publisher/subscriber nodes are very flexible, they are generally utilized when dealing with data streams. A service node would solve your problem and it is fairly simple to write a service/client node using rospy. You can start with this tutorial. The tutorial gives an example for writing service and client nodes in Python.

  • Please add some information/description/context about the linked resource – SanSolo Dec 24 '18 at 12:41
  • Thanks for the help, but I need help for ROS2, I already did this with roscpp. If you can help me with ROS2 that would be great – Amrit Das Dec 24 '18 at 12:58
  • I'm not experienced in ROS2. You might have seen this but, I found ROS2 [versions](https://github.com/ros2/examples/tree/master/rclpy/services) of the client and the service nodes. Hope it helps, cheers. – fatihksubasi Dec 24 '18 at 13:21