ROS2与docker入门教程-windows桌面显示docker中turtlesim
文章说明
- 介绍如何在windows中使用docker里的turtlesim
- 环境:windows + mobaxterm, ubuntu + docker
安装和启动docker
# 安装
docker pull osrf/ros:humble-desktop
# 启动
docker run -it osrf/ros:humble-desktop
- 启动docker之后,可以输入ros2查看是否正常启动
ubuntu@AiROS2-NUC:~$ ros2
usage: ros2 [-h] Call `ros2 <command> -h` for more detailed usage. ...
ros2 is an extensible command-line tool for ROS 2.
optional arguments:
-h, --help show this help message and exit
Commands:
action Various action related sub-commands
bag Various rosbag related sub-commands
component Various component related sub-commands
daemon Various daemon related sub-commands
doctor Check ROS setup and other potential issues
interface Show information about ROS interfaces
launch Run a launch file
lifecycle Various lifecycle related sub-commands
multicast Various multicast related sub-commands
node Various node related sub-commands
param Various param related sub-commands
pkg Various package related sub-commands
run Run a package specific executable
security Various security related sub-commands
service Various service related sub-commands
topic Various topic related sub-commands
wtf Use `wtf` as alias to `doctor`
Call `ros2 <command> -h` for more detailed usage.
下载工具
- 下载工具mobaxterm,地址
- 利用mobaxterm远程登录到安装了docker的ubuntu系统
桌面显示
- 确保安装 mobaxterm windows电脑和安装docker的ubuntu电脑在同一个网络下
- windows ip:192.168.0.16
- ubuntu ip:192.168.0.42
- 通过mobaxterm登录ubuntu系统,启动docker中的turtlesim
- 执行命令
# 启动docker镜像
docker run -it --privileged \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-e DISPLAY=192.168.0.16:0 osrf/ros:humble-desktop
# 启动小乌龟
ros2 run turtlesim turtlesim_node
mobaxterm会询问是否显示界面在windows中,确认后,出现小乌龟的界面
通过mobaxterm登录ubuntu系统,启动docker中的键盘控制
执行命令
# 启动docker镜像
docker run -it --privileged \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-e DISPLAY=192.168.0.16:0 osrf/ros:humble-desktop
# 启动键盘控制
ros2 run turtlesim turtle_teleop_key
- 通过键盘的方向键就可以控制小乌龟移动,根据你网络情况,移动可能很慢。
演示
- 相关软件已经安装,镜像已经下载,演示具体操作
获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号