PX4 SITL with Gazebo Simulation and ROS - Aeroclub-IITM/Installation-SITL-Gazebo-ROS GitHub Wiki

Go to px4 Firmware Github repo and git clone it. https://github.com/PX4/Firmware

Now go to this ​ site and navigate to ​ Gazebo with ROS Melodic ,​ download and run ubuntu_sim_ros_melodic.sh​ script.

To execute the script type :

source ​ ubuntu_sim_ros_melodic.sh​

Add these paths in .zshrc

export GAZEBO_PLUGIN_PATH=$GAZEBO_PLUGIN_PATH:$HOME/Firmware/build/px4_sitl_default/build_gazebo

export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:$HOME/Firmware/Tools/sitl_gazebo/models

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/Firmware/build/px4_sitl_default/build_gazebo

export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$HOME/Firmware

export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$HOME/Firmware/Tools/sitl_gazebo

Install gstreamer :

sudo apt-get install libgstreamer1.0-0 gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-doc gstreamer1.0-tools gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5 gstreamer1.0-pulseaudio

Then in terminal to source these path, type:

source ~/.zshrc

Now to get the vehicle, go to the Firmware folder and execute the commands in

https://dev.px4.io/v1.9.0/en/simulation/gazebo.html

Use this roslaunch statement to launch mavros:

roslaunch mavros px4.launch fcu_url:="udp://:[email protected]:14557"

Now the simulation is ready and can be controlled with ros nodes. Now we need to integrate with ros so that we can get and publish sensor datas from ros.

To install plugins:

sudo apt install ros-melodic-gazebo-ros ros-melodic-gazebo-plugins

Then to launch ros with px4 sitl gazebo,

cd Firmware

DONT_RUN=1 make px4_sitl_default gazebo

source ~/catkin_ws/devel/setup.zsh

roslaunch px4 posix_sitl.launch

Now type, rostopic list to see the additional ros topics. From there we can take outputs of sensors.

Install QGC( Qground Control).

Download from this site

To open the software -.

cd <directory it is in>(prob downloads)

./QGroundControl.AppImage.

You will see a drone is connected to it.This is because your SITL gives all data to QGC. Now try to arm and takeoff with QGC and observe gazebo.