Ubuntu 编译 voxblox++

61 篇文章 1 订阅
4 篇文章 0 订阅

Ubuntu 编译 voxblox++

Ubuntu 16 & 18

准备环境

sudo apt install python-dev python-pip python-wstool protobuf-compiler dh-autoreconf
sudo pip install protobuf scipy scikit-image ipython 'keras==2.1.6'
sudo pip install tensorflow-gpu
gedit ~/.bashrc

添加

# voxblox++
export ROS_VERSION=melodic # (Ubuntu 16.04: kinetic, Ubuntu 18.04: melodic, Ubuntu 20.04 noetic)
export CATKIN_WS=~/catkin_ws

初始化 ROS 工作空间

mkdir -p $CATKIN_WS/src && cd $CATKIN_WS
catkin init
catkin config --extend /opt/ros/$ROS_VERSION --merge-devel
catkin config --cmake-args -DCMAKE_CXX_STANDARD=14 -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=Yes
wstool init src

下载资源

cd $CATKIN_WS/src
git clone --recurse-submodules https://github.com/ethz-asl/voxblox-plusplus.git
wstool merge -t . voxblox-plusplus/voxblox-plusplus_https.rosinstall
wstool update

Ubuntu 20

准备环境

sudo apt install python3-dev python3-pip python3-wstool protobuf-compiler dh-autoreconf
sudo pip3 install -U numpy protobuf scipy scikit-image ipython keras wrapt simplejson netaddr osrf-pycommon scipy pillow catkin_pkg rospkg opencv-python empy
sudo pip3 install -U tensorflow-gpu
sudo pip3 list | grep '[Kk]eras' # and uninstall all keras
sudo pip3 install keras==2.4.3
echo "\"# voxblox++
export ROS_VERSION=noetic # (Ubuntu 16.04: kinetic, Ubuntu 18.04: melodic, Ubuntu 20.04 noetic)
export CATKIN_WS=~/catkin_ws\" >> ~/.bashrc"

初始化 ROS 工作空间

mkdir -p $CATKIN_WS/src && cd $CATKIN_WS
catkin init
catkin config --extend /opt/ros/$ROS_VERSION --merge-devel
catkin config --cmake-args -DCMAKE_CXX_STANDARD=14 -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=Yes
wstool init src

下载资源

cd $CATKIN_WS/src
git clone --recurse-submodules https://github.com/ethz-asl/voxblox-plusplus.git
wstool merge -t . voxblox-plusplus/voxblox-plusplus_https.rosinstall
wstool update
cd pcl_catkin
rm -rf geometry2
git clone https://github.com/ros/geometry2.git
cd ..

修改源码

修改为支持 opencv4
vi depth_segmentation/depth_segmentation/src/depth_segmentation.cpp
:%s/CV_BGR2GRAY/cv::COLOR_BGR2GRAY/g
:%s/CV_CHAIN_APPROX_NONE/cv::CHAIN_APPROX_NONE/g
:%s/CV_FILLED/cv::FILLED/g
:wq
添加 Boost 依赖路径
vi pcl_catkin/pcl_catkin/cmake/pcl-extras.cmake.in

修改为

set(Boost_LIBRARIES /usr/lib/x86_64-linux-gnu/libboost_system.so;/usr/lib/x86_64-linux-gnu/libboost_filesystem.so;/usr/lib/x86_64-linux-gnu/libboost_thread.so)

# find_package(Boost REQUIRED COMPONENTS system filesystem thread)

# set(PCL_LIBRARIES ${PclLibraries};${VTK_LIBRARIES};@Boost_LIBRARIES@)
# set(@PROJECT_NAME@_LIBRARIES ${PclLibraries};${VTK_LIBRARIES};@Boost_LIBRARIES@)

set(PCL_LIBRARIES ${PclLibraries};${VTK_LIBRARIES};${Boost_LIBRARIES})
set(@PROJECT_NAME@_LIBRARIES ${PclLibraries};${VTK_LIBRARIES};${Boost_LIBRARIES})

# Same thing for include dirs.
set(PCL_INCLUDE_DIRS @CATKIN_DEVEL_PREFIX@/include/pcl-1.10;${VTK_INCLUDE_DIRS};@Boost_INCLUDE_DIRS@)
set(@PROJECT_NAME@_INCLUDE_DIRS @CATKIN_DEVEL_PREFIX@/include/pcl-1.10;${VTK_INCLUDE_DIRS};@Boost_INCLUDE_DIRS@)
修改 mask_rcnn_ros 运行根目录
vi mask_rcnn_ros/scripts/mask_rcnn_node.py

修改为

#!/usr/bin/env python3
import sys
import os

curPath = os.path.abspath(os.path.dirname(__file__))
rootPath = os.path.split(curPath)[0]
sys.path.append(rootPath + "/src/mask_rcnn_ros")
修改 mask_rcnn_ros 为支持 tf2.4.0+
vi mask_rcnn_ros/src/mask_rcnn_ros/model.py

查找并替换

import tensorflow as tf
->import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
devices = tf.config.experimental.list_physical_devices('GPU')
tf.config.experimental.set_memory_growth(devices[0], True)

import keras.engine as KE
->import keras.engine.topology as KE

mrcnn_bbox = KL.Reshape((s[1], num_classes, 4), name="mrcnn_bbox")(x)
->mrcnn_bbox = KL.Reshape((-1, num_classes, 4), name="mrcnn_bbox")(x)

indices = tf.stack([tf.range(probs.shape[0]), class_ids], axis=1)
->indices = tf.stack([tf.range(1000), class_ids], axis=1)

from keras.engine import topology
->from tensorflow.python.keras.saving import hdf5_format

if by_name:
	topology.load_weights_from_hdf5_group_by_name(f, layers)
else:
	topology.load_weights_from_hdf5_group(f, layers)
->if by_name:
	hdf5_format.load_weights_from_hdf5_group_by_name(f, layers)
else:
	hdf5_format.load_weights_from_hdf5_group(f, layers)
vi opencv3_catkin/CMakeLists.txt

查找并替换

-DWITH_GTK_2_X=ON
->-DWITH_GTK_2_X=OFF

修改 mask_rcnn_ros 为支持最新版本 scipy

vi mask_rcnn_ros/src/mask_rcnn_ros/utils.py

添加

from PIL import Image
def scipy_misc_imresize(arr, size, interp='bilinear', mode=None):
	# im = scipy.misc.toimage(arr, mode=mode) # im为PIL.Image.Image对象
	im = Image.fromarray(arr, mode=mode)
	ts = type(size)
	if np.issubdtype(ts, np.signedinteger):
		percent = size / 100.0
		size = tuple((np.array(im.size)*percent).astype(int))
	elif np.issubdtype(type(size), np.floating):
		size = tuple((np.array(im.size)*size).astype(int))
	else:
		size = (size[1], size[0])
	func = {'nearest': 0, 'lanczos': 1, 'bilinear': 2, 'bicubic': 3, 'cubic': 3}
	imnew = im.resize(size, resample=func[interp]) # 调用PIL库中的resize函数
	# return scipy.misc.fromimage(imnew)
	return np.array(imnew)

修改为

:%s/scipy\.misc\.imresize/scipy_misc_imresize/g

编译源码

catkin build mask_rcnn_ros depth_segmentation gsm_node

下载环境包(大流量预警)

7.9G

wget http://robotics.ethz.ch/~asl-datasets/RAL-2019-voxblox-plusplus/scenenn_231/scenenn_231.bag

6.3G

wget http://robotics.ethz.ch/~asl-datasets/RAL-2019-voxblox-plusplus/office_floor/asl_office_floor.bag

下载预训练模型

cd $CATKIN_WS/src/mask_rcnn_ros/scripts
gedit mask_rcnn_node_download.py

添加

#!/usr/bin/env python
import os
from mask_rcnn_ros import utils

# Local path to trained weights file
ROS_HOME = os.environ.get('ROS_HOME', os.path.join(os.environ['HOME'], '.ros'))
COCO_MODEL_PATH = os.path.join(ROS_HOME, 'mask_rcnn_coco.h5')

utils.download_trained_weights(COCO_MODEL_PATH)

需要 pch 走 socks5

python mask_rcnn_node_download.py

在环境包上运行程序

roslaunch gsm_node scenenn_dataset.launch bag_file:=<path-to-.bag-file>

正常会出现

一个 Map1 可交互实时重建查看窗口
一个实时逐帧语义分割结果窗口

接口说明

详情见

https://github.com/ethz-asl/voxblox-plusplus/wiki/The-voxblox-plusplus-node

尽情享用吧~

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值