目录
conda create -n randros38 python=3.8
conda activate randros38
mkdir -p rosrandla_ws/src
cd rosrandla/src
git clone https://github.com/corenel/ros-randla-net.git
cd ros-randla-net
pip install -r requirements.txt
pip install rospkg catkin-pkg catkin-tools empy
requirements.txt文件内容:
numpy>=1.16
torch
torchvision
future
pandas
sklearn
python-pcl
tensorboardX
tqdm
open3d==0.9.0
安装pytorch时选择可以运用gpu的版本例如我的环境是cuda11.3,我的安装命令式:
# CUDA 11.3
pip install torch==1.11.0+cu113 torchvision==0.12.0+cu113 torchaudio==0.11.0 --extra-index-url https://download.pytorch.org/whl/cu113
在python3环境下使用该编译文件,如果是在python2环境下,使用该目录下的另一个编译文件
./script/build_deps_py3.sh
在工作空间下?
catkin_make
/home/liyan/anaconda3/envs/randros38/lib/python3.8/site-packages/setuptools/_distutils/cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated. !! ******************************************************************************** Please avoid running setup.py directly. Instead, use pypa/build, pypa/installer or other standards-based tools. See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details. ********************************************************************************
修改:
调低setuptools的版本到60以下,果然没有安装什么什么的经典报错了
pip uninstall setuptools
pip install setuptools==58
gcc -pthread -B /home/liyan/anaconda3/envs/randros37/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I./ -I/home/liyan/anaconda3/envs/randros37/lib/python3.7/site-packages/numpy/core/include -I/home/liyan/anaconda3/envs/randros37/include/python3.7m -c knn.cxx -o build/temp.linux-x86_64-3.7/knn.o -std=c++11 -fopenmp gcc: error: knn.cxx: 没有那个文件或目录 error: command 'gcc' failed with exit status 1
关于这个knn文件,用vscode打开项目文件,然后搜索knn.cxx,发现有一个文件中显示的是knn.cxx,但是项目中的相关文件是knn_.cxx,所以把文件中调用的改成knn_.cxx,编译之后这个报错没有了,应该编译结果没问题了吧。
roslaunch ros_randla_net pointcloud_segmentation.launch
Command 'roslaunch' not found, but can be installed with: sudo apt install python-roslaunch
按照指示安装相对应的包,会出现一系列关于缺失ros包的报错
python-roslaunch : 依赖: python-roslib 但是它将不会被安装 python-roslib : 依赖: catkin 但是它将不会被安装 catkin : 依赖: python-catkin-pkg 但是它将不会被安装
根据提示安装以下ros包,再次运行,还是会出现相同的报错
然后发现启动roscore无法启动,
Command 'roscore' not found, but can be installed with: sudo apt install python-roslaunch
经过查资料,发现ros没有安装完整版,ros包有缺失,指令 “roscore” 之所以能够被执行,首先需要在文件夹 “/opt/ros/indigo/bin/” 里面存在名为 “roscore” 的二进制可执行文件,打开文件夹,检查文件是否存在,发现相关文件并不存在,然后输入sudo apt-get install ros-melodic-desktop,如果执行这条命令后没有相关文件产生,那么就sudo apt-get update,然后再执行sudo apt-get install ros-melodic-desktop的命令,最终对应文件中有相应的文件,可以成功执行roscore和roslaunch
process[ros_randla_net-1]: started with pid [26347] Traceback (most recent call last): File "/home/liyan/randla_ws/src/ros-randla-net/src/ros_main.py", line 11, in <module> from ros_node import InferenceNode File "/home/liyan/randla_ws/src/ros-randla-net/src/ros_node.py", line 13, in <module> import ros_helper File "/home/liyan/randla_ws/src/ros-randla-net/src/ros_helper.py", line 4, in <module> import pcl File "/home/liyan/anaconda3/envs/randros37/lib/python3.7/site-packages/pcl/__init__.py", line 2, in <module> from ._pcl import * ImportError: libpcl_keypoints.so.1.7: cannot open shared object file: No such file or directory [ros_randla_net-1] process has died [pid 26347, exit code 1, cmd /home/liyan/randla_ws/src/ros-randla-net/src/ros_main.py __name:=ros_randla_net __log:=/home/liyan/.ros/log/f08db64e-8d2c-11ee-b086-10e7c6dc155f/ros_randla_net-1.log]. log file: /home/liyan/.ros/log/f08db64e-8d2c-11ee-b086-10e7c6dc155f/ros_randla_net-1*.log all processes on machine have died, roslaunch will exit shutting down processing monitor... ... shutting down processing monitor complete done
主要报错就是
ImportError: libpcl_keypoints.so.1.8: cannot open shared object file: No such file or directory
解决:
在Ubuntu20.04中,python-pcl库已经还没有支持到Ubuntu20.04,所以采用python3-pcl库,python3-pcl库安装命令是
sudo apt install python3-pcl
安装完成后将系统目录 /usr/lib/python3/dist-packages/ 目录下的pcl和python_pcl-0.3.egg-info两个文件夹放在conda环境 /anaconda3/envs/rosrand38/lib/python3.8/site-packages/ 目录下,然后验证pcl库
python
import pcl
如果没有报错,则说明导入成功。
Ubuntu18.04直接安装python-pcl库在这一步也会出现问题,具体解决方法参考下面这个作者的解决方法,亲测有效。?
根据这篇文章做了相对应的操作,完美解决报错。