Running the Simulation

8 posts / 0 new
Last post
Running the Simulation


Really excited to me part of formula pi!

I'm trying to get the simulation running and having a few issues - I have the java part running on a windows machine, that seems to be working ok. I'm then running on a raspberry pi zero W, that as well appears to run ok, it gives me 'WaitForGo()' and then begins printing FPS values, but when I say go on the simulation (green/red/green) the AI cars all go and mine doesn't...

Does anyone have any suggestions on what I could try or thoughts on what might be going wrong?


Got slightly further... the

Got slightly further... the console output on the Pi now shows it seeing the lights, and then appears to start working through the code in, but on the simulation it still doesn't move...

When I try running on the windows machine (same machine as the java part), it fails with 'AttributeError: 'module' object has no attribute 'CV_LOAD_IMAGE_COLOR'. I read somewhere on the forum that to get round that quickly you could change a line in to use ImageProcessor.FIRST_STRAIGHT instead of ImageProcessor.WAIT_FOR_LIGHTS, when I do that I get the same situation as when running on the Pi, in the console the code appears to be executing but on the simulation the car doesn't move...

Simon Bugler (not verified)
IP address

Have you set the IP address in on the Pi too that of the Windows machine?

Yep, that's set - the Pi see

Yep, that's set - the Pi see's the lights change (the console output shows that) so it is seeing it correctly, but then nothing happens only the simulation when the car should start moving.

Arron Churchill
Arron Churchill's picture
Simulation not working

That is very odd. Normally these problems are because the images are not transmitted correctly, however that prevents the light sequence from working.

Can you attach a screenshot of the simulation?

The error running on Windows is because you have a different version of OpenCV installed. Unfortunately they renamed some of the values which is the cause of the problem. To install the version used on the robots see OpenCV under Windows.

Finally got chance to have

Finally got chance to have another go today!
The first time I ran it, the car moved (and just drove straight off the track), each time after that it just stays still again (as in the screenshot)

Comment Images: 
Now if I exit everything and

Now if I exit everything and restart it all, it drives the first time, but then I can't stop/reset/restart - most likely I'm just doing something wrong there.

Any idea why it would just drive straight off the track, the code in use is the BetterLap code at the moment.

Arron Churchill
Arron Churchill's picture
Might be a problem with the Python code

Given that the code is now starting I think the simulation is probably working correctly

My guess is that the Python script has an error which causes the script to fail after it has set the initial speed, hence the robot drives straight on instead of following the track.

I know we have had a bug in the past where sample code for had the line:

while time.time < endTime:

which should be:

while time.time() < endTime:

so I would check for that first.

If that is not the problem then it would help to see the output from the Python script.

To reset the robots to start again:

  1. Stop the Python script running
  2. Press the reset button to put the robots back at the start
  3. Run the Python script again
  4. Go through the light sequence

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.
Comment Images
Files must be less than 10 MB.
Allowed file types: png gif jpg jpeg.
Comment Attachments
Files must be less than 10 MB.
Allowed file types: txt pdf nfo doc docx rtf jpg png gif bmp zip tar gz csv xls.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.