https://zhuanlan.zhihu.com/p/668901249
Ubuntu20.04+ros的环境适配安装Moveit
首先要求环境配置:
- Ubuntu20.04
- ROS noetic
安装的主要参考依据是官网,主打一个权威。
安装moveit官方说明文档:
MoveIt 1 Source Build - Linuxmoveit.ros.org/install/source/
源码地址:
https://github.com/ros-planning/moveit_tutorialsgithub.com/ros-planning/moveit_tutorials
一、安装moveit库
不用纠结于网上安装的melodic版本,因为20.04的noetic其实已经有量身定做的库。
rosdep update
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install python3-wstool python3-catkin-tools python3-rosdep
sudo apt-get install ros-noetic-moveit
二、工作空间和代码
mkdir ~/ws_moveit
cd ~/ws_moveit
确认下ROS环境:
source /opt/ros/noetic/setup.bash
这将设置环境变量ROS_DISTRO
安装源码:
方案一:
先列出官方的方式,如果网络环境允许,使用官方的即可。
wstool init src
wstool merge -t src https://raw.githubusercontent.com/ros-planning/moveit/master/moveit.rosinstall
wstool update -t 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
方案二:
如果网络有问题,再使用以下操作。
因为官网中的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: GitHub - ros-planning/moveit_resources: URDFs, meshes, and config packages for MoveIt testing
version: master
- git:
local-name: geometric_shapes
uri: https://github.com/ros-planning/geometric_shapes.git
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: melodic-devel
所以我们可以根据需要单独下载:
我这里下载的两个,注意一下分支名即可,其实有些是明确提供的noetic的分支的。
git clone https://github.com/ros-planning/moveit_tutorials.git -b master
git clone https://github.com/ros-planning/panda_moveit_config.git -b noetic-devel
三、安装ccache编译器缓存(可选项)
sudo apt-get install ccache
echo 'export PATH=/usr/lib/ccache:$PATH' >> $HOME/.bashrc
source $HOME/.bashrc
验证是否安装成功:
ccache --show-stats
四、编译项目
mkdir ~/ws_moveit
catkin build
至此安装完成,可以开始demo玩耍了。
五、demo
测试一个demo程序。
1.
source ~/ws_moveit/devel/setup.bash
roslaunch panda_moveit_config demo.launch rviz_tutorial:=true
启动成功后空白,是因为没有添加正确的显示内容
启动界面
2. 左下角的“add”添加,MotionPlanning
add添加界面
3. 添加机械臂后,开始学习操作
YAML 问题
ubuntu下使用yaml cpp报和YAML::detail::node_data::convert_to_map和empty_scalar未定义的错误
ubuntu下将yaml cpp从git上拉取后make 和install后,在项目中引用yaml cpp,编译时报
undefined reference to `YAML::detail::node_data::empty_scalar[abi:cxx11]()'
和undefined reference to `YAML::detail::node_data::convert_to_map(std::shared_ptr<YAML::detail::memory_holder> const&)'
最终解决方法,改为使用yaml cpp静态库,不使用动态库,即编译成功。
link_directories(/usr/local/lib)或者link_directories(libyaml-cpp.a文件所在的目录)
target_link_libraries(projectname yaml-cpp)
修改source 路径
_SETUP_UTIL="$_CATKIN_SETUP_DIR/devel/_setup_util.py"
rviz_visual_tools
[ WARN] [1721008111.653523120]: Topic '/rviz_visual_tools' unable to connect to any subscribers within 0.5 sec. It is possible initially published visual messages will be lost.
https://blog.csdn.net/m0_54871410/article/details/130501956
c++filt工具解析符号
/opt/ros/noetic/lib/move_base/move_base: symbol lookup error: /home/winter/ROS/ros_learning_tutorials/Lecture19/devel/lib//libmy_planner.so: undefined symbol: _ZN18base_local_planner12CostmapModelC1ERKN10costmap_2d9Costmap2DE
未定义符号错误undefined symbol一般是依赖配置错误导致,采用c++filt工具解析符号。c++filt是什么?g++编译器有名字修饰机制,其目的是给同名的重载函数不同的、唯一的签名识别,所有函数在编译后的文件中都会生成唯一的符号,c++filt可以逆向解析符号,还原函数,定位代码。
采用c++filt工具解析符号
c++filt _ZN18base_local_planner12CostmapModelC1ERKN10costmap_2d9Costmap2DE
base_local_planner::CostmapModel::CostmapModel(costmap_2d::Costmap2D const&)
原文链接:https://blog.csdn.net/FRIGIDWINTER/article/details/128838376
moveit 和 rviz 版本不匹配
sudo apt install --reinstall ros-noetic-rviz
[rviz_demphi_y7000p_control_39308_3648750848624591607-5] process has died [pid 39336, exit code 127, cmd /opt/ros/noetic/lib/rviz/rviz -d /home/demphi/cldata/ws_moveit/src/panda_moveit_config/launch/moveit.rviz __name:=rviz_demphi_y7000p_control_39308_3648750848624591607 __log:=/home/demphi/.ros/log/7604f404-54a6-11ef-833d-3bdf7f3635e3/rviz_demphi_y7000p_control_39308_3648750848624591607-5.log].
log file: /home/demphi/.ros/log/7604f404-54a6-11ef-833d-3bdf7f3635e3/rviz_demphi_y7000p_control_39308_3648750848624591607-5*.log
sudo apt-get install librviz-dev
找不到库
process[motion_planning_pipeline_tutorial-1]: started with pid [107606]
/home/demphi/ws_moveit/devel/lib/moveit_tutorials/motion_planning_pipeline_tutorial: error while loading shared libraries: libmoveit_robot_model_loader.so.1.1.13: cannot open shared object file: No such file or directory
$ echo $LD_LIBRARY_PATH
$ locate libmoveit_robot_model_loader.so.1.1.13
/opt/ros/noetic/lib/libmoveit_robot_model_loader.so.1.1.13
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/ros/noetic/lib
或者打开$ gedit ~/.bashrc
$ source ~/.bashrc