AirSim
AirSim copied to clipboard
GazeboDrone works with WSL2?
Question
What's your question?
I would like to work airsim on Windows 11, PX4 gazebo simulation on WSL2. What is the neccesary step? I am already able to get to work Airsim on Windows 11 and PX4 on WSL2 and run the simulation for multicopters. I would like to simulate plane model in AirSim and use PX4 gazebo plane. On ubuntu environment, I was able to work with AirSim and PX4 gazebo plane. For wsl, Is ip config or something neccesary?
Include context on what you are trying to achieve
N/A
Context details
Latest AirSim UE4 4.25 Latest PX4 WSL2 Ubuntu 18.04 installed
Include details of what you already did to find answers
Following this pages, I already can work AirSim on Windows and PX4 on WSL2 together. https://microsoft.github.io/AirSim/px4_sitl_wsl2/ And installed neccesary packages and built AirSim https://microsoft.github.io/AirSim/gazebo_drone/ When I run ./GazeboDrone it does not connect and shows the message "Waiting for connection - XXX"
Can anyone help this?
Thank you.
Hi and welcome @inuex3 !
If you look at this line, GazeboDrone connects with AirSim there. You should pass the ip address of windows as a string in that constructor. You can get it by running: $(cat /etc/resolv.conf | grep nameserver | awk '{print $2}')
in WSL.
It would be great if you can share a video with that setup when you have it working. Let me know if you need more help.
Thank you for the reply, @jonyMarino
As you mentioned, I added ip address here
https://github.com/microsoft/AirSim/blob/dc06ac9d77bee5b2176dc81abdbc54dbd0e1221e/GazeboDrone/src/main.cpp#L42
msr::airlib::MultirotorRpcLibClient client("my_ip_address");
and built.
And it started connecting!
Thanks!
How should I modify the code to accept ip address as an argument for pull request?
Saved this $(cat /etc/resolv.conf | grep nameserver | awk '{print $2}' as WSL_IP in my bashrc and then changed line 42 to: msr::airlib::MultirotorRpcLibClient client(getenv(WSL_IP)); to dynamically pass the ip. This has allowed me to connect to a client using GazeboDrone but have been unable to operate it.
My questions are;
- GazeboDrone was build using gcc-8.4 compiler; Do I have to copy this directory and place it in an AirSim that is compiled with clang (right now I have 2 AirSim folders one compiled with clang and one with gcc, Gazebodrone works with gcc and Unreal plugin of airsim with clang, if I understood correctly)
- How do i control this GazeboDrone? From what I read in the documentation after loading a settings file with PhysicsEngine ="ExternalPhysicsEngine", I must use setVehiclePose to pass the movement to AirSim ?! Is this correct ?
- I have started a roscore and the gazebo simulator before launching this but my drone doesn't spawn in the Gazebo simulator. Is that to be expected ?
@HarrySoteriou
1_ You don't need to copy anything, just use GazeboDrone on the AirSim folder compiled with GCC. 2_ No, you need to control the drone through Gazebo (For example connecting PX4 to it or just executing PX4 with a Gazebo instance (make px4_sitl gazebo...)) 3_ Yes. You need to spawn a drone in Gazebo. It is not something that GazeboDrone takes care of.
Appreciate the speedy response, I was very confused as to how to proceed, this was very helpful :)
I'm glad to be of help. Close the problem when you succeed with this.
@jonyMarino and @inuex3
Hello Jony. I am trying to realize the same use case : Run Airsim in Windows, while the gazebo engine backend is running in WSL2 along with px4 (also in WSL2). What I don't understand are the step in :
https://microsoft.github.io/AirSim/gazebo_drone/
They appear to apply to Airsim being built for linux. If I try to run the build binaries of the environment "supposedly compiled using clang", my windows UE (4.27) complain that the binaries are built with a different engine version and a message comes up "try building manually"