clipskerop.blogg.se

Tracking in fast forward any-maze
Tracking in fast forward any-maze






tracking in fast forward any-maze

When the main sensor, SENSOR_3, detects a light patch, it knows it has lost the path so searches. Then while it’s in the maze it follows that line using the search algorithm.

#Tracking in fast forward any maze code

*/ sub Search () Īll this code does, is get the rover to find the line and enter the maze. With the main program moving forward until we lose the line, the code below creates the turns required to search for, and reacquire, the line we’re trying to follow. This carries on for three more turns until the curve of the line favours our strategy and we find the line by turning a little to the right each time. This time we don’t find the line and need to try anti-clockwise until we do, then carry on forward again. Since our last search was clockwise we try that again. Once it finds the line it carries on across the line until it again loses the line. Finding nothing it then tries the opposite direction. It then turns anti-clockwise far enough to find the line. It moves across the path it needs to follow until it can no longer see the line. The orange line shows the path of the light sensor. The result of these simple rules is shown in the following pattern of movement. Eventually you will cross over the line and will need to try the opposite direction but overall this small consideration saves the rover a lot of time. If you are trying to follow a straight line but are just slightly off track, then continually adjusting in the same direction allows you to straighten up. The one optimisation I added to the above algorithm, is the assumption that if you tried to turn clockwise last time, you’ll likely need to do so again.

  • Once we find the line, carry on moving forward.
  • If we don’t find the line turn the other way.
  • Turn one way far enough to find the line.
  • This requires a light sensor and these simple steps which allows the robot to follow an apparently wiggly line: In the real world, to follow the line we need to be able to see the line. All of these things cause a real world robot to eventually drift off the line. Maybe the rover is not quite aligned to the track, or perhaps the two motors driving the rover will turn at slightly different speeds.

    tracking in fast forward any-maze

    There might be a slight curve to the paper or the tape I stuck down. The real world is not perfect so there are no real straight lines. We can’t just find the line and then tell the LEGO rover to drive in a straight line down it until something happens. As it happens this is not as straight forward as it might appear. The first step in being able to solve this maze, is being able to follow a line. Rather then using the black lines as the wall of the maze, they form the path which the rover has to follow. Instead I used black electrical tape to create a flat maze which could be rolled up and transported easily. If I’d done that, I would have had to build and transport a big cardboard maze. Typically a maze would have walls, so I would need to create a rover which touched the relevant wall to complete the maze. I stuck them together with packing tape (the brown line you can see on the maze) which gave me a large enough surface to mark out a half decent maze. For this I went to a local supermarket and asked them for the sheets of paper you get between layers of sugar. The size of the rover, dictated by the size of a LEGO RCX, meant that I needed a large maze. To demonstrate this and bring things to life for them, I built a LEGO rover to solve any maze. Instead I gave them clues and we discussed several solutions before they found the wall follower algorithm. Maze traversal is a classic computer science problem, something I studied in university, so I wasn’t expecting them to work out the solution from first principles. This is an easy enough task for primary school kids but what I was really leading them to was a means of solving any maze. In my code club I asked the kids to solve a maze. LEGO maze solver :: DarkSnow DarkSnow Freelance Web Developer








    Tracking in fast forward any-maze