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
#include
#ifndef MAVLINK_H
typedef mavlink::mavlink_message_t mavlink_message_t;
#include
#endif
#include
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