Overview
Coursera Flash Sale
40% Off Coursera Plus for 3 Months!
Grab it
Learn to implement ROS 2 services using C++ for synchronous communication between nodes in this comprehensive tutorial. Explore the request/response model that enables direct interaction between nodes, ideal for sending commands or querying data. Build both a service server and client using C++ and the rclcpp library, starting with creating a server node that listens for incoming requests using the example_interfaces/srv/AddTwoInts interface and responds with calculated results. Master the use of create_service() and bound callback functions within custom node classes. Develop the client side implementation that periodically sends random requests using async_send_request() and handles responses through shared futures. Understand the critical role of shared_future in ROS 2 asynchronous callbacks and how it integrates into the request lifecycle. Discover best practices for managing node timing, error handling, and clean shutdown procedures. Test your implementations using built-in ROS 2 tools including ros2 service call and the rqt GUI for visual introspection. Configure CMakeLists.txt properly to build and install nodes correctly while avoiding common C++ development pitfalls in ROS 2. Work within a Docker container environment for clean and portable ROS 2 development. Access accompanying written guides and GitHub repository with Docker images and example code to support your learning journey.
Syllabus
0:00 Intro
0:43 Writing a Service in C++
5:50 Testing the Service
8:43 Writing a Client in C++
14:32 Testing the Client
16:08 Conclusion
Taught by
Digi-Key