2


First - I've looked through similar looking questions but they did not solve my problem, this is no repetition (I hope).
I'm building and programming a robot with an Arduino Nano that is supposed to solve a maze. It gets put somewhere in the maze and then has to find an item. The next time it is supposed to go straight to the item (it does not have to be the shortest way but no dead ends allowed).
It is not necessary to know the whole maze because as long as he has one way to the item it is good. As I said, I don't need the shortest way.
The maze is 2D, I just put black tape on a white table and the robot is supposed to use a line sensor to follow the lines.
There are no other sensors to orientate himself. First I thought of making an 2D array and each field of the maze a field in there. But since it's just a normal line sensor the robot doesn't know if a straight line is one or two fields long and the whole thing does not work.
I also tried DFS or something like that but a similar problem here. The maze is circular and how is the robot supposed to know the Node was already found before and it is the same?
It would be nice if anyone had an idea!

po0l
  • 23
  • 5
  • " the robot is supposed to use a *line sensor to follow the lines*." I'm just curious - how does a line sensor reacts to a 2 or 3 way split? – Adrian Colomitchi Dec 04 '16 at 14:31
  • It has 3 seperate sensors. Each one has a different value and only the middle one is on the line. If on the left or the right a new way starts one of the sensors left or right will notice a black color while hovering over the line and that way notice a split – po0l Dec 04 '16 at 14:34
  • How about choosing branches randomly? – melpomene Dec 04 '16 at 14:47
  • From the description, it looks like you necessarily need to perform dead reckoning to determine position based on your commanded motions. Essentially, you need to keep track of how far you have moved and what your orientation is for each forward motion. – theorifice Dec 04 '16 at 14:48
  • Anyway, the 16/32kB doesn't let too much free memory after loading the binary. Perhaps you should consider some extra USB external storage for your nano. About location: maybe you can cobble together a local positioning system using ultrasonic sensors? (20kHz may offer cm precision location) – Adrian Colomitchi Dec 04 '16 at 14:52
  • would there be a possibility where precise location isn't necessary? Something like only the nodes count, the robot just has to know it is between two certain nodes and then drive there until he finds it? After all it follows lines and he can follow a line between two nodes even if it isn't straight.. But I can't think of a possibility without precise location to know whether he already was at a node..

    edit:
    – po0l Dec 04 '16 at 15:57
  • edit: I actually just found two ultrasonic sensors ( HC-SR04, 40 kHz ). I could 3d-print something to fix it on the robot. The maze is a 10 by 10 grid, each dot 10 centimetres away from the one next to it, so 70 by 70 centimetres in total. Plus a bit free space makes 80 - 90 cm. A border around the whole labyrinth would be enough to make it possible for the robot to orientate himself. So if we find no other solution I'll certainly try it. To the storage: How much do you think I'll need? @AdrianColomitchi – po0l Dec 04 '16 at 16:08
  • "To the storage: How much do you think I'll need?" I don't know, all depends on the algo that you chose, but my guess is anything you actually find on the market nowadays is more than plenty (I don't think you'll be able to find micro-sd less than 1Gb). Note that using external storage is another type of fish than using memory - it's very much like using [good ol' MIX](https://en.wikipedia.org/wiki/MIX#Memory_and_input.2Foutput) and reading/writing data from the tapes into limited memory space (use an Nano with ATMega328) – Adrian Colomitchi Dec 04 '16 at 21:39
  • @po0l You might want to wait before accepting an answer. This would encourage further attempts. I, for one, am still interested in a solution which handles loops... but if you're not often on SatckOverflow or if you believe it definitely resolves your problem, it's fine to accept one. – MrBrushy Dec 05 '16 at 15:29

1 Answers1

0

Although orientation is a little bit fuzzy it is possible by using the decisions. A decision has to be reproducable. It could be represented by a class:

public class Decision {
    boolean[] directions = new boolean[2]; // 0 = left, 1 = straight, 2 = right
    // at least 2 of them should be true or it is no decision
    int path; // 0-2 to mark the current path
}
  1. Create a stack of decisions.

  2. If there is only one possible direction at the beginning (back doesn't count and is treated later), then move forward until you meet the first decision.

  3. Push the decision with all possible directions on the stack.

  4. Set path to the first possible direction and move that way.

  5. If you end up with another decision: continue at 3.

    If you find the token: abort, you found a reproducible way without dead-ends.

    If it is a dead-end: return to the previous decision node (the first one one the way back) and continue with 6.

  6. Pop the decision and try the next possible direction (set the new path and push the decision) and continue at 5.

    Unless you have tried all directions, then move back another decision and continue with 6.

    If there are no more decisions (the special case mentioned above, we went in the wrong direction at the beginning): move forward until you meet the first decision and continue at 3. This means you need another boolean variable to indicate if you should go backwards right at the beginning.

    You have to be careful when coming back from left and want to try straight next you would have to turn left and don't go straight. So there is a little calculation involved.

The algorithm has a problem for loop shaped decisions if you start the wrong way at the beginning. I think this could be escaped by setting an upper boundary, e.g. if you still haven't found the token and met 30 decision nodes (going forward), then you are probably running in circles, so go back to start and now instead of trying the directions in increasing order, try them in decreasing order.

maraca
  • 8,468
  • 3
  • 23
  • 45
  • Thanks! That could be exactly what I was looking for. In step 6, 'pop the decision' - I suppose instead of popping the decision you mean I should pop the direction (remove the last path and set new path to the next possible direction)? – po0l Dec 04 '16 at 18:12
  • @po0l yes you set it to the next possible direction and push it again only if there is any left to explore. You have to keep the decisions as is otherwise or you probably lose track of the way back if it is a dead end, all the decisions are oriented the way they are first encountered, so you also need the decision to know which path you were exploring just before and how to continue. – maraca Dec 04 '16 at 18:20