Summary | ROS2 II |
Topic, Service, Action์ด๋ž€?

Table of Contents

[ ROS2 ] ROS ๊ธฐ์ดˆ II (Topic, Service, Action)

์ด์ „ ํฌ์ŠคํŠธ์˜ ๋‚ด์šฉ์—์„œ๋Š” Node์™€ Package์— ๋Œ€ํ•ด ๋‹ค๋ฃจ์—ˆ๋‹ค. Node์™€ Package์ด ๋ฌด์—‡์ธ์ง€ ๊ถ๊ธˆํ•˜๋‹ค๋ฉด ํ•ด๋‹น ํฌ์ŠคํŠธ๋ฅผ ๋ฐฉ๋ฌธํ•˜๊ธฐ ๋ฐ”๋ž€๋‹ค. ๋ณธ ํฌ์ŠคํŠธ์—์„œ๋Š” ๋ฉ”์‹œ์ง€ ํ†ต์‹  ๋ฐฉ์‹ Topic, Service, Action์— ๋Œ€ํ•ด ์•Œ์•„๋ณด์ž.


1๏ธโƒฃ Topic

ROS2 Topic

ROS2์—์„œ๋Š” ๋ชจ๋“ˆ์‹ ๋…ธ๋“œ๋ฅผ ๋งŽ์ด ๋ถ„ํ• ํ•จ์œผ๋กœ์จ ๋ณต์žกํ•œ ์‹œ์Šคํ…œ์„ ๋งŒ๋“ค ์ˆ˜ ์žˆ๋‹ค. ์ด๋•Œ Topic์ด Node ์‚ฌ์ด์— ๋ฐ์ดํ„ฐ Message๊ฐ€ ์˜ค๊ฐ€๋Š” ๊ธธ Bus ์—ญํ• ์„ ํ•œ๋‹ค.

์ •๋ฆฌํ•˜์ž๋ฉด, Topic์€ ๋น„๋™๊ธฐ์‹ ๋‹จ๋ฐฉํ–ฅ ๋ฉ”์‹œ์ง€ ์†ก์ˆ˜์‹  ๋ฐฉ์‹์œผ๋กœ ๋™์ž‘ํ•œ๋‹ค. ์ด๋Š” msg ์ธํ„ฐํŽ˜์ด์Šค ํ˜•ํƒœ์˜ ๋ฉ”์‹œ์ง€๋ฅผ ์†ก์‹ ํ•˜๋Š” publisher์™€ ๋ฉ”์‹œ์ง€๋ฅผ ์ˆ˜์‹ ํ•˜๋Š” subscriber๋กœ ์ด๋ฃจ์–ด์ ธ ์žˆ๋‹ค. ๊ณต์‹๋ฌธ์„œ์— ๊ฒŒ์‹œ๋œ ๋‹ค์Œ์˜ gif๋ฅผ ํ†ตํ•ด Topic์ด ์–ด๋–ป๊ฒŒ ๋™์ž‘ํ•˜๋Š”์ง€ ์•Œ์•„๋ณด์ž.

Understanding topics

Topic์€ ์—ฌ๋Ÿฌ Node์—์„œ ๋ฐ์ดํ„ฐ๋ฅผ ๋ฐ›์„ ์ˆ˜ ์žˆ๊ณ , ์—ฌ๋Ÿฌ Node์—๊ฒŒ ๋ฐ์ดํ„ฐ ์ „์†ก๋„ ๊ฐ€๋Šฅํ•˜๋‹ค.

์ด๋Ÿฌํ•œ ์  ๋•Œ๋ฌธ์ผ๊นŒ? ROS ํ”„๋กœ๊ทธ๋ž˜๋ฐ์˜ 70% ์ด์ƒ์ด Topic์œผ๋กœ ์ด๋ฃจ์–ด์ ธ ์žˆ๋‹ค๊ณ  ํ•œ๋‹ค. ๊ทธ๋งŒํผ ๋ฉ”์‹œ์ง€ ํ†ต์‹  ๋ฐฉ์‹ ์ค‘ ๊ฐ€์žฅ ๊ธฐ๋ณธ์ ์ด๊ณ  ๊ฐ€์žฅ ๋„๋ฆฌ ์‚ฌ์šฉ๋œ๋‹ค. ๋˜ํ•œ, ๋น„๋™๊ธฐ์„ฑ์ด๋ฉฐ ์—ฐ์†์„ฑ์ด๋ผ๋Š” ์„ฑ์งˆ์„ ๊ฐ€์ง€๊ณ  ์žˆ์–ด ์„ผ์„œ ๊ฐ’ ์ „์†ก ๋ฐ ํ•ญ์‹œ ์ •๋ณด๋ฅผ ์ฃผ๊ณ ๋ฐ›์•„์•ผ ํ•˜๋Š” ๋ถ€๋ถ„์—์„œ ์ฃผ๋กœ ์‚ฌ์šฉ๋œ๋‹ค.

Topic์„ ๋งŒ๋“ค ์ˆ˜ ์žˆ๋Š” ๋‹ค๋ฅธ ๋ช…๋ น์–ด๋“ค์€ ๋‹ค์Œ ๊ธฐํšŒ์— ์ •๋ฆฌํ•˜๊ฒ ๋‹ค.


2๏ธโƒฃ Service

ROS2 Service

Service๋Š” ๋™๊ธฐ์‹ ์–‘๋ฐฉํ–ฅ ๋ฉ”์‹œ์ง€ ์†ก์ˆ˜์‹  ๋ฐฉ์‹์œผ๋กœ ๋™์ž‘ํ•œ๋‹ค. ๋ชจํ„ฐ on/off, ์ˆœ๊ฐ„์  ํšŒํ”ผ ๊ธฐ๋™, ํŒŒ๋ผ๋ฏธํ„ฐ service ๋“ฑ ๋‹จ๋ฐœ์ ์ด๊ณ  ๋น ๋ฅธ ํ†ต์‹ ์ด ์š”๊ตฌ๋  ๋•Œ ๋งŽ์ด ์‚ฌ์šฉ๋˜๋Š” ๋ฉ”์‹œ์ง€ ํ†ต์‹  ๊ธฐ๋ฒ•์ด๋‹ค.

์„œ๋น„์Šค๋ฅผ ์š”์ฒญํ•˜๋Š” Service Client์™€ ์š”์ฒญ๋ฐ›์€ ์„œ๋น„์Šค๋ฅผ ์ˆ˜ํ–‰ํ•œ ํ›„ ์‘๋‹ตํ•˜๋Š” Service Server๋กœ ์ด๋ฃจ์–ด์ ธ ์žˆ๋‹ค.

Understanding services

์œ„์˜ gif๋ฅผ ๋ณด๋ฉด ์•Œ ์ˆ˜ ์žˆ๋“ฏ์ด, ํ•˜๋‚˜์˜ Service Server์—๋Š” ์—ฌ๋Ÿฌ Client Node๊ฐ€ requestํ•  ์ˆ˜ ์žˆ์ง€๋งŒ Server๋Š” ๋™์‹œ์— ์—ฌ๋Ÿฌ request๋ฅผ ์ฒ˜๋ฆฌํ•˜์ง€๋Š” ๋ชปํ•œ๋‹ค๋Š” ๊ฒƒ์„ ๊ธฐ์–ตํ•ด์•ผ ํ•œ๋‹ค.


๐Ÿ“Œ Topic๊ณผ Service์˜ ์ฐจ์ด์ 

Topic๊ณผ Service๋Š” ์–ธ๋œป ๋ณด๋ฉด ๋น„์Šทํ•ด ๋ณด์ด์ง€๋งŒ ๋‹ค๋ฅด๋‹ค.

Topic์€ Publishํ•˜๋ฉด ์—ฌ๋Ÿฌ Node๊ฐ€ Subscribe ๊ฐ€๋Šฅํ•œ ๋ฐ˜๋ฉด, Service๋Š” request๊ฐ€ ์˜จ ๋Œ€์ƒ์—๋งŒ response๋ฅผ ์ฃผ๋Š” 1:1์˜ ํ†ต์‹  ๊ธฐ๋ฒ•์„ ๊ฐ€์ง€๊ณ  ์žˆ๋‹ค๊ณ  ํ•  ์ˆ˜ ์žˆ๋‹ค. ๋˜, Topic์€ ๋Œ€๋ถ€๋ถ„ ์ง€์†์ ์œผ๋กœ publish๋ฅผ ์ง„ํ–‰ํ•  ์ˆ˜ ์žˆ์ง€๋งŒ Service๋Š” ๋‹จ๋ฐœ์„ฑ์— ๊ฐ€๊น๋‹ค๋Š” ์ ๋„ ์ฐจ์ด์ ์œผ๋กœ ๋“ค ์ˆ˜ ์žˆ๋‹ค.

  • ๋ถ„๋ช…ํ•œ ์š”์ฒญ์˜ ์ฃผ์ฒด๊ฐ€ ์กด์žฌ, ๋น ๋ฅด๊ฒŒ ๋™์ž‘ ์™„๋ฃŒ๋˜๋Š” ๊ฒฝ์šฐ โžก๏ธ Service
  • ๋ถˆํŠน์ •ํ•œ Node๊ฐ€ subscribe์˜ ๋Œ€์ƒ์ด ๋˜๋ฉฐ, ์ง€์†์ ์œผ๋กœ ๋ฐ์ดํ„ฐ ์†ก์ˆ˜์‹  ์ผ์–ด๋‚˜๋Š” ๊ฒฝ์šฐ โžก๏ธ Topic


3๏ธโƒฃ Action

Action์˜ ํŠน์ง•

Action Client๋Š” Action Server๊ฐ€ response๋ฅผ ๋ณด๋‚ด๊ธฐ ์ „๊นŒ์ง€ ๊ณ„์† ๊ธฐ๋‹ค๋ฆฌ์ง€ ์•Š๊ณ , ๋‹ค๋ฅธ ์ผ์„ ํ•  ์ˆ˜ ์žˆ๋‹ค. ๋˜ํ•œ Action Client๋Š” request ๋ณด๋‚ธ ๋’ค์—๋„ ์ง€์†์ ์œผ๋กœ feedback์„ ๋ฐ›์„ ์ˆ˜ ์žˆ๋‹ค. ์ด๋•Œ, feedback์„ ๋ฐ›๋‹ค๊ณ  ๋ญ”๊ฐ€๊ฐ€ ์ž˜๋ชป ๋Œ์•„๊ฐ€๊ณ  ์žˆ๋‹ค๋Š” ๊ฒƒ์„ ๊ฐ์ง€ํ•œ ๊ฒฝ์šฐ์—” cancelํ•  ์ˆ˜๋„ ์žˆ๋‹ค.

์—ฌ๋Ÿฌ request๋ฅผ ๋™์‹œ์— ์ž‘์—…ํ•˜๋Š” ๊ฑด ๋ณธ์งˆ์ ์œผ๋กœ ๋ถˆ๊ฐ€ํ•˜์ง€๋งŒ ํ”„๋กœ๊ทธ๋ž˜๋ฐ์ ์œผ๋กœ ํ•ด๊ฒฐ์ด ๊ฐ€๋Šฅํ•˜๋‹ค๋Š” ํŠน์ง•์„ ๊ฐ€์ง€๊ณ  ์žˆ๋‹ค.


Action์˜ ์˜ˆ์‹œ

"Action = ๋‚ด๋น„๊ฒŒ์ด์…˜ ?"

Action์€ ๋‚ด๋น„๊ฒŒ์ด์…˜์˜ ์ž‘๋™ ์›๋ฆฌ์™€ ์ƒ๋‹นํžˆ ์œ ์‚ฌํ•˜๋‹ค.

๋ชฉ์ ์ง€ request ๋ฐ›๊ณ , ๊ฒฝ๋กœ๊ฒ€์ƒ‰์„ ๋งˆ์น˜๋ฉด ์•ˆ๋‚ด๊ฐ€ ์‹œ์ž‘๋œ๋‹ค. ์šด์ „ ๋„์ค‘์—๋„ ๋„๋กœ ์ƒํ™ฉ์„ ๊ณ ๋ คํ•œ feedback์„ ๊ณ„์†ํ•ด์„œ ์ œ๊ณต๋ฐ›๋Š”๋‹ค. ๋ชฉ์ ์ง€์— ๋„์ฐฉํ•˜๋ฉด ๊ฒฝ๋กœ ์•ˆ๋‚ด๋ฅผ ์ข…๋ฃŒํ•˜๊ณ  ๋‹ค์Œ request ๋Œ€๊ธฐํ•œ๋‹ค.

โžก๏ธ ์‹ค์ œ๋กœ ROS2์˜ ์ž์œจ ์ฃผํ–‰ Nav2 ํ”„๋กœ์ ํŠธ์—์„œ Action์„ ์ ๊ทน ํ™œ์šฉํ•˜๊ณ  ์žˆ๋‹ค๊ณ  ํ•œ๋‹ค.


Next Post..

๋‹ค์Œ ํฌ์ŠคํŠธ๋Š” DDS์™€ QoS์— ๋Œ€ํ•ด ์ •๋ฆฌํ•  ์˜ˆ์ •์ด๋‹ค.

 

Related Posts



๐Ÿ’™ You need to log in to GitHub to write comments. ๐Ÿ’™
If you can't see comments, please refresh page(F5).