ROS2_Foxy學習4——常用工具
- 1 rqt
-
- 1.1 安裝
- 1.2 rqt_graph
- 1.3 rqt_console
- 2 launch file
- 3 ros2bag
1 rqt
1.1 安裝
不同的版本 安裝方式不同。
# apt2.0 Ubuntu 20.04 and newer
$ sudo apt update
$ sudo apt install ~nros-<distro>-rqt*
# apt1.x Ubuntu 18.04 and older
$ sudo apt update
$ sudo apt install ros-<distro>-rqt*
1.2 rqt_graph
運作rqt_graph,也可以從rqt打開,rqt_graph清晰地展示了節點、話題等圖元素的關系。
![](https://img.laitimes.com/img/__Qf2AjLwojIjJCLyojI0JCLiAzNfRHLGZkRGZkRfJ3bs92YsYTMfVmepNHL9cmeNhXSU1kb1cVWtRWbihmWywEMW1mY1RzRapnTtxkb5ckYplTeMZTTINGMShUYfRHelRHLwEzX39GZhh2css2RkBnVHFmb1clWvB3MaVnRtp1XlBXe0xyayFWbyVGdhd3LcV2Zh1Wa9M3clN2byBXLzN3btg3Pn5GcuITM5IDOzcTMzIjMxAjMwIzLc52YucWbp5GZzNmLn9Gbi1yZtl2Lc9CX6MHc0RHaiojIsJye.png)
1.3 rqt_console
記錄終端的日志,也是一個節點,收集/rosout的資訊,可以根據日志等級過濾,也可以高亮一些内容。
$ ros2 run rqt_console rqt_console
上中下一共三個視窗,上面視窗列出了所有的日志,中間視窗可以根據日志等級進行篩選,下面的額視窗可以高亮一些需要的字元串。
日志等級按嚴重性,如下排列:
Fatal
Error
Warn
Info
Debug
2 launch file
Launch files allow you to start up and configure a number of executables containing ROS 2 nodes simultaneously.
$ ros2 launch <launch_file_name>
launch檔案的編寫在後續博文中單列一節~
3 ros2bag
記錄topic釋出的資料,可選擇記錄哪些topic,事後可以對ros包進行回放。
# 錄包
# 包存在于 錄包終端 所在的目錄下
$ ros2 bag record <topic_name>
# 同時錄多個話題,話題之間使用空格分開
# 使用 -o 選項可以設定包名
$ ros2 bag record -o <bag_file_name> <topic1_name> <topic2_name>
# 使用 -a 選項是記錄所有topic,在存在循環依賴的系統中 不建議使用
$ ros2 bag record -a
# 檢視包的資訊
$ ros2 bag info <bag_file_name>
# 有這些資訊
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
# 回放
$ ros2 bag play <bag_file_name>