newhaneul

[Robocup@Home 2026] 2026.01.14 (RB-Y1 Technical Training Manual, ROS2 bag) 본문

3. Robotics/Robocup@Home 2026

[Robocup@Home 2026] 2026.01.14 (RB-Y1 Technical Training Manual, ROS2 bag)

뉴하늘 2026. 1. 14. 22:26
728x90

 

RB-Y1 WebUI

estop -> power on -> servos on -> reset -> enable -> control 가능

RBY1_교육자료 (1).pdf
12.59MB

 

ROS2 bag

 ROS2 bag은 로봇 운영 체제 (ROS 2)에서 시스템 내의 토픽으로 주고받는 메시지 데이터를 기록하고, 필요할 때 재생할 수 있게 해주는 도구이다.

 

 로봇이 동작하는 동안 센서 데이터 (카메라, 라이다, 마이크 등)와 로봇의 상태 정보(위치, 속도 등)를 파일로 저장한다.

  • 기록 (Record): 로봇이 실제 환경에서 움직일 때 발생하는 데이터를 .mcap 또는 .db3 형식의 파일로 저장합니다.
  • 재생 (Play): 저장된 파일을 재생하면, 로봇이 실제로 움직이지 않아도 마치 센서가 데이터를 보내는 것처럼 똑같은 상황을 재현할 수 있습니다.

 기본적인 사용법은 터미널에서 다음과 같은 명령어로 간단히 사용할 수 있다.

 

  • 기록하기:
ros2 bag record -a  # 모든 토픽 기록
ros2 bag record /image_raw /scan  # 특정 토픽만 기록
  • 재생하기:
ros2 bag play my_recording_data.mcap
  • 정보 확인:
ros2 bag info my_recording_data.mcap

 

 

실습 진행

 

1단계: turtlesim 노드 실행

 

첫 번째 터미널:

newhaneul@newhaneul-950QDB:~$ ros2 run turtlesim turtlesim_node
Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
[INFO] [1768384055.065251981] [turtlesim]: Starting turtlesim with node name /turtlesim
[INFO] [1768384055.067259566] [turtlesim]: Spawning turtle [turtle1] at x=[5.544445], y=[5.544445], theta=[0.000000]

 

두 번째 터미널:

newhaneul@newhaneul-950QDB:~$ ros2 run turtlesim turtle_teleop_key
Reading from keyboard
---------------------------
Use arrow keys to move the turtle.
Use G|B|V|C|D|E|R|T keys to rotate to absolute orientations. 'F' to cancel a rotation.
'Q' to quit.

 

2단계: ros2 bag으로 기록할 토픽 확인

세 번째 터미널:

newhaneul@newhaneul-950QDB:~$ ros2 topic list
/parameter_events
/rosout
/turtle1/cmd_vel
/turtle1/color_sensor
/turtle1/pose

 

3단계: ros2 bag record - 토픽 데이터 녹화하기

디렉토리 만들기:

newhaneul@newhaneul-950QDB:~$ mkdir bag_files
newhaneul@newhaneul-950QDB:~$ cd bag_files
newhaneul@newhaneul-950QDB:~/bag_files$

 

기록 시작:

newhaneul@newhaneul-950QDB:~/bag_files$ ros2 bag record /turtle1/cmd_vel
[INFO] [1768384295.295913274] [rosbag2_recorder]: Press SPACE for pausing/resuming
[INFO] [1768384295.297178011] [rosbag2_storage]: Opened database 'rosbag2_2026_01_14-18_51_35/rosbag2_2026_01_14-18_51_35_0.db3' for READ_WRITE.
[INFO] [1768384295.297708158] [rosbag2_recorder]: Listening for topics...
[INFO] [1768384295.297719578] [rosbag2_recorder]: Event publisher thread: Starting
[INFO] [1768384295.298364027] [rosbag2_recorder]: Subscribed to topic '/turtle1/cmd_vel'
[INFO] [1768384295.298413854] [rosbag2_recorder]: Recording...
[INFO] [1768384295.298534464] [rosbag2_recorder]: All requested topics are subscribed. Stopping discovery...

 

4단계: ros2 bag info - 녹화된 파일 정보 확인

newhaneul@newhaneul-950QDB:~/bag_files$ ros2 bag info rosbag2_2026_01_14-19_02_30/

Files:             rosbag2_2026_01_14-19_02_30_0.db3
Bag size:          33.0 KiB
Storage id:        sqlite3
Duration:          12.468125252s
Start:             Jan 14 2026 19:02:42.096130157 (1768384962.096130157)
End:               Jan 14 2026 19:02:54.564255409 (1768384974.564255409)
Messages:          94
Topic information: Topic: /turtle1/cmd_vel | Type: geometry_msgs/msg/Twist | Count: 94 | Serialization Format: cdr

 

5단계: ros2 bag play - 녹화된 데이터 재생

newhaneul@newhaneul-950QDB:~/bag_files$ ros2 bag play rosbag2_2026_01_14-19_02_30/
[INFO] [1768385051.239975599] [rosbag2_storage]: Opened database 'rosbag2_2026_01_14-19_02_30/rosbag2_2026_01_14-19_02_30_0.db3' for READ_ONLY.
[INFO] [1768385051.240018377] [rosbag2_player]: Set rate to 1
[INFO] [1768385051.241657726] [rosbag2_player]: Adding keyboard callbacks.
[INFO] [1768385051.241684475] [rosbag2_player]: Press SPACE for Pause/Resume
[INFO] [1768385051.241694352] [rosbag2_player]: Press CURSOR_RIGHT for Play Next Message
[INFO] [1768385051.241701273] [rosbag2_player]: Press CURSOR_UP for Increase Rate 10%
[INFO] [1768385051.241707394] [rosbag2_player]: Press CURSOR_DOWN for Decrease Rate 10%
[INFO] [1768385051.241927537] [rosbag2_storage]: Opened database 'rosbag2_2026_01_14-19_02_30/rosbag2_2026_01_14-19_02_30_0.db3' for READ_ONLY.

 

 

 

RB-Y1 모델을 MuJoCo 시뮬레이션에 띄우고 팔 뻗기 작업 진행

 

1단계: RB-Y1 모델 파일 준비

가장 먼저 Rainbow Robotics 공식 SDK에서 시뮬레이션용 모델 파일을 확보해야 한다.

  • rby1-sdk clone:
newhaneul@newhaneul-950QDB:~/rby1$ git clone https://github.com/RainbowRobotics/rby1-sdk.git
Cloning into 'rby1-sdk'...
remote: Enumerating objects: 6639, done.
remote: Counting objects: 100% (928/928), done.
remote: Compressing objects: 100% (427/427), done.
remote: Total 6639 (delta 571), reused 557 (delta 490), pack-reused 5711 (from 1)
Receiving objects: 100% (6639/6639), 93.55 MiB | 4.28 MiB/s, done.
Resolving deltas: 100% (2893/2893), done.
Updating files: 100% (3118/3118), done.

 

 

  • 모델 파일 확인:

 'rby1-sdk/models/urdf/' 폴더 내에 'rby1.urdf'가 있는지 확인한다. 해당 URDF 파일을 열어 관절의 정확한 이름 (joint name)을 확인해야한다.

 

2단계: MuJoCo 라이브러리 설치

터미널에서 공식 MuJoCo 라이브러리를 설치한다.

newhaneul@newhaneul-950QDB:~/rby1$ pip install mujoco
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: mujoco in /home/newhaneul/.local/lib/python3.10/site-packages (3.4.0)
Requirement already satisfied: absl-py in /home/newhaneul/.local/lib/python3.10/site-packages (from mujoco) (2.3.1)
Requirement already satisfied: etils[epath] in /home/newhaneul/.local/lib/python3.10/site-packages (from mujoco) (1.13.0)
Requirement already satisfied: glfw in /home/newhaneul/.local/lib/python3.10/site-packages (from mujoco) (2.10.0)
Requirement already satisfied: numpy in /home/newhaneul/.local/lib/python3.10/site-packages (from mujoco) (1.26.4)
Requirement already satisfied: pyopengl in /home/newhaneul/.local/lib/python3.10/site-packages (from mujoco) (3.1.10)
Requirement already satisfied: fsspec in /home/newhaneul/.local/lib/python3.10/site-packages (from etils[epath]->mujoco) (2025.12.0)
Requirement already satisfied: importlib_resources in /home/newhaneul/.local/lib/python3.10/site-packages (from etils[epath]->mujoco) (6.5.2)
Requirement already satisfied: typing_extensions in /home/newhaneul/.local/lib/python3.10/site-packages (from etils[epath]->mujoco) (4.15.0)
Requirement already satisfied: zipp in /usr/lib/python3/dist-packages (from etils[epath]->mujoco) (1.0.0)
 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

728x90