【点云检测】OpenPCDet 教程系列 [1] 安装 与 ROS运行

前言与参考

主要是介绍库的使用,做笔记区

首先搜索的时候有个问题 一直在我脑子里 hhh 就是MMlab其实还有一个叫mmdetection3d 的库,然后搜的时候发现 hhh 有网友和我一样的疑惑:OpenPCDet和mmdetection3d有什么区别 ? – 知乎 (zhihu.com)

这是OpenMMLab官方的回复:

OpenPCDet 和 mmdetection3d 是两个不同的团队开发和维护的。

从功能角度上讲,mmdet3d 支持的场景和任务更多(包含室内室外场景的物体检测和点云分割),各种模态设定更全面(多模态,以及点云或图像的单模态),总体支持的模型数量更多,覆盖面更广,可以适应不同用户多样的使用和研发需求。OpenPCDet 主要聚焦在基于点云的 3D 目标检测这一种设定上,代码结构相对简单轻量一些。从更新维护的频率上看,MMDet3D 的更新和维护更加频繁,保持了月度的版本更新。

作者:OpenMMLab

链接:https://www.zhihu.com/question/489303511/answer/2206147084

来源:知乎,著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

相关ROS版本的代码参考:

  1. https://github.com/Cram3r95/OpenPCDet-ROS
  2. https://github.com/kwea123/ROS_notes

本博客还有一个视频手把手教程,主要是配合此博文同时教学Docker使用,毕竟不是所有人都想用20.04,视频比较基础 建议倍速播放:https://www.bilibili.com/video/BV1xe4y1j72q

这个系列主要是自己学习过程的记录,本文首次书写于: December 24, 2022 可能会随着时间的变化 此教程会有过时概念哦

测试环境

测试环境:

  • 本机环境:i9-12900KF, GPU 3090, CUDA 11.3
  • 本机系统:Ubuntu 20.04, ROS noetic (Python 3.8)
  • 使用的repo和对应的commit:
    • https://github.com/Kin-Zhang/OpenPCDet commit 977cd1c
    • https://github.com/Kin-Zhang/OpenPCDet_ros commit 7a39361

安装与运行

本机环境的话,建议使用测试环境,如果不想换系统,建议从**目录直接跳转Docker运行**

本机坏境下

数据集 (无ROS)

注意一定要先安装OpenPCDet 才能进行ROS 实时/BAG的显示哈

以下为 能运行的版本

git clone https://github.com/Kin-Zhang/OpenPCDet
cd OpenPCDet
# please install in your own env
pip install torch==1.10.0+cu113 torchvision==0.11.0+cu113 torchaudio==0.10.0 -f https://download.pytorch.org/whl/torch_stable.html
pip install spconv-cu113
sudo apt-get install python-setuptools

# have some potential risks
sudo chown -R $USER /usr/local/lib/python3.8/
sudo chown -R $USER /usr/local/bin/
# have some potential risks

python3 setup.py develop

然后截图如下为成功安装:

然后我们下载一个model 和 放一个kitti的一帧数据,运行demo.py即可看到效果:

cd tools
python3 demo.py --cfg_file cfgs/kitti_models/pv_rcnn.yaml \
    --ckpt pv_rcnn_8369.pth \
    --data_path 000002.bin

遇到的错误总结:

  1. pip install failing with: OSError: [Errno 13] Permission denied on directory, reference link

    给权限就行

    # have some potential risks
    sudo chown -R $USER /usr/local/lib/python3.8/
    sudo chown -R $USER /usr/local/bin/
    # have some potential risks
    
  2. CUDA版本必须和自己的本机安装的版本对应上,因为develop.py里会检查安装的pytorch版本、CUDA、spconv

    显卡驱动与CUDA安装:

    Ubuntu下的NVIDIA显卡【驱动&CUDA 安装与卸载】

  3. THC/THC.h: No such file or directory

    !!!Torch不能高于10.0,相关issue链接:https://github.com/open-mmlab/mmdetection3d/issues/1332,https://github.com/1ytic/warp-rnnt/issues/35

  4. RuntimeError: Python version >= 3.8 required.

    解决办法,使用py3.8

ROS 实时/BAG

注意:一定要根据上面先安装好OpenPCDet哈!并且是直接安装在系统默认的py38下的 这样才能和ROS链接起来,后面我放个Dockerfile 这样无论什么版本都能拿这个topic就行

结合参考内容自己进行了一点修改,主要是 以2的boundingbox为主 去掉1的一些没啥必要的依赖,代码地址为:https://github.com/Kin-Zhang/OpenPCDet_ros,依赖处理情况 基本就是有ROS即可,但是仅在ROS noetic测试了 因为noetic 默认的py3.8

我后面再好好重构一下,但是现在也是能用的 hhh 只是README 写的可能太简洁了,配合这个博文读会更好一些

实时跑的情况,就是数据在BAG里,理论上这个跑通了 也可以放在实际车上部署(只是py估计真用上产品实车肯定还是不太行的哈

遇到的一些问题:

  1. glog print在ros_init后无法log使用,详情见:https://github.com/ros/ros_comm/issues/1384

后面有问题可以评论区留言 我再加进来

Docker container

首先是nvidia-docker的插件安装:

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

Build 或者 pull image 选一个:

# choose one!
# option A: pull
docker pull zhangkin/openpcdet:ros
# option B: build by yourself
git clone https://github.com/Kin-Zhang/OpenPCDet_ros.git && cd OpenPCDet_ros
docker build -t zhangkin/openpcdet:ros .

run 一个容器:

# if you want to display open3d, check the reference for more info
xhost +local:docker
docker run -it --net=host --gpus all -e DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix --name pcdet_ros zhangkin/openpcdet:ros /bin/zsh

# if not, simple one
docker run -it --net=host --gpus all --name pcdet_ros zhangkin/openpcdet:ros /bin/zsh

编译OpenPCDet

cd OpenPCDet && python3 setup.py develop
# After screen print: Finished processing dependencies for pcdet==0.6.0

# Test step cp model and test pcd to container:
docker cp /home/kin/workspace/OpenPCDet/tools/pv_rcnn_8369.pth pcdet_ros:/home/kin/workspace/OpenPCDet/tools/
docker cp /home/kin/workspace/OpenPCDet/tools/000002.bin pcdet_ros:/home/kin/workspace/OpenPCDet/tools

# test demo
cd tools && python3 demo.py --cfg_file cfgs/kitti_models/pv_rcnn.yaml \
    --ckpt pv_rcnn_8369.pth \
    --data_path 000002.bin

然后在直接走到ros版本

cd /home/kin/workspace/OpenPCDet_ws
catkin build && source devel/setup.zsh
roslaunch openpcdet 3d_object_detector.launch

如图为示意:

赠人点赞 手有余香 😆;正向回馈 才能更好开放记录 hhh

文章出处登录后可见!

已经登录?立即刷新

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(0)
扎眼的阳光的头像扎眼的阳光普通用户
上一篇 2023年7月28日
下一篇 2023年7月28日

相关推荐