Go to Post Winning or losing on the field has nothing to do with this success. - E. Wood [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 14-02-2009, 22:25
Dave Scheck's Avatar
Dave Scheck Dave Scheck is offline
Registered User
FRC #0111 (WildStang)
Team Role: Engineer
 
Join Date: Feb 2003
Rookie Year: 2002
Location: Arlington Heights, IL
Posts: 574
Dave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond repute
IterativeRobot Race Condition

We were testing our autonomous lockin procedure tonight and noticed a pretty bad race condition within the IterativeRobot class.

Traditionally, our lockin procedure consists of switches at the driver station to select the program to run and a lockin switch to confirm the selection. If the switch is set to "unlock" we will run our "sleeper" program in which nothing moves. If the switch is "locked" we will run whatever program is desired.

The lockin function is called within DisabledPeriodic and has the following flow
Code:
if switch == unlocked
    program = number based on switches
else
    program = 0
Then, in AutonomousInit we read the program number and instantiate the correct autonomous program class
Code:
if program == 0
    prog = new Sleeper()
else if program == 1
    prog = new Program1()
else
    prog = new Sleeper() // For safety in case there is an invalid combination
With that explained, we noticed that there were times where we would take our robot from Autonomous/Disabled to Autonomous/Enabled and the Sleeper program would run even though we confirmed the program to be run when we locked in.

After investigation, we found that the lockin switch state was being transitioned from locked to unlocked within the DisabledPeriodic function. This caused our lockin procedure to set the program number to 0.

We believe that the issue is due to the fact that new driver station data is being read while we are in DisabledPeriodic and the driver station is in Autonomous/Enable, thus zeroing out the inputs.

We worked around this by limiting the chance that we'll hit the race condition by checking IsDisabled before calling the lockin function and reading the switch states immediately upon entering the function (we were doing this from the start).

If this can be fixed within WPILib we would really appreciate it. Until then, teams should be aware of this situation and guard against it.
Reply With Quote
  #2   Spotlight this post!  
Unread 14-02-2009, 22:55
Jared Russell's Avatar
Jared Russell Jared Russell is online now
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,071
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: IterativeRobot Race Condition

Dave,

Thanks for this post. Hopefully it will save somebody a headache!

To novice programmers: read about race conditions here.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
NOT condition in PBASIC? CHSguard72 Programming 7 03-02-2003 17:42
<> condition? CHSguard72 Programming 5 03-02-2003 15:27
Race Car PC Munkaboo Chit-Chat 5 22-01-2003 16:48
How many comp's did u attend? / The condition of last year's bot? purplehaze357 General Forum 30 09-08-2002 11:34


All times are GMT -5. The time now is 02:38.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi