ROS无人机仿真rotor_simulations配置篇
电脑配置
Ubuntu 16.04+ROS kinetic
相关背景
我最近看到github上已经有大牛把rotor_simulation代码放出来了,想用来仿真学习一下无人机,但是苦于配置问题困扰了一段时间,最近跑通了分享一下配置的方法和遇到配置问题的解决办法。
准备工作
1. 下载好ROS相关功能包、wstool、catkin-tools.
$ sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu `lsb_release -sc` main" > /etc/apt/sources.list.d/ros-latest.list'
$ wget http://packages.ros.org/ros.key -O - | sudo apt-key add -
$ sudo apt-get update
$ sudo apt-get install ros-kinetic-joy ros-kinetic-octomap-ros ros-kinetic-mavlink python-wstool python-catkin-tools protobuf-compiler libgoogle-glog-dev ros-kinetic-control-toolbox
$ sudo rosdep init
$ rosdep update
$ source /opt/ros/kinetic/setup.bash
2. 在一个src文件夹中编译(文件夹可以自己定,这里以初学者catkin_ws的为例)
$ mkdir -p ~/catkin_ws/src
$ cd ~/catkin_ws/src
$ catkin_init_workspace # initialize your catkin workspace
$ wstool init
$ wget https://raw.githubusercontent.com/ethz-asl/rotors_simulator/master/rotors_hil.rosinstall
$ wstool merge rotors_hil.rosinstall
$ wstool update
3. 用python_catkin_tools编译你的工作空间
$ cd ~/catkin_ws/
$ catkin build
如果没有python_catkin_tools,先执行下面一步配置,然后在执行上面操作
sudo apt-get install python-catkin-tools
4. 添加路径(如果是在catkin_ws一般都有添加过了,可以不用这一步骤)
永久添加
$ echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
$ source ~/.bashrc
参考资料
https://github.com/ethz-asl/rotors_simulator
编译过程中各种可能出现问题以及解决方法
(本过程涉及到修改文件的,其具体路径请参照错误提示的查找)
1. Could not find a package configuration file provided by "geographic_msgs"
sudo apt-get install ros-kinetic-geographic-msgs
2. from future import standard_library
ImportError: No module named future
sudo pip install future
3. Could not find a package configuration file provided by "geographic_msgs"
sudo apt-get install ros-kinetic-geographic-msgs
4. Could NOT find GeographicLib (missing: GeographicLib_LIBRARIES
GeographicLib_INCLUDE_DIRS)
sudo apt-get install libgeographic-dev
sudo apt-get install libgeographic14
参考https://packages.ubuntu.com/source/xenial/geographiclib
5. Could not find a package configuration file provided by "octomap_ros"
sudo apt-get install ros-kinetic-octomap-ros
6. Failed to find glog - Could not find glog include directory, set
GLOG_INCLUDE_DIR to directory containing glog/logging.h
sudo apt-get install libgoogle-glog-dev
7. Errors << rotors_hil_interface:make
在hil_interface.h 加入代码
#include <mavros_msgs/HilControls.h>
#include <mavros_msgs/mavlink_convert.h>
#ifndef MAVLINK_H
typedef mavlink::mavlink_message_t mavlink_message_t;
#include <mavlink/v2.0/common/mavlink.h>
#endif
#include <rotors_hil_interface/hil_listeners.h>
namespace rotors_hil {
具体添加的代码是上面的第3~6段,列出周围行代码方便找位置。
参考https://github.com/ethz-asl/rotors_simulator/pull/522/files
8. odom.cpp:234:51: error: ‘struct mavlink::common::msg::ODOMETRY’ has no member named ‘twist_covariance’
ftf::covariance_urt_to_mavlink(cov_vel_map, msg.twist_covariance);
将odom.cpp的234行注释掉
//ftf::covariance_urt_to_mavlink(cov_vel_map, msg.twist_covariance);
如果要使用此cpp再具体解决
9. make[2]: *** No rule to make target '/home/dale/rotor/src/rotors_simulator/rotors_gazebo_plugins/PROTOBUF_PROTOC_EXECUTABLE-NOTFOUND', needed by 'PoseWithCovarianceStamped.pb.cc'. Stop.
删除build文件夹里面的
rotors_gazebo_plugins
重新编译
参考https://blog.csdn.net/qq_27474467/article/details/80506882
参考资料
https://blog.csdn.net/qq_38019633/article/details/84074442
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)