# 用 FlightGear 进行多机仿真

本节介绍如何在SITL中使用 FlightGear 进行多机仿真 所有车辆实例都有其启动脚本定义的参数。

注解

This is the most environmentally realistic way to simulate multiple vehicles running PX4, and allows easy testing of multiple different types of vehicles. It is suitable for testing multi-vehicle support in QGroundControl, MAVSDK (opens new window), etc.

Multi-Vehicle Simulation with Gazebo Classic should be used instead for: swarm simulations with many vehicles, and testing features like computer vision that are only supported by Gazebo Classic. 对于准备好的脚本,你应该看到以下视图。

# 如何启动多机实例

To start multiple instances (on separate ports and IDs):

  1. 确定 支持多机的 PX4 分支 (opens new window)(查阅ThunderFly-aerospace):
    git clone https://github.com/ThunderFly-aerospace/PX4Firmware.git
    cd PX4Firmware
    git checkout flightgear-multi  
    
  2. 使用标准工具链构建PX4固件(并已安装 FlightGear)。
  3. 使用 预定义脚本 (opens new window) 启动第一个实例:
    cd ./Tools/flightgear_bridge/scripts
    ./vehicle1.sh
    
  4. 使用另一个脚本开始后续实例:
    ./vehicle2.sh
    

Each instance should have its own startup script, which can represent a completely different vehicle type. For prepared scripts you should get the following view.

Multi-vehicle simulation using PX4 SITL and FlightGear

Ground stations such as QGroundControl connect to all instances using the normal UDP port 14550 (all traffic goes to the same port).

The number of simultaneously running instances is limited mainly by computer resources. FlightGear is a single-thread application, but aerodynamics solvers consume a lot of memory. Therefore splitting to multiple computers and using a multiplayer server (opens new window) is probably required to run many vehicle instances.

# 额外资源

  • 查看 仿真 章节查看端口配置的更多信息。