|
Re: Serious crashing issues
For sure there is over feeding of the watchdog timer (WDT). You could even disable it completely to eliminate it as a possible source of a problem. I think you can safely comment out all the watchdog lines of code. In either case:
GetWatchdog().SetExpiration(1);
means you have one whole second before you need to Feed(). That's a long, long time so once per loop call should be plenty. I don't know how long the SmartDashboard calls take (I know they can mess up Command-based programs due to delays), so I still think it is safer to dump the Watchdog until you find the issue. And you can leave it out since there is a global WDT the OS provides for safety reasons. We only use it if we have sketch code that might hang so we don't lock up the 'bot. To beat this to submission, these lines come right from the WPILib Getting Started Guide:
void Autonomous(void)
{
SetWatchdogEnabled(false);
Drive(0.5, 0.0);
Wait(2.0);
Drive(0.0, 0.0);
}
Some more observations on the code:
I'm not sure what you're doing here:
for(intAutoCtrl = 0; intAutoCtrl < (1);intAutoCtrl++)
{
It looks to me like this line of code really does nothing. The first time though intAutoCrtl is 0 so the code in the loop runs, but the next time intAutoCtrl==1 so the loop is done. Why the loop? It won't crash, just odd. Also, the parenthesis around the (1) shouldn't be there.
GetWatchdog().Feed();
for(intDelay = 0; intDelay< (((intPause)*2)+1);intDelay++)
{
GetWatchdog().Feed();
Wait(0.5);
}
GetWatchdog().Feed();
Here it looks like you're trying to sleep for certain period of time. I guess you're not calling Wait() directly since you were afraid the WDT would kick? It's OK, but another reason to nuke the WDT. You don't need the Feed() before and after. Every 500ms is fine.
So, to wrap this all up, I think your Auton code should like like so:
void Autonomous(void)
{
SetWatchdogEnabled(false);
s[0]->Set(true);
s[1]->Set(true);
SmartDashboard::PutString("Gear","High");
compressor->Start();
// You can probably leave this, but in debugging I get rid of everything
// myRobot.SetSafetyEnabled(true);
// change these to doubles so they match the return value below
double WaitDash = 0;
double FireDash = 0;
double intPause = 0;
// Stuff deleted
// get rid of casts
WaitDash = SmartDashboard::GetNumber("fire_wait");
FireDash = SmartDashboard::GetNumber("fire_amount");
intPause = SmartDashboard::GetNumber("fire_pause");
// deleted all the camera stuff that was commented out
while (IsAutonomous() && IsEnabled())
{
myShooter1.Set(-1);
myShooter2.Set(-1);
// Couldn't tell what the intPause*2+1 x 500ms was all
// about so I just used the double value here directly. You
// might need to convert to a float.
// Wait before firing.
Wait(intPause);
// Fire frisbees
for(intCount = 0; intCount < (FireDash+1); intCount++)
{
s[2]->Set(true);
// This is the same math as your loop (almost)
// or you could just enter the wait value in the dash
Wait(WaitDash*2.0*0.5);
s[2]->Set(false);
Wait(intSecondWait*3*0.5);
} // end of auton frisbee chuck
myShooter1.Set(0);
myShooter2.Set(0);
}
}
That should be a lot easier to read in order to follow the flow.
|