PX4/sitl_gazebo make failure

I’m running a clean version of Ubuntu 18.04 LTS on a Mac. I’m trying to follow the instructions at PX4/sitl_gazebo, but I’m running into an error during make:

[ 71%] Built target gazebo_geotagged_images_plugin
Scanning dependencies of target gazebo_multirotor_base_plugin
/home/sean/src/sitl_gazebo/src/gazebo_mavlink_interface.cpp: In member function ‘void gazebo::GazeboMavlinkInterface::LidarCallback(gazebo::LidarPtr&, const int&)’:
/home/sean/src/sitl_gazebo/src/gazebo_mavlink_interface.cpp:1048:14: error: ‘mavlink_distance_sensor_t {aka struct __mavlink_distance_sensor_t}’ has no member named ‘signal_quality’
sensor_msg.signal_quality = lidar_message->signal_quality();
/home/sean/src/sitl_gazebo/src/gazebo_mavlink_interface.cpp: In member function ‘void gazebo::GazeboMavlinkInterface::SonarCallback(gazebo::SonarPtr&, const int&)’:
/home/sean/src/sitl_gazebo/src/gazebo_mavlink_interface.cpp:1120:14: error: ‘mavlink_distance_sensor_t {aka struct __mavlink_distance_sensor_t}’ has no member named ‘signal_quality’
sensor_msg.signal_quality = sonar_message->signal_quality();
[ 72%] Building CXX object CMakeFiles/gazebo_multirotor_base_plugin.dir/src/gazebo_multirotor_base_plugin.cpp.o
At global scope:
cc1plus: warning: unrecognized command line option ‘-Wno-address-of-packed-member’
CMakeFiles/gazebo_mavlink_interface.dir/build.make:62: recipe for target ‘CMakeFiles/gazebo_mavlink_interface.dir/src/gazebo_mavlink_interface.cpp.o’ failed
make[2]: *** [CMakeFiles/gazebo_mavlink_interface.dir/src/gazebo_mavlink_interface.cpp.o] Error 1
CMakeFiles/Makefile2:865: recipe for target ‘CMakeFiles/gazebo_mavlink_interface.dir/all’ failed
make[1]: *** [CMakeFiles/gazebo_mavlink_interface.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs…
[ 73%] Linking CXX shared library libgazebo_wind_plugin.so

Any help would be greatly appreciated.

@TSC21 looks like the mavlink submodules are not in sync now.

Depends: is this being buily inside the PX4 Firmware build system, or inside a catkin workspace? If it is the former, then the current upstream master already has the correct Mavlink headers submodule up to date. If it is the latest, then no, it’s not up-to-date, since it depends on the releases of Mavlink to the ROS build farm (mavlink-gbp-release).

@Sean_Roelofs Were you able to solve this problem? I’m getting the same exact error when trying to set up sitl_gazebo.

@Sean_Roelofs @Lnoah are you building within ROS or PX4 only?

@JulianOes I’m building within ROS in a catkin ws

Are there any workarounds for this while building inside a catkin workspace?

Yes you can clone https://github.com/mavlink/mavlink-gbp-release branch debian/melodic/bionic/mavlink into your catkin workspace source folder and build the workspace.

When I do this and try to build with catkin_make I get the error:

CMake Error at /opt/ros/melodic/share/catkin/cmake/catkin_workspace.cmake:100 (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:67 (catkin_workspace)

-- Configuring incomplete, errors occurred!
See also "/home/gus/Documents/git/jason_ros_ws/build/CMakeFiles/CMakeOutput.log".
See also "/home/gus/Documents/git/jason_ros_ws/build/CMakeFiles/CMakeError.log".
Invoking "cmake" failed

Thus, I tried building with catkin build but I get the error:

Errors     << mavlink_sitl_gazebo:cmake /home/gus/Documents/git/jason_ros_ws/logs/mavlink_sitl_gazebo/build.cmake.000.log                                                                                         
CMake Error at /opt/ros/melodic/share/catkin/cmake/assert.cmake:3 (message):

  Assertion failed: GTEST_LIBRARIES (value is '')

Call Stack (most recent call first):
  /opt/ros/melodic/share/catkin/cmake/test/gtest.cmake:185 (assert)
  /opt/ros/melodic/share/catkin/cmake/test/gtest.cmake:89 (_catkin_add_executable_with_google_test)
  /opt/ros/melodic/share/catkin/cmake/test/gtest.cmake:37 (_catkin_add_google_test)
  unit_tests/CMakeLists.txt:17 (catkin_add_gtest)
  unit_tests/CMakeLists.txt:31 (add_unit_test)

cd /home/gus/Documents/git/jason_ros_ws/build/mavlink_sitl_gazebo; catkin build --get-env mavlink_sitl_gazebo | catkin env -si  /usr/bin/cmake /home/gus/Documents/git/jason_ros_ws/src/sitl_gazebo --no-warn-unused-cli -DCATKIN_DEVEL_PREFIX=/home/gus/Documents/git/jason_ros_ws/devel/.private/mavlink_sitl_gazebo -DCMAKE_INSTALL_PREFIX=/home/gus/Documents/git/jason_ros_ws/install; cd -

Did I miss something?

Yes, you don’t have GTest installed in your system.

In any case let me rephrase that while a new release for ROS Mavlink is done, you won’t be able to compile the Firmware inside a catkin_ws.

1 Like

Ok, thanks for you reply. I switched to normal building and it is working.

How did you fix it by switching to normal building? Can you describe it more specifically because I meet the same problem?

Take a look on this page: https://dev.px4.io/master/en/simulation/ros_interface.html#launching-gazebo-with-ros-wrappers

You should clone Firmware in a directory outside your ros workspace, build it and source.

cd <Firmware_clone>
DONT_RUN=1 make px4_sitl_default gazebo
source ~/catkin_ws/devel/setup.bash    # (optional)
source Tools/setup_gazebo.bash $(pwd) $(pwd)/build/px4_sitl_default
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$(pwd)/Tools/sitl_gazebo
roslaunch px4 posix_sitl.launch

Something I think is worth highlighting, to run something within your workspace together with px4 you must first source your workspace and then px4 (as far as I know). I think it is worth adding the commands for source in the correct order in your ~ / .bashrc