- ๊ฐ์
- ์ค์ต
- ์ค์
- topic ์ ํํ๊ธฐ
- ros2 bag record
- ros2 bag info
- ros2 bag play
-
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๊ฐ turtlesim nodes ๊ตฌ๋์ํค๊ธฐ : /turtlesim , /teleop_turtle
-
์ ํฐ๋ฏธ๋์์ ์๋ ๋ช ๋ น ์คํ
ros2 run turtlesim turtlesim_node- ์ ํฐ๋ฏธ๋์์ ์๋ ๋ช ๋ น ์คํ
ros2 run turtlesim turtle_teleop_key
* ์ ํฐ๋ฏธ๋์ ์ด๊ณ data๋ฅผ ์ ์ฅํ ์ ๋๋ ํ ๋ฆฌ ๋ง๋ค๊ธฐ
```bash
mkdir bag_files
cd bag_files-
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
---
- ํน์ 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๋ก ์ข ๋ฃํ๊ธฐ
- 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...
- 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๋ฅผ ์ด์ด์ ํ์ธ ๊ฐ๋ฅ
-
bag ํ์ผ์ ์ฌ์ํ๊ธฐ ์ํ ์ค๋น
- teleop๋ฅผ ์คํํ๋ ํฐ๋ฏธ๋ stop ์ํค๊ธฐ(Ctrl+C)
- turtlesim ์ฐฝ์ด ๋ณด์ด๋๋ก ์์น์ํค๊ธฐ
-
subset ์ด๋ผ๋ bag ํ์ผ ์ฌ์ ๋ช ๋ น
ros2 bag play subset- ๊ฒฐ๊ณผ
[INFO] [rosbag2_storage]: Opened database 'subset'.

