8.1.4 - Driving

Click on Menu and start a New program

Write the following program to drive the Edison robot forward.

#-------------Setup---------------- import Ed Ed.EdisonVersion = Ed.V2 Ed.DistanceUnits = Ed.CM Ed.Tempo = Ed.TEMPO_MEDIUM #--------Your code below----------- Ed.Drive(Ed.FORWARD, Ed.SPEED_5, 8)

As you type in the “Ed”  notice that a box pops up prompting you for what your next command might be. This is a feature of the EdPy App called “command line completion” and it makes it quicker for you to program.

Once you have typed in the above code, press the “Check Code” button to make sure you haven’t made any errors typing. These types of errors are called ‘syntax errors’ because the Python compiler can’t understand words that aren’t part of its language or ‘syntax’.

Ed.Drive() is a function in Python from the Edison Ed library module. Functions are pieces of code that perform a particular ‘function’ depending on which parameters are input. The Drive() function has three input parameters:

  • direction – the direction the Edison will drive
  • speed – the speed the Edison will travel at from 1 to 10 where 10 is the maximum
  • distance – the distance the Edison will travel according to Ed.DistanceUnits (either centimetres as specified by the constant Ed.CM, or inches as specified by the constant Ed.INCH, or time as specified by Ed.TIME.)

Use Activity sheet 2.1 as start and stop markers. 

Measure the distance between the start line and finish line and try and modify your program to make the Edison finish right before the finish line.