View unanswered posts | View active topics It is currently Fri Sep 30, 2016 1:07 am

 Page 2 of 2 [ 16 posts ] Go to page Previous  1, 2
 Print view Previous topic | Next topic
IR Seeker inaccuracy
Author Message
Guru

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1523
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
Display posts from previous:  Sort by
 Page 2 of 2 [ 16 posts ] Go to page Previous  1, 2

#### Who is online

Users browsing this forum: No registered users and 1 guest

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

Search for:
 Jump to:  Select a forum ------------------ ROBOTC Applications    ROBOTC for LEGO MINDSTORMS       Third-party sensors    ROBOTC for CORTEX & PIC    ROBOTC for VEX IQ    ROBOTC for Arduino    Robot Virtual Worlds    Multi-Robot Communications    Issues and Bugs Competitions & Partners    Mini Urban Challenge    CS2N Robot Virtual Worlds Competitions       VEX Skyrise Competition 2014-2015       VEX Toss Up 2013-2014       FTC Block Party! 2013-2014    Competitions using VEX - BEST, TSA, VEX, and RoboFest!    FTC Programming    RoboCup Junior and Other ROBOT Competitions Virtual Brick Robotics Discussions    General Discussions    Project Discussions Off-Topic ROBOTC Forum & ROBOTC.net Suggestions/Feedback    ROBOTC Forums Suggestions/Comments    ROBOTC.net Suggestions/Comments       NXT Programming: Tips for Beginning with ROBOTC       VEX Programming: Tips for Beginning with ROBOTC    2013 Robotics Summer Of Learning       VEX Toss Up Programming Challenge       FTC Ring It Up! Programming Challenge    International Forums       Spanish Forums          ROBOTC for MINDSTORMS          ROBOTC for VEX       French Forums          ROBOTC pour Mindstorms          ROBOTC pour IFI VEX       Japanese Forums （日本語のフォーラム）       German Forums    2015 Spring Carnival Event    PLTW (Project Lead The Way)    Robotics Merit Badge    2014 Robotics Academy Summer of Learning