ROBOTC.net forumshttp://www.robotc.net/forums/ IR Seeker inaccuracyhttp://www.robotc.net/forums/viewtopic.php?f=52&t=2780 Page 2 of 2

Author:  MHTS [ Sat Nov 26, 2011 10:11 pm ]
Post subject:  Re: IR Seeker inaccuracy    hongyeus wrote:the max(acS[idx], acS[idx + 1]); returns an "undefined procedure" error. What is that meant to do?    Sorry, max() is a macro. You can include these lines at the top of your code to define them.    Code:#define max(a, b)               (((a) > (b))? (a): (b))#define min(a, b)               (((a) < (b))? (a): (b))        hongyeus wrote:
Also, what is the purpose of this    Code:idx = (idx - 1)/2;        if ((idx < 4) && (acS[idx] != 0) && (acS[idx + 1] != 0))        {            currDir += (float)(acS[idx + 1] - acS[idx])/                          max(acS[idx], acS[idx + 1]);    what is the meaning of subtracting 1 and dividing by 2, etc.    The IR seeker sensor has 5 IR sensors in it. It returns a value of zone 1 through 9. The direct zone of the five sensors are the odd zones 1, 3, 5, 7, 9. The even zones are interpolated zones of the adjacent zones. For example, zone 2 is the interpolation of zone 1 and 3. By doing idx = (idx - 1)/2, it is translating it back to sensor 1 to 5 (or index 0 to 4). For example:    Code:Zone    SensorIndex   Comment  1           0       Zone 1 is the direct zone of sensor 0  2           0       Zone 2 is the interpolated zone of sensors 0 and 1  3           1       Zone 3 is the direct zone of sensor 1  4           1       Zone 4 is the interpolated zone of sensors 1 and 2  5           2       Zone 5 is the direct zone of sensor 2  6           2       Zone 6 is the interpolated zone of sensors 2 and 3  7           3       Zone 7 is the direct zone of sensor 3  8           3       Zone 8 is the interpolated zone of sensors 3 and 4  9           4       Zone 9 is the direct zone of sensor 4        //        // idx < 4 is to make sure it is one of the first four sensors (0-3) because we are going to        // examine sensor idx and idx + 1 to calculate the interpolated strength between them.        // So if idx is within 3 and idx + 1 is within 4 and both of the sensors idx and idx + 1        // read non-zero IR strength, we can use the strength of the two adjacent sensors to interpolate        // whether the IR beacon is closer to sensor idx or sensor idx + 1.        //        if ((idx < 4) && (acS[idx] != 0) && (acS[idx + 1] != 0))        {            currDir += (float)(acS[idx + 1] - acS[idx])/                          max(acS[idx], acS[idx + 1]);    Does it make sense?

 Page 2 of 2 All times are UTC - 5 hours [ DST ] Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Grouphttp://www.phpbb.com/