Simple project created to practice creating and using custom services in ROS 2 (Humble), with Python client and server nodes. Uses a custom .srv interface to perform basic math operations: addition, subtraction, multiplication, and division.
- calc_interfaces/: package that defines the custom service interface
DoMath.srv. - calc_service/: package containing client and server nodes that use this interface.
-
Clone the repository and go to the workspace folder:
cd ros2_ws -
Build the workspace:
colcon build source install/setup.bash -
In terminal 1, run the server node:
ros2 run calc_service service
-
In terminal 2, run the client node with parameters:
ros2 run calc_service client <num1> <num2> <operation>
Where:
<num1>and<num2>are integers.<operation>can be:soma,subtracao,multiplicacao, ordivisao.
ros2 run calc_service client 10 5 somaExpected output:
Result: 15
Message: a soma de 10 + 5 = 15
- ROS 2 Humble
- Python 3
rclpy- Custom
.srvservice interface
Apache License 2.0 — see LICENSE file for details.
Project made for study and practice, ideal for beginners learning custom services in ROS 2.