赞
踩
此文档记录了如何在ubuntu 22.04中使用docker(ubuntu 18.04) + ROS进行VINS-Mono实验。
https://docs.docker.com/desktop/install/ubuntu/
- 可以通过在宿主机安装xserver,将docker容器视为客户端,
- 通过网络或挂载的方式就可以实现将需要显示的图像显示在宿主机显示器。
- 网络方式:
- A.在宿主机
- 查看宿主机IP
- $ ifconfig ##假设为xxx.xxx.xxx.xx
- 查看当前显示的环境变量值
- $ echo $DISPLAY (要在显示屏查看,其他ssh终端不行) ##假设为:0
- 或通过socket文件分析:
- $ ll /tmp/.X11-unix/ ##假设为X0= ---> :0
-
- 安装xserver
- $ sudo apt install x11-xserver-utils
- $ sudo vim /etc/lightdm/lightdm.conf
- 增加许可网络连接
- [SeatDefaults]
- xserver-allow-tcp=true
- 重启xserver
- $ sudo systemctl restart lightdm
- 许可所有用户都可访问xserver
- xhost +
-
- B.在docker 容器内
- # export DISPLAY=xxx.xxx.xxx.xx:0
- 注意:环境变量设置需要每次进docker设置,可以写在:/etc/bash.bashrc 文件中,避免每次进终端时设置
-
- 挂载方式:
- A.在宿主机
- 查看宿主机IP
- $ ifconfig ##假设为xxx.xxx.xxx.xx
- 查看当前显示的环境变量值
- $ echo $DISPLAY (要在显示屏查看,其他ssh终端不行) ##假设为:0
- 或通过socket文件分析:
- $ ll /tmp/.X11-unix/ ##假设为X0= ---> :0
-
- 安装xserver
- $ sudo apt install x11-xserver-utils
- 许可所有用户都可访问xserver
- xhost +
-
-
- B.在docker 容器创建时
- -v /tmp/.X11-unix:/tmp/.X11-unix
- -e DISPLAY=:0
-
- 例如:
- docker run -itd --name 容器名 -h 容器主机名 --privileged \
- -v /tmp/.X11-unix:/tmp/.X11-unix \
- -e DISPLAY=:0 镜像名或id /bin/bash
- # 建议使用挂载方式
- docker pull ubuntu:18.04
- docker run -it --name vins2 --privileged -v /home/huangsen:/home/huangsen -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=:0.0 ubuntu:18.04 /bin/bash
- docker exec -it vins2 /bin/bash
http://wiki.ros.org/cn/melodic/Installation/Ubuntu
- vim /etc/apt/sources.list
-
- deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
- deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
- deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
- deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
- deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
- deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
- deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
- deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
- deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
- deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
-
- # https://blog.csdn.net/Williamcsj/article/details/123384482
- apt-get update
- apt install lsb-core
- sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
- sh -c '. /etc/lsb-release && echo "deb http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list'
-
- apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
- apt update
- apt install ros-melodic-desktop-full
-
- apt-get install python-rosdep
- rosdep init
- rosdep update
-
- echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
- source ~/.bashrc
-
- apt-get install python-rosinstall python-rosinstall-generator python-wstool build-essential
- #要安装合适的显卡驱动
- apt install nvidia-driver-525
- nvidia-smi
- #ceres 安装
- http://ceres-solver.org/installation.html
-
-
- cd ~
- mkdir -p catkin_ws/src
- cd ~/catkin_ws/src
- git clone https://github.com/HKUST-Aerial-Robotics/VINS-Mono.git
- cd ../
- catkin_make
- source ~/catkin_ws/devel/setup.bash
-
- #Open three terminals, launch the vins_estimator, rviz and play the bag file respectively.
- cd ~/catkin_ws
- roslaunch vins_estimator euroc.launch
- roslaunch vins_estimator vins_rviz.launch
- rosbag play YOUR_PATH_TO_DATASET/MH_01_easy.bag
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。