参照 windows 下使用docker搭建ROS_windos docker ros-CSDN博客
可以安装melodic支持Ubuntu 18.04,也可以安装noetic支持Ubuntu 20.04;
下面是安装的melodic的示例,也可以安装noetic。
1、安装docker
拉取镜像: docker pull osrf/ros:melodic-desktop-full
拉取并运行: docker run -it -p 6000:22 -p 6001:8080 –name=base-ros-melodic osrf/ros:melodic-desktop-full /bin/bash
2、新建一个 Dockerfile 文件后写入下面的
FROM osrf/ros:melodic-desktop-full
# nvidia-container-runtime
ENV NVIDIA_VISIBLE_DEVICES
${NVIDIA_VISIBLE_DEVICES:-all}
ENV NVIDIA_DRIVER_CAPABILITIES
${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics
Dockerfile 接下去
RUN apt-get update &&
apt-get install -y
build-essential
libgl1-mesa-dev
libglew-dev
libsdl2-dev
libsdl2-image-dev
libglm-dev
libfreetype6-dev
libglfw3-dev
libglfw3
libglu1-mesa-dev
freeglut3-dev
vim
3、构建docker容器rocker
docker build -t rocker .
docker run -it –group-add video –volume=/tmp/.X11-unix:/tmp/.X11-unix –env=”DISPLAY=$DISPLAY” –name=rocker osrf/ros:melodic-desktop-full /bin/bash
4、windows上打开cmd,并进入容器启动ros节点
进入容器
docker attach rocker
自动配置ros环境
./ros_entrypoint.sh
启动ros节点
roscore
5、切换到 bash shell 然后再 source:
bash –login
source /opt/ros/melodic/setup.bash
恭喜,可用rosbag相关的命令啦!
rosbag info