Driving School Basics

Driving School is a virtual robot playground, with ducks, obstacles and traffic lights in the Micromelon Robot Simulator.

In Driving School Basics we program the rovers to stay in the centre of the lanes, while avoiding running over ducks and hitting other rovers.

Activity Demonstration

Setup

This exercise has no physical setup as it is completed in the Micromelon Robot Simulator. To learn more about the Robot Simulator check out the Getting Started With The Robot Simulator post.

 

Here’s Our Approach

Stage 1

Add a while true loop and an IF/ELSE IF/ELSE statement so that we can continuously ask our rover questions about its environment.

Stage 2

The simulator’s roads actually have a slight brightness gradient towards the edges, so using the colour sensors you can work out where the rover is on the road. This approach uses an IF/ELSE IF/ELSE statement together with the colour sensor blocks to work out whether it is too far to the left or right. You can use the set motor speeds blocks to slightly turn to the left or right and adjust the position on the road.

Stage 3

Now we need to make sure we do not run into the duck! We can use our front ultrasonic sensor distance block to get our robot to wait for the duck to cross. It will also avoid other rovers now!

Example Code

 

Related Posts

Previous
Previous

Activity: Rover Van Gogh

Next
Next

Random Bug Bot 2