Using SITL with Webots

Webots is a simulator mainly used for robotics. It is easy to build many vehicles using it. ArduPilot has Rover, Quadcopter, and Tricopters examples that have been built especially for this simulator.

You can download Webots simulator from www.cyberbotics.com. To run Webots just type webots in command line.

Running the Examples

  1. Open Webots using the command line.
  2. Download and open a vehicle from the vehicle examples folder such as webots_quadPlus.wbt .
  3. Compile the Robot Controller and WorldInfo physics plugin using Webots GUI.
  4. Press Run on Webots GUI. Now the simulator is running.
  5. Run ArduPilot’s SITL using available scripts in the examples folder.
./libraries/SITL/examples/Webots/dronePlus.sh
or
./Tools/autotest/sim_vehicle.py -v ArduCopter -w --model webots-quad:127.0.0.1:5599 --add-param-file=libraries/SITL/examples/Webots/quadPlus.parm

Warning

It is always important to run Webots before ArduPilot’s SITL , otherwise the socket connection will not establish.

Simulation Parameters

There are two types of parameters, the first type is passed to SITL and the second is configured in Webots.

SITL communicates with Webots using TCP sockets, so SITL should have the same port number as Webots. Usually you don’t need to change the default port 5599, but when you run multiple robots you will need to use different ports for each simulation instance.

Advantage of Webots

  1. Controllers can be written in c, c++, python, and MatLab.
  2. A lot of sensors exist.
  3. Ability to add custom physics to simulate things such as wind.
  4. Ability to add OpenStreetMap and run the simulator in environments very similar to reality.

How to Connect Your Own World with Ardupilot

WorldInfo

The following parameters are important to be set in WorldInfo

  • Field “basicTimeStep” = 1 or 2
  • Field “northDirection” needs to be updated when using OpenStreetMap
  • Field “physics” is used to attach the physics plugin file “sitl_physics_env” which is used to simulate wind and drag in a very simple way.

Supervisor RobotSupervisor Robot

This is a technical tweak in Webots. You need to make your robot as a supervisor to be able to retrieve important information such as robot velocity, and northDirection. So if you are using a single robot it is safe to make it the supervisor as in the vehicle example. For multiple robots you need to create a supervisor robot that collects this info for all robots and forwards it to each robot. This is done by creating a dummy robot that is named “supervisor_sync”.

Other vehicles in the examples use a dummy supervisor robot to allow you to easily add multiple robots in the world without any changes. So you can use this robot as it is, in any new world without changes.

Vehicle Robot

You can copy & paste the vehicle robot multiple times, each time you need to:

  1. give the new robot a new name.
  2. Field “CustomData” should be equal to robot index number i.e. 1,2,3,…etc.
  3. Field “controller” should is selected based on the vehicle used.
  4. Field “controllerArgs” specifies many important factors, mainly the TCP port which should be equal to SITL’s TCP port that will connect to this robot in the simulator.