Main Site Documentation

SIMPLE Maze Navigation Robot Design Overiew and Code


#1

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: http://www.youtube.com/watch?v=9V8UTVA89u4
On the floor: http://www.youtube.com/watch?v=0wsL1tfWCPw


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

#2

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


#3

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


#4

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.


#5

Shh chris thats my rhino project :>


#6

Oh, oops, sorry :-[

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


#7

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:


#8

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


#9

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!


#10

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

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


#11

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

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


#12

it’s a honor indeed 8)