semantic_slam环境配置

orb_slam2 + 语义分割 + 八叉树地图,
github地址:https://github.com/floatlazer/semantic_slam

根据github上环境的版本要求,选择在ubuntu16.04的docker容器中搭建

首先pull了一个ubuntu16.04 + python2.7 + opencv3.3.0的镜像,在这个基础上搭建环境

1.download semantic slam的code
在$HOME下

$ mkdir catkin_ws
$ cd catkin_ws
$ mkdir src
$ cd src
$ git clone https://github.com/floatlazer/semantic_slam.git

2.安装orb slam2的环境
参考了https://www.jianshu.com/p/dbf39b9e4617
这中间涉及到ros, pangolin, eigen等的安装

进入sematic_slam文件夹中的ORB_SLAM2文件夹,build成功即可

3.安装语义分割相关
按照semantic slam的github中的要求

$ sudo apt-get install ros-kinetic-openni2-launch

4.安装八叉树地图相关

sudo apt-get install ros-kinetic-octomap-ros
sudo apt-get install ros-kinetic-octomap-msgs
sudo apt-get install ros-kinetic-octomap-server
sudo apt-get install ros-kinetic-octomap-rviz-plugins

5.安装语义分割相关

pip install torch-0.4.0-cp27-cp27mu-linux_x86_64.whl #1.0之前的版本要在官网上下载
pip install torchvision==0.2.0
pip install numpy
pip install future
pip install matplotlib

然后github上说依赖pytorch-semseg
打开pytorch-semseg中的requirements.txt, 看到里面还有一些依赖要安装

pip install scikit-image
pip install opencv-python==3.3.0.10
pip install tqdm==4.11.2
pip install cython
pip install pydensecrf
pip install tensorboardX
pip install scipy==0.19.0
pip install imgaug

然后安装semantic_slam包

$ rosdep install semantic_slam
ERROR: the following packages/stacks could not have their rosdep keys resolved
to system dependencies:
semantic_slam: Cannot locate rosdep definition for [catkin]

这一步会报找不到相关依赖的错误
命令改为:

$ rosdep install --from-paths semantic_slam --ignore-src --rosdistro=kinetic -r -y
#All required rosdeps installed successfully

这些都安装好之后,到~/catkin_ws下catkin_make

开始启动launch:

roslaunch semantic_slam semantic_mapping.launch

会报如下错误:
ImportError: No module named google.protobuf.internal
解决方法:

pip install protobuf

再启动launch:
会报错:AttributeError: ‘module’ object has no attribute ‘_cuda_getDevice’
Traceback (most recent call last):
File “/home/xx/catkin_ws/src/semantic_slam/semantic_cloud/src/semantic_cloud.py”, line 295, in
main(sys.argv)
File “/home/xx/catkin_ws/src/semantic_slam/semantic_cloud/src/semantic_cloud.py”, line 288, in main
seg_cnn = SemanticCloud(gen_pcl = True)
File “/home/xx/catkin_ws/src/semantic_slam/semantic_cloud/src/semantic_cloud.py”, line 123, in init
state = torch.load(model_path)

这是因为它的weight, 也就是pth文件,是用GPU训练出来的,
而docker里面没有GPU, 要把这个pth转为cpu模式:
把这个 state = torch.load(model_path)
改为:

state = torch.load(model_path, map_location={'cuda:0': 'cpu'})

到~/catkin_ws下

$ rm -rf build devel
$ catkin_make

再试一次

$ roslaunch semantic_slam semantic_mapping.launch
[ INFO] [1655366319.121127159]: Semantic octomap generator [max fusion]
Generate semantic point cloud [max fusion].
Setting up CNN model...
Setting up ROS...
Ready.

另起一个窗口

$ rosbag play demo.bag

图建出来了
在这里插入图片描述

  • 4
    点赞
  • 41
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 10
    评论
Semantic SLAM是一种基于语义分割技术的同时定位与建图方法。它结合了ORB-SLAM2和八叉树地图,并通过使用语义分割技术来增强SLAM系统的感知能力。Semantic SLAM的GitHub地址是https://github.com/floatlazer/semantic_slam 。 在开始使用semantic_slam包之前,您需要先安装一些依赖项。根据引用提供的信息,安装过程中可能会出现一个错误,提示无法解析rosdep定义。这意味着可能需要检查您的系统中是否安装了catkin,因为semantic_slam依赖于catkin。确保您已正确安装catkin后,您可以继续安装semantic_slam包。 安装完依赖项后,您可以启动semantic_mapping.launch文件来启动Semantic SLAM系统。根据引用提供的信息,您可以使用以下命令启动launch文件:roslaunch semantic_slam semantic_mapping.launch。 启动后,semantic_mapping.launch文件将开始执行Semantic SLAM算法,同时定位与建图,并将语义信息与地图进行关联,从而提高系统的感知能力。 总结起来,Semantic SLAM是一种基于语义分割的同时定位与建图方法,它结合了ORB-SLAM2和八叉树地图。您可以从GitHub地址https://github.com/floatlazer/semantic_slam获取该方法的实现代码。在使用semantic_slam包之前,您需要安装catkin作为依赖项,并确保已成功安装并配置相关的依赖项后,您可以使用roslaunch命令启动semantic_mapping.launch文件来启动Semantic SLAM系统。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

蓝羽飞鸟

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值