Developing your code
On first run, the robot will execute an example program for convenience. On first run, this will be copied to the directory
competition-simulator-<version> is stored in:
. ├── competition-simulator-<version> │ ├── ... │ └─ worlds │ └── Arena.wbt └── robot.py
Your code should be developed in
Unless otherwise stated, the simulator’s API is the same as the real SR API described in the programming docs.
Your robot has one motor board attached, the left wheel in port
m0, and the right wheel in
The motor board does not have a part code, so it needs to be indexed using
Your robot has two microswitches and six distance sensors, attached to the digital and analogue pins respectively. These are all attached to a single ruggeduino.
Because these sensors are pre-attached to the ruggeduino, you do not need to set its
The microswitches are attached to digital pins 2 and 3:
These are shown as red coloured blocks on the robot. Using the
digital_read method, you’ll receive a
bool telling you whether the switch is current actuated.
Analogous to ultrasound sensors, distance sensors allow you to retrieve the distance between your robot and an object. These are attached to analogue pins 0-5:
These are shown as blue coloured blocks on the robot. The
analogue_read method will return the distance in metres. They can see in a narrow cone up to a maximum of about 2m away.
Since these sensors rely on echoes being reflected back from objects, if the angle of incidence between the sensor’s pulse and the contacted surface exceeds 22.5 degrees then the sensor will be unable to detect the object.
The LEDs are attached to digital pins 4-9:
digital_write method, you can set these to True (On) or False (Off).
In the simulated environment, time advances only at the pace that the simulator
is run. As a result, using
time.time to know how long your robot has been
running for or
time.sleep to wait for some duration will be unreliable.
As a result the API present in the simulator supports a slightly different approach to handling time. See the documentation about simulated time for more details.