05장 ROS2 Tools(RVIZ...)

ROS2에서 사용하는 Tools(RVIZ ...)

  • rqt console

ros2 run rqt_console rqt_console

https://index.ros.org/doc/ros2/Tutorials/Rqt-Console/Using-Rqt-Console/

Using rqt_console

Goal: 로그 메시지를 검사하는 도구.Contents

- rqt_console은 ROS 2에서 로그 메시지를 검사하는데 사용되는 GUI 도구임.

- 일반적으로 로그 메시지는 터미널 창에 표시되는데 rqt_console을 사용하면 시간이 지남에 따라 해당 메시지를 수집하여,보다

체계적으로 보고, 필터링하고, 저장하고, 저장된 파일을 다시 로드하여 검사할 수 있음

- 노드는 로그를 사용하여 다양한 방식으로 이벤트 및 상태와 관련된 메시지를 출력 -> 사용자를 위해 정보를 제공

- 로그 메시지의 의도는 노드 작성자가 정의하지만 컨텐츠는 런타임에 기록될 수 있음

C++ 언어

RCLCPP_DEBUG(nh_->get_logger(), "[%s]: pos_x: %f pos_y: %f theta: %f", nh_->get_namespace(), pos_.x(), pos_.y(), orient_);

RCLCPP_INFO(nh_->get_logger(), "Rotation goal canceled");

RCLCPP_WARN(nh_->get_logger(), "Velocity command received during rotation goal. Aborting goal");

Python 언어

self.get_logger().debug('Publishing: "%s"' % msg.data)

self.get_logger().info('Rotation goal canceled')

self.get_logger().warn('Velocity command received during rotation goal. Aborting goal')

rqt_console 및 turtlesim 설치.

다음 명령을 사용하여 새 터미널에서 rqt_console을 실행:

$rqt -s rqt_console rqt_consol

image.png

- 콘솔의 첫 번째 섹션은 시스템의 로그 메시지 표시

- 중간에는 심각도 수준을 제외하여 메시지를 필터링 가능. 오른쪽에 있는 더하기 기호 버튼을 사용하여 더 많은 제외 필터를 추가할 수도 있음

- 하단 섹션은 입력한 문자열이 포함된 메시지를 강조하기 위함. 이 섹션에 더 많은 필터를 추가 할 수도 있음.

Message

• 사용자가 지정한 메시지, 예를들면 화면에서 "hello world..."

Severity

• 메시지의 심각도 수준, 예를들면 Debug, Info 등.

Node

• 메시지를 브로드 캐스트하는 노드의 이름

Time

• 메시지가 브로드 캐스트된 시간

Topics

• 메시지를 브로드 캐스트하는 노드가 알리는 주제

Location

• colons 사용하는 파일, 함수, 라인을 결합합니다, 예를들면 /ros/base/pkgs/ros_tutorials/roscpp_tutorials/talker/talker.cpp:main:92

이제 다음 명령으로 turtlesim을 시작:

$ ros2 run turtlesim turtlesim_node

2 Messages on rqt_console¶

rqt_console에 표시할 로그 메시지를 생성하려면 거북이가 벽에 닿도록 해야 하기 때문에 새 터미널에서 아래에 ros2 topic pub 명령을 입력 :

$ ros2 topic pub -r 1 /turtle1/cmd_vel geometry_msgs/msg/Twist '{linear: {x: 2.0, y: 0.0, z: 0.0}, angular: {x: 0.0,y: 0.0,z: 0.0}}'

위의 명령은 topic을 꾸준한 속도로 publish하기 때문에 거북이는 계속 벽으로 흘러 들어가며 rqt_console에서 Warn 심각도 레벨이 반복해서 표시되는 동일한 메시지가 다음과 같이 표시됨:

image.png

ros2 topic pub 명령을 실행 한 터미널에서 Ctrl + C를 눌러 거북이가 벽으로 들어가는 것을 멈춤.

3 Logger levels¶

ROS 2의 로그 레벨은 심각도에 따라 정렬이 됨:

각 수준이 나타내는 정확한 표준은 없지만 다음과 같이 가정하는 것이 안전함:

• Fatal : 시스템이 자신을 손상으로부터 보호하려고 종료하려고 함을 나타냄.

• Error : 반드시 시스템을 손상 시키지는 않지만 제대로 작동하지 못하게하는 중요한 문제를 나타냄.

• Warn : 기능을 완전히 손상시키지 않는 예기치 않은 활동 또는 비 이상적인 결과를 나타냄.

• Info : 시스템이 예상대로 실행되고 있는지 시각적으로 확인하는 이벤트 및 상태 업데이트를 나타냄.

• Debug 메시지는 시스템 실행의 전체 단계 별 프로세스를 자세히 설명함.

기본 레벨은함 Info 메시지로 기본 심각도 수준 이상의 메시지만 표시함. 예를 들어 기본 수준을 경고로 설정하면 심각도 경고, 오류 및 치명적 메시지만 표시됨.

3.1 Set the default logger level¶

/turtlesim 노드를 처음 실행할 때 기본 로그 레벨을 설정할 수 있음.

터미널에 다음 명령을 입력:

$ros2 run turtlesim turtlesim_node --ros-args --log-level WARN

→ Before Eloquent,

$ros2 run turtlesim turtlesim_node --ros-args __log_level:=WARN

turtlesim을 시작할 때 콘솔에 나타난 초기 정보 수준 경고가 표시되지 않으며 이는 정보 메시지가 새로운 기본 심각도인 경고보다 우선 순위가 낮기 때문임.

Summary¶

시스템에서 로그 메시지를 면밀히 조사해야 하는 경우 rqt_console이 매우 유용할 수 있음.

참고)

* rqt (플러그인 방식의 ROS의 종합 GUI 툴)

• 그래픽 인터페이스 개발을 위한 Qt 기반 프레임 워크 제공

• 노드와 그들 사이의 연결 정보 표시(rqt_graph)

• 인코더, 전압, 또는 시간이 지남에 따라 변화하는 숫자를 플로팅(rqt_plot)

• 데이터를 메시지 형태로 기록하고 재생(rqt_bag)

• rqt는 Qt로 개발되어 있기 때문에 유저들이 자유롭게 플러그인을 개발하여 추가할 수도 있음.

• rqt의 대표적인 플러그인으로 rqt_image_view, rqt_graph, rqt_plot, rqt_bag가 있으며 그 이외에도

• rqt_action, rqt_gui, rqt_plot, rqt_runtime_monitorrqt_bag, rqt_gui_cpp, rqt_pose_view, rqt_rvizrqt_bag_plugins, rqt_gui_py, rqt_publisher, rqt_service_callerrqt_capabilities, rqt_image_view, rqt_py_common, rqt_shellrqt_console, rqt_launch, rqt_py_console, rqt_srvrqt_controller_manager, rqt_logger_level, rqt_reconfigure, rqt_tf_treerqt_dep, rqt_moveit, rqt_robot_dashboard, rqt_toprqt_ez_publisher, rqt_msg, rqt_robot_monitor, rqt_topicrqt_graph, rqt_nav_view, rqt_robot_steering, rqt_web 등의 플러그인이 존재.

ros1에서 plugin 20여개 이상 존재, 현재 ros2로 porting 수행 진행중

참고자료

https://index.ros.org/doc/ros2/Tutorials/RQt-Overview-Usage/

http://wiki.ros.org/rqt/UserGuide

https://github.com/ros-visualization

RQT 실행

$ rqt

RQT plugin 개별 실행

$ rqt -s rqt_graph

Commandline options

-b BINDING, --qt-binding BINDING choose Qt bindings to be used [pyqt|pyside]

--clear-config clear the configuration (including all perspectives and plugin settings)

-m, --multi-process use separate processes for each plugin instance (currently only supported under X11)

-s PLUGIN, --standalone PLUGIN

start only this plugin (implies -l). To pass arguments to the plugin use --args

--list-plugins list available plugins

* rqt plugin

1. 액션 (Action)

• Action Type Browser | Action 타입의 데이터 구조를 확인

2. 구성 (Configuration)

• Dynamic Reconfigure | 노드들에서 제공하는 설정값 변경을 위한 GUI 설정값 변경

• Launch | roslaunch 의 GUI 버전

3. 내성 (Introspection)

• Node Graph | 구동중인 노드들의 관계도 및 메시지의 흐름을 확인 가능한 그래프 뷰

• Package Graph | 노드의 의존 관계를 표시하는 source /usr/share/gazebo/setup.sh.그래프 뷰

• Process Monitor | 실행중인 노드들의 CPU사용률, 메모리사용륭, 스레드수 등을 확인

4. 로깅 (Logging)

• Bag | ROS 데이터 로깅

• Console | 노드들에서 발생되는 경고(Warning), 에러(Error) 등의 메시지를 확인

• Logger Level | ROS의 Debug, Info, Warn, Error, Fatal 로거 정보를 선택하여 표시

5. 다양한 툴 (Miscellaneous Tools)

• Python Console | 파이썬 콘솔 화면

• Shell | 쉘(shell)을 구동

• Web | 웹 브라우저를 구동

6. 로봇 (Robot)

• 사용하는 로봇에 따라 계기판(dashboard) 등의 플러그인을 이곳에 추가

7. 로봇툴 (Robot Tools)

• Controller Manager | 컨트롤러 제어에 필요한 플로그인

• Diagnostic Viewer | 로봇 디바이스 및 에러 확인

• Moveit! Monitor | 로봇 팔 계획에 사용되는 Moveit! 데이터를 확인

• Robot Steering | 로봇 조정 GUI 툴, 원격 조정에서 이 GUI 툴을 이용하여 로봇 조종

• Runtime Monitor | 실시간으로 노드들에서 발생되는 에러 및 경고를 확인

8. 서비스 (Services)

source /usr/share/gazebo/setup.sh. • Service Caller | 구동중인 서비스 서버에 접속하여 서비스를 요청

• Service Type Browser | 서비스 타입의 데이터 구조를 확인

9. 토픽 (Topics)

• Easy Message Publisher | 토픽을 GUI 환경에서 발행

• Topic Publisher | 토픽을 생성하여 발행

• Topic Type Browser | 토픽 타입의 데이터 구조 확인

• Topic Monitor | 사용자가 선택한 토픽의 정보를 확인

10. 시각화 (Visualization)

• Image View | 카메라의 영상 데이터를 확인

• Navigation Viewer | 로봇 네비게이션의 위치 및 목표지점 확인

• Plot | 2차원 데이터 플롯 GUI 플러그인, 2차원 데이터의 도식화

• Pose View | 현재 TF의 위치 및 모델의 위치 표시

• RViz | 3차원 시각화 툴인 RViz 플러그인

• TF Tree | tf 관계를 트리로 나타내는 그래프 뷰

* ros-rqt-plugin : QT기반 ROS 통합 IDE 개발환경

https://ros-qtc-plugin.readthedocs.io/en/latest/_source/How-to-Install-Users.html

통합 IDE 개발환경을 사용하면 소스코드를 작성하고 빌드하고 실행하는 동작을 하나의 GUI 에서 수행하기 때문에 편리함.

특히 Breakpoint를 사용하여 디버깅 실행이 가능하기 때문에 소프트웨어 개발자들은 IDE 개발환경이 필수적으로 필요함.

ros-qtc-plugin 사용시 문의사항 있으시면 연락 바랍니다.

* beyond compare: 소스 비교 도구

소프트웨어 개발자들은 작성하고 있는 현재 소스코드 상태를 확인하는 과정이 매우 빈번하게 요구됨. 예를들어 어제 작성된 소스코드와 지금 작성하고 있는 소스코드를 한눈에 비교하여 작성되는 과정이 적절한지 평가하는 행위가 반드시 필요한데 이때 소스코드 비교를 위한 프로그램이 반드시 필요하며, 이런 측면에서 Beyondcompare는 매우 강력한 듯 합니다.

다른 분들은 어떤 compare 툴을 사용하시나요?

Beyondcompare 사용시 문의사항 있으시면 연락 바랍니다.

설치파일 :

https://www.scootersoftware.com/download.php

2. RVIZ

2.1 RVIZ 소개

RVIZ is a ROS graphical interface that allows you to visualize a lot of information, using plugins for many kinds of available topics. RVIZ2 is simply a port of RVIZ into ROS2.

2.2 RVIZ 사용 예제1, dummy robot demo

https://index.ros.org/doc/ros2/Tutorials/dummy-robot-demo/

image.png

pkg list명령어로 확인해보니 dummy_robot_bringup이 이미 설치되어있다.

ros2 launch dummy_robot_bringup dummy_robot_bringup.launch.py

다른 터미널에서 rviz 실행

rviz2

"Fixed Me" 문제가 발생하여 Tutorial에서 보여준 그림이 보이지 않았다. 구글 검색을 통해 "Fixed Frame"을 "world"로 변경하면 문제가 해결되는 것을 알았다.

https://github.com/ethz-adrl/towr/issues/27

image.png

"Fixed Me" 문제를 해결하면 ros.org에 있는 것과 동일한 그림을 볼 수 있다.

→ dummy robot이 rviz상에 표시되기 위해서는 Displays에 "TF"를 add해 주어야 합니다.

동영상은 image.pnghttps://blog.naver.com/zeta0807/221814293021image.png

2.3 RVIZ 사용 예제2, Turtlebot3 fakenode

2.3.1 Turtlebot3 환경 설치

http://emanual.robotis.com/docs/en/platform/turtlebot3/ros2_setup/를 보고 설치하였다.

Install ROS2 Dependent Packages

# Install Colcon

$ sudo apt install python3-colcon-common-extensions

# Install Cartographer dependencies

$ sudo apt install -y \

google-mock \

libceres-dev \

liblua5.3-dev \

libboost-dev \

libboost-iostreams-dev \

libprotobuf-dev \

protobuf-compiler \

libcairo2-dev \

libpcl-dev \

python3-sphinx

# Install Gazebo9

$ curl -sSL http://get.gazebosim.org | sh

$ sudo apt install ros-dashing-gazebo-*

# Install Cartographer

$ sudo apt install ros-dashing-cartographer

$ sudo apt install ros-dashing-cartographer-ros

# Install Navigation2

$ sudo apt install ros-dashing-navigation2

$ sudo apt install ros-dashing-nav2-bringup

# Install vcstool

$ sudo apt install python3-vcstool

Install TurtleBot3 Packages

$ mkdir -p ~/turtlebot3_ws/src

$ cd ~/turtlebot3_ws

$ wget https://raw.githubusercontent.com/ROBOTIS-GIT/turtlebot3/ros2/turtlebot3.repos

$ vcs import src < turtlebot3.repos

$ colcon build --symlink-install

Save Bash Command for Setup

$ echo 'source ~/turtlebot3_ws/install/setup.bash' >> ~/.bashrc

$ echo 'export ROS_DOMAIN_ID=30 #TURTLEBOT3' >> ~/.bashrc

$ source ~/.bashrc

.bashrc의 내용중 ros2, turtlebot 관련 설정을 보면 아래와 같습니다. 이 중 맨 아래 두 줄은 3.2절에서 추가한 내용이다.

source /opt/ros/dashing/setup.bash

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

source ~/turtlebot3_ws/install/setup.bash

export ROS_DOMAIN_ID=30 #TURTLEBOT3

export TURTLEBOT3_MODEL=burger

export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:~/turtlebot3_ws/src/turtlebot3/turtlebot3_simulations/turtlebot3_gazebo/models

http://emanual.robotis.com/docs/en/platform/turtlebot3/ros2_simulation/#turtlebot3-simulation-using-fake-node

Terminal #1

zeta@changwhan:~$ ros2 launch turtlebot3_fake_node turtlebot3_fake_node.launch.py

Terminal #2

zeta@changwhan:~$ ros2 run turtlebot3_teleop teleop_keyboard

2.4 pinkwink 예제, 저는 실패했습니다.

https://pinkwink.kr/903

ROS1에서는 catkin을 사용하지만 ROS2에서는 catkin을 사용하지 않으므로 아래 내용은 유효하지 않다.

cd ~/catkin_ws/src/

catkin_create_pkg testbot_description urdf

cd testbot_description

mkdir urdf

cd urdf

gedit testbot.urdf

check_urdf testbot.urdf

cd ~/catkin_ws/src/testbot_description

mkdir launch

cd launch

gedit testbot.launch

ROS2, 즉 ament_cmkae를 사용해서 아래와 같이 만들었으나 lauch를 만드는데 실패하였다.

cd ~/rviz_ws/src

ros2 pkg create --build-type ament_cmake testbot_description

cd testbot_description

mkdir urdf

cd urdf

gedit testbot.urdf

check_urdf testbot.urdf

cd ~/rviz_ws/src/testbot_description

mkdir launch

cd launch

gedit testbot.launc

~/rviz2_ws$ colcon build --symlink-install

~/rviz2_ws$ source install/setup.bash

ros2 launch testbot_description testbot.launch

testbot.urdf, testbot.launch 내용은 아래 사이트에서 받을 수 있지만 ROS1용이다.

https://github.com/ROBOTIS-GIT/ros_tutorials/tree/master/testbot_description

즉 아래에 말한 것처럼 CMakeLists.txt와 Lanch file을 변경하여야하는 것이다. testbot.lanch를 testbot.launch.py로 변경하고 내용을 아래 규칙에 맞춰받으나 실패하였다.

https://index.ros.org/doc/ros2/Tutorials/Launch-system/

3. Gazebo

3.1 Gazebo란

http://gazebosim.org/tutorials?tut=ros2_overview#Node

Gazebo is a stand-alone application which can be used independently of ROS or ROS 2. The integration of Gazebo with either ROS version is done through a set of packages called gazebo_ros_pkgs. These packages provide a bridge between Gazebo's C++ API and transport system, and ROS 2 messages and services. Not all functionality from ROS 1 has been ported to ROS 2 yet. You can check the progress on this issue.

3.2 Gazebo에제 1, Turtlebot3

image.png

$ echo 'export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:~/turtlebot3_ws/src/turtlebot3/turtlebot3_simulations/turtlebot3_gazebo/models' >> ~/.bashrc

$ echo 'export TURTLEBOT3_MODEL=burger' >> ~/.bashrc

$ source ~/.bashrc

ros2 launch turtlebot3_gazebo turtlebot3_house.launch.py

teleop_keyboard를 사용하여 움직임을 만들수 있다.

zeta@changwhan:~$ ros2 run turtlebot3_teleop teleop_keyboard

3.3 Gazebo예제2, Tutorial

https://www.youtube.com/watch?v=eKoTMdMPNKM

http://gazebosim.org/tutorials?tut=ros2_installing&cat=connect_ros

아래의 명령을 입력하여 패키지를 설치해주세요

mkdir -p ~/ws/src

cd ~/ws

wget https://bitbucket.org/api/2.0/snippets/chapulina/geRKyA/f02dcd15c2c3b83b2d6aac00afe281162800da74/files/ros2.yaml

vcs import src < ros2.yaml

colcon build --symlink-install

source ~/ws/install/setup.bash

gazebo --verbose /opt/ros/dashing/share/gazebo_plugins/worlds/gazebo_ros_diff_drive_demo.world

하기의 명령으로 소스코드의 의존성 검사는 정상 수행이 되었습니다.

$ sudo rosdep install -i --from-path src --rosdistro dashing -

그런데 colcon build 수행중 에러가 발생하네요..

(self 해결 방법)

1. camera-calibration-parsers를 deb 설치

$ sudo apt-get update

$ sudo apt-get install camera-calibration-parsers-tools

2. camera-calibration-parsers 빌드 제외

~/ws/src/ros-perception/image_common/camera-calibration-parsers/COLCON_IGNORE 파일 생성

3. arguments.h 추가 (~/ws/src/ros-simulation/gazebo_ros_pkgs/gazebo_ros/include/rcl/arguments.h)

http://docs.ros2.org/eloquent/api/rcl/arguments_8h_source.html

4. $ colcon build --symlink-install 실행 -> 빌드 완료

다른 터미널에서 아래 명령어를 입력하여 움직임을 만든다.

ros2 topic pub /demo/cmd_demo geometry_msgs/Twist '{linear: {x: 1.0}}' -1

여기서 문제!!

아래오픈 소스를 활용해서 rqt를 이용해서 카메라 화면을 보여주자

https://github.com/klintan/ros2_usb_camera

다른 터미널에서 아래 명령어를 입력하여 움직임을 만든다.

ros2_usb_camera 빌드

$ ros2 run usb_camera_driver usb_camera_driver_node

$ rqt -s rqt_image_view

Last updated