.. _Client ROS: ROS Service Client ====================== The Follow Along Examples: - :ref:`Command ROS` - :ref:`Server ROS` - :ref:`Client ROS` <- you are here .. raw:: html

Follow along: ROS Topic Subscriber Example

The program launching process along with parameter settings are all simplified and set up on the Jupyter Notebook Environment.
(The Jetson Board used for these examples are => Jetson Nano)
.. raw:: html
Open the following jupyter notebook: - 02_01_ros_service_server.ipynb - To run the cells within the notebook use Ctrl + Enter .. thumbnail:: /_images/robot_control_move/comm10.webp .. thumbnail:: /_images/robot_control_move/comm11.webp - Import print_function from `__future__` module for Python3 compatibility - Import AddTwoInts, AddTwoIntsResponse from rospy_tutorials.srv module - Import rospy modules .. code-block:: python from __future__ import print_function from rospy_tutorials.srv import AddTwoInts,AddTwoIntsResponse import rospy - Create handle_add_two_ints() function - Output req.a, req.b, req.a + req.b - Return instances of req.a + req.b in AddTwoIntsResponse .. code-block:: python def handle_add_two_ints(req): print("Returning [%s + %s = %s]"%(req.a, req.b, (req.a + req.b))) return AddTwoIntsResponse(req.a + req.b) - Create `add_two_ints_server()` function - Create add_two_ints_server Node - Create add_two_ints Service .. code-block:: python def add_two_ints_server(): rospy.init_node('add_two_ints_server') s = rospy.Service('add_two_ints', AddTwoInts, handle_add_two_ints) print("Ready to add two ints.") rospy.spin() - Execute the add_two_ints_server() function .. code-block:: python add_two_ints_server()