Skip to content

Latest commit

ย 

History

History
166 lines (136 loc) ยท 4.24 KB

File metadata and controls

166 lines (136 loc) ยท 4.24 KB

data ๊ธฐ๋ก ๋ฐ ์žฌ์ƒ

  1. ๊ฐœ์š”
  2. ์‹ค์Šต
    1. ์„ค์ •
    2. topic ์„ ํƒํ•˜๊ธฐ
    3. ros2 bag record
    4. ros2 bag info
    5. ros2 bag play

1. ๊ฐœ์š”

  • ros2 bag ๋ช…๋ น

    • topic์—์„œ publish๋˜๋Š” data๋ฅผ ์ €์žฅ
  • ๋‚˜์ค‘์— ์ €์žฅ๋œ data๋ฅผ ์žฌ์ƒ

  • ๊ฐœ๋ฐœํ•˜๋ฉด์„œ ํ…Œ์ŠคํŠธ ๋ฐ ์‹คํ—˜ ๋ชฉ์ 

  • ์ค€๋น„

sudo apt-get install ros-foxy-ros2bag \
                     ros-foxy-rosbag2-converter-default-plugins \
                     ros-foxy-rosbag2-storage-default-plugins

2. ์‹ค์Šต

2-1 ์„ค์ •

  • 2๊ฐœ turtlesim nodes ๊ตฌ๋™์‹œํ‚ค๊ธฐ : /turtlesim , /teleop_turtle

  • ์ƒˆ ํ„ฐ๋ฏธ๋„์—์„œ ์•„๋ž˜ ๋ช…๋ น ์‹คํ–‰

ros2 run turtlesim turtlesim_node
  • ์ƒˆ ํ„ฐ๋ฏธ๋„์—์„œ ์•„๋ž˜ ๋ช…๋ น ์‹คํ–‰
ros2 run turtlesim turtle_teleop_key

* ์ƒˆ ํ„ฐ๋ฏธ๋„์„ ์—ด๊ณ  data๋ฅผ ์ €์žฅํ•  ์ƒˆ ๋””๋ ‰ํ† ๋ฆฌ ๋งŒ๋“ค๊ธฐ
```bash
mkdir bag_files
cd bag_files

2-2 topic ์„ ํƒํ•˜๊ธฐ

  • ros2 bag์€ topics์œผ๋กœ publish๋˜๋Š” messages๋งŒ ๊ธฐ๋กํ•œ๋‹ค.

  • ์ƒˆ ํ„ฐ๋ฏธ๋„์—์„œ ํ˜„์žฌ ์‹œ์Šคํ…œ์— ์žˆ๋Š” topics ๋ชฉ๋ก์„ ๋ณด๋Š” ๋ช…๋ น ์‹คํ–‰

ros2 topic list
/parameter_events
/rosout
/turtle1/cmd_vel
/turtle1/color_sensor
/turtle1/pose
  • /turtle_teleop node๊ฐ€ /turtle1_cmd_vel topic์œผ๋กœ ๋ช…๋ น์„ ์ „๋‹ฌํ•˜์—ฌ turtle์„ ์ด๋™์‹œํ‚จ๋‹ค๋Š” ๊ฒƒ์„ ๋ฐฐ์› ๋‹ค.

  • /turtle1/cmd_vel์ด publishํ•˜๋Š” data ๋‚ด์šฉ์„ ๋ณด๊ธฐ ์œ„ํ•ด์„œ ์•„๋ž˜ ๋ช…๋ น ์‹คํ–‰

ros2 topic echo /turtle1/cmd_vel
  • ์‹คํ–‰ ํ›„ ๋ฉ”์‹œ์ง€ ํ™•์ธ์„ ์œ„ํ•ด์„œ๋Š” teleop๋ฅผ ์‹คํ–‰ํ•œ ํ„ฐ๋ฏธ๋„๋กœ ๊ฐ€์„œ ํ™”์‚ดํ‘œ๋กœ ์›€์ง์—ฌ๋ณด๊ธฐ

  • ๊ฒฐ๊ณผ

linear:
  x: 2.0
  y: 0.0
  z: 0.0
angular:
  x: 0.0
  y: 0.0
  z: 0.0
  ---

2-3 ros2 bag record

  • ํŠน์ • topic์œผ๋กœ publish๋˜๋Š” data ๊ธฐ๋กํ•˜๋Š” ๋ช…๋ น ํ˜•ํƒœ
ros2 bag record <topic_name>
  • /turtle1/cmd_vel topic ์ €์žฅํ•˜๋Š” ๋ช…๋ น ์‹คํ–‰
ros2 bag record /turtle1/cmd_vel
  • ๊ฒฐ๊ณผ
[INFO] [rosbag2_storage]: Opened database 'rosbag2_2019_10_11-05_18_45'.
[INFO] [rosbag2_transport]: Listening for topics...
[INFO] [rosbag2_transport]: Subscribed to topic '/turtle1/cmd_vel'
[INFO] [rosbag2_transport]: All requested topics are subscribed. Stopping discovery...
  • ros2 bag ๋ช…๋ น์œผ๋กœ /turtle1/cmd_vel topic์—์„œ publish๋˜๋Š” data๋ฅผ ๊ธฐ๋กํ•˜๊ธฐ ์‹œ์ž‘ํ•œ๋‹ค. teleop ํ„ฐ๋ฏธ๋„๋กœ ์™€์„œ turtle ์ด๋™์‹œํ‚ค๊ธฐ.
  • ๋‚˜์ค‘์— replay๋ฅผ ์œ„ํ•ด์„œ ์›€์ง์ธ ํŒจํ„ด์„ ๊ธฐ์–ตํ•ด ๋‘์ž!

  • ์ €์žฅ๋˜๋Š” data ํŒŒ์ผ ํ˜•ํƒœ : rosbag2_year_month_day-hour_minute_second

  • ์ถ”๊ฐ€๋กœ metadata.yaml ํŒŒ์ผ์„ ํฌํ•จ

  • Ctrl+C๋กœ ์ข…๋ฃŒํ•˜๊ธฐ

2-3-1 ์—ฌ๋Ÿฌ topics ์ €์žฅํ•˜๊ธฐ

  • ros2 bag์œผ๋กœ ์ €์žฅํ•˜๋Š” ํŒŒ์ผ ์ด๋ฆ„ ์„ค์ •ํ•˜๋Š” ๋ช…๋ น ์‹คํ–‰
ros2 bag record -o subset /turtle1/cmd_vel /turtle1/pose
  • -o ์˜ต์…˜ : bag ํŒŒ์ผ ์ด๋ฆ„ ์ง€์ •

  • ๊ฒฐ๊ณผ

[INFO] [rosbag2_storage]: Opened database 'subset'.
[INFO] [rosbag2_transport]: Listening for topics...
[INFO] [rosbag2_transport]: Subscribed to topic '/turtle1/cmd_vel'
[INFO] [rosbag2_transport]: Subscribed to topic '/turtle1/pose'
[INFO] [rosbag2_transport]: All requested topics are subscribed. Stopping discovery...

2-4 ros2 bag info

  • ros bag ํŒŒ์ผ์— ๋Œ€ํ•œ ์ƒ์„ธ ์ •๋ณด ๋ช…๋ น ํ˜•์‹
ros2 bag info <bag_file_name>
  • subset์ด๋ผ๋Š” bag ํŒŒ์ผ์— ๋Œ€ํ•ด์„œ ๋ช…๋ น ์‹คํ–‰
ros2 bag info subset
  • ๊ฒฐ๊ณผ
Files:             subset.db3
Bag size:          228.5 KiB
Storage id:        sqlite3
Duration:          48.47s
Start:             Oct 11 2019 06:09:09.12 (1570799349.12)
End                Oct 11 2019 06:09:57.60 (1570799397.60)
Messages:          3013
Topic information: Topic: /turtle1/cmd_vel | Type: geometry_msgs/msg/Twist | Count: 9 | Serialization Format: cdr
                 Topic: /turtle1/pose | Type: turtlesim/msg/Pose | Count: 3004 | Serialization Format: cdr
  • ์ฐธ๊ณ  : ๊ฐœ๋ณ„ message๋Š” sqlite3๋กœ DB๋ฅผ ์—ด์–ด์„œ ํ™•์ธ ๊ฐ€๋Šฅ

2-5 ros2 bag play

  • bag ํŒŒ์ผ์„ ์žฌ์ƒํ•˜๊ธฐ ์œ„ํ•œ ์ค€๋น„

    • teleop๋ฅผ ์‹คํ–‰ํ•˜๋Š” ํ„ฐ๋ฏธ๋„ stop ์‹œํ‚ค๊ธฐ(Ctrl+C)
    • turtlesim ์ฐฝ์ด ๋ณด์ด๋„๋ก ์œ„์น˜์‹œํ‚ค๊ธฐ
  • subset ์ด๋ผ๋Š” bag ํŒŒ์ผ ์žฌ์ƒ ๋ช…๋ น

ros2 bag play subset
  • ๊ฒฐ๊ณผ
[INFO] [rosbag2_storage]: Opened database 'subset'.