参考1:Ubuntu18.04安装Moveit框架_moveit_core: cannot locate rosdep definition for [-CSDN博客从
参考2:
1、安装ubuntu18.04
2、ROS_melodic安装:参考鱼香ROS
终端输入:wget http://fishros.com/install -O fishros && . fishros
3、路径规划必须安装Moveit+ompl(源码安装)
(1)安装Moveit:
a)下载依赖文件: sudo apt-get install python-wstool python-catkin-tools clang-format-3.9
b)创建工作区和软件源
mkdir ~/ws_moveit
cd ~/ws_moveit
c)加载必要的环境变量
source /opt/ros/melodic/setup.bash
d)下载源代码
wstool init src
wstool merge -t src https://raw.githubusercontent.com/ros-planning/moveit/master/moveit.rosinstall
上述代码获取不到源代码,则去相应网站下载(如下)
# This file is intended for users who want to build MoveIt from source.
# Used with wstool, users can download source of all packages of MoveIt.
- git:
local-name: moveit_msgs
uri: https://github.com/ros-planning/moveit_msgs.git
version: master
- git:
local-name: moveit_resources
uri: https://github.com/ros-planning/moveit_resources.git
version: master
- git:
local-name: geometric_shapes
uri: https://github.com/ros-planning/geometric_shapes.git
version: noetic-devel
- git:
local-name: srdfdom
uri: https://github.com/ros-planning/srdfdom
version: noetic-devel
- git:
local-name: moveit
uri: https://github.com/ros-planning/moveit.git
version: master
- git:
local-name: rviz_visual_tools
uri: https://github.com/PickNikRobotics/rviz_visual_tools
version: master
- git:
local-name: moveit_visual_tools
uri: https://github.com/ros-planning/moveit_visual_tools.git
version: master
- git:
local-name: moveit_tutorials
uri: https://github.com/ros-planning/moveit_tutorials.git
version: master
- git:
local-name: panda_moveit_config
uri: https://github.com/ros-planning/panda_moveit_config.git
version: noetic-devel
需要注意的是下载版本得与ros-melodic相匹配(点击master选择melodic-devel)
将下载完的压缩包解压存储到src中,并执行:
rosdep install -y --from-paths src --ignore-src --rosdistro ${ROS_DISTRO}
catkin config --extend /opt/ros/${ROS_DISTRO} --cmake-args --DCMAKE_BUILD_TYPE=Release
若出现:
ERROR: the following packages/stacks could not have their rosdep keys resolved
to system dependencies:
moveit_resources_dual_panda_moveit_config: Cannot locate rosdep definition for [joint_state_publisher_gui]
panda_moveit_config: Cannot locate rosdep definition for [franka_description]
moveit_resources_panda_moveit_config: Cannot locate rosdep definition for [joint_state_publisher_gui]
moveit_tutorials: Cannot locate rosdep definition for [joy]
pilz_industrial_motion_planner: Cannot locate rosdep definition for [code_coverage]
moveit_servo: Cannot locate rosdep definition for [rosparam_shortcuts]
则:sudo apt-get install ros-melodic-你缺少的东西
例如:
sudo apt-get install ros-melodic-joint-state-publisher-gui
sudo apt-get install ros-melodic-joy
sudo apt-get install ros-melodic-rosparam-shortcuts
尚书
***(可选可不选)安装编译器缓存
***从源代码构建全部甚至部分MoveIt可能需要一个小时。 编译器缓存可以防止重新编译未更改的文件,从而可以将此时间减少到几分钟。 最常用的编译器缓存是适用于gcc和其他类似编译器的ccache
————————————————————————————————————————————————————
安装ccache:
sudo apt-get install ccache
安装后需要对ccache进行一系列的配置,要在所有受支持的编译器中自动使用ccache,需要将/ usr / lib / ccache目录放在PATH之前。
echo 'export PATH=/usr/lib/ccache:$PATH' >> $HOME/.bashrc
source $HOME/.bashrc
使用以下命令,可以利用ccache查看build过程中命中率和缓存使用情况的统计信息:
ccache --show-stats
————————————————————————————————————————————————————
e)编译Moveit
catkin build
注意:这里会出现一些关于opencv版本的错误,比如:
CMake Error at /opt/ros/melodic/share/cv_bridge/cmake/cv_bridgeConfig.cmake:113 (message):
Project 'cv_bridge' specifies '/usr/include/opencv' as an include dir,
which is not found. It does neither exist as an absolute directory nor in
'${{prefix}}//usr/include/opencv'. Check the issue tracker
'https://github.com/ros-perception/vision_opencv/issues' and consider
creating a ticket if the problem has not been reported yet
以上说明:cv_bridgeConfig.cmake
文件中指定的 OpenCV 头文件目录不存在。这可能是因为 cv_bridge
包没有正确配置。
解决方法:重新编译 cv_bridge
包以解决此问题。首先,确保你的工作空间已被清理。然后,按照以下步骤重新编译 cv_bridge
包
rm -rf /home/jzjt/ws_moveit/build
rm -rf /home/jzjt/ws_moveit/devel
cd /home/jzjt/ws_moveit/src
git clone -b melodic https://github.com/ros-perception/vision_opencv.git
cd /home/jzjt/ws_moveit
catkin build
或者
CMake Error at CMakeLists.txt:16 (find_package):
Could not find a configuration file for package "OpenCV" that is compatible
with requested version "3".
The following configuration files were considered but not accepted:
/usr/lib/aarch64-linux-gnu/cmake/opencv4/OpenCVConfig.cmake, version: 4.1.1
也就是说: cv_bridge
包需要的 OpenCV 版本与系统中安装的版本不匹配。cv_bridge
在寻找 OpenCV 3,但系统中安装的是 OpenCV 4.1.1,
解决方法1:安装OpenCV 3
步骤1:下载源代码:访问 OpenCV 的 GitHub 仓库(https://github.com/opencv/opencv),选择一个 3.x 版本,然后克隆或下载源代码。
步骤2:编译 OpenCV 3.x
进入源代码文件夹,
mkdir build && cd build
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..
make -j$(nproc)
sudo make install
解决方法2(不建议):修改 cv_bridge
包以使用 OpenCV 4,修改 cv_bridge
的源代码或 CMakeLists.txt 文件
最后再进行:catkin build,成功
(2)安装ompl
cd ~/moveit_ws/src
git clone https://github.com/ompl/ompl
sudo catkin build
(3)安装moveit,若不安装,就无法正常运行demo.launch文件
sudo apt-get install ros-melodic-moveit
(4)测试