[仿真开发] Ros_PX4_Mavros从零入门--哪些坑
摘自:https://bbs.amovlab.com/forum.php?mod=viewthread&tid=1093&extra=page%3D1
本文原文链接为 https://blog.****.net/qq_15390133/article/details/105327213
我感觉我是不是也可以用官方给的MAVROS的代码先去真机上跑跑?
[仿真开发] Ros_PX4_Mavros从零入门--哪些坑
本帖最后由 chasing 于 2020-5-1 13:40 编辑 写在前面的话: 一定要确保mavros安装成功。我在安装mavros的时候采用的是官网默认的安装方式,期间一定有Error出现,没有成功,导致后面需要补充安装一些东西。验证是否安装成功,可以在本地运行`roslaunch mavros px4.launch` 注: 1. 默认的mavros源码是安装在catkin_ws文件夹下,可以 首先采用 `catkin clean` 清除源码工程,然后采用`catkin build`(不是`catkin make`)进行编译。如果源码正常编译且环境变量设置正确的话,在其他地方创建ROS工程添加mavros依赖是不会报错的,否则会出现没有找到mavros功能包的错误。(如果显示catkin build没有这个指令,则运行`sudo apt-get install python-catkin-tools`进行安装即可) 2. ROS工程中生成的 可执行文件 放在 devel/lib下面。 3. ROS工程下cpp文件要在 Cmakelist中添加依赖,如下图所示。其中第一句话表示,查找src/offnode.cpp文件进行编译,生成的可执行文件名字为{PROJECT_NAME}. 在本次实验中,如下图2所示,project name 为 px4_simu。所以,生成的可执行文件为 px4_simu_node,参见下图 4.
Could not find the required component 'geographic_msgs'. The following CMake error indicates that you either need to install the package with the same name or change your environment so that it can be found. CMake Error at /opt/ros/kinetic/share/catkin/cmake/catkinConfig.cmake:83 (find_package): Could not find a package configuration file provided by "geographic_msgs" with any of the following names: geographic_msgsConfig.cmake geographic_msgs-config.cmake Add the installation prefix of "geographic_msgs" to CMAKE_PREFIX_PATH or set "geographic_msgs_DIR" to a directory containing one of the above files. If "geographic_msgs" provides a separate development package or SDK, be sure it has been installed. 紧接着编译仍然报错,
然后安装了
5. 当Ubuntu install某个东西时,给出下面提示
删除锁定文件,行了
CMake Error at /opt/ros/kinetic/share/catkin/cmake/catkin_workspace.cmake:95 (message): This workspace contains non-catkin packages in it, and catkin cannot build a non-homogeneous workspace without isolation. Try the 'catkin_make_isolated' command instead. Call Stack (most recent call first): CMakeLists.txt:68 (catkin_workspace) 7. 此时运行 roslaunch mavros px4_2.launch 时,可能会出现如下错误 (下图所示,转载的图片)
解决方法: mavros 工程下找到 `install_geographiclib_datasets.sh`,并采用sudo 运行。 8. 参照(https://answers.ros.org/question ... g-tried-three-ways/) 执行
下面展示如何从零开发mavros! 终于进入正题了 1. 首先创建Ros工作空间。 在期望的路径上创建文件夹,比如这里我们采用如下指令创建一个空的文件夹
完成整个工作空间的创建,创建之后如下图所示: 2. 创建Ros功能包 在src文件夹下,执行指令
创建Ros功能包,其中px4_simu为功能包名称,后面三个参数为依赖。分别表示python支持,cpp支持,ROS消息支持以及mavros。 3. 然后返回工程文件夹进行编译
最后通过如下指令声明一下路径:
4. 在ROS功能包(本文中为px4_simu)下创建源文件,路径为px4_simu/src,使用指令
6. 最后启动需要先启动gazebo:
然后启动mavros:
最后在启动Ros节点:
后续 这次实验中,打开的终端为3个,下一步将考虑采用roslaunch的方式进行整合。 本文原文链接为 https://blog.****.net/qq_15390133/article/details/105327213 |