RoboMind Projects - Example scripts, May 1, 2012, Cardinal Forest Elementary School

RoboMind website
RoboMind Example scripts
RoboMind Basic instructions: move, paint, grab, see
RoboMind Programming Structures: comment, loops, if-structures, procedures, end
Back to RoboMind Projects

For more programming challenges, see Robo Exercise Set 1

  • RoboMind example scripts/programs

    1. Example 1: Write your name or initials or draw a spiral with black and white:

      This is a simple drawing program. Use paintWhite() and stopPainting() to command the robot to put its brush on the ground or not. The robot can leave a line on the ground.
      Open the map openArea.map
      There is enough space to create a nice piece of art.
      Use remote control (Run > Remote control) to let the robot paint.
      See also: basic instructions: paint, and move



      #character 'A'
      paintWhite()
      
      
      forward(2)
      right()
      forward(1)
      right()
      forward(2)
      backward(1)
      right()
      forward(1)
      
      
      stopPainting()
      

    2. Example 2: Find the white spot:
      Open the map findSpot1.map. Somewhere on the left side there is a white spot.

      Let the robot take one step at a time

      • Check if the white spot is on the left
      • If it sees the spot, it has to stand on the spot and it is finished
      • Else take another step forward and check if the spot is on the left
      • This can be repeated in a loop

      See also: basic instructions: move, see,
      programming structures: loops, if-structures, end

      repeat(){
          if(leftIsWhite()){
              # There's a white spot on your left
              left()
              forward(1)
              end
          }
          else{
              # There's no white spot yet
              forward(1)
          }
      }
      

      Another way to do this: repeat moving forward until you don't see a wall anymore. Then turn and move on to the white spot.

      repeatWhile(leftIsObstacle()){
          forward(1)
      }
      
      
      left()
      forward(1)
      
    3. Example 3: Line follower.
      Load default.map, and find the white line in the east. Make the robot follow this white line track.

      • Bring the robot to the beginning of the track (Follow the Yellow Brick Road!)
      • Keep on the track step by step

       # Go to the start of the line
      right()
      forward(8)
      
      
      # Keep on track step by step
      repeat()
      {
          if(frontIsWhite()){	
              forward(1)
          }
          else if(rightIsWhite()){
              right()
          }
          else if(leftIsWhite()){
              left()
          }
          else if(frontIsObstacle()){
              end
          }
      }
      

      Another approach is to use recursion. Write a recursive procedure called follow().

      # Go to the start of the line
      right()
      forward(8)
      
      
      # Start tracking
      follow()
      
      
      # Recursive definition for tracking
      procedure follow(){
          if(frontIsWhite()){	
              forward(1)
              follow()
          }
          else if(rightIsWhite()){
              right()
              follow()
          }
          else if(leftIsWhite()){
              left()
              follow()
          }
          else if(frontIsObstacle()){
              # Finish the current procedure call
              # (because there is nothing to after 
              # this return, all calls will be finished
              # and the program stops)
              return
          }
      }
      

    4. Example 4: Maze runner - Escaping a maze
      Here is the trick: By always following the wall on the right side (or always following the wall on the left side) you will find the exit.

      Open maze1.map

      See also: basic instructions: move, see,
      programming structures: loops, if-structures, end

      repeat(){	
          if(rightIsObstacle()){
              if(frontIsClear()){
                  forward(1)
              }
              else{
                  left()
              }
          }
          else{
              right()
              forward(1)
          }
      
          if(frontIsBeacon()){	
              pickUp()
              end
          }
      }