Sections
You are here: Home Forum Project Discussion Circular robot, turning corners into a corridor.

Circular robot, turning corners into a corridor.

Up to Project Discussion

Circular robot, turning corners into a corridor.

Posted by Gilbert Davis at July 22. 2008

This has been vexing me for quite some time, and the two approaches I've taken haven't brought me to the desired result.

I've a circular robot whose chasis is taken from a simple Wal-Mart turn table with distance sensors bought from this very site attached at the front and to both sides of the robot.

Right now, I'm trying to make it do something that's really easy on paper but for some reason is absurdly difficult for me to execute. I'm trying to make it turn a corner and follow straight into a corridor like what's shown here: http://www.trincoll.edu/events/robot/images/EntryLevelLayout.jpg

There's two approaches I've taken, each with their own unique set of problems. The first of which is trying to make it follow the right wall and turn with it. As long as the right sensor reads the distance to the wall, keep going straight, and if it doesn't, turn to the right. The biggest problem with this that I'm having is that the data of the sensors are not linear at all, so there's often two distances that read the same value. For instance (A rough estimate), a reading of 700 from a sensor could be either 3 inches or 7 inches, and the robot can't differentiate. I'm not sure how to program it to make it sure it doesn't read the undesired value and go straight when it isn't supposed to. This is the code I have working for it currently, where s is the left sensor, t is the front sensor and u is the right sensor, and the Servos being used here are continuous rotation servos, so the 591, 468 combination propels it forward and the 470,0 combination is a turning motion:

void BlinkTask( void* p )
{
 (void)p;
  Led_SetState( 1 );
  Sleep( 1000 );

  while ( true )
  {
    Led_SetState( 0 );
    Sleep( 900 );
    Led_SetState( 1 );
    Sleep( 10 );
   
    AppLed_SetActive(0,1);
    AppLed_SetActive(1,1);
    AppLed_SetActive(2,1);
    AppLed_SetActive(3,1);
    Servo_SetActive(0,1);
    Servo_SetActive(1,1);
    AnalogIn_SetActive(0,1);
    AnalogIn_SetActive(1,1);
    AnalogIn_SetActive(2,1);
   
    int x = 0;
    int s;
    int t;
    int u;
   
    while (x==0)
    {
        s = AnalogIn_GetValue(0);
        t = AnalogIn_GetValue(1);
        u = AnalogIn_GetValue(2);
        if (u >= 770 && u < 800)
        {
            Servo_SetPosition(0,591);
            Servo_SetPosition(1,468);
        }
        if (u < 770 || u >= 800)
        {
            Servo_SetPosition(0,470);
            Servo_SetPosition(1,0);
        }
        Sleep(250);
    }
  }
}


Just a simple, rudimentary program to make it follow the wall. When it gets to the corner, it either overshoots the corner or turns too far and spins around aimlessly.


The -other- approach that I've been trying involves taking the sensor readings of the location I want it to turn, then programming the robot to turn at that location until it reads another set of sensor readings to indicate when it should move forward. This method's problem is that the sensor readings at one location aren't always consistent and tend to fluctuate. My approach is simply 'When the left and front sensors read x and y respectively, turn until the front and right sensors read x and y respectively', and it sounds great to me on paper, but when I try it, it's a very hit or miss affair thanks to the sensors range of fluctuation.


In the last five tests or so I've run, the robot managed to sort of turn into the corridor and go straight as I wanted while other attempts had it just missing the mark completely. Still, this has produced the closest result so far.


If anyone has an idea or insight to this and how to make the robot turn a corner and follow straight through into a corridor, I would greatly appreciate it. I feel like I'm missing something obvious, but no matter which way I slice it, I'm not getting it to work right.

-Gilbert Davis

Re: Circular robot, turning corners into a corridor.

Posted by Paul at July 25. 2008

Which Sensors are you using?

Re: Circular robot, turning corners into a corridor.

Posted by Gilbert Davis at July 27. 2008

I'm using the sensors bought from the site, featured here:

http://www.makingthings.com/products/ACC-IR-DIST-001

Re: Circular robot, turning corners into a corridor.

Posted by Paul at July 27. 2008

Ok you are correct in stating thats it has one value for 2 possible distances, this is because the curve is convave down and indeed has a max, all is not lost though there is a place on the curve that only one point exists at that y value as show by the table here (http://www.makingthings.com/documentation/how-to/distance-measuring-sensor). For example a parabola, at one y value the will be only one x value. Sown on this graph it seams to be around 15 cm - 2.75v. You should place the sensor 15cm near a wall and mesure the sensor value and instead of having the function read 'less than' or 'greater than' you will only have the program read if its greater than (i believe) in your code, hopefully this helps, and sorry if the math is a bit confusing(http://s333.photobucket.com/albums/m391/oconkero/?action=view&current=Untitled-1.gif).

Re: Circular robot, turning corners into a corridor.

Posted by Paul at July 27. 2008

Heres an example of the values and how they contain other possible values, hopefully it clears it up (http://s333.photobucket.com/albums/m391/oconkero/?action=view&current=Untitled-2.gif) so essentialy the sensor doenst know the diffrence between 7 and 40 cm.

Re: Circular robot, turning corners into a corridor.

Posted by Paul at July 27. 2008

The only thing is you wont know to turn left or right (closer of further) to the wall

Re: Circular robot, turning corners into a corridor.

Posted by Gilbert Davis at July 28. 2008

Mm, that is a rather worrisome problem, the robot won't have any good way of correcting and straightening its own path. Thank you for the help thus far though.

Re: Circular robot, turning corners into a corridor.

Posted by Gilbert Davis at July 28. 2008

Also, it's difficult to just choose one value for the robot to follow, as the sensor readings have a tendency to fluctuate. I'll need to choose a range in order for it to stay consistent, and when I do, that introduces the one value- two distances problem.


Re: Circular robot, turning corners into a corridor.

Posted by Paul at July 30. 2008

Your welcome, also i missed that even if you did get a range other than that it you wont be able to determine how close the wall is. and because of this you cannot determine if its getting close or getting farther, depending on which side of the parabola your on.

Re: Circular robot, turning corners into a corridor.

Posted by Gilbert Davis at August 03. 2008

Still no luck producing an intuitive wall following method though, are these sensors just not cut out for the task or am I still overlooking something here?

Re: Circular robot, turning corners into a corridor.

Posted by John (EBo) David at August 07. 2008
Just an idea... If you can back up, or move a little forward, then you can hopefully determine if the numbers are going up or down. That will allow you to use a little logic to figure out if it is in the 7cm or 40cm range...
Powered by Ploneboard
Document Actions