Setting Up PX4 Development Environment – Using Gazebo Classic Simulator

Hello. This is Aiden from the Marketing Team.

Next, I would like to introduce the setup of the PX4 development environment, specifically focusing on how to use the Gazebo Classic simulator. Please note that this content is registered under the copyright of the QUAD Drone Lab, and we kindly ask you to refrain from unauthorized distribution.


Gazebo Classic is a powerful 3D simulation environment for autonomous robots that is particularly suitable for object avoidance and computer vision testing. This page describes its use in SITL (Software In The Loop) and with a single vehicle. Gazebo Classic can also be used for HITL (Hardware In The Loop) and multi-vehicle simulations.

Supported Vehicles: Quad (Iris, Hex (Typhoon H480)), General Standard VTOL (QuadPlane), Tailsitter, Plane, Rover, and Submarine/UUV.

인어 그래프: Gazebo 플러그인

Installation

Gazebo Classic 9 or 11 settings are included in the Standard Build Instructions
for Linux, macOS, and Windows. Additional installation instructions can be found at gazebosim.org.

Running the Simulation

Bash
cd /path/to/PX4-Autopilot
make px4_sitl gazebo-classic

Supported vehicles and their corresponding make commands are listed below:

VehicleCommand
Quadrotormake px4_sitl gazebo-classic
Quadrotor with Optical Flowmake px4_sitl gazebo-classic_iris_opt_flow
Quadrotor with Depth Camera (forward-facing)make px4_sitl gazebo-classic_iris_depth_camera
Quadrotor with Depth Camera (downward-facing)make px4_sitl gazebo-classic_iris_downward_depth_camera
3DR Solo (Quadrotor)make px4_sitl gazebo-classic_solo
Typhoon H480 (Hexrotor) (with video streaming)make px4_sitl gazebo-classic_typhoon_h480
Standard Planemake px4_sitl gazebo-classic_plane
Standard Plane (with catapult launch)make px4_sitl gazebo-classic_plane_catapult
Standard VTOLmake px4_sitl gazebo-classic_standard_vtol
Tailsitter VTOLmake px4_sitl gazebo-classic_tailsitter
Ackerman UGV (Rover)make px4_sitl gazebo-classic_rover
Differential UGV (Rover)make px4_sitl gazebo-classic_r1_rover
HippoCampus TUHH (UUV: Unmanned Underwater Vehicle)make px4_sitl gazebo-classic_uuv_hippocampus
Boat (USV: Unmanned Surface Vehicle)make px4_sitl gazebo-classic_boat
Cloudship (Airship)make px4_sitl gazebo-classic_cloudship

Running SITL

Once PX4 starts, the PX4 shell will be initiated as shown below.

Bash
______  __   __    ___
| ___ \ \ \ / /   /   |
| |_/ /  \ V /   / /| |
|  __/   /   \  / /_| |
| |     / /^\ \ \___  |
\_|     \/   \/     |_/

px4 starting.

INFO  [px4] Calling startup script: /bin/sh etc/init.d-posix/rcS 0
INFO  [param] selected parameter default file eeprom/parameters_10016
[param] Loaded: eeprom/parameters_10016
INFO  [dataman] Unknown restart, data manager file './dataman' size is 11798680 bytes
INFO  [simulator] Waiting for simulator to connect on TCP port 4560
Gazebo multi-robot simulator, version 9.0.0
Copyright (C) 2012 Open Source Robotics Foundation.
Released under the Apache 2 License.
http://gazebosim.org
...
INFO  [ecl/EKF] 5188000: commencing GPS fusion

The console displays the status as PX4 loads the vehicle-specific initialization and parameter files and waits for (and connects to) the simulator. Once the INFO printout “[ecl/EKF] commencing GPS fusion” appears, the vehicle is ready to be armed.

MEMO

Right-clicking on the quadrotor model allows you to enable Follow Mode from the context menu, which is convenient for keeping the vehicle in view at all times.

Gazebo Classic UI

You can take off into the air by entering the following:

Bash
pxh> commander takeoff

Usage / Configuration Options

Simulating Sensor/Hardware Failures

Failsafe Simulation explains how to trigger safety features such as GPS failure and battery depletion.

Headless Mode

Gazebo Classic can be run in headless mode, where the Gazebo Classic UI is not launched. This results in faster startup times and uses fewer system resources (making it a “lighter” way to run simulations).

You can simply prepend the following to the standard make command: HEADLESS=1

Bash
HEADLESS=1 make px4_sitl gazebo-classic_plane

Setting a Custom Takeoff Location

The takeoff location in Gazebo Classic can be set using environment variables. This overrides both the default takeoff location and any values set within the world file.

The variables to be set are PX4_HOME_ALT, PX4_HOME_LAT, and PX4_HOME_LON.

For example:

Bash
export PX4_HOME_LAT=28.452386
export PX4_HOME_LON=-13.867138
export PX4_HOME_ALT=28.5
make px4_sitl gazebo-classic

Changing the Simulation Speed

You can increase or decrease the simulation speed relative to real-time by using the PX4_SIM_SPEED_FACTOR environment variable.

Bash
export PX4_SIM_SPEED_FACTOR=2
make px4_sitl_default gazebo-classic

For more details, please refer to Simulation > Running Simulations Faster than Real-time.

Changing the Wind Speed

To simulate wind speed, add the wind_plugin to your world file and set it in m/s (SET_YOUR_WIND_SPEED). Adjust the windVelocityMax and windVelocityMean parameters as necessary.

Bash
  <plugin name='wind_plugin' filename='libgazebo_wind_plugin.so'>
      <frameId>base_link</frameId>
      <robotNamespace/>
      <windVelocityMean>SET_YOUR_WIND_SPEED</windVelocityMean>
      <windVelocityMax>20.0</windVelocityMax>
      <windVelocityVariance>0</windVelocityVariance>
      <windDirectionMean>0 1 0</windDirectionMean>
      <windDirectionVariance>0</windDirectionVariance>
      <windGustStart>0</windGustStart>
      <windGustDuration>0</windGustDuration>
      <windGustVelocityMean>0</windGustVelocityMean>
      <windGustVelocityMax>20.0</windGustVelocityMax>
      <windGustVelocityVariance>0</windGustVelocityVariance>
      <windGustDirectionMean>1 0 0</windGustDirectionMean>
      <windGustDirectionVariance>0</windGustDirectionVariance>
      <windPubTopic>world_wind</windPubTopic>
    </plugin>

You can see how this is implemented in PX4/PX4-SITL_gazebo-classic/worlds/windy.world.

Using a Joystick

Joystick support is provided through QGroundControl (see the setup instructions here).

GPS Noise Simulation

Gazebo Classic can simulate GPS noise similar to what is typically found in real-world systems (otherwise, the reported GPS values would be noiseless and perfect). This is useful when working on applications that may be affected by GPS noise, such as precision positioning.

To enable GPS noise, the vehicle’s SDF file must contain the <gpsNoise> element set to true (i.e., <gpsNoise>true</gpsNoise>). This is enabled by default in the SDF files of many vehicles, such as solo.sdf, iris.sdf, standard_vtol.sdf, delta_wing.sdf, plane.sdf, typhoon_h480, and tailsitter.sdf.

To enable/disable GPS noise:

  1. To generate the SDF files, build the Gazebo target for any vehicle. For example:
Bash
   make px4_sitl gazebo-classic_iris
  1. If this line exists, it means GPS noise is enabled. You can disable it by deleting the following line: <gpsNoise>true</gpsNoise>.
  2. gpsNoise 요소를 검색합니다:
Bash
   <plugin name='gps_plugin' filename='libgazebo_gps_plugin.so'>
     <robotNamespace/>
     <gpsNoise>true</gpsNoise>
   </plugin>
  • If that line exists, it means GPS noise is enabled. You can disable it by deleting the following line: <gpsNoise>true</gpsNoise>
  • If the element does not exist, GPS noise is disabled. You can enable it by adding the gpsNoise element within the gps_plugin section, as shown below: <gpsNoise>true</gpsNoise>

The next time you build or restart Gazebo Classic, the new GPS noise settings will be applied.

특정 세계 로드

PX4 supports several Worlds stored in PX4-Autopilot/Tools/simulation/gazebo-classic/sitl_gazebo-classic/worlds. By default, Gazebo Classic displays a featureless flat plane as defined in empty.world.

You can load a specific world by specifying it as the final option in the PX4 configuration target.

For example, to load the Warehouse world, you can add it as follows:

Bash
make px4_sitl_default gazebo-classic_plane_cam__warehouse

Simulated Depth Camera

Gazebo Classic simulates the Intel® RealSense™ D455 stereo depth camera using the Openni Kinect plugin for its depth camera model.

This publishes depth images and camera information to the ROS topics /camera/depth/image_raw and /camera/depth/camera_info, respectively.

To use these images, you must have ROS or ROS 2 installed. Please refer to the warning at the top of this page regarding how to “avoid installation conflicts” when installing ROS and Gazebo.

You can simulate a quadrotor using a forward-facing depth camera.

Bash
make px4_sitl gazebo-classic_iris_depth_camera

Alternatively, a quadrotor with a downward-facing depth camera:

Bash
make px4_sitl gazebo-classic_iris_downward_depth_camera

Video Streaming

PX4 SITL for Gazebo Classic supports UDP video streaming from camera sensors attached to the simulated vehicle model. When streaming is enabled, you can connect to this stream in QGroundControl (UDP port 5600) and view the video of the Gazebo Classic environment from the simulated vehicle, just as you would with a real camera. The video is streamed using a gstreamer pipeline and can be enabled/disabled using a button in the Gazebo Classic UI.

Prerequisites

Video streaming requires GStreamer 1.0. The necessary dependencies should already be installed when you set up Gazebo Classic (they are included in the standard PX4 installation scripts and instructions for both macOS and Ubuntu Linux).

MEMO

For your reference, the dependencies include gstreamer1.0-plugins-base, gstreamer1.0-plugins-good, gstreamer1.0-plugins-bad, gstreamer1.0-plugins-ugly, and libgstreamer-plugins-base1.0-dev.

Starting/Stopping Video Streaming

Video streaming starts automatically if supported by the target vehicle. For example, to start video streaming on the Typhoon H480:

Bash
make px4_sitl gazebo-classic_typhoon_h480

You can pause or resume streaming by using the Video ON/OFF button in the Gazebo UI.

Video ON/OFF Button

How to View the Gazebo Video Stream

The simplest way to view the SITL/Gazebo Classic camera video stream is by using QGroundControl. Simply open Application Settings > General, set the Video Source to UDP h.264 Video Stream, and set the UDP Port to 5600.

QGC Video Streaming Settings for Gazebo

Then the video from Gazebo Classic should appear in QGroundControl, just as it would from a real camera.

Example: Viewing Gazebo Video Stream in QGC

MEMO

It is also possible to view the video using a GStreamer pipeline. Simply enter the following command in your terminal:

Bash
gst-launch-1.0  -v udpsrc port=5600 caps='application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264' \
! rtph264depay ! avdec_h264 ! videoconvert ! autovideosink fps-update-interval=1000 sync=false

Detailed Logging

If there is an issue with the model, SITL will fail automatically. You can enable more detailed logging using VERBOSE_SIM as follows:

Bash
export VERBOSE_SIM=1
make px4_sitl gazebo-classic

or

Bash
VERBOSE_SIM=1 make px4_sitl gazebo-classic


That concludes the third step: How to use the Gazebo Classic simulator. We covered quite a bit of ground today. Since the material is extensive, please take the time to review it repeatedly to ensure there are no mistakes in your implementation.
Next, I will return with a guide on configuring the ROS 2 + PX4 Toolchain.


Author: Aiden, Marketing Director of QUAD Drone Lab

DATE: February 16, 2026

Similar Posts

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다