orbslam2语义分割
仓库:wuhong1223/semantic_slam
环境ubuntu18.04 python27
一、下载仓库代码
cd /home/wheeltec-client/workspace/srcgit clone https://gitee.com/wuhong1223/semantic_slam
二、编译orb-slam2
需要安装依赖,自行百度
编译
cd /home/wheeltec-client/workspace/src/semantic_slam/ORB_SLAM2./build.sh
三、安装语义分割依赖
# 更新包列表
sudo apt update
sudo apt-get install ros-melodic-openni2-launch# 更新包列表
sudo apt update# 安装 Melodic 版本的 octomap 相关包
sudo apt-get install ros-melodic-octomap-ros
sudo apt-get install ros-melodic-octomap-msgs
sudo apt-get install ros-melodic-octomap-server
sudo apt-get install ros-melodic-octomap-rviz-pluginspip 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
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
pip install protobuf
四、安装semantic_slam
cd /home/wheeltec-client/workspace/rosdep install --from-paths semantic_slam --ignore-src --rosdistro=kinetic -r -ycatkin build
编译成功后试运行
1、打开深度相机
source wheeltec_robot/devel/setup.bash
roslaunch semantic_slam camera.launch
2、打开新终端运行slam
roslaunch semantic_slam slam.launch
3、打开新终端运行语义分割
roslaunch semantic_slam semantic_mapping.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)
修改semantic_slam/semantic_cloud/src/semantic_cloud.py123行为:
state = torch.load(model_path, map_location={'cuda:0': 'cpu'})
回workspace目录重新编译rm -rf build devel
catkin build
重新运行