Shop OBEX P1 Docs P2 Docs Learn Events
Wall-Following Code? — Parallax Forums

Wall-Following Code?

Carl LawhonCarl Lawhon Posts: 36
edited 2009-02-18 23:42 in Propeller 1
I've been working on my own wall-following code·so that my robot can track along exterior walls until it finds an opening and then enters the "doorway," but I have had some·issues getting it perfected.· I looked in the·Parallax Object Exchange to see if I could find any wall-following code either to work with or check what I'm doing. Does anyone·know if any wall-following code is posted that I haven't been able to find, or do you·have any to share? The robot is equipped with a compass, a gps module, and three sonar sensors (one on the front and two on the sides). Getting the robot to track along the wall is easy, but·problems arise when I try to get it to turn into the opening.

Thanks.···

Comments

  • Carl HayesCarl Hayes Posts: 841
    edited 2009-02-15 01:42
    Couldn't you just track along the wall (using the side sonar) until the distance suddenly increases (because the side sonar is looking through a doorway); turn 90 degrees (by compass); and march forward? I'm not into robots, but that would seem a reasonable approach that ought to work.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    · -- Carl, nn5i@arrl.net
  • RiJoRiRiJoRi Posts: 157
    edited 2009-02-16 16:49
    I will assume the wall should be to the right of the 'bot. If not, just replace "right" with "left."

    1) Lazy way: Use wheels or ball bearings to allow the 'bot to go forward with a tad of movement to the right. This would be like us going along keeping our shoulder to the wall.

    2) Fancier way: Use a switch with a long arm to "feel" the wall. When the switch changes state, move to the right until contact is made again. Like us using our fingers against the wall.

    In either case, another long-armed switch (arm longer than in (2) ) would be used to detect corners. When this switch changes state, start rotating to the right until the switch or switches go back to the "against the wall" state.

    --Rich

    ETA: Of course, you could use other sensors to detect the wall's distance!
  • CannibalRoboticsCannibalRobotics Posts: 535
    edited 2009-02-16 17:21
    I wrote a wall follower years ago in grad school. I'd give you the code but It was written in some bizarre AI scripting language that only my lab partner could write.
    Anyway I did the math and designed the algorithm. I was using a laser range finder with a 180 degree viewing area. The data came back as a series of rays extending from the sensor to the nearest object. I found that the best follower used only three of the rays. One perpendicular to the direction of travel and 'the wall'. The other two were at 45 degrees to the first. I used the perpendicular to determine wall distance then tracked the wall by adjusting the robot position to equalize the 45s. The rule was to turn into a longer forward ray and away from a shorter ray. This facilitated following curved walls. Corners worked particularly well with this approach.
    When the forward looking 45 lost it's reflection at the corner, the ray got very long so the robot would begin to turn into it. As it turned, the rear 45 would grow longer too and get lost at some point. The robot would continue to swing around until it received a forward 45 return. But now the rear 45 was long so it would stop turning and adjust back the other way. So there was a bit of a dance at the corner. It would always stabilize though. I found that with some filtering and clever usage of the perpendicular I could determine when I was 'in-turn' so I could ignore some of the huge variations in ray data. Had I a compass it would have made the whole thing a lot easier. Corners are interesting. Some of them are right angles, others are just openings in a wall. So the issue is: Which way to go once your inside the opening. The arrangement I've described here just starts following the wall once inside the doorway. Since the application was 'area mapping', that was perfect but you might not want your robot to act like a rat that stays by the wall once inside.
    Tracking a corner with a single sensor was difficult. Once the bot goes by the corner the side tracking sensor distance goes 'infinite'. If you stop right there then pivot, your distance is going to come back as the sensor will hit the corner again at some point. Have you thought about putting one of your sonar sensors on a pivot so you can get more information about the topology of the corner? It's very nice to be able to 'see around' it. There is also the problem of determining if the opening is large enough to fit through.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Signature space for rent, only $1.
    Send cash and signature to CannibalRobotics.
  • Five-sEvEnFive-sEvEn Posts: 7
    edited 2009-02-18 23:42
    For my last semester's EE project, I did a right hand wall hugger uMouse using a BS2p and a bodged together custom bot.

    I'm too lazy to rewrite the code for the propeller right now, but if you like, I could post what I have. It used 3 sharp distance sensors, one straight, and 2 at 45 degree ish angles from the center. There's a bunch of canned moves in the routine, but through some smart turning algorithms, I was able to track through the toughest of turns.

    What problems exactaly do you run into when you try and turn into the opening?
Sign In or Register to comment.