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
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()
Let the robot take one step at a time
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)
# 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
}
}
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
}
}