Building mavros failed (Having tried three ways)
I have tried to build the recent mavros package from its source. I have tried three different ways; they all failed. My OS is Ubutnu 16.04.03 LTS (xenial).
Can anyone let me know the right way to compile the package?
First try
$ git clone https://github.com/mavlink/mavros.git mavros_recent
$ catkin_make -DCATKIN_WHITELIST_PACKAGES="mavros_recent"
The compilation does not work, with the following message produced:
Multiple packages found with the same name "libmavconn":
- mavros/libmavconn
- mavros_recent/libmavconn
Multiple packages found with the same name "mavros":
- mavros/mavros
- mavros_recent/mavros
Second try
Then, I tried a more direct way.
$ cd src/mavros_recent/mavros/
$ mkdir build; cd build; cmake ..
I got an error from CMake
-- 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.
Call Stack (most recent call first):
CMakeLists.txt:7 (find_package)
-- Configuring incomplete, errors occurred!
Third try
According to a ROS official page
You can use rosdep and catkin to build any package in the ROS repository. Say that you want to build a package called AMAZING_PACKAGE, that you hadn't built on your machine before.
rosdep install AMAZING_PACKAGE
In my case, the amazing_package is mavros. It seems rosdep does not recognize mavros as a package, as shown from the error message below:
$rosdep install mavros
ERROR: Rosdep cannot find all required resources to answer your query
Missing resource mavros
ROS path [0]=/opt/ros/kinetic/share/ros
ROS path [1]=/opt/ros/kinetic/share
So, what's the right way to build it from source?
[EDIT] I would like to build from source, instead of use apt-get, because eventually I will need to build mavros of a special commiit hash.
You didn't say what your OS is, but assuming you're using Ubuntu 16.04 did you try
instead of building it?
Thanks and it is good to know the apt-get way. However, I would like to build from source instead of use apt-get, because eventually I will need to build mavros of a special commiit hash.
Maybe try reading documentation first next time.