View unanswered posts | View active topics It is currently Sat Nov 29, 2014 1:10 am






Reply to topic  [ 16 posts ]  Go to page Previous  1, 2
IR Seeker inaccuracy 
Author Message
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post 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?


Sat Nov 26, 2011 10:11 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 16 posts ]  Go to page Previous  1, 2

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.