GSoC 2019: AirSim Simulator Support for ArduPilot SITL Part II

The framerate shown by AP is the Physics rate, the graphics rate doesn’t affect the physics in Multirotor
Have you disabled Use Less CPU when in background?

You could also try using the new releases, they generally run faster than the Editor

I’m using the blocks pre-built, I don’t think we get any options there? I’ll try with the local build now.

I would definitely be very surprised if the binaries have the CPU problem
If you’re using Lidar, Note that right now there seems to be a problem with the lidar visualization in AirSim, enabling DrawDebugPoints in that will reduce your FPS like anything and might crash due to excessive memory usage. This is set in the Lidar settings in the AP documentation, so setting DrawDebug in the Lidar sensor settings to false will be enough
Just got to know about this problem yesterday

Yeah seems to be lidar, getting 200 fps on blocks with no lidar down to about 3 with. I will have a play with the settings. Also got the same with local build.

Good to know that the problem was being caused by lidar. I’ve added that in the Wiki PR
This is a change in behavior than UE 4.18 where it used to work without any problems

Yep with DrawDebugPoints false I get 190 fps. Must be a AirSim bug/inefficiency there.

Flying around a little seems to show the left and right side of the lidar is swapped. I guess there is a clockwise vs anti clockwise issue somewhere.

I’m looking forward to using this properly, its certainly a very powerful tool, Thanks for the help!

Hi,

I am a young student trying to build UE mit wsl2 - Ubuntu 18.04 where I installed ardupilot for SITL and they most of the time run themselves. Added the rule to my windows inbound rules. Don’t know any .profile-data. What is and where is my “.profile” ?
Putting your two lines of code in my Powershell just throws errors. Is WSL_HOST_IP a placeholder which I can replace with localhost?

ONe more question: Where is settings.json ? It is not in the win64 nor in windows taskbar search finable

Hi,
Sorry for the slightly incomplete steps. I seem to be unable to edit that post now, so will describe the steps here, will add to the Wiki directly as well after testing on a fresh WSL install

  1. The first step mostly isn’t directly required, for e.g. when launching a binary, the Windows Firewall will mostly popup saying the .exe file has been blocked, in that enable it to access Private networks as well. You can still follow the steps in https://github.com/mahmoudajawad/wsl-hacks/blob/master/wsl2-networking.md and it should work, if someone could confirm if it’s required or not, that would be great!

  2. The .profile file is located in the home directory in the Ubuntu system in WSL2. Add the below lines (you can edit using vim, nano or some other editor) -

export WSL_HOST_IP=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}')
export DISPLAY=$WSL_HOST_IP:0 
  1. The settings.json is in the Documents/AirSim folder in Windows. It’ll be created by AirSim on startup if not found. The entire settings is mentioned in the Wiki. Modify the specific lines below -
"LocalHostIp": "0.0.0.0",
"UdpIp": "172.25.239.255",

UdpIp can be found by running ip addr show eth0 inside Ubuntu in WSL

  1. Set the XWindows application settings, in particular Disable Access Control. This is described in Wiki’s WSL SITL Setup page also. The Step 2 export is also similar, just that an extra WSL_HOST_IP variable is added since it’s used next.

  2. Launch SITL finally - sim_vehicle.py -v ArduCopter -f airsim-copter -A --sim-address=$WSL_HOST_IP

Do comment if something doesn’t work!

1 Like

Thank you for your detailed instructions, and it worked for me! Below is some more feedback information from my tests, and I hope they might be helpful for others.

Test environment:
Windows 11 Pro build 22000.708, running Ubuntu 22.04LTS under WSL2. Installed Unreal Engine v4.27.2 via Epic Games Launcher. Complied AirSim under Visual Studio 2022 (Community) , and ArduPilot in WSL2 with waf.

Now, for Step 1. I’ve tested that you don’t have to follow the exact steps in https://github.com/mahmoudajawad/wsl-hacks/blob/master/wsl2-networking.md . Just check the boxes in your Windows Firewall to grant communications for UE4Editor.exe on Public and Private networks, and there’s no need to manually add new Inbound Rules.

For my case, Ubuntu 22.04LTS in WSL2 comes natively with graphical support via WSLg, so I didn’t add export DISPLAY=$WSL_HOST_IP:0 to .profile, nor the command described in WSL Setup Steps. I also didn’t install any additional XWindows app.

Other steps are done exactly as what you mentioned in your comment, and simple_vehicle.py example works perfectly fine, following the official Wiki Using SITL with AirSim.

I will be running more tests and maybe come back to this thread. Thanks again!

2 Likes

I’ve tried everything proposed above, but still not able to link AirSim on windows 10 with ArduPilot on WSL on Ubuntu 22.04.
Also “LocalHostIp”: “0.0.0.0” doesn’t work for me, instead I use “127.0.0.1”. Otherwise UE4 binareas freezes and don’t move when run.
For “UdpIp” is’t fine, i use the one obtained from “ip addr show eth0”, the right one.
But in general it doesn’t work, I got an error:
“no sensor message received in last 1s, error - bad file descriptor, resending servos”


I tried everython from all the guided I found, but always have this error

2 Likes

I’m in the same boat as you, I’m getting those same errors and I’m on Windows 11 using Colosseum and unreal engine 5. It seems like this issue is something that occurred recently.

I also had a hope that Colosseum fork will work. And I also tested ue4.27 branch, but unfortinately it doesn’t work.

Same results using AirSim unfortunately. Doesn’t seem to be unique to just Colosseum

I finally got it working, I had to downgrade to WSL1 and use XWindows to finally get everything to work and talk with each other.

Same issue here…
Tried WSL 1 & 2. Even tried using a VM with no success.
If i use 0.0.0.0 or windows ip as LocalHostIp in the settings.json, airsim just freezes once it opens.
switching to 127.0.0.1 loads the graphics with no response.
same message from sitl:
“no sensor message received in last 1s, error - bad file descriptor, resending servos”

I get a similar error message with slight variation. “No sensor message received in last 1s, error - Resource temporarily unavailable, resending servos”

Using Colosseum. Latest Windows 11. UE5.2.1.

image

In the settings file, I set the LocalHostIp to 0.0.0.0 and UdpIp to the ip found with ip addr show eth0 (one starting after “brd”).

Added “export WSL_HOST_IP=$(cat /etc/resolv.conf | grep nameserver | awk ‘{print $2}’)” to .profile.

Hi @iampete . I am trying to make this work but unable to do it. Do u have any suggestions? Im unable to connect sitl to Airsim (I followed the steps as suggested by rajat2004). But still says connection refused.

1 Like

were you able to resolve this issue ? facing same issue

1 year ago, I found rajat2004 comment and follow with great success.
but recently, when i revisit airsim and try connect airsim with ardu pilot (because i’m unemployed :smile: ), i ran into the problem again, not sure why??
→ But, rajat2004 comment still supper helpful to me, I follow the step in follow the steps in https://github.com/mahmoudajawad/wsl-hacks/blob/master/wsl2-networking.md specifically these step

, and then restart wsl and i sucessful connect ardu pilot and airsim

  • In 1 year, i haven’t pulled new code from ardu pilot, i still use airsim on unreal 4.27.2, but i updated window 11 alot, so i think one of those updates cause problem
  • Hope this comment can help
  • fly on :flags:

What worked for me is to tell Airsim and SITL explicitly which IP addresses to use. I didn’t use rajat2004 fix.
So your C:\Users\YourUsername\Documents\AirSim\settings.json looks like this:
{
“SeeDocsAt”: “AirSim/docs/settings.md at main · microsoft/AirSim · GitHub”,
“SettingsVersion”: 1.2,
“LogMessagesVisible”: true,
“SimMode”: “Multirotor”,
“OriginGeopoint”: {
“Latitude”: 37.334947,
“Longitude”: -122.012715,
“Altitude”: 583
},
“Vehicles”: {
“Copter”: {
“VehicleType”: “ArduCopter”,
“UseSerial”: false,
“LocalHostIp”: “192.168.0.85”, ← this is IP of your main Windows
“UdpIp”: “172.26.240.75”, ← this is IP of your Linux(Ubuntu) under WSL2.
“UdpPort”: 9003,
“ControlPort”: 9002
}
}
}

And you run your SITL under WSL2 by this command:
sim_vehicle.py -v ArduCopter -f airsim-copter --console --map --sim-address=192.168.0.85

It worked on Colosseum fork of Airsim on UnrealEngine 5.4 (after fixing build errors). But I guess it should work on older UE versions (5.2 is last officially supported) as well.

2 Likes