[ROS2] Service ์ค์ต(Call-And-Response)
๐ค Service
์๋ ๋งํฌ์ demo_nodes_cpp ํจํค์ง์ ๋ด์ฉ๋ค์ ์ฐธ๊ณ ํ๊ธธ ๋ฐ๋๋๋ค.
GitHub - ros2/demos
Contribute to ros2/demos development by creating an account on GitHub.
github.com
์๋์ ๊ฐ์ ์ฝ๋๋ฅผ ํตํด add_two_ints_server ๋ ธ๋๋ฅผ ์์ฑํฉ๋๋ค.
service ๊ด๋ จ commands๋ฅผ ํตํด ํ์ฌ ์คํ์ค์ธ ROS2 ๋ ธ๋์ ๋ฆฌ์คํธ๋ฅผ ์ถ๋ ฅํ๊ณ ์ฌ์ฉ๊ฐ๋ฅํ ๋ชจ๋ ์๋น์ค์ ๋ฆฌ์คํธ๋ฅผ ์ถ๋ ฅํฉ๋๋ค.
์ดํ ์ง์ ๋ ์๋น์ค์ ํ์ ์ ์กฐํํฉ๋๋ค.
/add_two_ints ์๋น์ค์ ํ์ ์ example_interfaces/srv/AddTwoInts ์ด๋ฉฐ ํด๋น ์๋น์ค๋ ๋ ๊ฐ์ int64 ํ์ ์ ์ ๋ ฅ ('a', 'b')๋ฅผ ๋ฐ์๋ค์ด๊ณ int64 ํ์ ์ ์ถ๋ ฅ 'sum'์ ๋ฐํํ๋ค๋ ๊ฒ์ ์ ์ ์์ต๋๋ค.
์ฆ, ๋ ์ ์๋ฅผ ์ ๋ ฅ์ผ๋ก ๋ฐ์ ๊ทธ ํฉ์ ๋ฐํํ๋ ์๋น์ค์ ๋๋ค.