SIMPLE Maze Navigation Robot Design Overiew and Code

Here it is Guys…

Notice: I modified the robot design orientation a little, so it won’t look the same on the original demo video.

Overview: [url]- YouTube
On the floor: [url]- YouTube


static int percentValue = 60; 

static FEZ_Components.DistanceDetector A1 = new FEZ_Components.DistanceDetector(FEZ_Pin.AnalogIn.An1, FEZ_Components.DistanceDetector.SharpSensorType.GP2D120);
static FEZ_Components.DistanceDetector A2 = new FEZ_Components.DistanceDetector(FEZ_Pin.AnalogIn.An2, FEZ_Components.DistanceDetector.SharpSensorType.GP2D120);
static FEZ_Components.DistanceDetector A3 = new FEZ_Components.DistanceDetector(FEZ_Pin.AnalogIn.An3, FEZ_Components.DistanceDetector.SharpSensorType.GP2D120);

static FEZ_Components.ReflectiveSensor InputPortA6 = new FEZ_Components.ReflectiveSensor(FEZ_Pin.AnalogIn.An6, percentValue);
static FEZ_Components.ReflectiveSensor InputPortA7 = new FEZ_Components.ReflectiveSensor(FEZ_Pin.AnalogIn.An7, percentValue);

float far  = 7;
float near = 4; 
while (true)
{ 
    //all clear, go freakin full speed
    if (A1.GetDistance_cm() >= far+2 &&
       A2.GetDistance_cm() >= far &&
       A3.GetDistance_cm() >= far && 
       !((int)InputPortA6.GetState() == 1 || (int)InputPortA7.GetState() == 1))
    {
        if (!((int)InputPortA6.GetState() == 1 || (int)InputPortA7.GetState() == 1))
            FEZMini_Robot.MoveRamp(65, 65, 0);
    }
    
    //reduce speed getting ready to stop
    else if (A1.GetDistance_cm() >= near+2 && A1.GetDistance_cm() <= far+2 &&
             A2.GetDistance_cm() >= near && A2.GetDistance_cm() <= far &&
             A3.GetDistance_cm() >= near && A3.GetDistance_cm() <= far && 
        !((int)InputPortA6.GetState() == 1 || (int)InputPortA7.GetState() == 1))
    {
        if (!((int)InputPortA6.GetState() == 1 || (int)InputPortA7.GetState() == 1))
            FEZMini_Robot.MoveRamp(40,40, 0); 
    }  

    //at least one sensor closes to an object
    else if ((A1.GetDistance_cm() <= near+2 ||
               A2.GetDistance_cm() <= near ||
               A3.GetDistance_cm() <= near) &&
               (A2.GetDistance_cm() >= A3.GetDistance_cm()) &&
         !((int)InputPortA6.GetState() == 1 || (int)InputPortA7.GetState() == 1)) { 
            //turn left 
            while (
                A1.GetDistance_cm() <= near+2 || 
                A3.GetDistance_cm() <= near &&
                !((int)InputPortA6.GetState() == 1 || (int)InputPortA7.GetState() == 1) )
              FEZMini_Robot.MoveRamp(-22,80,0);
            
        for (int ii = 0; ii < 7 && !((int)InputPortA6.GetState() == 1 || (int)InputPortA7.GetState() == 1); ii++) 
                FEZMini_Robot.MoveRamp(80,-10,0);
    } 

    //at least one sensor closes to an object
    else if ((A1.GetDistance_cm() <= near+2 ||
               A2.GetDistance_cm() <= near ||
               A3.GetDistance_cm() <= near) &&
           (A2.GetDistance_cm() < A3.GetDistance_cm() &&
         !((int)InputPortA6.GetState() == 1 || (int)InputPortA7.GetState() == 1))
           ) { 
                //turn right 
               while (
                        A1.GetDistance_cm() <= near+2 || 
                        A2.GetDistance_cm() <= near &&
                        !((int)InputPortA6.GetState() == 1 || (int)InputPortA7.GetState() == 1))
                        FEZMini_Robot.MoveRamp(80,-22,0);
               for (int ii = 0; ii < 7 && !((int)InputPortA6.GetState() == 1 || (int)InputPortA7.GetState() == 1) ; ii++) 
                FEZMini_Robot.MoveRamp(-10,80,0); 
    }

      
    
    //possibly stuck, back up a litle
    if ((int)InputPortA6.GetState() == 1 || (int)InputPortA7.GetState() == 1)
    {
        FEZMini_Robot.MoveRamp(0,0,0);
        for (int ii = 0; ii <2; ii++)
        {
            FEZMini_Robot.Beep(5000, 300);
            Thread.Sleep(300);  
            FEZMini_Robot.MoveRamp(-40, -40, 0);
            Debug.Print("II: " + ii.ToString());
        }
    }
    
}//while

Freakin’ Awesome. I will try to make my own and take to make fair in NYC

Gus,
No way man, you are an expert on this field, if you happen to make one, it will be something close to like US drone :slight_smile:

-Hai

Actually, that might not be such a bad idea. We have the ArduinoAutoPilot, why not a FEZ version? Yeah, timing is going to be an issue, but that could be relocated to another chip.

Shh chris thats my rhino project :>

Oh, oops, sorry :-[

Mind if I ask what kind of UAV project you’re planning?

Hai,
Why don’t you try to use touch buttons instead of the reflective sensors?
http://www.tinyclr.com/hardware/1/fez-domino/#/grid/item/9/

But your idea s very smart. :wink:

Rafik,

I would if I have one in house. I just work on the parts I have available. To be honest with you, I didn’t know about the touch button until you told me. I thought I would have to get some kinds of micro-range/short-range sensors or something instead of reflective sensor. I know this idea was just like replace a dog with a cat, and it will not be a solution for a permanent project. But if one doesnt have a touch button, a reflective sensor may become handy.

Thanks, Hai

Chris,
Aren’t you just becoming a Master? if so congratulation!!! Did you get a reward or anything from tinyclr for becoming master?
Just curiosity…

Thanks!

Chris was the second one not the first but he still got a free custom enclosure fro his free FEZ Cobra! See this [url]http://www.tinyclr.com/forum/9/634/[/url]

The first one got FEZ Rhino [url]http://www.tinyclr.com/forum/9/601/[/url]

I’ve been a master for a few days now…

Thanks! It’s great to be in a community like this!

it’s a honor indeed 8)