Race Code Processing states

These are the various modes that Formula.py can be in during a race event.

1. Ready to race

In this mode the YetiBorg is not doing very much at all.

The script is still taking frames from the camera but it is not trying to do anything with them.
We start off in this mode when powered up, leaving Race.py in control.

2. Waiting for the start lights

In this mode we are waiting to see the start light sequence.

The script goes into this mode when WaitForGo() is called by Race.py.
When we see the lights make their last change in the sequence we switch mode and return control to Race.py.

The mode we switch to is set by firstStraightOverride in Settings.py.
If True we will switch to mode 8 to make a dash off the starting line ignoring the camera input.
If False we will switch to mode 3 and start following the track normally.

3. Following the track

In this mode the YetiBorg tries to follow the track.

We spend most of the race in this mode with control split between Formula.py and Race.py.
Some basic overtaking behaviour is also included based on the way the track is obscured by robots in front.
Different conditions detected will change the mode (4-6) to deal with a specific situation.

4. Crashed or stuck

In this mode we try and get unstuck and resume racing.

When we are in this mode Formula.py takes over to get going again.
The YetiBorg will go backwards briefly and try to judge which way to turn to follow the track again.
After this we return to mode 3.

5. Flipped over

In this mode we have ended up upside-down :P

Control works like mode 3, but we have to drive the wrong way and flip the camera image over instead.

6. Driving the wrong way

In this mode we have ended up facing the wrong way on the track.

We try and spin around to face the correct way again before returning to mode 3.

7. Race over

In this mode we power the motors down and end the scripts.

The script goes into this mode when FinishRace() is called by Race.py.
At this stage both Formula.py and Race.py will end.

Robots which have finished will remain on the track stationary until the race has completely finished.

Calls to FinishRace() before completing the whole race will count as an early retirement or failure.

8. First straight

In this mode we drive straight forward for a preset length of time before switching to mode 3 for the standard track following code.

As this mode prevents any control from the camera, we recommend that you do not extend the firstStraightMax setting.
Making it longer will likely cause the YetiBorg to fail to make the first turn :(

By using this mode we get around any problems caused by the camera's automatic corrections when it sees the starting lights.
It also prevents the stuck logic (mode 4) kicking in by mistake if we do not accelerate fast enough :)

As the YetiBorg will move straight forward in this mode it will keep to the current position on the track.

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <pre>
  • Syntax highlight code surrounded by the <pre class="brush: lang">...</pre> tags, where lang is one of the following language brushes: bash, cpp, perl, python.
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.