nxtprograms.com

Fun Projects for your LEGO® MINDSTORMS® NXT!

Home     Projects     Help     Contacts

Robot Vacuum
Building  
Programming  

Building Instructions


Programming Instructions

Real robot vacuums use a variety of different program strategies to try to cover your whole floor, and will often switch between different strategies during their operation. Here are three different programs that try out simplified versions of some of these strategies.

1. Random turns

The first and simplest program just drives forward until it encounters an obstacle and then turns by a random amount, and just keeps repeating this. This will make the robot criss-cross the room randomly, and eventually have a chance at reaching most parts of the floor if you left it running long enough. 

2. Horizontal Rows

This program makes the robot go back and forth in straight rows, doing a U-turn each time an obstacle is detected, with each row making progress across the room. It uses the brick hub's gyro sensor to keep the rows horizontal, and it will even recover back to horizontal if knocked off-course. This simple overall strategy will not ensure the entire room is covered, but it looks cool and leaves realistic-looking row marks on the carpet!

Start the robot near a wall and facing directly out into the room, as shown below. The robot will start with a 90-degree left turn and then make a series of rows perpendicular to the starting direction.

Warning: The hub gyro sensor appears to have a bug in it that sometimes prevents it from working. If the robot just spins around or turns erratically, then try this workaround.

3. 90-Degree Turns

The last and most complex program tries a strategy of making all 90-degree turns, but in random directions. Using the gyro sensor, it tries to always travel either parallel or perpendicular to its starting direction. In other words, if the staring direction is "North", then it will always try to travel either directly North, South, East, or West.

If you start the robot perpendicular or parallel to a wall, then the overall effect is to spend a lot of time moving around the edges of the room (the extra-dusty parts).

Warning: The hub gyro sensor appears to have a bug in it that sometimes prevents it from working. If the robot just spins around or turns erratically, then try this workaround.

 

Home     Projects     Help     Contacts

 

Copyright © 2007-2021 by Dave Parker.  All rights reserved. 
All project designs, images, and programs are protected by copyright.  Please see the usage policy.