【Ubuntu 18.04 LTS】AirSim + PX4 软件在环仿真(SITL)

【Ubuntu 18.04 LTS】AirSim + PX4 软件在环仿真(SITL)

    • 1.PX4设置
      • 1.1 PX4配置
      • 1.2 编译并以SITL模式启动PX4固件
    • 2.准备仿真
      • 2.1 编辑AirSim的配置文件~/Documents/settings.json
      • 2.2 启动虚幻引擎,打开准备好的仿真环境
      • 2.3 代码控制无人机

1.PX4设置

1.1 PX4配置

在终端执行:

mkdir -p PX4
cd PX4
git clone https://github.com/PX4/Firmware.git
cd Firmware
git checkout v1.10.1 # recommended version

1.2 编译并以SITL模式启动PX4固件

make px4_sitl_default none_iris

当看到终端有下面的输出时,即编译成功,且PX4在等待仿真器(AirSim)的连接:

| ___ \ \ \ / /   /   |
| |_/ /  \ V /   / /| |
|  __/   /   \  / /_| |
| |     / /^\ \ \___  |
\_|     \/   \/     |_/
px4 starting.
INFO  [px4] Calling startup script: /bin/sh etc/init.d-posix/rcS 0
INFO  [dataman] Unknown restart, data manager file './dataman' size is 11798680 bytes
INFO  [simulator] Waiting for simulator to connect on TCP port 4560
INFO  [init] Mixer: etc/mixers/quad_w.main.mix on /dev/pwm_output0
INFO  [mavlink] mode: Normal, data rate: 4000000 B/s on udp port 14570 remote port 14550
INFO  [mavlink] mode: Onboard, data rate: 4000000 B/s on udp port 14580 remote port 14540
INFO  [logger] logger started (mode=all)
INFO  [logger] Start file log (type: full)
INFO  [logger] Opened full log file: ./log/2020-06-03/02_03_00.ulg
INFO  [mavlink] MAVLink only on localhost (set param MAV_BROADCAST = 1 to enable network)
INFO  [px4] Startup script returned successfully

2.准备仿真

2.1 编辑AirSim的配置文件~/Documents/settings.json

{
  "SeeDocsAt": "https://github.com/Microsoft/AirSim/blob/master/docs/settings.md",
  "SettingsVersion": 1.2,
  "SimMode": "Multirotor",
  "Vehicles": {
    "PX4": {
      "VehicleType": "PX4Multirotor",
      "UseSerial": false,
      "UseTcp": true,
      "TcpPort": 4560,
      "ControlPort": 14580,
      "params": {
        "NAV_RCL_ACT": 0,
        "NAV_DLL_ACT": 0,
        "LPE_LAT": 47.641468,
        "LPE_LON": -122.140165,
        "COM_OBL_ACT": 1
      }
    }
  }
}

2.2 启动虚幻引擎,打开准备好的仿真环境

此时我们可以看到终端输出

INFO  [simulator] Simulator connected on TCP port 4560.
INFO  [mavlink] partner IP: 127.0.0.1
INFO  [ecl/EKF] EKF aligned, (pressure height, IMU buf: 22, OBS buf: 14)
INFO  [ecl/EKF] 1888415: EKF GPS checks passed (WGS-84 origin set)
INFO  [ecl/EKF] 6442748: EKF commencing GPS fusion

虚幻引擎显示:

2.3 代码控制无人机

cd ~/AirSim/PythonClient/multirotor
python hello_drone.py

按数字键1.2.3还可以查看AirSim准备好的深度图、分割图和相机图像等。

你可能感兴趣的:(AirSim)