I am working on building PX4 source code along with Gazebo 9 on Ubuntu 18.04. I am following the PX4 tutorial from this link: https://docs.px4.io/v1.12/en/simulation/gazebo.html
These are the steps I did:
- I downloaded PX4 source code (succeeded):
$git clone https://github.com/PX4/PX4-Autopilot.git --recursive
$bash ./PX4-Autopilot/Tools/setup/ubuntu.sh
$reboot
I downloaded ROS Melodic (succeeded):
#Note: ROS 1 full desktop builds come with Gazebo Classic)
$wget https://raw.githubusercontent.com/PX4/Devguide/master/build_scripts/ubuntu_sim_ros_melodic.sh
$bash ubuntu_sim_ros_melodic.sh
Running the simulation (Here is my problem):
#Note: Run a simulation by starting PX4 SITL and gazebo with the airframe configuration to load the Quad frame. #Running with cmake version 3.10.2
$cd /path/to/PX4-Autopilot
$**make px4_sitl gazebo #failed**
Making the px4_sitl with gazebo gives this error :
FAILED: CMakeFiles/gazebo_aruco_plugin.dir/src/gazebo_aruco_plugin.cpp.o
and here are some log messages for warnings and error of making the px4_sitl gazebo command:
/gazebo-classic/sitl_gazebo-classic/src/gazebo_aruco_plugin.cpp
In file included from /usr/include/opencv2/aruco.hpp:44:0,
from /home/kjarrah/workspace/Jarrah_thesis/PX4-Autopilot/Tools/simulation/gazebo-classic/sitl_gazebo-classic/include/gazebo_aruco_plugin.h:42,
from /home/kjarrah/workspace/Jarrah_thesis/PX4-Autopilot/Tools/simulation/gazebo-classic/sitl_gazebo-classic/src/gazebo_aruco_plugin.cpp:31:
/usr/include/opencv2/aruco/dictionary.hpp:61:20: error: redefinition of ‘class cv::aruco::Dictionary’
class CV_EXPORTS_W Dictionary {
^~~~~~~~~~
In file included from /usr/local/include/opencv4/opencv2/objdetect/aruco_detector.hpp:7:0,
from /usr/local/include/opencv4/opencv2/objdetect.hpp:874,
from /usr/local/include/opencv4/opencv2/opencv.hpp:80,
from /home/kjarrah/workspace/Jarrah_thesis/PX4-Autopilot/Tools/simulation/gazebo-classic/sitl_gazebo-classic/include/gazebo_aruco_plugin.h:40,
from /home/kjarrah/workspace/Jarrah_thesis/PX4-Autopilot/Tools/simulation/gazebo-classic/sitl_gazebo-classic/src/gazebo_aruco_plugin.cpp:31:
/usr/local/include/opencv4/opencv2/objdetect/aruco_dictionary.hpp:25:27: note: previous definition of ‘class cv::aruco::Dictionary’
class CV_EXPORTS_W_SIMPLE Dictionary {
^~~~~~~~~~
In file included from /usr/include/opencv2/aruco.hpp:44:0,
from /home/kjarrah/workspace/Jarrah_thesis/PX4-Autopilot/Tools/simulation/gazebo-classic/sitl_gazebo-classic/include/gazebo_aruco_plugin.h:42,
from /home/kjarrah/workspace/Jarrah_thesis/PX4-Autopilot/Tools/simulation/gazebo-classic/sitl_gazebo-classic/src/gazebo_aruco_plugin.cpp:31:
/usr/include/opencv2/aruco/dictionary.hpp:142:19: error: redeclaration of ‘DICT_4X4_50’
DICT_4X4_50 = 0,
^
/usr/include/opencv2/aruco/dictionary.hpp:158:5: error: redeclaration of ‘DICT_ARUCO_ORIGINAL’
DICT_ARUCO_ORIGINAL
^~~~~~~~~~~~~~~~~~~
In file included from /usr/local/include/opencv4/opencv2/objdetect/aruco_detector.hpp:7:0,
from /usr/local/include/opencv4/opencv2/objdetect.hpp:874,
from /usr/local/include/opencv4/opencv2/opencv.hpp:80,
from /home/kjarrah/workspace/Jarrah_thesis/PX4-Autopilot/Tools/simulation/gazebo-classic/sitl_gazebo-classic/include/gazebo_aruco_plugin.h:40,
from /home/kjarrah/workspace/Jarrah_thesis/PX4-Autopilot/Tools/simulation/gazebo-classic/sitl_gazebo-classic/src/gazebo_aruco_plugin.cpp:31:
/usr/local/include/opencv4/opencv2/objdetect/aruco_dictionary.hpp:109:5: note: previous declaration ‘cv::aruco::PredefinedDictionaryType DICT_ARUCO_ORIGINAL’
DICT_ARUCO_ORIGINAL, ///< 6x6 bits, minimum hamming distance between any two codes = 3, 1024 codes
^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/opencv2/aruco.hpp:44:0,
from /home/kjarrah/workspace/Jarrah_thesis/PX4-Autopilot/Tools/simulation/gazebo-classic/sitl_gazebo-classic/include/gazebo_aruco_plugin.h:42,
from /home/kjarrah/workspace/Jarrah_thesis/PX4-Autopilot/Tools/simulation/gazebo-classic/sitl_gazebo-classic/src/gazebo_aruco_plugin.cpp:31:
/usr/include/opencv2/aruco/dictionary.hpp:171:30: error: ambiguating new declaration of ‘cv::Ptr<cv::aruco::Dictionary> cv::aruco::getPredefinedDictionary(int)’
CV_EXPORTS_W Ptr<Dictionary> getPredefinedDictionary(int dict);
^~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/local/include/opencv4/opencv2/objdetect/aruco_detector.hpp:7:0,
from /usr/local/include/opencv4/opencv2/objdetect.hpp:874,
from /usr/local/include/opencv4/opencv2/opencv.hpp:80,
from /home/kjarrah/workspace/Jarrah_thesis/PX4-Autopilot/Tools/simulation/gazebo-classic/sitl_gazebo-classic/include/gazebo_aruco_plugin.h:40,
from /home/kjarrah/workspace/Jarrah_thesis/PX4-Autopilot/Tools/simulation/gazebo-classic/sitl_gazebo-classic/src/gazebo_aruco_plugin.cpp:31:
/usr/local/include/opencv4/opencv2/objdetect/aruco_dictionary.hpp:124:25: note: old declaration ‘cv::aruco::Dictionary cv::aruco::getPredefinedDictionary(int)’
CV_EXPORTS_W Dictionary getPredefinedDictionary(int dict);
^~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/kjarrah/workspace/Jarrah_thesis/PX4-Autopilot/Tools/simulation/gazebo-classic/sitl_gazebo-classic/include/gazebo_aruco_plugin.h:42:0,
from /home/kjarrah/workspace/Jarrah_thesis/PX4-Autopilot/Tools/simulation/gazebo-classic/sitl_gazebo-classic/src/gazebo_aruco_plugin.cpp:31:
/usr/include/opencv2/aruco.hpp:124:21: error: redefinition of ‘struct cv::aruco::DetectorParameters’
struct CV_EXPORTS_W DetectorParameters {
^~~~~~~~~~~~~~~~~~
In file included from /usr/local/include/opencv4/opencv2/objdetect.hpp:874:0,
from /usr/local/include/opencv4/opencv2/opencv.hpp:80,
from /home/kjarrah/workspace/Jarrah_thesis/PX4-Autopilot/Tools/simulation/gazebo-classic/sitl_gazebo-classic/include/gazebo_aruco_plugin.h:40,
from /home/kjarrah/workspace/Jarrah_thesis/PX4-Autopilot/Tools/simulation/gazebo-classic/sitl_gazebo-classic/src/gazebo_aruco_plugin.cpp:31:
/usr/local/include/opencv4/opencv2/objdetect/aruco_detector.hpp:346:19: note: previous specification in ‘void cv::aruco::drawDetectedMarkers(cv::InputOutputArray, cv::InputArrayOfArrays, cv::InputArray, cv::Scalar)’ here
CV_EXPORTS_W void drawDetectedMarkers(InputOutputArray image, InputArrayOfArrays corners,
^~~~~~~~~~~~~~~~~~~
cc1plus: warning: unrecognized command line option ‘-Wno-address-of-packed-member’
[120/142] Building CXX object CMakeFiles/gazebo_gst_camera_plugin.dir/src/gazebo_gst_camera_plugin.cpp.o
ninja: build stopped: subcommand failed.
[945/949] Linking CXX executable bin/px4
FAILED: external/Stamp/sitl_gazebo-classic/sitl_gazebo-classic-build
cd /home/kjarrah/workspace/Jarrah_thesis/PX4-Autopilot/build/px4_sitl_default/build_gazebo-classic && /usr/bin/cmake --build /home/kjarrah/workspace/Jarrah_thesis/PX4-Autopilot/build/px4_sitl_default/build_gazebo-classic -- -j 3
ninja: build stopped: subcommand failed.
Makefile:232: recipe for target 'px4_sitl' failed
make: *** [px4_sitl] Error 1
I do appreciate helping me what dependencies are missing to fix this issue.