【AirSim+PX4】WSL2上运行PX4连接Airsim步骤

1.打开ubuntu终端

2.进入到 PX4-Autopilot 文件夹

cd PX4
cd PX4-Autopilot

3.修改AirSim里settings文件

将无人机的飞行模式改为PX4模式,代码如下:

{
  "SettingsVersion": 1.2,
  "SimMode": "Multirotor",
  "ClockType": "SteppableClock",
  "SubWindows": [
    {
      "WindowID": 0,
      "CameraName": "front_center_custom",
      "ImageType": 0,
      "Visible": true,
      "ImageSize": [ 480, 270 ],
      "CameraPosition": [ 0.0, 0.0, -2.5 ],
      "CameraRotation": [ 0.0, 0.0, 0.0 ]
    },
    {
      "WindowID": 1,
      "CameraName": "front_center_custom",
      "ImageType": 3,
      "Visible": true,
      "ImageSize": [ 480, 270 ],
      "CameraPosition": [ 0.0, 0.0, -2.5 ],
      "CameraRotation": [ 0.0, 0.0, 0.0 ]
    },
    {
      "WindowID": 2,
      "CameraName": "front_center_custom",
      "ImageType": 5,
      "Visible": true,
      "ImageSize": [ 480, 270 ],
      "CameraPosition": [ 0.0, 0.0, -2.5 ],
      "CameraRotation": [ 0.0, 0.0, 0.0 ]
    }
  ],
  "Vehicles": {
    "Drone": {
      "VehicleType": "PX4Multirotor",
      "UseSerial": false,
      "LockStep": true,
      "UseTcp": true,
      "TcpPort": 4560,
      "ControlIp": "172.18.105.223",
      "ControlPortLocal": 14540,
      "ControlPortRemote": 14580,
      "LocalHostIp": "172.18.96.1",
      "Sensors": {
        "Barometer": {
          "SensorType": 1,
          "Enabled": true,
          "PressureFactorSigma": 0.001825,
          "PressureFactorTau": 3600,
          "UncorrelatedNoiseSigma": 2.7,
          "UpdateLatency": 0,
          "UpdateFrequency": 50,
          "StartupDelay": 0

        },
        "Imu": {
          "SensorType": 2,
          "Enabled": true,
          "AngularRandomWalk": 0.3,
          "GyroBiasStabilityTau": 500,
          "GyroBiasStability": 4.6,
          "VelocityRandomWalk": 0.24,
          "AccelBiasStabilityTau": 800,
          "AccelBiasStability": 36
        },
        "Magnetometer": {
          "SensorType": 4,
          "Enabled": true,
          "NoiseSigma": 0.005,
          "ScaleFactor": 1,
          "NoiseBias": 0,
          "UpdateLatency": 0,
          "UpdateFrequency": 50,
          "StartupDelay": 0
        },
        "LidarSensor1": {
          "SensorType": 6,
          "Enabled": true,
          "NumberOfChannels": 16,
          "RotationsPerSecond": 10,
          "PointsPerSecond": 100000,
          "X": 0,
          "Y": 0,
          "Z": -1,
          "Roll": 0,
          "Pitch": 0,
          "Yaw": 0,
          "VerticalFOVUpper": -15,
          "VerticalFOVLower": -25,
          "HorizontalFOVStart": -20,
          "HorizontalFOVEnd": 20,
          "DrawDebugPoints": true,
          "DataFrame": "SensorLocalFrame"
        },
        "Distance": {
          "SensorType": 5,
          "Enabled": true,
          "Yaw": 0,
          "Pitch": -90,
          "Roll": 0
        }
      }
    },
      "Parameters": {
        "NAV_RCL_ACT": 0,
        "NAV_DLL_ACT": 0,
        "COM_OBL_ACT": 1,
        "LPE_LAT": 47.641468,
        "LPE_LON": -122.140165
      }
    }
  }
}

4.设置环境变量

在 Linux 命令行中输入以下命令以添加(或改变)环境变量 。注意,此处的 IP 地址应为主机 IP(LocalHostIp)

export PX4_SIM_HOST_ADDR=172.18.96.1

5.启动 sln 文件的调试以进入 UE4 编辑器,并在 Linux 中启动 PX4

make px4_sitl_default none_iris

就可以啦~

最后记得关防火墙!!!

  • 7
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值