ubuntu22.04运行VINS-Mono

此文档记录了如何在ubuntu 22.04中使用docker(ubuntu 18.04) + ROS进行VINS-Mono实验。

1.安装Docker

https://docs.docker.com/desktop/install/ubuntu/

2.运行docker container

可以通过在宿主机安装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

3.ROS安装 + VINS编译运行

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 

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值