Using ArduPilot/PX4 with custom SITL simulation

I am building an open-source standardised SITL using Webots for object-tracking. How can I add ardupilot to my Webots SITL for Quadcopter?

I have been working on this since past 1 week. But, my controller is barely usable and I would like to integrate Ardupilot/PX4. (Specifically because I had used APM hardware before and I would like to simulate that). However, whenever I search for APM SITL, I only get results for ROS-Gazebo SITL.

Any help would be greatly appreciated!

P.S.: Please note that I have not included any links deliberately. I would be more than happy to update this post and share links of the open-source project & my research if needed.

Also, if this can be created as a feature request in Github ArduPilot repo, I would be more than happy to contribute if I am given some pointers regarding the same. (Please note that I have worked on ROS and Gazebo using Ardupilot before. However, I am not very familiar with ArduPilot codebase per se)


Support for Webots was added recently in ArduPilot. There’s a Readme here -

There’s no Wiki page till now, but hopefully gets added soon


@rajat2004 Thank you for this! I am trying this out with Cygwin (Windows).
When I run bash, I get the following: line 5: /cygdrive/d/ardupilot/libraries/SITL/examples/Webots/Tools/autotest/ No such file or directory

I am trying to compile this now (I checked the path too. That folder isn’t there) If this works out, I will help with the Wiki page if I can! :slight_smile:

EDIT: This doesn’t work in docker as sudo doesn’t work in docker. Also, GUI doesn’t work directly in docker. I am trying to get this up and running in Windows itself. However, how do I standardize this? The setup instructions need to be the same for my simulator for Windows, Mac OS and Linux

EDIT 2: No matter what I do, I get the same line 5 error even after compiling. I am not sure if I have to download examples from somewhere. I am not able to get this up and running. Let alone standardisation. ~/ardupilot/libraries/SITL/examples/Webots does not have Tools folder.

The script has to be executed from the ardupilot root directory, rather than from the Webots folder.

It’s mentioned in the script as well -

I haven’t personally used SITL with Webots before so I’m not aware of any specific problems with it, the author of the PR would be better equipped to help

1 Like

this is HefnySco,
I developed the SITL / Webot itegration.

First I use Ubuntu in my testing so I am not sure about Windows problems.
but the should be called from ardupilot root as @rajat2004 mentioned.


1- open webots.
2- open world you want to Run for example webots_quadX.wbt
3- press “RUN” button on webots. it is very important that ardupilot SITL simulator is not running.
4- now run after step “3” the order is VERY important here.

Side Notes:
1- Please make sure that you compile controller and world physics plugin.
2- controller argument takes port number in case you want to change port numbers.
3- when ever you need to rerun you should
a. STOP SITL simulator
b. Restart webots simulator
c. rerun SITL simulator.

I hope this helps

1 Like

@rajat2004 I have been running it in the ardupilot root itself. I am trying MHefny’s solution now.

@MHefny Thanks for the reply. I am facing the same issue as before! Please check

reference to our conversation here:

using your suggested docker

please add -p 5599:5599 in the run command to open port 5599 in the docker.

xhost +
docker run -it --privileged \
 --env=LOCAL_USER_ID="$(id -u)" \
 -v /tmp/.X11-unix:/tmp/.X11-unix:ro \
 -v ~/ARDU_PILOT_PATH:/ardupilot:rw \
 -e DISPLAY=:0 \
 -p 14556:14556/udp \
 -p 8080:8080 \
 -p 5599:5599 \
  evans000/uav-sitl bash
1 Like

Also you can change the .sh file that runs simulator in Webots examples.

change IP and port by adding them as extra parameters as shown:
$PWD/Tools/autotest/ -v ArduCopter -w --model webots-quad:IP:PORT --add-param-file=libraries/SITL/examples/Webots/quadPlus.parm

you dont need to change port so keep it 5599, incase you want to change it please remember to change it also in controller args in webots the -p parameter.

1 Like

As I could not run ardupilot with Webots ODE physics engine, I wrote my own flight controller capable of doing waypoint navigation. The code can be found and can be used in other projects if needed. I was thinking along the lines of this for ardupilot. But, I found my own flight controller much easier to work with.


Kindly find sitl-webots documentation here.