Society of Robots - Robot Forum

Software => Software => Topic started by: JonMarkGo on March 17, 2008, 06:48:32 AM

Title: Algorithm Help
Post by: JonMarkGo on March 17, 2008, 06:48:32 AM
I am trying to develop an algorithm to align my robot with its sensor. Essentially, the sensor moves freely until it detects a flame (so that I don't have to waste time moving the whole robot). But then I need to move towards the flame. Ideally I need to align the robot itself in the direction of the flame just from the servo value of the motor moving the sensor. The robot is on two motorized wheels and one third free-rolling wheel. Any help would be appreciated.
Title: Re: Algorithm Help
Post by: airman00 on March 17, 2008, 06:58:15 AM
Hey Jon,

The algorithm in Pseudo Code:

Quote
Start:
Give Servo a pulse of x
Add values to x to make it scan back and forth
Check Value of Sensor
If Flame is detected Then
       Servo tracks flame by finding the limits of the flame [ see at what two servo positions ( on opposite sides)  there no longer is a flame]

       If the general position of the flame is on the right side, then turn right and with every cycle for turning right the servo for the sensor moves left until the sensor servo is at center , then the robot is aligned

         If the general position of the flame is on the left side, then turn left and with every cycle for turning left the servo for the sensor moves right  until the sensor servo is at center , then the robot is aligned


Or you could use encoders on your robot and then just do
If servo position is at 1.00ms then turn wheels for a certain amount which you found out by experimenting/ calculating





   
Title: Re: Algorithm Help
Post by: JonMarkGo on March 17, 2008, 07:03:18 AM
I was planning to just use encoders. How I have it written now (not yet tested) is that the flame sensor turns from 0 to 180 degrees (servo) and then when it finds the flame, it stops. I then move the sensor left one unit if its more than 90 and the robot right one unit (as determined through trial and error with quadrature encoders). It does this until the servo is at the middle position. I was hoping there would be a more precise way to do it though.
Title: Re: Algorithm Help
Post by: JonMarkGo on March 17, 2008, 07:04:57 AM
Basically I was hoping there would be some sort of formula to determine what the target encoder values were to have the robot aligned with the sensor.
Title: Re: Algorithm Help
Post by: superchiku on March 17, 2008, 07:07:41 AM
when u are turning try to keep the servo values in an array keep a mid value which is aligned for both the sensor and the body when u turn the body to the sensor's position try moving the sensor back to the position of the mid value this will work but try to do some experimentations
Title: Re: Algorithm Help
Post by: JonMarkGo on March 17, 2008, 07:09:22 AM
The encoder values constantly change as it moves about a room. I may not be thinking enough into this, but I can't imagine a definite mid value for the robot itself, though its easy to find for the sensor.
Title: Re: Algorithm Help
Post by: superchiku on March 17, 2008, 07:15:27 AM
hmm try using the usart and get different values now when u do that try plotting a graph like the amin has told and just get the best case value
Title: Re: Algorithm Help
Post by: JonMarkGo on March 17, 2008, 07:17:07 AM
What's usart?
Title: Re: Algorithm Help
Post by: airman00 on March 17, 2008, 07:24:52 AM
http://www.societyofrobots.com/microcontroller_uart.shtml
Title: Re: Algorithm Help
Post by: superchiku on March 17, 2008, 07:26:44 AM
u must know abt usart
Title: Re: Algorithm Help
Post by: JonMarkGo on March 17, 2008, 07:18:20 PM
I'm using OOPic, thats all built in.
Title: Re: Algorithm Help
Post by: superchiku on March 17, 2008, 10:14:40 PM
ok then use it other wise ull not be able to know exact readings
Title: Re: Algorithm Help
Post by: airman00 on March 18, 2008, 05:45:19 AM

Make a graph like superchiku said , and perhaps there is a formula that is usable by the microcontroller


then you would have the robot turn for a certain amount based on the position of the sensor's servo.


You would use the encoders for the robot to know how much it turned and if it turned the amount needed .
Title: Re: Algorithm Help
Post by: superchiku on March 18, 2008, 09:04:37 AM
can encoders be used to tell the angle the wheel has turned ,.. i thought it was only for speed and displacement
Title: Re: Algorithm Help
Post by: airman00 on March 18, 2008, 09:06:00 AM
can encoders be used to tell the angle the wheel has turned ,.. i thought it was only for speed and displacement

http://www.societyofrobots.com/sensors_encoder.shtml
Title: Re: Algorithm Help
Post by: superchiku on March 18, 2008, 09:10:39 AM
hey thats the wheel turn angle i was meaning the whole bot turning angle or u meant to say indirectly we are measuring the servo's turning angle... now i get it
Title: Re: Algorithm Help
Post by: airman00 on March 18, 2008, 10:23:41 AM
hey thats the wheel turn angle i was meaning the whole bot turning angle or u meant to say indirectly we are measuring the servo's turning angle... now i get it

by knowing the angle changes of the drive wheels , we know the delta angle ( change in angle) of the robot itself

The sensor servo does not need an encoder since a servo "listens" and goes to the position you want
Title: Re: Algorithm Help
Post by: Webbot on March 18, 2008, 12:25:17 PM
Isn't this the same as the Stampy Edge Detection algorithm except that you are sensing heat rather than an object. http://www.societyofrobots.com/robot_iRobot_Create_mod.shtml (http://www.societyofrobots.com/robot_iRobot_Create_mod.shtml)
Title: Re: Algorithm Help
Post by: superchiku on March 18, 2008, 11:51:50 PM
yes fire detection will be not as difficult as object detection
Title: Re: Algorithm Help
Post by: Admin on March 23, 2008, 11:54:57 AM
Quote
aligned for both the sensor and the body when u turn the body to the sensor's position try moving the sensor back to the position of the mid value
http://www.societyofrobots.com/robot_mobot_2007.shtml