wsl --install
If you encounter issues with this command, like I did, then manually install the correct linux distribution with the following command. wsl --install Ubuntu
WSL can be linked with Visual Studio Code by clicking the Remote Window button on the bottom left of the IDE and selecting WSL. Once connected to WSL, you can then open a new terminal and it will show the files you have connected to your WSL environment.
Running in-the-loop can be aided by a ground control station, the few that I have used for this project are:
Building and Installing the flight controller software is required for all who wish to run Software-in-the-Loop on their machine. Whether you decide to use Ardupilot or PX4 flight control software, the steps are the same. If you run into issues with any of these steps, especially starting Software-in-the-Loop, consider checking your ground control station downloads.
Documentation for what I am showing you can be found here:
Basic examples for this process are:
git clone https://github.com/ArduPilot/ardupilot.git --recursive
cd ardupilot/ArduCopter/
sim_vehicle.py --map --console
git clone https://github.com/PX4/PX4-Autopilot --recursive
cd PX4-Autopilot/
make px4_sitl_default
By default, PX4 SITL outputs data to a localhost IP. Since we are using WSL, you need to retarget this IP to the address Windows uses to communicate with WSL.
ipconfig
#!/bin/sh
export PX4_HOME_LAT=
export PX4_HOME_LON=
export PX4_HOME_ALT=0
export PX4_SIM_HOST_ADDR=
make px4_sitl_default
Setting up the Unreal Engine environment is probably the easiest part of this whole process. The steps are:
Make sure you are familiar with the Unreal Engine Project Structure before trying to use the engine.
Setting up AirSim is easy once you have the correct environment prerequisites satisified. The steps for building AirSim are:
git clone https://github.com/microsoft/AirSim.git --recursive
cd AirSim
build.cmd
This will create a folder in your AirSim repo called Unreal. This folder will contain a folder called Plugins. Once you have created an Unreal Project, copy the entire Plugins folder into the Unreal project directory.
AirSim uses a file called settings.json to specify the simulation environment settings. By default, settings.json is created in C:\Documents\Airsim\settings.json. Personally, I have moved my settings.json file to my Unreal Engine location because I have multiple Unreal Engine versions for separate projects and want the extra control. This location to put the settings.json file is …/"{UE_4.27}"/Engine/Binaries/Win64/settings.json.
Setting up the integrated simulation environment should have been done in the environment prerequisites. Therefore, this section will talk about setting up the networking requirements and settings for AirSim to accomplish integrated simulation through Software-in-the-Loop and Hardware-in-the-Loop.
Software applications open:
Networking Requirements (must allow through firewall):
ipconfig
looking for ipv4 for Windows Subsystem for Linux. Replace the LocalHostIp with this Ip address or else windows will not know where to listen for the SITL data.Example PX4 SITL settings.json file:
{
"SeeDocsAt": "https://github.com/Microsoft/AirSim/blob/main/docs/settings.md",
"SettingsVersion": 1.2,
"SimMode": "Multirotor",
"ClockType": "SteppableClock",
"Vehicles": {
"PX4Drone": {
"VehicleType": "PX4Multirotor",
"UseSerial": false,
"LockStep": true,
"UseTcp": true,
"TcpPort": 4560,
"LocalHostIp": "172.22.240.1",
"ControlPortLocal": 14540,
"ControlPortRemote": 14580,
"Sensors":{
"Barometer":{
"SensorType": 1,
"Enabled": true,
"PressureFactorSigma": 0.0001825
}
},
"Parameters": {
"NAV_RCL_ACT": 0,
"NAV_DLL_ACT": 0,
"COM_OBL_ACT": 1,
"LPE_LAT": 47.641468,
"LPE_LON": -122.140165
}
}
}
}
Example Ardupilot SITL settings.json file:
REMEMBER TO CREATE AND ADD AN ARDUPILOT SITL FILE TOO
Hardware-in-the-Loop is a little more involved. This is not within the scope of our capstone project timeline, so I hope that future iterations of this project can figure that out and fill in this section.