参考:[d2slam的github地址](/https://github.com/HKUST-Aerial-Robotics/D2SLAM/)的Evaluation on single PC for multi-robot datasets 部分。
Prerequisite
- 安装ROS(省略)
- 安装python或先是anaconda/miniconda再create一个虚拟环境(省略)
- 下载数据集:百度网盘 请输入提取码 提取码: D2SL。下载到 ~/datasets 的目录中
- 安装docker(以下命令来自ChatGPT):
$ sudo apt update $ sudo apt install docker.io $ sudo systemctl enable --now docker
部署
- 创建工作空间:
$ mkdir -p ~/d2slam_ws/src
- 在主机部署,代码已经集成到shell和Python文件中。首先下载这个功能包:GitHub - HKUST-Swarm/sync_bag_player
$ cd ~/d2slam_ws/src/ $ git clone https://github.com/HKUST-Swarm/sync_bag_player
- 编译
$ cd .. $ catkin_make
如果报错:
-- Could NOT find PY_em (missing: PY_EM) CMake Error at /opt/ros/noetic/share/catkin/cmake/empy.cmake:30 (message): Unable to find either executable 'empy' or Python module 'em'... try installing the package 'python3-empy'
则改为:
$ catkin_make -DPYTHON_EXECUTABLE=/usr/bin/python3
-
(虚拟环境中的)Python至少安装了如下库,若无,需要在终端输入以下命令:
$ pip install pyyaml lcm readchar
- 修改 ~/datasets/d2vins.yaml 中的workspace为自己下载的路径:~/d2slam_ws/
- 运行:
如果报错:$ source ./devel/setup.bash $ rosrun sync_bag_player environment_setup.sh $ rosrun sync_bag_player docker_swarm_test.py ~/datasets/d2vins.yaml
则是权限不足,解决方式是在 "docker_swarm_test.py" 中第51行添加 "sudo ":docker: permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/create?name=swarm1_264300": dial unix /var/run/docker.sock: connect: permission denied.
cmd = f"""sudo docker run --name {container_name} --gpus all --rm -it \
如果报错:
Unable to find image 'd2slam:pc' locally docker: Error response from daemon: pull access denied for d2slam, repository does not exist or may require 'docker login': denied: requested access to the resource is denied.
说明没有安装镜像,请查阅我的前一篇文章:$D^2$SLAM(d2slam)ubuntu部署经验1:docker in PC-CSDN博客
最终没有运行成功,因为报错:
docker: Error response from daemon: could not select device driver "" with capabilities: [[gpu]].
解决方法可自行查找,但是都需要安装nvidia驱动,由于我的电脑存储空间不足,所以就不安装了。
需要安装docker的nvidia驱动,参考:
Docker 使用GPU 错误之Error could not select device driver ““ with capabilities: [[gpu]] - 知乎
总结就是:
$ distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
$ sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit
$ sudo systemctl restart docker
--2023/11/09更新--
找不到GPU是因为基础镜像不支持GPU,更换即可,详见我的前一篇文章:
实际运行
[rospack] Error: package 'sync_bag_player' not found
find: '': No such file or directory
[rosrun] Couldn't find executable named sync_rosplay.py below
find: '': No such file or directory
RLException: [quadcam.launch] is neither a launch file in package [d2vins] nor is [d2vins] a launch file name
这个意思是没找到这个 package ,但是我自己docker进去是可以的,问题出现在 docker_swarm_test.py 这个Python文件里的这段代码:
if workspace == "":
workspace_mount = ""
else:
workspace_mount = workspace+"/:/root/swarm_ws/"
cmd = f"""docker run --name {container_name} --gpus all --rm -it \
-v {workspace_mount} \
将本地工作空间的路径挂载到镜像里面的工作空间了,这样就找不到。修改方法也很简单,把这段去掉或者注释掉,但是不能在原来的地方注释。此问题也出现在该代码的Github仓库的issues里面:
Failed to replace the workspace in Docker · Issue #22 · HKUST-Aerial-Robotics/D2SLAM · GitHub
(补充一下,这里我把前面提到的 "sudo docker run" 中的 "sudo" 删掉了,因为我让docker不需要使用超级用户权限了,详情见我的d2slam部署经历1.5:
这下可以了,泪目。
记录下原来的标题:$D^2$SLAM(d2slam)ubuntu部署过程2(失败):Evaluation on single PC。这下不是失败了!
若有帮助,还望给一个小小的赞,不胜感激。