본문 바로가기

로보틱스/ROS

ROS2 기본예제 Turtlesim 실행하기

Backgroud

오픈소스 기반의 ROS (Robot Operating System)는 로봇 애플리케이션을 만들기 위한 라이브러리 및 도구 모음 입니다. 디바이스 드라이버에서 알고리즘에 이르기까지 강력한 개발자 도구를 갖춘 ROS는 로봇 프로젝트에 필요한 많은 것을 갖추고 있습니다. ROS 의 두 번째 버전 ROS2 에서는 기존 버전에서 문제를 많이 개선해서 실시간 (Realtime) 성이 보장된 로봇 애플리케이션 프레임워크를 제공합니다.

Goal

ROS 에서 가장 기본이 되는 turtlesim 예제를 빌드하고 실행한다.

Turtlesim 이란?

  • ros_tutorials repository 하위에 속해 있는 튜토리얼 ROS 패키지
  • 간단한 Package, Node, Service, Action, Parameter 예제
  • CLI (Command Line Interface), RQT 실습을 위한 좋은 예제

Step by step

git 명령어를 통해서 ros_tutorials git repository 를 clone 하여 저장소를 복제 합니다.

~/dev_ws/src$ git clone https://github.com/ros/ros_tutorials.git -b dashing-devel

Cloning into 'ros_tutorials'...
remote: Enumerating objects: 9, done.
remote: Counting objects: 100% (9/9), done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 2689 (delta 3), reused 3 (delta 1), pack-reused 2680
Receiving objects: 100% (2689/2689), 574.30 KiB | 678.00 KiB/s, done.
Resolving deltas: 100% (1620/1620), done.

ros_tutorials 로 이동하여 colcon 으로 빌드합니다.

~/dev_ws/src/ros_tutorials$ colcon build
Starting >>> turtlesim
Finished <<< turtlesim [0.63s]

Summary: 1 package finished [0.84s]

bash 환경 파일인 setup.bash 을 실행하여 빌드된 package 설치합니다.

~/dev_ws/src/ros_tutorials$ source ./install/setup.bash

Run & Test

ros2 build 명령어로 turtlesim 패키지의 turtlesim_node 노드를 실행

~/dev_ws/src/ros_tutorials$ ros2 run turtlesim turtlesim_node

 

ROS2 Turtlesim

turtle 을 이동하기 위해서, turtlesim 패키지의 turtle_teleop_key 노드를 실행 합니다. 그리고 키보드의 방향키를 누르면 아래의 그림처럼 turtle 이 움직이는 것을 볼 수 있습니다.

~/dev_ws/src/ros_tutorials$ 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.

ROS2 Turtlesim / turtle_teleop_key

ROS (Robot Operating System)는 로봇 애플리케이션을 만들기 위한 라이브러리 및 도구 모음를 지원합니다. rgt_gragh 도구를 이용하면, 2개의 Node 와 주고 받는 메세지를 쉽게 이해할 수 있습니다.

~/dev_ws/src/ros_tutorials$ rqt_graph

rqt_graph

ROS 시각화 도구인 rqt 를 이용하면, topic 값을 확인할 수 있습니다.

~/dev_ws/src/ros_tutorials$ rqt

ROS2 Turtlesim 예제릍 통해 ROS2 의 기본 동작을 확인 했습니다.