基于Ubuntu 16.04和ros kinetc平台源码编译安装moveit和ompl及编译警告的解决方法

安装依赖项

rosdep update
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install python-wstool python-catkin-tools clang-format-3.9

下载moveit的源码

mkdir -p ~/ws_moveit/src
cd ~/ws_moveit
source /opt/ros/kinetic/setup.bash
wstool init src
wstool merge -t src https://raw.githubusercontent.com/ros-planning/moveit/kinetic-devel/moveit.rosinstall
wstool update -t src

下载ompl源码

cd ~/ws_moveit/src
git clone -b kinetic-devel https://github.com/ompl/ompl.git

下载由catkin build编译ompl需要的package.xml文件

cd ~/ws_moveit/src/ompl
wget https://raw.githubusercontent.com/ros-gbp/ompl-release/debian/kinetic/xenial/ompl/package.xml

修改moveit_planners的CMakeLists.txt文件

gedit ~/ws_moveit/src/moveit/moveit_planners/ompl/CMakeLists.txt #找到include_directories的位置并互换${OMPL_INCLUDE_DIRS} 和 ${catkin_INCLUDE_DIRS}的位置, 让${OMPL_INCLUDE_DIRS}变量出现在${catkin_INCLUDE_DIRS}变量之前

#安装依赖

cd ~/ws_moveit/src
rosdep install -y --from-paths . --ignore-src --rosdistro kinetic

#开始编译ompl和moveit

cd ~/ws_moveit
catkin config --extend /opt/ros/kinetic --cmake-args -DCMAKE_BUILD_TYPE=Release
catkin build

上述过程主要参考了官网教程,部分结合了知乎上的相关经验。

如果一切顺利的话,可能没有警告,编译一次通过。
但是,我在编译的过程中出现了一次错误一次警告
错误的原因可能是没有指定ompl版本:

#通过添加 -b kinetic-devel解决版本问题
git clone -b kinetic-devel https://github.com/ompl/ompl.git

警告的原因确定是CMake版本导致的,我尝试过多个CMake版本,包括cmake3.13.2和cmake3.13.4都出现严重的编译错误

liuqiang@liuqiang-Vulcan-JINGANG-GTSeries:~/ws_moveit$ catkin build
-------------------------------------------------------------
Profile:                     default
Extending:        [explicit] /opt/ros/kinetic
Workspace:                   /home/liuqiang/ws_moveit
-------------------------------------------------------------
Source Space:       [exists] /home/liuqiang/ws_moveit/src
Log Space:          [exists] /home/liuqiang/ws_moveit/logs
Build Space:        [exists] /home/liuqiang/ws_moveit/build
Devel Space:        [exists] /home/liuqiang/ws_moveit/devel
Install Space:      [unused] /home/liuqiang/ws_moveit/install
DESTDIR:            [unused] None
-------------------------------------------------------------
Devel Space Layout:          linked
Install Space Layout:        None
-------------------------------------------------------------
Additional CMake Args:       -DCMAKE_BUILD_TYPE=Release
Additional Make Args:        None
Additional catkin Make Args: None
Internal Make Job Server:    True
Cache Job Environments:      False
-------------------------------------------------------------
Whitelisted Packages:        None
Blacklisted Packages:        None
-------------------------------------------------------------
Workspace configuration appears valid.
-------------------------------------------------------------
[build] Found '33' packages in 0.0 seconds.                                                                                                                                                                
[build] Updating package table.                                                                                                                                                                            
Starting  >>> geometric_shapes                                                                                                                                                                             
Starting  >>> moveit_experimental                                                                                                                                                                          
Starting  >>> moveit_msgs                                                                                                                                                                                  
Starting  >>> moveit_resources                                                                                                                                                                             
Starting  >>> srdfdom                                                                                                                                                                                      
Finished  <<< moveit_resources                                 [ 0.1 seconds ]                                                                                                                             
Finished  <<< geometric_shapes                                 [ 0.1 seconds ]                                                                                                                             
Finished  <<< srdfdom                                          [ 0.2 seconds ]                                                                                                                             
Finished  <<< moveit_experimental                              [ 0.2 seconds ]                                                                                                                             
Finished  <<< moveit_msgs                                      [ 1.0 seconds ]                                                                                                                             
Starting  >>> moveit_core                                                                                                                                                                                  
Finished  <<< moveit_core                                      [ 0.4 seconds ]                                                                                                                             
Starting  >>> chomp_motion_planner                                                                                                                                                                         
Starting  >>> moveit_controller_manager_example                                                                                                                                                            
Starting  >>> moveit_ros_perception                                                                                                                                                                        
Starting  >>> moveit_simple_controller_manager                                                                                                                                                             
___________________________________________________________________________________________________________________________________________________________________________________________________________
Errors     << moveit_controller_manager_example:cmake /home/liuqiang/ws_moveit/logs/moveit_controller_manager_example/build.cmake.002.log                                                                  
CMake Error at /home/liuqiang/ws_moveit/devel/share/moveit_core/cmake/moveit_coreConfig.cmake:148 (message):
  Project 'moveit_controller_manager_example' tried to find library
  '-lpthread'.  The library is neither a target nor built/installed properly.
  Did you compile project 'moveit_core'? Did you find_package() it before the
  subdirectory containing its code is included?
Call Stack (most recent call first):
  /opt/ros/kinetic/share/catkin/cmake/catkinConfig.cmake:76 (find_package)
  CMakeLists.txt:13 (find_package)


cd /home/liuqiang/ws_moveit/build/moveit_controller_manager_example; catkin build --get-env moveit_controller_manager_example | catkin env -si  /opt/cmake-3.13.4-Linux-x86_64/bin/cmake /home/liuqiang/ws_moveit/src/moveit/moveit_plugins/moveit_controller_manager_example --no-warn-unused-cli -DCATKIN_DEVEL_PREFIX=/home/liuqiang/ws_moveit/devel/.private/moveit_controller_manager_example -DCMAKE_INSTALL_PREFIX=/home/liuqiang/ws_moveit/install -DCMAKE_BUILD_TYPE=Release; cd -
...........................................................................................................................................................................................................
Failed     << moveit_controller_manager_example:cmake          [ Exited with code 1 ]                                                                                                                      
Failed    <<< moveit_controller_manager_example                [ 0.5 seconds ]                                                                                                                             
Abandoned <<< moveit_commander                                 [ Unrelated job failed ]                                                                                                                    
Abandoned <<< moveit_chomp_optimizer_adapter                   [ Unrelated job failed ]                                                                                                                    
Abandoned <<< moveit_ros_planning                              [ Unrelated job failed ]                                                                                                                    
Abandoned <<< moveit_fake_controller_manager                   [ Unrelated job failed ]                                                                                                                    
Abandoned <<< moveit_kinematics                                [ Unrelated job failed ]                                                                                                                    
Abandoned <<< moveit_planners_ompl                             [ Unrelated job failed ]                                                                                                                    
Abandoned <<< moveit_ros_move_group                            [ Unrelated job failed ]                                                                                                                    
Abandoned <<< moveit_ros_manipulation                          [ Unrelated job failed ]                                                                                                                    
Abandoned <<< moveit_ros_robot_interaction                     [ Unrelated job failed ]                                                                                                                    
Abandoned <<< moveit_ros_warehouse                             [ Unrelated job failed ]                                                                                                                    
Abandoned <<< moveit_ros_benchmarks                            [ Unrelated job failed ]                                                                                                                    
Abandoned <<< moveit_ros_planning_interface                    [ Unrelated job failed ]                                                                                                                    
Abandoned <<< moveit_planners_chomp                            [ Unrelated job failed ]                                                                                                                    
Abandoned <<< moveit_ros_visualization                         [ Unrelated job failed ]                                                                                                                    
Abandoned <<< moveit_setup_assistant                           [ Unrelated job failed ]                                                                                                                    
Abandoned <<< moveit_ros_control_interface                     [ Unrelated job failed ]                                                                                                                    
Abandoned <<< moveit_visual_tools                              [ Unrelated job failed ]                                                                                                                    
Abandoned <<< moveit_tutorials                                 [ Unrelated job failed ]                                                                                                                    
___________________________________________________________________________________________________________________________________________________________________________________________________________
Errors     << chomp_motion_planner:cmake /home/liuqiang/ws_moveit/logs/chomp_motion_planner/build.cmake.002.log                                                                                            
CMake Error at /home/liuqiang/ws_moveit/devel/share/moveit_core/cmake/moveit_coreConfig.cmake:148 (message):
  Project 'chomp_motion_planner' tried to find library '-lpthread'.  The
  library is neither a target nor built/installed properly.  Did you compile
  project 'moveit_core'? Did you find_package() it before the subdirectory
  containing its code is included?
Call Stack (most recent call first):
  /opt/ros/kinetic/share/catkin/cmake/catkinConfig.cmake:76 (find_package)
  CMakeLists.txt:6 (find_package)


cd /home/liuqiang/ws_moveit/build/chomp_motion_planner; catkin build --get-env chomp_motion_planner | catkin env -si  /opt/cmake-3.13.4-Linux-x86_64/bin/cmake /home/liuqiang/ws_moveit/src/moveit/moveit_planners/chomp/chomp_motion_planner --no-warn-unused-cli -DCATKIN_DEVEL_PREFIX=/home/liuqiang/ws_moveit/devel/.private/chomp_motion_planner -DCMAKE_INSTALL_PREFIX=/home/liuqiang/ws_moveit/install -DCMAKE_BUILD_TYPE=Release; cd -
...........................................................................................................................................................................................................
Failed     << chomp_motion_planner:cmake                       [ Exited with code 1 ]                                                                                                                      
Failed    <<< chomp_motion_planner                             [ 0.6 seconds ]                                                                                                                             
___________________________________________________________________________________________________________________________________________________________________________________________________________
Errors     << moveit_simple_controller_manager:cmake /home/liuqiang/ws_moveit/logs/moveit_simple_controller_manager/build.cmake.002.log                                                                    
CMake Error at /home/liuqiang/ws_moveit/devel/share/moveit_core/cmake/moveit_coreConfig.cmake:148 (message):
  Project 'moveit_simple_controller_manager' tried to find library
  '-lpthread'.  The library is neither a target nor built/installed properly.
  Did you compile project 'moveit_core'? Did you find_package() it before the
  subdirectory containing its code is included?
Call Stack (most recent call first):
  /opt/ros/kinetic/share/catkin/cmake/catkinConfig.cmake:76 (find_package)
  CMakeLists.txt:12 (find_package)


cd /home/liuqiang/ws_moveit/build/moveit_simple_controller_manager; catkin build --get-env moveit_simple_controller_manager | catkin env -si  /opt/cmake-3.13.4-Linux-x86_64/bin/cmake /home/liuqiang/ws_moveit/src/moveit/moveit_plugins/moveit_simple_controller_manager --no-warn-unused-cli -DCATKIN_DEVEL_PREFIX=/home/liuqiang/ws_moveit/devel/.private/moveit_simple_controller_manager -DCMAKE_INSTALL_PREFIX=/home/liuqiang/ws_moveit/install -DCMAKE_BUILD_TYPE=Release; cd -
...........................................................................................................................................................................................................
Failed     << moveit_simple_controller_manager:cmake           [ Exited with code 1 ]                                                                                                                      
Failed    <<< moveit_simple_controller_manager                 [ 0.5 seconds ]                                                                                                                             
___________________________________________________________________________________________________________________________________________________________________________________________________________
Errors     << moveit_ros_perception:cmake /home/liuqiang/ws_moveit/logs/moveit_ros_perception/build.cmake.002.log                                                                                          
CMake Error at /home/liuqiang/ws_moveit/devel/share/moveit_core/cmake/moveit_coreConfig.cmake:148 (message):
  Project 'moveit_ros_perception' tried to find library '-lpthread'.  The
  library is neither a target nor built/installed properly.  Did you compile
  project 'moveit_core'? Did you find_package() it before the subdirectory
  containing its code is included?
Call Stack (most recent call first):
  /opt/ros/kinetic/share/catkin/cmake/catkinConfig.cmake:76 (find_package)
  CMakeLists.txt:27 (find_package)


cd /home/liuqiang/ws_moveit/build/moveit_ros_perception; catkin build --get-env moveit_ros_perception | catkin env -si  /opt/cmake-3.13.4-Linux-x86_64/bin/cmake /home/liuqiang/ws_moveit/src/moveit/moveit_ros/perception --no-warn-unused-cli -DCATKIN_DEVEL_PREFIX=/home/liuqiang/ws_moveit/devel/.private/moveit_ros_perception -DCMAKE_INSTALL_PREFIX=/home/liuqiang/ws_moveit/install -DCMAKE_BUILD_TYPE=Release; cd -
...........................................................................................................................................................................................................
Failed     << moveit_ros_perception:cmake                      [ Exited with code 1 ]                                                                                                                      
Failed    <<< moveit_ros_perception                            [ 0.6 seconds ]                                                                                                                             
[build] Summary: 6 of 28 packages succeeded.                                                                                                                                                               
[build]   Ignored:   5 packages were skipped or are blacklisted.                                                                                                                                           
[build]   Warnings:  None.                                                                                                                                                                                 
[build]   Abandoned: 18 packages were abandoned.                                                                                                                                                           
[build]   Failed:    4 packages failed.                                                                                                                                                                    
[build] Runtime: 2.7 seconds total.                        

总是提示无法找到lpthread线程库,最后我在这个网页:https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=915148
确定是cmake版本的问题。
当前只有Cmake3.12.4能够完美编译

之前我用的是cmake3.10.2,出现了警告,后来我换成了cmake3.12.4版本后,没有了警告

我是通过上述两步解决了编译过程中遇到的所有问题。

添加环境变量

gedit ~/.bashrc
#在文件的末尾添加类似如下的一行,注意要把家路径换成你自己电脑上的路径
source /home/liuqiang/ws_moveit/devel/setup.bash
#保存并关闭.bashrc文件,在终端执行命令:source ~/.bashrc

你可能感兴趣的:(MoveIt)