欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

世界再一次被我拯救

程序员文章站 2022-03-03 12:42:06
...

最近一直想要实现在ROS运行python3,但是搞砸了很多,其中有一些报错让我不得不重视一些之前没研究过的毛病。
1.cmake 中的find_package
2.错误:Could not find a package configuration file provided by xxx
当我们

FIND_PACKAGE( OpenCV REQUIRED ) 时

系统默认在/usr/share/OpenCV下找OpenCVConfig.cmake,确定引入的Opencv的头文件和库文件的位置。

我在catkin_make的中途报错,因为在navigation的pkg的fake_localization中的CMakelist.txt有一句find_package(Boost REQUIRED COMPONENTS signals)

CMake Error at /usr/local/lib/cmake/Boost-1.72.0/BoostConfig.cmake:120 (find_package):
  Could not find a package configuration file provided by "boost_signals"
  (requested version 1.72.0) with any of the following names:

    boost_signalsConfig.cmake
    boost_signals-config.cmake

  Add the installation prefix of "boost_signals" to CMAKE_PREFIX_PATH or set
  "boost_signals_DIR" to a directory containing one of the above files.  If
  "boost_signals" provides a separate development package or SDK, be sure it
  has been installed.
Call Stack (most recent call first):
  /usr/local/lib/cmake/Boost-1.72.0/BoostConfig.cmake:185 (boost_find_component)
  /usr/share/cmake-3.5/Modules/FindBoost.cmake:245 (find_package)
  navigation/fake_localization/CMakeLists.txt:17 (find_package)

python2安装教程,BOOST下载,安装及卸载BOOST
我之前是没有安装BOOST的,安装BOOST之后有尝试过很多个路径,如果在后面加了prefix参数则会安装include和lib在对应的目录下,如果不加,装好后,默认的头文件在/usr/local/include /boost目录下。库文件在/usr/local/lib/目录下。
如果编译好程序后,在运行时提示无法加载某个库文件,则把/usr/local/lib下的所有boost的库文件mv到/usr/lib目录下就可以了。
卸载方法:直接将以上两个目录中有关boost的内容删除就可以了。
检查过后发现除了在usr/local/include/boost这里貌似有一些signals signals2.hpp的头文件
以及在usr/local/lib下发现一些libboost开头的.so文件之外(可以看到是之前安装的时候安装的python2.7版本的1.67和python3.4的1.72)
其他地方是没有boost库的痕迹的。
将usr/local/lib下所有libboost开头的文件放到别的文件夹之后,我们开始python2的boost的安装
reference
./b2 install (默认安装的话是将头文件放在/usr/local/include/boost文件夹中,库文件放在/usr/local/lib当中)
这样的话在cm的时候依然是找不到的,我们接下来按照 ./b2 install --prefix=/usr进行安装
依然没找到,那说明这个不是普通的没有安装boost的问题
我们看报错

CMake Error at /usr/local/lib/cmake/Boost-1.72.0/BoostConfig.cmake:120 (find_package):
Could not find a package configuration file provided by “boost_signals”
(requested version 1.72.0) with any of the following names:

这说明Boost这个文件夹有问题,删除之后果然可以开始编译,虽然还有如下报错,我们之后再进行python3的Boost安装(如果有需要的话)

/usr/bin/ld: warning: libcudart.so.8.0, needed by /home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libcublas.so.8.0, needed by /home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libcurand.so.8.0, needed by /home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so, not found (try using -rpath or -rpath-link)
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘cudaGetDevice’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘cudaSetupArgument’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘cudaFreeHost’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘cudaStreamCreateWithFlags’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘cublasDdot_v2’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘cudaMemcpyAsync’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘cudaMallocHost’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘cudaGetDeviceProperties’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘cudaStreamCreate’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘cublasDscal_v2’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘cudaConfigureCall’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘cublasDestroy_v2’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘cublasDasum_v2’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘cudaSetDevice’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘cudaGetErrorString’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘cudaEventElapsedTime’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘cublasSaxpy_v2’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘curandSetGeneratorOffset’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘cudaStreamDestroy’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘cublasDgemm_v2’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘cudaGetDeviceCount’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘cublasSasum_v2’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘__cudaRegisterFunction’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘cublasCreate_v2’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘cudaFree’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘cudaPeekAtLastError’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘cublasSetStream_v2’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘cudaEventDestroy’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘__cudaUnregisterFatBinary’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘curandGenerateUniform’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘__cudaRegisterFatBinary’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘curandGenerateUniformDouble’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘cudaGetLastError’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘cudaMalloc’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘cudaMemcpy’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘cublasDaxpy_v2’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘__cudaRegisterVar’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘curandCreateGenerator’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘cublasScopy_v2’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘cudaMemset’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘cublasSgemv_v2’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘cublasSdot_v2’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘curandSetPseudoRandomGeneratorSeed’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘cudaStreamSynchronize’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘curandDestroyGenerator’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘cublasDcopy_v2’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘curandGenerateNormalDouble’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘cublasSgemm_v2’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘cublasDgemv_v2’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘cublasGetStream_v2’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘cudaLaunch’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘cudaEventSynchronize’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘curandGenerate’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘cublasSscal_v2’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘cudaEventCreate’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘curandGenerateNormal’未定义的引用
/home/asber/catkin_ws/src/ros_caffe/caffe/build/lib/libcaffe.so:对‘cudaEventRecord’未定义的引用

去掉ros_caffe之后报错

Traceback (most recent call last):
  File "/home/asber/catkin_ws/src/rbx1/rbx1_nav/cfg/CalibrateAngular.cfg", line 5, in <module>
    from dynamic_reconfigure.parameter_generator_catkin import *
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/dynamic_reconfigure/__init__.py", line 38, in <module>
    import roslib
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/roslib/__init__.py", line 50, in <module>
    from roslib.launcher import load_manifest
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/roslib/launcher.py", line 42, in <module>
    import rospkg
ImportError: No module named rospkg
Checking md5sum on /home/asber/catkin_ws/devel/share/pcl_ros/samples/data/table_scene_lms400.pcd
rbx1/rbx1_nav/CMakeFiles/rbx1_nav_gencfg.dir/build.make:65: recipe for target '/home/asber/catkin_ws/devel/include/rbx1_nav/CalibrateAngularConfig.h' failed
make[2]: *** [/home/asber/catkin_ws/devel/include/rbx1_nav/CalibrateAngularConfig.h] Error 1
make[2]: *** 正在等待未完成的任务....
Traceback (most recent call last):
  File "/home/asber/catkin_ws/src/rbx1/rbx1_nav/cfg/CalibrateLinear.cfg", line 5, in <module>
    from dynamic_reconfigure.parameter_generator_catkin import *
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/dynamic_reconfigure/__init__.py", line 38, in <module>
    import roslib
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/roslib/__init__.py", line 50, in <module>
    from roslib.launcher import load_manifest
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/roslib/launcher.py", line 42, in <module>
    import rospkg
ImportError: No module named rospkg
rbx1/rbx1_nav/CMakeFiles/rbx1_nav_gencfg.dir/build.make:83: recipe for target '/home/asber/catkin_ws/devel/include/rbx1_nav/CalibrateLinearConfig.h' failed
make[2]: *** [/home/asber/catkin_ws/devel/include/rbx1_nav/CalibrateLinearConfig.h] Error 1
CMakeFiles/Makefile2:8121: recipe for target 'rbx1/rbx1_nav/CMakeFiles/rbx1_nav_gencfg.dir/all' failed
make[1]: *** [rbx1/rbx1_nav/CMakeFiles/rbx1_nav_gencfg.dir/all] Error 2
[ 15%] Built target table_scene_lms400.pcd
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j4 -l4" failed

catkin config --no-cmake-args之后还是这样报错
然后我现在在系统默认的python环境下,cm结果一样,这不得不怀疑可能系统这边的pkg没做好。我在默认cmd下python竟然进入anaconda的python。usr/bin下的pthon指向python2.7 python2.7直接运行就是anaconda的python

lrwxrwxrwx  1 root  root          26 8月  16 08:59 dh_pypy -> ../share/dh-python/dh_pypy
-rwxr-xr-x  1 root  root        1056 11月 24  2017 dh_python2
lrwxrwxrwx  1 root  root          29 8月  16 08:59 dh_python3 -> ../share/dh-python/dh_python3
lrwxrwxrwx  1 root  root          23 10月  9 01:01 pdb2.7 -> ../lib/python2.7/pdb.py
lrwxrwxrwx  1 root  root          23 10月  8 22:41 pdb3.5 -> ../lib/python3.5/pdb.py
-rwxr-xr-x  1 root  root       73384 5月  16  2016 pvtkpython
lrwxrwxrwx  1 root  root          31 12月  4 04:46 py3versions -> ../share/python3/py3versions.py
-rwxr-xr-x  1 root  root         293 9月  17  2015 pybabel-python2
lrwxrwxrwx  1 root  root          26 8月  16 08:59 pybuild -> ../share/dh-python/pybuild
lrwxrwxrwx  1 root  root           9 12月  4 04:46 python -> python2.7
lrwxrwxrwx  1 root  root           9 12月  4 04:46 python2 -> python2.7
-rwxr-xr-x  1 root  root     3492656 10月  9 01:01 python2.7
lrwxrwxrwx  1 root  root          33 10月  9 01:01 python2.7-config -> x86_64-linux-gnu-python2.7-config
lrwxrwxrwx  1 root  root          16 11月 24  2017 python2-config -> python2.7-config
lrwxrwxrwx  1 root  root           9 12月  4 04:46 python3 -> python3.5
-rwxr-xr-x  2 root  root     4452016 10月  8 22:41 python3.5
lrwxrwxrwx  1 root  root          33 10月  8 22:41 python3.5-config -> x86_64-linux-gnu-python3.5-config
-rwxr-xr-x  2 root  root     4452016 10月  8 22:41 python3.5m
lrwxrwxrwx  1 root  root          34 10月  8 22:41 python3.5m-config -> x86_64-linux-gnu-python3.5m-config
lrwxrwxrwx  1 root  root          16 3月  23  2016 python3-config -> python3.5-config
lrwxrwxrwx  1 root  root          10 12月  4 04:46 python3m -> python3.5m
lrwxrwxrwx  1 root  root          17 3月  23  2016 python3m-config -> python3.5m-config
lrwxrwxrwx  1 root  root          16 11月 24  2017 python-config -> python2.7-config
lrwxrwxrwx  1 root  root          29 12月  4 04:46 pyversions -> ../share/python/pyversions.py
lrwxrwxrwx  1 root  root          45 12月  5 21:06 sphinx-apidoc -> ../share/sphinx/scripts/python2/sphinx-apidoc
lrwxrwxrwx  1 root  root          46 12月  5 21:06 sphinx-autogen -> ../share/sphinx/scripts/python2/sphinx-autogen
lrwxrwxrwx  1 root  root          44 12月  5 21:06 sphinx-build -> ../share/sphinx/scripts/python2/sphinx-build
lrwxrwxrwx  1 root  root          49 12月  5 21:06 sphinx-quickstart -> ../share/sphinx/scripts/python2/sphinx-quickstart
-rwxr-xr-x  1 root  root       14704 5月  16  2016 vtk6python
-rwxr-xr-x  1 root  root        2909 10月  9 00:59 x86_64-linux-gnu-python2.7-config
lrwxrwxrwx  1 root  root          34 10月  8 22:41 x86_64-linux-gnu-python3.5-config -> x86_64-linux-gnu-python3.5m-config
-rwxr-xr-x  1 root  root        3185 10月  8 22:39 x86_64-linux-gnu-python3.5m-config
lrwxrwxrwx  1 root  root          33 3月  23  2016 x86_64-linux-gnu-python3-config -> x86_64-linux-gnu-python3.5-config
lrwxrwxrwx  1 root  root          34 3月  23  2016 x86_64-linux-gnu-python3m-config -> x86_64-linux-gnu-python3.5m-config
lrwxrwxrwx  1 root  root          33 11月 24  2017 x86_64-linux-gnu-python-config -> x86_64-linux-gnu-python2.7-config

把Anconda的bashrc注释之后然后把anaconda的文件夹删除(或者重命名)之后python就进入系统python,cm没有报错找不到rospkg,但是cm的时候还是如下报错

In file included from /opt/ros/kinetic/include/open_karto/Mapper.h:24:0,
                 from /home/asber/catkin_ws/src/slam_karto/src/spa_solver.h:21,
                 from /home/asber/catkin_ws/src/slam_karto/src/spa_solver.cpp:18:
/opt/ros/kinetic/include/open_karto/Karto.h: In member function ‘virtual kt_bool karto::OccupancyGrid::AddScan(karto::LocalizedRangeScan*, kt_bool)’:
/opt/ros/kinetic/include/open_karto/Karto.h:5857:59: error: ‘isnan’ was not declared in this scope
         if (rangeReading >= maxRange || isnan(rangeReading))
                                                           ^
/opt/ros/kinetic/include/open_karto/Karto.h:5857:59: note: suggested alternative:
In file included from /usr/include/c++/5/random:38:0,
                 from /usr/include/c++/5/bits/stl_algo.h:66,
                 from /usr/include/c++/5/algorithm:62,
                 from /opt/ros/kinetic/include/open_karto/Karto.h:24,
                 from /opt/ros/kinetic/include/open_karto/Mapper.h:24,
                 from /home/asber/catkin_ws/src/slam_karto/src/spa_solver.h:21,
                 from /home/asber/catkin_ws/src/slam_karto/src/spa_solver.cpp:18:
/usr/include/c++/5/cmath:641:5: note:   ‘std::isnan’
     isnan(_Tp __x)
     ^

我看了一下
from /home/asber/catkin_ws/src/slam_karto/src/spa_solver.cpp:18
调用#include “spa_solver.h”
/home/asber/catkin_ws/src/slam_karto/src/spa_solver.h:21
调用#include <open_karto/Mapper.h>
/opt/ros/kinetic/include/open_karto/Mapper.h:24:0
调用#include <open_karto/Karto.h>
然后在 <open_karto/Karto.h>的确如报错所示,是有isnan,按照此处有说要降低版本,但是5.5可以通过,我5.4自然可以,除非系统调用了其他g++ 来编译cm
我下面尝试将报错的文件进行修改
把if (rangeReading >= maxRange || isnan(rangeReading))修改为if (rangeReading >= maxRange || std::isnan(rangeReading))
通过。
然后删除报错包就完事了

相关标签: Robot