在ROS2中安装turtlesim package 和rqt 工具。
1、 更新系统,安装ros-galactic-turtlesim
sudo apt update
sudo apt install ros-galactic-turtlesim
前期ROS2安装时,此包已安装。
Reading package lists... Done
Building dependency tree
Reading state information... Done
ros-galactic-turtlesim is already the newest version (1.3.3-1focal.20211011.231138).
ros-galactic-turtlesim set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 11 not upgraded.
检查结果
ros2 pkg executables turtlesim
turtlesim draw_square
turtlesim mimic
turtlesim turtle_teleop_key
turtlesim turtlesim_node
运行仿真
ros2 run turtlesim turtlesim_node
输出信息
[INFO] [1637888026.115145954] [turtlesim]: Starting turtlesim with node name /turtlesim
[INFO] [1637888026.119554592] [turtlesim]: Spawning turtle [turtle1] at x=[5.544445], y=[5.544445], theta=[0.000000]
2、程控turtlesim
另开一个终端,输入行命令:
ros2 run turtlesim turtle_teleop_key
turtle_teleop_key是前面已安装的turtlesim 包之一,用于在新开启的终端中控制turtlesim_node。
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.
[INFO] [1637888777.692750673] [turtlesim]: Rotation goal completed successfully
[WARN] [1637888780.027846593] [turtlesim]: Rotation goal received before a previous goal finished. Aborting previous goal
[WARN] [1637888780.060247450] [turtlesim]: Rotation goal received before a previous goal finished. Aborting previous goal
[WARN] [1637888780.092547238] [turtlesim]: Rotation goal received before a previous goal finished. Aborting previous goal
[INFO] [1637888780.316034265] [turtlesim]: Rotation goal completed successfully
[INFO] [1637888785.852153918] [turtlesim]: Rotation goal completed successfully
[INFO] [1637888786.028783877] [turtlesim]: Rotation goal completed successfully
[INFO] [1637888786.060231422] [turtlesim]: Rotation goal completed successfully
[INFO] [1637888786.092725477] [turtlesim]: Rotation goal completed successfully
[INFO] [1637888786.124283493] [turtlesim]: Rotation goal completed successfully
[INFO] [1637888786.140362266] [turtlesim]: Rotation goal completed successfully
[INFO] [1637888791.724726207] [turtlesim]: Rotation goal completed successfully
[WARN] [1637888793.804016958] [turtlesim]: Oh no! I hit the wall! (Clamping from [x=4.847247, y=-0.017683])
[WARN] [1637888793.820645140] [turtlesim]: Oh no! I hit the wall! (Clamping from [x=4.846979, y=-0.031999])
查看节点运行信息:
ros2 node list
/turtlesim
ros2 topic list
/parameter_events
/rosout
/turtle1/cmd_vel
/turtle1/color_sensor
/turtle1/pose
ros2 service list
/clear
/kill
/reset
/spawn
/turtle1/set_pen
/turtle1/teleport_absolute
/turtle1/teleport_relative
/turtlesim/describe_parameters
/turtlesim/get_parameter_types
/turtlesim/get_parameters
/turtlesim/list_parameters
/turtlesim/set_parameters
/turtlesim/set_parameters_atomically
ros2 action list
/turtle1/rotate_absolute
3、安装和使用rqt 工具
rqt 是ROS2提供的一个图形化用户接口。
安装rqt 工具:
sudo apt install ~nros-galactic-rqt*
Reading package lists... Done
Building dependency tree
Reading state information... Done
ros-galactic-rqt-action is already the newest version (2.0.0-2focal.20211101.131158).
ros-galactic-rqt-action set to manually installed.
ros-galactic-rqt-bag is already the newest version (1.1.1-2focal.20211012.051134).
ros-galactic-rqt-bag set to manually installed.
ros-galactic-rqt-bag-plugins is already the newest version (1.1.1-2focal.20211012.053712).
ros-galactic-rqt-bag-plugins set to manually installed.
ros-galactic-rqt-common-plugins is already the newest version (1.1.0-2focal.20211101.142005).
ros-galactic-rqt-common-plugins set to manually installed.
ros-galactic-rqt-console is already the newest version (2.0.2-2focal.20211101.113240).
ros-galactic-rqt-console set to manually installed.
ros-galactic-rqt-graph is already the newest version (1.2.0-2focal.20211011.214849).
ros-galactic-rqt-graph set to manually installed.
ros-galactic-rqt-gui is already the newest version (1.1.2-1focal.20211011.213937).
ros-galactic-rqt-gui set to manually installed.
ros-galactic-rqt-gui-cpp is already the newest version (1.1.2-1focal.20211012.002304).
ros-galactic-rqt-gui-cpp set to manually installed.
ros-galactic-rqt-gui-py is already the newest version (1.1.2-1focal.20211011.214240).
ros-galactic-rqt-gui-py set to manually installed.
ros-galactic-rqt-image-view is already the newest version (1.1.1-2focal.20211012.002625).
ros-galactic-rqt-image-view set to manually installed.
ros-galactic-rqt-msg is already the newest version (1.0.5-1focal.20211101.130851).
ros-galactic-rqt-msg set to manually installed.
ros-galactic-rqt-plot is already the newest version (1.1.0-1focal.20211011.214755).
ros-galactic-rqt-plot set to manually installed.
ros-galactic-rqt-publisher is already the newest version (1.1.3-1focal.20211011.214755).
ros-galactic-rqt-publisher set to manually installed.
ros-galactic-rqt-py-common is already the newest version (1.1.2-1focal.20211011.213939).
ros-galactic-rqt-py-common set to manually installed.
ros-galactic-rqt-py-console is already the newest version (1.0.2-1focal.20211011.215010).
ros-galactic-rqt-py-console set to manually installed.
ros-galactic-rqt-reconfigure is already the newest version (1.0.8-1focal.20211101.130853).
ros-galactic-rqt-reconfigure set to manually installed.
ros-galactic-rqt-service-caller is already the newest version (1.0.5-1focal.20211011.214753).
ros-galactic-rqt-service-caller set to manually installed.
ros-galactic-rqt-shell is already the newest version (1.0.2-1focal.20211011.214850).
ros-galactic-rqt-shell set to manually installed.
ros-galactic-rqt-srv is already the newest version (1.0.3-1focal.20211101.131158).
ros-galactic-rqt-srv set to manually installed.
ros-galactic-rqt-top is already the newest version (1.0.2-1focal.20211011.214755).
ros-galactic-rqt-top set to manually installed.
ros-galactic-rqt-topic is already the newest version (1.2.2-1focal.20211011.214847).
ros-galactic-rqt-topic set to manually installed.
The following additional packages will be installed:
python3-rospkg
The following NEW packages will be installed:
python3-rospkg ros-galactic-rqt ros-galactic-rqt-gui-cpp-dbgsym
ros-galactic-rqt-image-view-dbgsym ros-galactic-rqt-moveit
ros-galactic-rqt-robot-dashboard ros-galactic-rqt-robot-monitor
ros-galactic-rqt-robot-steering ros-galactic-rqt-runtime-monitor
0 upgraded, 9 newly installed, 0 to remove and 0 not upgraded.
Need to get 4,024 kB of archives.
After this operation, 7,151 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://packages.ros.org/ros2/ubuntu focal/main amd64 python3-rospkg all 1.3.0-100 [2,172 B]
Get:2 http://packages.ros.org/ros2/ubuntu focal/main amd64 ros-galactic-rqt amd64 1.1.2-1focal.20211012.002712 [6,892 B]
Get:3 http://packages.ros.org/ros2/ubuntu focal/main amd64 ros-galactic-rqt-gui-cpp-dbgsym amd64 1.1.2-1focal.20211012.002304 [1,956 kB]
Get:4 http://packages.ros.org/ros2/ubuntu focal/main amd64 ros-galactic-rqt-image-view-dbgsym amd64 1.1.1-2focal.20211012.002625 [1,940 kB]
Get:5 http://packages.ros.org/ros2/ubuntu focal/main amd64 ros-galactic-rqt-moveit amd64 1.0.1-2focal.20211011.215017 [14.7 kB]
Get:6 http://packages.ros.org/ros2/ubuntu focal/main amd64 ros-galactic-rqt-robot-monitor amd64 1.0.4-2focal.20211011.214754 [28.8 kB]
Get:7 http://packages.ros.org/ros2/ubuntu focal/main amd64 ros-galactic-rqt-robot-dashboard amd64 0.6.1-1focal.20211101.130855 [51.5 kB]
Get:8 http://packages.ros.org/ros2/ubuntu focal/main amd64 ros-galactic-rqt-robot-steering amd64 1.0.0-3focal.20211011.214902 [10.9 kB]
Get:9 http://packages.ros.org/ros2/ubuntu focal/main amd64 ros-galactic-rqt-runtime-monitor amd64 1.0.0-1focal.20211011.214754 [13.1 kB]
Fetched 4,024 kB in 13s (299 kB/s)
Selecting previously unselected package python3-rospkg.
(Reading database ... 277567 files and directories currently installed.)
Preparing to unpack .../0-python3-rospkg_1.3.0-100_all.deb ...
Unpacking python3-rospkg (1.3.0-100) ...
Selecting previously unselected package ros-galactic-rqt.
Preparing to unpack .../1-ros-galactic-rqt_1.1.2-1focal.20211012.002712_amd64.de
b ...
Unpacking ros-galactic-rqt (1.1.2-1focal.20211012.002712) ...
Selecting previously unselected package ros-galactic-rqt-gui-cpp-dbgsym.
Preparing to unpack .../2-ros-galactic-rqt-gui-cpp-dbgsym_1.1.2-1focal.20211012.
002304_amd64.deb ...
Unpacking ros-galactic-rqt-gui-cpp-dbgsym (1.1.2-1focal.20211012.002304) ...
Selecting previously unselected package ros-galactic-rqt-image-view-dbgsym.
Preparing to unpack .../3-ros-galactic-rqt-image-view-dbgsym_1.1.1-2focal.202110
12.002625_amd64.deb ...
Unpacking ros-galactic-rqt-image-view-dbgsym (1.1.1-2focal.20211012.002625) ...
Selecting previously unselected package ros-galactic-rqt-moveit.
Preparing to unpack .../4-ros-galactic-rqt-moveit_1.0.1-2focal.20211011.215017_a
md64.deb ...
Unpacking ros-galactic-rqt-moveit (1.0.1-2focal.20211011.215017) ...
Selecting previously unselected package ros-galactic-rqt-robot-monitor.
Preparing to unpack .../5-ros-galactic-rqt-robot-monitor_1.0.4-2focal.20211011.2
14754_amd64.deb ...
Unpacking ros-galactic-rqt-robot-monitor (1.0.4-2focal.20211011.214754) ...
Selecting previously unselected package ros-galactic-rqt-robot-dashboard.
Preparing to unpack .../6-ros-galactic-rqt-robot-dashboard_0.6.1-1focal.20211101
.130855_amd64.deb ...
Unpacking ros-galactic-rqt-robot-dashboard (0.6.1-1focal.20211101.130855) ...
Selecting previously unselected package ros-galactic-rqt-robot-steering.
Preparing to unpack .../7-ros-galactic-rqt-robot-steering_1.0.0-3focal.20211011.
214902_amd64.deb ...
Unpacking ros-galactic-rqt-robot-steering (1.0.0-3focal.20211011.214902) ...
Selecting previously unselected package ros-galactic-rqt-runtime-monitor.
Preparing to unpack .../8-ros-galactic-rqt-runtime-monitor_1.0.0-1focal.20211011
.214754_amd64.deb ...
Unpacking ros-galactic-rqt-runtime-monitor (1.0.0-1focal.20211011.214754) ...
Setting up ros-galactic-rqt-gui-cpp-dbgsym (1.1.2-1focal.20211012.002304) ...
Setting up python3-rospkg (1.3.0-100) ...
Setting up ros-galactic-rqt (1.1.2-1focal.20211012.002712) ...
Setting up ros-galactic-rqt-image-view-dbgsym (1.1.1-2focal.20211012.002625) ...
Setting up ros-galactic-rqt-robot-steering (1.0.0-3focal.20211011.214902) ...
Setting up ros-galactic-rqt-robot-monitor (1.0.4-2focal.20211011.214754) ...
Setting up ros-galactic-rqt-moveit (1.0.1-2focal.20211011.215017) ...
Setting up ros-galactic-rqt-robot-dashboard (0.6.1-1focal.20211101.130855) ...
Setting up ros-galactic-rqt-runtime-monitor (1.0.0-1focal.20211011.214754) ...