non tactile maze robot

  1. I assume you're using GP2D12s or somesuch, but it's not indicated.

  2. first off, I would make the debug printouts a little more descriptive,
    maybe add a string label in front of each IRR reading, as
    Serial.print("Front ");
    Serial.println(Front);

  3. also, your case statements look a little weird to me, they probably work
    ok, but are usually written "without" the braces. ???

  4. one usually adds a default: line at the end of the switch to handle nonmatches.

  5. the statement if(state == 0) {...} doesn't do anything once inside the switch;
    is it supposed to?

  6. switch case 2: //right executes for almost 5-seconds, that seems an awfully
    long time to turn, and may explain the 270-deg turns.

  7. also, if you analyze your decision structure, you'll see there are large holes
    in it, eg for Front in 91...99, and for Frontside<=89 AND Backside=anything,
    and vice versa. These are logical holes that may be causing behavioral holes.
    Best to try and plug the logical holes.

if (FrontSide < 90 && BackSide < 90 && Front > 100) { }
else if (FrontSide > 90 && BackSide > 90) { }
else if (Front < 90) { }

It might work better to say ... else if (Front <= 100) { }.

  1. It also might help to have a default at the end of the decision structure,
    eg ... else { setting for go_straight }.

  2. Also, for if (FrontSide > 90 && BackSide > 90) { }, I might try using a
    right_turn less than a full turn, more like a hard_adjust_right, so just
    bear over towards the wall rather than try to turn a full 90-deg, and
    possibly overshooting 90-deg.

Other than that, I don't have the robot here in front of me to play with
until I get it to work. :slight_smile: