View unanswered posts | View active topics It is currently Thu Dec 25, 2014 5:13 pm






Reply to topic  [ 18 posts ]  Go to page Previous  1, 2
Need help with dimensions If else 
Author Message
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3308
Location: Rotterdam, The Netherlands
Post Re: Need help with dimensions If else
Ziram

Sorry I didn't get back to you sooner, I've been super busy with all kinds of things :)

Anyway, looking at your code, it took me a minute to spot it but it's a really sneaky bug. Look at the values of the actual states:
Code:
const int STATE_CRUISING = 0;
const int STATE_LOOK_FOR_END_OF_GAP = 1;
const int STATE_PARK_CAR = 3;
const int STATE_ALL_DONE = 4;


Now look at the switch block:
Code:
task main()
{
  while (true) {
    switch(next_state) {
      case 0: doSTATE_CRUISING();
              break;

      case 1: doSTATE_LOOK_FOR_END_OF_GAP();
              break;

      case 2: doPARK_CAR();
              break;

      case 3: doALL_DONE();
              break;

    }
  }
}


Now if you were to replace the numbers in the switch block with the names of the constants declared above, do you notice the problem?

- Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Fri Nov 12, 2010 9:27 am
Profile WWW
Rookie

Joined: Mon Nov 01, 2010 2:44 pm
Posts: 9
Post Re: Need help with dimensions If else
Ok i was able to figure it out and the program all works.

Thanks.


Sat Nov 13, 2010 1:45 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3308
Location: Rotterdam, The Netherlands
Post Re: Need help with dimensions If else
Now all you need to do is make a video!

- Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Sat Nov 13, 2010 1:48 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 18 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.