由于moveit依赖opencv3.2,之前装的opencv版本为3.4,需要卸载掉3.4版本安装opencv3.2
MotionPlanning
The class required for this display, 'moveit_rviz_plugin/MotionPlanning', could not be loaded.
Error:
Failed to load library /opt/ros/melodic/lib/libmoveit_motion_planning_rviz_plugin.so. Make sure that you are calling the PLUGINLIB_EXPORT_CLASS macro in the library code, and that names are consistent between this macro and your XML. Error string: Could not load library (Poco exception = libopencv_core.so.3.2: 无法打开共享对象文件: 没有那个文件或目录)
卸载opencv3.4
1.进入本地opencv工程build文件夹中进行卸载
sudo make uninstall
2.删除usr目录下opencv相关文件
sudo rm -r /usr/local/include/opencv2 /usr/local/include/opencv /usr/include/opencv /usr/include/opencv2 /usr/local/share/opencv /usr/local/share/OpenCV /usr/share/opencv /usr/share/OpenCV /usr/local/bin/opencv* /usr/local/lib/libopencv*
cd /usr
find . -name "*opencv*" | xargs sudo rm -rf
3.检查是否卸载干净
pkg-config opencv --libs
pkg-config opencv --modversion
安装opencv-3.2
- 下载
git clone -b 3.2.0 https://gitee.com/mirrors/opencv.git
- 编译
cd opencv-3.4.13
mkdir build
cd build
sudo cmake -D CMAKE_BUILD_TYPE=Release \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D WITH_CUDA=OFF -D BUILD_DOCS=OFF -D BUILD_EXAMPLES=OFF \
-D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_TIFF=ON ..
错误:CMake Error at cmake/OpenCVCompilerOptions.cmake:21 (else):
CMake Error at cmake/OpenCVCompilerOptions.cmake:21 (else):
A duplicate ELSE command was found inside an IF block.
Call Stack (most recent call first):
CMakeLists.txt:495 (include)
解决方法:
直接打开cmake/OpenCVCompilerOptions.cmake:21 ,找到21行,直接删除掉就好了
错误:opencv_lapack.h缺失
In file included from /home/zhan/Lib/opencv-3.2.0/modules/core/src/hal_internal.cpp:49:0:
/home/zhan/Lib/opencv-3.2.0/build/opencv_lapack.h:2:10: fatal error: LAPACKE_H_PATH-NOTFOUND/lapacke.h: 没有那个文件或目录
#include "LAPACKE_H_PATH-NOTFOUND/lapacke.h"
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
modules/core/CMakeFiles/opencv_core.dir/build.make:522: recipe for target 'modules/core/CMakeFiles/opencv_core.dir/src/hal_internal.cpp.o' failed
make[2]: *** [modules/core/CMakeFiles/opencv_core.dir/src/hal_internal.cpp.o] Error 1
make[2]: *** 正在等待未完成的任务....
CMakeFiles/Makefile2:1042: recipe for target 'modules/core/CMakeFiles/opencv_core.dir/all' failed
make[1]: *** [modules/core/CMakeFiles/opencv_core.dir/all] Error 2
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2
解决方法:
sudo apt-get install liblapacke-dev checkinstall
-
在/build文件夹中找到opencv_lapack.h文件,把#include
"LAPACKE_H_PATH-NOTFOUND/lapacke.h"改为#include “lapacke.h” -
重新编译