Do I just write the code for one lap, and the computer then repeats that code over and over until it receives a stop command, or do I have to write the script for each of the 23 laps separately?
It's your choice: I have been working on writing a couple of different methods to use on different laps. If you do the same thing on every lap, and the method that you have chosen has problems on the day, then you're going to have problems on every single lap. On the other hand if you select two different methods, but find that one has problems and the other doesn't, then you're only going to have problems on half the laps.
I've been trying out a few variations on a theme and will put in a number depending upon how well I find they do after I finish testing on the simulator.
I must get the image uploaded before the next test runs; I just couldn't get sorted out for the first tests. :(
### Enable logging ###
StartDetailedLoging()
StartUserLog()
### Wait for the lights ###
WaitForGo()
### Racing for 23 laps ###
while LapCount() < 23:
# Wait until we reach the first corner
WaitForWaypoint(2)
# Wait until we reach the start / finish line
WaitForWaypoint(1)
### Wait for a few seconds ###
WaitForSeconds(4)
### Disable logging ###
EndDetailedLog()
EndUserLog()
### End of the race ###
FinishRace()
Anything between the while LapCount() < 23: line and before the WaitForWaypoint(1) line will be run once per lap.
For example:
while LapCount() < 23:
print 'I have done ' + LapCount() + ' laps'
# Wait until we reach the first corner
WaitForWaypoint(2)
# Wait until we reach the start / finish line
WaitForWaypoint(1)
will print the number of laps completed at the start of each new lap.
Alternatively you can replace the while loop entirely.
You can use WaitForWaypoint(1) to wait until the next lap, for example:
print 'Lap 1'
WaitForWaypoint(1) # Start line at the end of lap 1
print 'Lap 2''
WaitForWaypoint(1) # Start line at the end of lap 2
print 'Lap 3'
WaitForWaypoint(1) # Start line at the end of lap 3
print 'Lap 4'
WaitForWaypoint(1) # Start line at the end of lap 4
It's your choice: I have been working on writing a couple of different methods to use on different laps. If you do the same thing on every lap, and the method that you have chosen has problems on the day, then you're going to have problems on every single lap. On the other hand if you select two different methods, but find that one has problems and the other doesn't, then you're only going to have problems on half the laps.
I've been trying out a few variations on a theme and will put in a number depending upon how well I find they do after I finish testing on the simulator.
I must get the image uploaded before the next test runs; I just couldn't get sorted out for the first tests. :(
Hope that helps.
Geoff
As Geoff says, it is completely up to you :)
The basic example Race.py looks like this:
Anything between the
while LapCount() < 23:
line and before theWaitForWaypoint(1)
line will be run once per lap.For example:
will print the number of laps completed at the start of each new lap.
Alternatively you can replace the
while
loop entirely.You can use
WaitForWaypoint(1)
to wait until the next lap, for example:Add new comment