mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-18 01:33:34 +08:00
Move PX4 Guide source into /docs (#24490)
* Add vitepress tree * Update existing workflows so they dont trigger on changes in the docs path * Add nojekyll, package.json, LICENCE etc * Add crowdin docs upload/download scripts * Add docs flaw checker workflows * Used docs prefix for docs workflows * Crowdin obvious fixes * ci: docs move to self hosted runner runs on a beefy server for faster builds Signed-off-by: Ramon Roche <mrpollo@gmail.com> * ci: don't run build action for docs or ci changes Signed-off-by: Ramon Roche <mrpollo@gmail.com> * ci: update runners Signed-off-by: Ramon Roche <mrpollo@gmail.com> * Add docs/en * Add docs assets and scripts * Fix up editlinks to point to PX4 sources * Download just the translations that are supported * Add translation sources for zh, uk, ko * Update latest tranlsation and uorb graphs * update vitepress to latest --------- Signed-off-by: Ramon Roche <mrpollo@gmail.com> Co-authored-by: Ramon Roche <mrpollo@gmail.com>
This commit is contained in:
co-authored by
Ramon Roche
parent
8e6d2ebe4a
commit
88d623bedb
@@ -0,0 +1,21 @@
|
||||
# Community Supported Simulators
|
||||
|
||||
This section contains information about _community-supported_ simulations
|
||||
|
||||
:::warning
|
||||
These simulators are not maintained, tested, or supported, by the core development team.
|
||||
They may or may not work with current versions of PX4.
|
||||
|
||||
See [Toolchain Installation](../dev_setup/dev_env.md) for information about the environments and tools supported by the core development team.
|
||||
:::
|
||||
|
||||
The tools have variable levels of support from their communities (some are well supported and others are not).
|
||||
Questions about these tools should be raised on the [discussion forums](../contribute/support.md#forums-and-chat)
|
||||
|
||||
| Simulator | Description |
|
||||
| ---------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| [FlightGear](../sim_flightgear/index.md) | <p>A simulator that provides physically and visually realistic simulations. In particular it can simulate many weather conditions, including thunderstorms, snow, rain and hail, and can also simulate thermals and different types of atmospheric flows. [Multi-vehicle simulation](../sim_flightgear/multi_vehicle.md) is also supported.</p> <p><strong>Supported Vehicles:</strong> Plane, Autogyro, Rover</p> |
|
||||
| [JMAVSim](../sim_jmavsim/index.md) | <p>A simple multirotor/quad simulator. This was previously part of the PX4 development toolchain but was removed in favour of [Gazebo](../sim_gazebo_gz/index.md).</p> <p><strong>Supported Vehicles:</strong> Quad</p> |
|
||||
| [JSBSim](../sim_jsbsim/index.md) | <p>A simulator that provides advanced flight dynamics models. This can be used to model realistic flight dynamics based on wind tunnel data.</p> <p><strong>Supported Vehicles:</strong> Plane, Quad, Hex</p> |
|
||||
| [AirSim](../sim_airsim/index.md) | <p>A cross platform simulator that provides physically and visually realistic simulations. This simulator is resource intensive, and requires a very significantly more powerful computer than the other simulators described here.</p><p><strong>Supported Vehicles:</strong> Iris (MultiRotor model and a configuration for PX4 QuadRotor in the X configuration).</p> |
|
||||
| [Simulation-In-Hardware](../sim_sih/index.md) (SIH) | <p>An alternative to HITL that offers a hard real-time simulation directly on the hardware autopilot. This simulator is implemented in C++ as a PX4 module directly in the Firmware [code](https://github.com/PX4/PX4-Autopilot/tree/main/src/modules/simulation/simulator_sih). </p><p><strong>Supported Vehicles:</strong> Plane, Quad, Tailsitter, Standard VTOL</p> |
|
||||
@@ -0,0 +1,70 @@
|
||||
# Simulate Failsafes
|
||||
|
||||
[Failsafes](../config/safety.md) define the safe limits/conditions under which you can safely use PX4, and the action that will be performed if a failsafe is triggered (for example, landing, holding position, or returning to a specified point).
|
||||
|
||||
In SITL some failsafes are disabled by default to enable easier simulation usage.
|
||||
This topic explains how you can test safety-critical behavior in SITL simulation before attempting it in the real world.
|
||||
|
||||
::: info
|
||||
You can also test failsafes using [HITL simulation](../simulation/hitl.md).
|
||||
HITL uses the normal configuration parameters of your flight controller.
|
||||
:::
|
||||
|
||||
## Data Link Loss
|
||||
|
||||
The _Data Link Loss_ failsafe (unavailability of external data via MAVLink) is enabled by default.
|
||||
This makes the simulation only usable with a connected GCS, SDK, or other MAVLink application.
|
||||
|
||||
Set the parameter [NAV_DLL_ACT](../advanced_config/parameter_reference.md#NAV_DLL_ACT) to the desired failsafe action to change the behavior.
|
||||
For example, set to `0` to disable it.
|
||||
|
||||
::: info
|
||||
All parameters in SITL including this one get reset when you do `make clean`.
|
||||
:::
|
||||
|
||||
## RC Link Loss
|
||||
|
||||
The _RC Link Loss_ failsafe (unavailability of data from a remote control) is enabled by default.
|
||||
This makes the simulation only usable with either an active MAVLink or remote control connection.
|
||||
|
||||
Set the parameter [NAV_RCL_ACT](../advanced_config/parameter_reference.md#NAV_RCL_ACT) to the desired failsafe action to change the behavior.
|
||||
For example, set to `0` to disable it.
|
||||
|
||||
::: info
|
||||
All parameters in SITL including this one get reset when you do `make clean`.
|
||||
:::
|
||||
|
||||
## Low Battery
|
||||
|
||||
The simulated battery is implemented to never run out of energy, and by default only depletes to 50% of its capacity and hence reported voltage.
|
||||
This enables testing of battery indication in GCS UIs without triggering low battery reactions that might interrupt other testing.
|
||||
|
||||
To change this minimal battery percentage value use the parameter [SIM_BAT_MIN_PCT](../advanced_config/parameter_reference.md#SIM_BAT_MIN_PCT).
|
||||
|
||||
To control how fast the battery depletes to the minimal value use the parameter [SIM_BAT_DRAIN](../advanced_config/parameter_reference.md#SIM_BAT_DRAIN).
|
||||
|
||||
:::tip
|
||||
By changing [SIM_BAT_MIN_PCT](../advanced_config/parameter_reference.md#SIM_BAT_MIN_PCT) in flight, you can also test regaining capacity to simulate inaccurate battery state estimation or in-air charging technology.
|
||||
:::
|
||||
|
||||
It is also possible to disable the simulated battery using [SIM_BAT_ENABLE](../advanced_config/parameter_reference.md#SIM_BAT_ENABLE) in order to, for example, provide an external battery simulation via MAVLink.
|
||||
|
||||
## Sensor/System Failure
|
||||
|
||||
[Failure injection](../debug/failure_injection.md) can be used to simulate different types of failures in many sensors and systems.
|
||||
For example, this can be used to simulate absent or intermittent GPS, RC signal that has stopped or got stuck on a particular value, failure of the avoidance system, and much more.
|
||||
|
||||
For example, to simulate GPS failure:
|
||||
|
||||
1. Enable the parameter [SYS_FAILURE_EN](../advanced_config/parameter_reference.md#SYS_FAILURE_EN).
|
||||
1. Enter the following commands on the SITL instance _pxh shell_:
|
||||
|
||||
```sh
|
||||
# Turn (all) GPS off
|
||||
failure gps off
|
||||
|
||||
# Turn (all) GPS on
|
||||
failure gps ok
|
||||
```
|
||||
|
||||
See [System Failure Injection](../debug/failure_injection.md) for a list of supported target sensors and failure modes.
|
||||
@@ -0,0 +1,165 @@
|
||||
# Hardware in the Loop Simulation (HITL)
|
||||
|
||||
:::warning
|
||||
HITL is [community supported and maintained](../simulation/community_supported_simulators.md).
|
||||
It may or may not work with current versions of PX4.
|
||||
|
||||
See [Toolchain Installation](../dev_setup/dev_env.md) for information about the environments and tools supported by the core development team.
|
||||
:::
|
||||
|
||||
Hardware-in-the-Loop (HITL or HIL) is a simulation mode in which normal PX4 firmware is run on real flight controller hardware.
|
||||
This approach has the benefit of testing most of the actual flight code on the real hardware.
|
||||
|
||||
PX4 supports HITL for multicopters (using [jMAVSim](../sim_jmavsim/index.md) or [Gazebo Classic](../sim_gazebo_classic/index.md)) and VTOL (using Gazebo Classic).
|
||||
|
||||
<a id="compatible_airframe"></a>
|
||||
|
||||
## HITL-Compatible Airframes
|
||||
|
||||
The set of compatible airframes vs simulators is:
|
||||
|
||||
| Airframe | `SYS_AUTOSTART` | Gazebo Classic | jMAVSim |
|
||||
| ---------------------------------------------------------------------------------------------------------------- | --------------- | -------------- | ------- |
|
||||
| [HIL Quadcopter X](../airframes/airframe_reference.md#copter_simulation_hil_quadcopter_x) | 1001 | Y | Y |
|
||||
| [HIL Standard VTOL QuadPlane](../airframes/airframe_reference.md#vtol_standard_vtol_hil_standard_vtol_quadplane) | 1002 | Y |
|
||||
| [Generic Quadrotor x](../airframes/airframe_reference.md#copter_quadrotor_x_generic_quadcopter) copter | 4001 | Y | Y |
|
||||
|
||||
<a id="simulation_environment"></a>
|
||||
|
||||
## HITL Simulation Environment
|
||||
|
||||
With Hardware-in-the-Loop (HITL) simulation the normal PX4 firmware is run on real hardware.
|
||||
JMAVSim or Gazebo Classic (running on a development computer) are connected to the flight controller hardware via USB/UART.
|
||||
The simulator acts as gateway to share MAVLink data between PX4 and _QGroundControl_.
|
||||
|
||||
::: info
|
||||
The simulator can also be connected via UDP if the flight controller has networking support and uses a stable, low-latency connection (e.g. a wired Ethernet connection - WiFi is usually not sufficiently reliable).
|
||||
For example, this configuration has been tested with PX4 running on a Raspberry Pi connected via Ethernet to the computer (a startup configuration that includes the command for running jMAVSim can be found [here](https://github.com/PX4/PX4-Autopilot/blob/main/posix-configs/rpi/px4_hil.config)).
|
||||
:::
|
||||
|
||||
The diagram below shows the simulation environment:
|
||||
|
||||
- A HITL configuration is selected (via _QGroundControl_) that doesn't start any real sensors.
|
||||
- _jMAVSim_ or _Gazebo Classic_ are connected to the flight controller via USB.
|
||||
- The simulator is connected to _QGroundControl_ via UDP and bridges its MAVLink messages to PX4.
|
||||
- _Gazebo Classic_ and _jMAVSim_ can also connect to an offboard API and bridge MAVLink messages to PX4.
|
||||
- (Optional) A serial connection can be used to connect Joystick/Gamepad hardware via _QGroundControl_.
|
||||
|
||||

|
||||
|
||||
## HITL vs SITL
|
||||
|
||||
SITL runs on a development computer in a simulated environment, and uses firmware specifically generated for that environment.
|
||||
Other than simulation drivers to provide fake environmental data from the simulator the system behaves normally.
|
||||
|
||||
By contrast, HITL runs normal PX4 firmware in "HITL mode", on normal hardware.
|
||||
The simulation data enters the system at a different point than for SITL.
|
||||
Core modules like commander and sensors have HITL modes at startup that bypass some of the normal functionality.
|
||||
|
||||
In summary, HITL runs PX4 on the actual hardware using standard firmware, but SITL actually executes more of the standard system code.
|
||||
|
||||
## Setting up HITL
|
||||
|
||||
### PX4 Configuration
|
||||
|
||||
1. Connect the autopilot directly to _QGroundControl_ via USB.
|
||||
1. Enable HITL Mode
|
||||
|
||||
1. Open **Setup > Safety** section.
|
||||
1. Enable HITL mode by selecting **Enabled** from the _HITL Enabled_ list:
|
||||
|
||||

|
||||
|
||||
1. Select Airframe
|
||||
|
||||
1. Open **Setup > Airframes**
|
||||
1. Select a [compatible airframe](#compatible_airframe) you want to test.
|
||||
Then click **Apply and Restart** on top-right of the _Airframe Setup_ page.
|
||||
|
||||

|
||||
|
||||
1. Calibrate your RC or Joystick, if needed.
|
||||
1. Setup UDP
|
||||
|
||||
1. Under the _General_ tab of the settings menu, uncheck all _AutoConnect_ boxes except for **UDP**.
|
||||
|
||||

|
||||
|
||||
1. (Optional) Configure Joystick and Failsafe.
|
||||
Set the following [parameters](../advanced_config/parameters.md) in order to use a joystick instead of an RC remote control transmitter:
|
||||
|
||||
- [COM_RC_IN_MODE](../advanced_config/parameter_reference.md#COM_RC_IN_MODE) to "Joystick/No RC Checks". This allows joystick input and disables RC input checks.
|
||||
- [NAV_RCL_ACT](../advanced_config/parameter_reference.md#NAV_RCL_ACT) to "Disabled". This ensures that no RC failsafe actions interfere when not running HITL with a radio control.
|
||||
|
||||
:::tip
|
||||
The _QGroundControl User Guide_ also has instructions on [Joystick](https://docs.qgroundcontrol.com/master/en/qgc-user-guide/setup_view/joystick.html) and [Virtual Joystick](https://docs.qgroundcontrol.com/master/en/qgc-user-guide/settings_view/virtual_joystick.html) setup.
|
||||
:::
|
||||
|
||||
Once configuration is complete, **close** _QGroundControl_ and disconnect the flight controller hardware from the computer.
|
||||
|
||||
### Simulator-Specific Setup
|
||||
|
||||
Follow the appropriate setup steps for the specific simulator in the following sections.
|
||||
|
||||
#### Gazebo Classic
|
||||
|
||||
::: info
|
||||
Make sure _QGroundControl_ is not running!
|
||||
:::
|
||||
|
||||
1. Build PX4 with [Gazebo Classic](../sim_gazebo_classic/index.md) (in order to build the Gazebo Classic plugins).
|
||||
|
||||
```sh
|
||||
cd <Firmware_clone>
|
||||
DONT_RUN=1 make px4_sitl_default gazebo-classic
|
||||
```
|
||||
|
||||
1. Open the vehicle model's sdf file (e.g. **Tools/simulation/gazebo-classic/sitl_gazebo-classic/models/iris_hitl/iris_hitl.sdf**).
|
||||
1. Replace the `serialDevice` parameter (`/dev/ttyACM0`) if necessary.
|
||||
|
||||
::: info
|
||||
The serial device depends on what port is used to connect the vehicle to the computer (this is usually `/dev/ttyACM0`).
|
||||
An easy way to check on Ubuntu is to plug in the autopilot, open up a terminal, and type `dmesg | grep "tty"`.
|
||||
The correct device will be the last one shown.
|
||||
:::
|
||||
|
||||
1. Set up the environment variables:
|
||||
|
||||
```sh
|
||||
source Tools/simulation/gazebo-classic/setup_gazebo.bash $(pwd) $(pwd)/build/px4_sitl_default
|
||||
```
|
||||
|
||||
and run Gazebo Classic in HITL mode:
|
||||
|
||||
```sh
|
||||
gazebo Tools/simulation/gazebo-classic/sitl_gazebo-classic/worlds/hitl_iris.world
|
||||
```
|
||||
|
||||
1. Start _QGroundControl_.
|
||||
It should autoconnect to PX4 and Gazebo Classic.
|
||||
|
||||
#### jMAVSim (Quadrotor only)
|
||||
|
||||
::: info
|
||||
Make sure _QGroundControl_ is not running!
|
||||
:::
|
||||
|
||||
1. Connect the flight controller to the computer and wait for it to boot.
|
||||
1. Run jMAVSim in HITL mode:
|
||||
|
||||
```sh
|
||||
./Tools/simulation/jmavsim/jmavsim_run.sh -q -s -d /dev/ttyACM0 -b 921600 -r 250
|
||||
```
|
||||
|
||||
::: info
|
||||
Replace the serial port name `/dev/ttyACM0` as appropriate.
|
||||
On macOS this port would be `/dev/tty.usbmodem1`.
|
||||
On Windows (including Cygwin) it would be the COM1 or another port - check the connection in the Windows Device Manager.
|
||||
:::
|
||||
|
||||
1. Start _QGroundControl_.
|
||||
It should autoconnect to PX4 and jMAVSim.
|
||||
|
||||
## Fly an Autonomous Mission in HITL
|
||||
|
||||
You should be able to use _QGroundControl_ to [run missions](https://docs.qgroundcontrol.com/master/en/qgc-user-guide/fly_view/fly_view.html#missions) and otherwise control the vehicle.
|
||||
@@ -0,0 +1,336 @@
|
||||
# Simulation
|
||||
|
||||
Simulators allow PX4 flight code to control a computer modeled vehicle in a simulated "world".
|
||||
You can interact with this vehicle just as you might with a real vehicle, using _QGroundControl_, an offboard API, or a radio controller/gamepad.
|
||||
|
||||
:::tip
|
||||
Simulation is a quick, easy, and most importantly, _safe_ way to test changes to PX4 code before attempting to fly in the real world.
|
||||
It is also a good way to start flying with PX4 when you haven't yet got a vehicle to experiment with.
|
||||
:::
|
||||
|
||||
PX4 supports both _Software In the Loop (SITL)_ simulation, where the flight stack runs on computer (either the same computer or another computer on the same network) and _Hardware In the Loop (HITL)_ simulation using a simulation firmware on a real flight controller board.
|
||||
|
||||
Information about available simulators and how to set them up are provided in the next section.
|
||||
The other sections provide general information about how the simulator works, and are not required to _use_ the simulators.
|
||||
|
||||
## Supported Simulators
|
||||
|
||||
The following simulators are supported by the PX4 core development team.
|
||||
|
||||
| Simulator | Description |
|
||||
| ------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| [Gazebo](../sim_gazebo_gz/index.md) | Gazebo supersedes [Gazebo Classic](../sim_gazebo_classic/index.md), featuring more advanced rendering, physics and sensor models. It is the only version of Gazebo available from Ubuntu Linux 22.04<br><br>A powerful 3D simulation environment that is particularly suitable for testing object-avoidance and computer vision. It can also be used for [multi-vehicle simulation](../simulation/multi-vehicle-simulation.md) and is commonly used with [ROS](../simulation/ros_interface.md), a collection of tools for automating vehicle control. <br><br><strong>Supported Vehicles:</strong> Quad, VTOL (Standard, Tailsitter, Tiltroter), Plane, Rovers |
|
||||
| [Gazebo Classic](../sim_gazebo_classic/index.md) | A powerful 3D simulation environment that is particularly suitable for testing object-avoidance and computer vision. It can also be used for [multi-vehicle simulation](../simulation/multi-vehicle-simulation.md) and is commonly used with [ROS](../simulation/ros_interface.md), a collection of tools for automating vehicle control.<br><br>**Supported Vehicles:** Quad ([Iris](../airframes/airframe_reference.md#copter_quadrotor_x_generic_quadcopter)), Hex (Typhoon H480), [Generic Standard VTOL (QuadPlane)](../airframes/airframe_reference.md#vtol_standard_vtol_generic_standard_vtol), Tailsitter, Plane, Rover, Submarine |
|
||||
|
||||
There are also a number of [Community Supported Simulators](../simulation/community_supported_simulators.md).
|
||||
|
||||
---
|
||||
|
||||
The remainder of this topic is a "somewhat generic" description of how the simulation infrastructure works.
|
||||
It is not required to _use_ the simulators.
|
||||
|
||||
## Simulator MAVLink API
|
||||
|
||||
All simulators except for Gazebo communicate with PX4 using the Simulator MAVLink API.
|
||||
This API defines a set of MAVLink messages that supply sensor data from the simulated world to PX4 and return motor and actuator values from the flight code that will be applied to the simulated vehicle.
|
||||
The image below shows the message flow.
|
||||
|
||||

|
||||
|
||||
::: info
|
||||
A SITL build of PX4 uses [SimulatorMavlink.cpp](https://github.com/PX4/PX4-Autopilot/blob/main/src/modules/simulation/simulator_mavlink/SimulatorMavlink.cpp) to handle these messages while a hardware build in HIL mode uses [mavlink_receiver.cpp](https://github.com/PX4/PX4-Autopilot/blob/main/src/modules/mavlink/mavlink_receiver.cpp).
|
||||
Sensor data from the simulator is written to PX4 uORB topics.
|
||||
All motors / actuators are blocked, but internal software is fully operational.
|
||||
:::
|
||||
|
||||
The messages are described below (see links for specific detail).
|
||||
|
||||
| Message | Direction | Description |
|
||||
| --------------------------------------------------------------- | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| [MAV_MODE:MAV_MODE_FLAG_HIL_ENABLED][mav_mode_flag_hil_enabled] | NA | Mode flag when using simulation. All motors/actuators are blocked, but internal software is fully operational. |
|
||||
| [HIL_ACTUATOR_CONTROLS][hil_actuator_controls] | PX4 to Sim | PX4 control outputs (to motors, actuators). |
|
||||
| [HIL_SENSOR][hil_sensor] | Sim to PX4 | Simulated IMU readings in SI units in NED body frame. |
|
||||
| [HIL_GPS][hil_gps] | Sim to PX4 | The simulated GPS RAW sensor value. |
|
||||
| [HIL_OPTICAL_FLOW][hil_optical_flow] | Sim to PX4 | Simulated optical flow from a flow sensor (e.g. PX4FLOW or optical mouse sensor) |
|
||||
| [HIL_STATE_QUATERNION][hil_state_quaternion] | Sim to PX4 | Contains the actual "simulated" vehicle position, attitude, speed etc. This can be logged and compared to PX4's estimates for analysis and debugging (for example, checking how well an estimator works for noisy (simulated) sensor inputs). |
|
||||
| [HIL_RC_INPUTS_RAW][hil_rc_inputs_raw] | Sim to PX4 | The RAW values of the RC channels received. |
|
||||
|
||||
<!-- links for table above -->
|
||||
|
||||
[mav_mode_flag_hil_enabled]: https://mavlink.io/en/messages/common.html#MAV_MODE_FLAG_HIL_ENABLED
|
||||
[hil_actuator_controls]: https://mavlink.io/en/messages/common.html#HIL_ACTUATOR_CONTROLS
|
||||
[hil_sensor]: https://mavlink.io/en/messages/common.html#HIL_SENSOR
|
||||
[hil_gps]: https://mavlink.io/en/messages/common.html#HIL_GPS
|
||||
[hil_optical_flow]: https://mavlink.io/en/messages/common.html#HIL_OPTICAL_FLOW
|
||||
[hil_state_quaternion]: https://mavlink.io/en/messages/common.html#HIL_STATE_QUATERNION
|
||||
[hil_rc_inputs_raw]: https://mavlink.io/en/messages/common.html#HIL_RC_INPUTS_RAW
|
||||
|
||||
<!-- above ^^^ links for table -->
|
||||
|
||||
PX4 directly uses the [Gazebo API](https://gazebosim.org/docs) to interface with [Gazebo](../sim_gazebo_gz/index.md) and MAVlink is not required.
|
||||
|
||||
## Default PX4 MAVLink UDP Ports
|
||||
|
||||
By default, PX4 uses commonly established UDP ports for MAVLink communication with ground control stations (e.g. _QGroundControl_), Offboard APIs (e.g. MAVSDK, MAVROS) and simulator APIs (e.g. Gazebo).
|
||||
These ports are:
|
||||
|
||||
- PX4's remote UDP Port **14550** is used for communication with ground control stations.
|
||||
GCS are expected to listen for connections on this port.
|
||||
_QGroundControl_ listens to this port by default.
|
||||
- PX4's remote UDP Port **14540** is used for communication with offboard APIs.
|
||||
Offboard APIs are expected to listen for connections on this port.
|
||||
::: info
|
||||
Multi-vehicle simulations use a separate remote port for each instance, allocated sequentially from `14540` to `14549`
|
||||
(additional instances all use port `14549`).
|
||||
:::
|
||||
- The simulator's local TCP Port, **4560**, is used for communication with PX4.
|
||||
The simulator listens to this port, and PX4 initiates a TCP connection to it.
|
||||
|
||||
::: info
|
||||
The ports for the GCS, offboard APIs and simulator are specified by startup scripts.
|
||||
See [System Startup](../concept/system_startup.md) to learn more.
|
||||
:::
|
||||
|
||||
<!-- A useful discussion about UDP ports here: https://github.com/PX4/PX4-user_guide/issues/1035#issuecomment-777243106 -->
|
||||
|
||||
## SITL Simulation Environment
|
||||
|
||||
The diagram below shows a typical SITL simulation environment for any of the supported simulators that use MAVLink (i.e. all of them except Gazebo).
|
||||
|
||||

|
||||
|
||||
The different parts of the system connect via UDP, and can be run on either the same computer or another computer on the same network.
|
||||
|
||||
- PX4 uses a simulation-specific module to connect to the simulator's local TCP port 4560.
|
||||
Simulators then exchange information with PX4 using the [Simulator MAVLink API](#simulator-mavlink-api) described above.
|
||||
PX4 on SITL and the simulator can run on either the same computer or different computers on the same network.
|
||||
|
||||
::: info
|
||||
Simulators can also use the _uxrce-dds bridge_ ([XRCE-DDS](../middleware/uxrce_dds.md)) to directly interact with PX4 (i.e. via [UORB topics](../middleware/uorb.md) rather than MAVLink).
|
||||
This approach _may_ used by Gazebo Classic for [multi-vehicle simulation](../sim_gazebo_classic/multi_vehicle_simulation.md#build-and-test-xrce-dds).
|
||||
:::
|
||||
|
||||
- PX4 uses the normal MAVLink module to connect to ground stations and external developer APIs like MAVSDK or ROS
|
||||
- Ground stations listen to PX4's remote UDP port: `14550`
|
||||
- External developer APIs listen to PX4's remote UDP port: `14540`.
|
||||
For multi-vehicle simulations, PX4 sequentially allocates a separate remote port for each instance from `14540` to `14549` (additional instances all use port `14549`).
|
||||
- PX4 defines a number of _local_ UDP ports (`14580`,`18570`), which are sometimes used when networking with PX4 running in a container or virtual machine.
|
||||
These are not recommended for "general" use and may change in future.
|
||||
- A serial connection may be used to connect [Joystick/Gamepad](../config/joystick.md) hardware via _QGroundControl_.
|
||||
|
||||
If you use the normal build system SITL `make` configuration targets (see next section) then both SITL and the Simulator will be launched on the same computer and the ports above will automatically be configured.
|
||||
You can configure additional MAVLink UDP connections and otherwise modify the simulation environment in the build configuration and initialisation files.
|
||||
|
||||
### Starting/Building SITL Simulation
|
||||
|
||||
The build system makes it very easy to build and start PX4 on SITL, launch a simulator, and connect them.
|
||||
The syntax (simplified) looks like this:
|
||||
|
||||
```sh
|
||||
make px4_sitl simulator[_vehicle-model]
|
||||
```
|
||||
|
||||
where `simulator` is `gz` (for Gazebo), `gazebo-classic`, `jmavsim` or some other simulator, and vehicle-model is a particular vehicle type supported by that simulator ([Gazebo](../sim_gazebo_gz/index.md) and [jMAVSim](../sim_jmavsim/index.md) only support multicopters at time of writing, while [Gazebo Classic](../sim_gazebo_classic/index.md) supports many different types).
|
||||
|
||||
A number of examples are shown below, and there are many more in the individual pages for each of the simulators:
|
||||
|
||||
```sh
|
||||
# Start Gazebo with the x500 multicopter
|
||||
make px4_sitl gz_x500
|
||||
|
||||
# Start Gazebo Classic with plane
|
||||
make px4_sitl gazebo-classic_plane
|
||||
|
||||
# Start Gazebo Classic with iris and optical flow
|
||||
make px4_sitl gazebo-classic_iris_opt_flow
|
||||
|
||||
# Start JMavSim with iris (default vehicle model)
|
||||
make px4_sitl jmavsim
|
||||
|
||||
# Start PX4 with no simulator (i.e. to use your own "custom" simulator)
|
||||
make px4_sitl none_iris
|
||||
```
|
||||
|
||||
The simulation can be further configured via environment variables:
|
||||
|
||||
- `PX4_ESTIMATOR`: This variable configures which estimator to use.
|
||||
Possible options are: `ekf2` (default), `lpe` (deprecated).
|
||||
It can be set via `export PX4_ESTIMATOR=lpe` before running the simulation.
|
||||
|
||||
The syntax described here is simplified, and there are many other options that you can configure via _make_ - for example, to set that you wish to connect to an IDE or debugger.
|
||||
For more information see: [Building the Code > PX4 Make Build Targets](../dev_setup/building_px4.md#px4-make-build-targets).
|
||||
|
||||
### Run Simulation Faster than Realtime {#simulation_speed}
|
||||
|
||||
SITL can be run faster or slower than real-time when using Gazebo, Gazebo Classic, or jMAVSim.
|
||||
|
||||
The speed factor is set using the environment variable `PX4_SIM_SPEED_FACTOR`.
|
||||
|
||||
::: info
|
||||
PX4 SITL and the simulators are run in _lockstep_, which means that they are locked to run at the same speed, and therefore can react appropriately to sensor and actuator messages.
|
||||
This is what makes it possible to run the simulation at different speeds, and also pause the simulation in order to step through code.
|
||||
:::
|
||||
|
||||
For more information see:
|
||||
|
||||
- Gazebo: [Change Simulation Speed](../sim_gazebo_gz/index.md#change-simulation-speed)
|
||||
- Gazebo Classic: [Change Simulation Speed](../sim_gazebo_classic/index.md#change-simulation-speed) and [Lockstep](../sim_gazebo_classic/index.md#lockstep)
|
||||
- jMAVSim: [Change Simulation Speed](../sim_jmavsim/index.md#change-simulation-speed) and [Lockstep](../sim_jmavsim/index.md#lockstep)
|
||||
|
||||
### Startup Scripts
|
||||
|
||||
Scripts are used to control which parameter settings to use or which modules to start.
|
||||
They are located in the [ROMFS/px4fmu_common/init.d-posix](https://github.com/PX4/PX4-Autopilot/tree/main/ROMFS/px4fmu_common/init.d-posix) directory, the `rcS` file is the main entry point.
|
||||
See [System Startup](../concept/system_startup.md) for more information.
|
||||
|
||||
### Simulating Failsafes and Sensor/Hardware Failure
|
||||
|
||||
[Simulate Failsafes](../simulation/failsafes.md) explains how to trigger safety failsafes like GPS failure and battery drain.
|
||||
|
||||
## HITL Simulation Environment
|
||||
|
||||
With Hardware-in-the-Loop (HITL) simulation the normal PX4 firmware is run on real hardware.
|
||||
The HITL Simulation Environment in documented in: [HITL Simulation](../simulation/hitl.md).
|
||||
|
||||
## Joystick/Gamepad Integration
|
||||
|
||||
_QGroundControl_ desktop versions can connect to a USB Joystick/Gamepad and send its movement commands and button presses to PX4 over MAVLink.
|
||||
This works on both SITL and HITL simulations, and allows you to directly control the simulated vehicle.
|
||||
If you don't have a joystick you can alternatively control the vehicle using QGroundControl's onscreen virtual thumbsticks.
|
||||
|
||||
For setup information see the _QGroundControl User Guide_:
|
||||
|
||||
- [Joystick Setup](https://docs.qgroundcontrol.com/master/en/qgc-user-guide/setup_view/joystick.html)
|
||||
- [Virtual Joystick](https://docs.qgroundcontrol.com/master/en/qgc-user-guide/settings_view/virtual_joystick.html)
|
||||
|
||||
<!-- FYI Airsim info on this setting up remote controls: https://github.com/Microsoft/AirSim/blob/master/docs/remote_controls.md -->
|
||||
|
||||
## Camera Simulation
|
||||
|
||||
PX4 supports capture of both still images and video from within the [Gazebo Classic](../sim_gazebo_classic/index.md) simulated environment.
|
||||
This can be enabled/set up as described in [Gazebo Glassic > Video Streaming](../sim_gazebo_classic/index.md#video-streaming).
|
||||
|
||||
The simulated camera is a gazebo classic plugin that implements the [MAVLink Camera Protocol](https://mavlink.io/en/protocol/camera.html) <!-- **PX4-Autopilot/Tools/simulation/gazebo-classic/sitl_gazebo-classic/src/gazebo_geotagged_images_plugin.cpp -->.
|
||||
PX4 connects/integrates with this camera in _exactly the same way_ as it would with any other MAVLink camera:
|
||||
|
||||
1. [TRIG_INTERFACE](../advanced_config/parameter_reference.md#TRIG_INTERFACE) must be set to `3` to configure the camera trigger driver for use with a MAVLink camera
|
||||
:::tip
|
||||
In this mode the driver just sends a [CAMERA_TRIGGER](https://mavlink.io/en/messages/common.html#CAMERA_TRIGGER) message whenever an image capture is requested.
|
||||
For more information see [Cameras Connected to Flight Controller Outputs](../camera/fc_connected_camera.md).
|
||||
:::
|
||||
1. PX4 must forward all camera commands between the GCS and the (simulator) MAVLink Camera.
|
||||
You can do this by starting [MAVLink](../modules/modules_communication.md#mavlink) with the `-f` flag as shown, specifying the UDP ports for the new connection.
|
||||
|
||||
```sh
|
||||
mavlink start -u 14558 -o 14530 -r 4000 -f -m camera
|
||||
```
|
||||
|
||||
::: info
|
||||
More than just the camera MAVLink messages will be forwarded, but the camera will ignore those that it doesn't consider relevant.
|
||||
:::
|
||||
|
||||
The same approach can be used by other simulators to implement camera support.
|
||||
|
||||
## Running Simulation on a Remote Server
|
||||
|
||||
It is possible to run the simulator on one computer, and access it from another computer on the same network (or on another network with appropriate routing).
|
||||
This might be useful, for example, if you want to test a drone application running on real companion computer hardware running against a simulated vehicle.
|
||||
|
||||
This does not work "out of the box" because PX4 does not route packets to external interfaces by default (in order to avoid spamming the network and different simulations interfering with each other).
|
||||
Instead it routes traffic internally - to "localhost".
|
||||
|
||||
There are a number of ways to make the UDP packets available on external interfaces, as outlined below.
|
||||
|
||||
### Use MAVLink Router
|
||||
|
||||
The [mavlink-router](https://github.com/mavlink-router/mavlink-router) can be used to route packets from localhost to an external interface.
|
||||
|
||||
To route packets between SITL running on one computer (sending MAVLink traffic to localhost on UDP port 14550), and QGC running on another computer (e.g. at address `10.73.41.30`) you could:
|
||||
|
||||
- Start _mavlink-router_ with the following command:
|
||||
|
||||
```sh
|
||||
mavlink-routerd -e 10.73.41.30:14550 127.0.0.1:14550
|
||||
```
|
||||
|
||||
- Use a _mavlink-router_ conf file.
|
||||
|
||||
```ini
|
||||
[UdpEndpoint QGC]
|
||||
Mode = Normal
|
||||
Address = 10.73.41.30
|
||||
Port = 14550
|
||||
|
||||
[UdpEndpoint SIM]
|
||||
Mode = Eavesdropping
|
||||
Address = 127.0.0.1
|
||||
Port = 14550
|
||||
```
|
||||
|
||||
::: info
|
||||
More information about _mavlink-router_ configuration can be found [here](https://github.com/mavlink-router/mavlink-router#running).
|
||||
:::
|
||||
|
||||
### Enable UDP Broadcasting
|
||||
|
||||
The [mavlink module](../modules/modules_communication.md#mavlink_usage) routes to _localhost_ by default, but you can enable UDP broadcasting of heartbeats using its `-p` option.
|
||||
Any remote computer on the network can then connect to the simulator by listening to the appropriate port (i.e. 14550 for _QGroundControl_).
|
||||
|
||||
::: info
|
||||
UDP broadcasting provides a simple way to set up the connection when there is only one simulation running on the network.
|
||||
Do not use this approach if there are multiple simulations running on the network (you might instead [publish to a specific address](#enable-streaming-to-specific-address)).
|
||||
:::
|
||||
|
||||
This should be done in an appropriate configuration file where `mavlink start` is called.
|
||||
For example: [/ROMFS/px4fmu_common/init.d-posix/px4-rc.mavlink](https://github.com/PX4/PX4-Autopilot/blob/main/ROMFS/px4fmu_common/init.d-posix/px4-rc.mavlink).
|
||||
|
||||
### Enable Streaming to Specific Address
|
||||
|
||||
The [mavlink module](../modules/modules_communication.md#mavlink_usage) routes to _localhost_ by default, but you can specify an external IP address to stream to using its `-t` option.
|
||||
The specified remote computer can then connect to the simulator by listening to the appropriate port (i.e. 14550 for _QGroundControl_).
|
||||
|
||||
This should be done in various configuration files where `mavlink start` is called.
|
||||
For example: [/ROMFS/px4fmu_common/init.d-posix/px4-rc.mavlink](https://github.com/PX4/PX4-Autopilot/blob/main/ROMFS/px4fmu_common/init.d-posix/px4-rc.mavlink).
|
||||
|
||||
### SSH Tunneling
|
||||
|
||||
SSH tunneling is a flexible option because the simulation computer and the system using it need not be on the same network.
|
||||
|
||||
::: info
|
||||
You might similarly use VPN to provide a tunnel to an external interface (on the same network or another network).
|
||||
:::
|
||||
|
||||
One way to create the tunnel is to use SSH tunneling options.
|
||||
The tunnel itself can be created by running the following command on _localhost_, where `remote.local` is the name of a remote computer:
|
||||
|
||||
```sh
|
||||
ssh -C -fR 14551:localhost:14551 remote.local
|
||||
```
|
||||
|
||||
The UDP packets need to be translated to TCP packets so they can be routed over SSH.
|
||||
The [netcat](https://en.wikipedia.org/wiki/Netcat) utility can be used on both sides of the tunnel - first to convert packets from UDP to TCP, and then back to UDP at the other end.
|
||||
|
||||
:::tip
|
||||
QGC must be running before executing _netcat_.
|
||||
:::
|
||||
|
||||
On the _QGroundControl_ computer, UDP packet translation may be implemented by running following commands:
|
||||
|
||||
```sh
|
||||
mkfifo /tmp/tcp2udp
|
||||
netcat -lvp 14551 < /tmp/tcp2udp | netcat -u localhost 14550 > /tmp/tcp2udp
|
||||
```
|
||||
|
||||
On the simulator side of the SSH tunnel, the command is:
|
||||
|
||||
```sh
|
||||
mkfifo /tmp/udp2tcp
|
||||
netcat -lvup 14550 < /tmp/udp2tcp | netcat localhost 14551 > /tmp/udp2tcp
|
||||
```
|
||||
|
||||
The port number `14550` is valid for connecting to QGroundControl or another GCS, but should be adjusted for other endpoints (e.g. developer APIs etc.).
|
||||
|
||||
The tunnel may in theory run indefinitely, but _netcat_ connections may need to be restarted if there is a problem.
|
||||
|
||||
The [QGC_remote_connect.bash](https://raw.githubusercontent.com/ThunderFly-aerospace/sitl_gazebo/autogyro-sitl/scripts/QGC_remote_connect.bash) script can be run on the QGC computer to automatically setup/run the above instructions.
|
||||
The simulation must already be running on the remote server, and you must be able to SSH into that server.
|
||||
@@ -0,0 +1,22 @@
|
||||
# Multi-Vehicle Simulation
|
||||
|
||||
PX4 supports multi-vehicle simulation using the following simulators:
|
||||
|
||||
- [Multi-Vehicle Sim with Gazebo](../sim_gazebo_gz/multi_vehicle_simulation.md) (both with and without ROS)
|
||||
- [Multi-Vehicle Sim with Gazebo Classic](../sim_gazebo_classic/multi_vehicle_simulation.md) (both with and without ROS)
|
||||
- [Multi-Vehicle Sim with FlightGear](../sim_flightgear/multi_vehicle.md)
|
||||
- [Multi-Vehicle Sim with JMAVSim](../sim_jmavsim/multi_vehicle.md)
|
||||
|
||||
The choice of the simulator depends on the vehicle to be simulated, how "good" the simulation needs to be (and for what features), and how many vehicles need to be simulated at a time:
|
||||
|
||||
- FlightGear is the most accurate simulator, and as a result the most heavy weight.
|
||||
It might be used if you need a great simulation but not too many vehicles at a time.
|
||||
It can also be used if different types of vehicles need to be simulated at the same time.
|
||||
- [Gazebo](../sim_gazebo_gz/index.md) is less accurate and less heavy-weight and supports many features that aren't available for FlightGear.
|
||||
It can simulate many more vehicles at a time than FlightGear and it allows for different types of vehicles to be simulated at the same time.
|
||||
It can only be used with Ubuntu 20.04 and newer.
|
||||
Note, this is the successor of [Gazebo Classic](../sim_gazebo_classic/index.md) (below).
|
||||
- [Gazebo Classic](../sim_gazebo_classic/index.md) is less accurate and less heavy-weight and supports many features and vehicles that aren't available for FlightGear.
|
||||
It can simulate many more vehicles at a time than FlightGear and it allows for different types of vehicles to be simulated at the same time.
|
||||
- JMAVSim is a very light-weight simulator that supports only quadcopters.
|
||||
It is recommended if you need to support a lot of quadcopters, and the simulation only needs to be approximate.
|
||||
@@ -0,0 +1,139 @@
|
||||
# ROS with Gazebo Classic Simulation
|
||||
|
||||
[ROS](../ros/index.md) (Robot Operating System) can be used with PX4 and the [Gazebo Classic](../sim_gazebo_classic/index.md) simulator.
|
||||
It uses the [MAVROS](../ros/mavros_installation.md) MAVLink node to communicate with PX4.
|
||||
|
||||
The ROS/Gazebo Classic integration with PX4 follows the pattern in the diagram below (this shows the _generic_ [PX4 simulation environment](../simulation/index.md#sitl-simulation-environment)).
|
||||
PX4 communicates with the simulator (e.g. Gazebo Classic) to receive sensor data from the simulated world and send motor and actuator values.
|
||||
It communicates with the GCS and an Offboard API (e.g. ROS) to send telemetry from the simulated environment and receive commands.
|
||||
|
||||

|
||||
|
||||
::: info
|
||||
The only _slight_ difference to "normal behaviour" is that ROS initiates the connection on port 14557, while it is more typical for an offboard API to listen for connections on UDP port 14540.
|
||||
:::
|
||||
|
||||
## Installing ROS and Gazebo Classic
|
||||
|
||||
[ROS (1) with MAVROS Installation Guide](../ros/mavros_installation.md) explains how to set up a guide for working with ROS (1), MAVROS, and PX4.
|
||||
|
||||
::: info
|
||||
_ROS_ is only supported on Linux (not macOS or Windows).
|
||||
:::
|
||||
|
||||
## Launching ROS/Simulation
|
||||
|
||||
The command below can be used to launch the simulation and connect ROS to it via [MAVROS](../ros/mavros_installation.md), where `fcu_url` is the IP / port of the computer running the simulation:
|
||||
|
||||
```sh
|
||||
roslaunch mavros px4.launch fcu_url:="udp://:14540@192.168.1.36:14557"
|
||||
```
|
||||
|
||||
To connect to localhost, use this URL:
|
||||
|
||||
```sh
|
||||
roslaunch mavros px4.launch fcu_url:="udp://:14540@127.0.0.1:14557"
|
||||
```
|
||||
|
||||
::: info
|
||||
It can be useful to call _roslaunch_ with the `-w NUM_WORKERS` (override number of worker threads) and/or `-v` (verbose) in order to get warnings about missing dependencies in your setup. For example:
|
||||
|
||||
```sh
|
||||
roslaunch mavros px4.launch fcu_url:="udp://:14540@127.0.0.1:14557"
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
## Launching Gazebo Classic with ROS Wrappers
|
||||
|
||||
The Gazebo Classic simulation can be modified to integrate sensors publishing directly to ROS topics e.g. the Gazebo Classic ROS laser plugin.
|
||||
To support this feature, Gazebo Classic must be launched with the appropriate ROS wrappers.
|
||||
|
||||
There are ROS launch scripts available to run the simulation wrapped in ROS:
|
||||
|
||||
- [posix_sitl.launch](https://github.com/PX4/PX4-Autopilot/blob/main/launch/posix_sitl.launch): plain SITL launch
|
||||
- [mavros_posix_sitl.launch](https://github.com/PX4/PX4-Autopilot/blob/main/launch/mavros_posix_sitl.launch): SITL and MAVROS
|
||||
|
||||
To run SITL wrapped in ROS the ROS environment needs to be updated, then launch as usual:
|
||||
|
||||
(optional): only source the catkin workspace if you compiled MAVROS or other ROS packages from source:
|
||||
|
||||
```sh
|
||||
cd <PX4-Autopilot_clone>
|
||||
DONT_RUN=1 make px4_sitl_default gazebo-classic
|
||||
source ~/catkin_ws/devel/setup.bash # (optional)
|
||||
source Tools/simulation/gazebo-classic/setup_gazebo.bash $(pwd) $(pwd)/build/px4_sitl_default
|
||||
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$(pwd)
|
||||
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$(pwd)/Tools/simulation/gazebo-classic/sitl_gazebo-classic
|
||||
roslaunch px4 posix_sitl.launch
|
||||
```
|
||||
|
||||
Include one of the above mentioned launch files in your own launch file to run your ROS application in the simulation.
|
||||
|
||||
## What's Happening Behind the Scenes
|
||||
|
||||
This section shows how the _roslaunch_ instructions provided previously actually work (you can follow them to manually launch the simulation and ROS).
|
||||
|
||||
You will need three terminals, in all of them the ros environment must be sourced.
|
||||
|
||||
First start the simulator using the command below:
|
||||
|
||||
```sh
|
||||
cd <PX4-Autopilot_clone>
|
||||
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$(pwd)
|
||||
roslaunch px4 px4.launch
|
||||
```
|
||||
|
||||
The console will look like this:
|
||||
|
||||
```sh
|
||||
INFO [px4] instance: 0
|
||||
|
||||
______ __ __ ___
|
||||
| ___ \ \ \ / / / |
|
||||
| |_/ / \ V / / /| |
|
||||
| __/ / \ / /_| |
|
||||
| | / /^\ \ \___ |
|
||||
\_| \/ \/ |_/
|
||||
|
||||
px4 starting.
|
||||
|
||||
INFO [px4] startup script: /bin/sh etc/init.d-posix/rcS 0
|
||||
INFO [init] found model autostart file as SYS_AUTOSTART=10016
|
||||
INFO [param] selected parameter default file parameters.bson
|
||||
INFO [param] importing from 'parameters.bson'
|
||||
INFO [parameters] BSON document size 295 bytes, decoded 295 bytes (INT32:12, FLOAT:3)
|
||||
INFO [param] selected parameter backup file parameters_backup.bson
|
||||
INFO [dataman] data manager file './dataman' size is 7866640 bytes
|
||||
etc/init.d-posix/rcS: 31: [: Illegal number:
|
||||
INFO [init] PX4_SIM_HOSTNAME: localhost
|
||||
INFO [simulator_mavlink] Waiting for simulator to accept connection on TCP port 4560
|
||||
```
|
||||
|
||||
In the second terminal make sure you will be able to start gazebo with the world files defined in PX4-Autopilot. To do this set your environment variables to include the appropriate `sitl_gazebo-classic` folders.
|
||||
|
||||
```sh
|
||||
cd <PX4-Autopilot_clone>
|
||||
source Tools/simulation/gazebo-classic/setup_gazebo.bash $(pwd) $(pwd)/build/px4_sitl_default
|
||||
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$(pwd)/Tools/simulation/gazebo-classic/sitl_gazebo-classic
|
||||
```
|
||||
|
||||
Now start Gazebo Classic like you would when working with ROS
|
||||
|
||||
```sh
|
||||
roslaunch gazebo_ros empty_world.launch world_name:=$(pwd)/Tools/simulation/gazebo-classic/sitl_gazebo-classic/worlds/empty.world
|
||||
```
|
||||
|
||||
In the third terminal make sure you will be able to spawn the model with the sdf files defined in PX4-Autopilot. To do this set your environment variables to include the appropriate `sitl_gazebo-classic` folders.
|
||||
|
||||
```sh
|
||||
cd <PX4-Autopilot_clone>
|
||||
source Tools/simulation/gazebo-classic/setup_gazebo.bash $(pwd) $(pwd)/build/px4_sitl_default
|
||||
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$(pwd)/Tools/simulation/gazebo-classic/sitl_gazebo-classic
|
||||
```
|
||||
|
||||
Now insert the Iris quadcopter model like you would when working with ROS. Once the Iris is loaded it will automatically connect to the px4 app.
|
||||
|
||||
```sh
|
||||
rosrun gazebo_ros spawn_model -sdf -file $(pwd)/Tools/simulation/gazebo-classic/sitl_gazebo-classic/models/iris/iris.sdf -model iris -x 0 -y 0 -z 0 -R 0 -P 0 -Y 0
|
||||
```
|
||||
Reference in New Issue
Block a user