Fun Projects for your LEGO® MINDSTORMS® NXT! |
Robot Vacuum |
|
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 turnsThe 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 RowsThis 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.
3. 90-Degree TurnsThe 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).
|
Copyright
©
2007-2021 by Dave Parker. All rights reserved. |