View Single Post
  #3   Spotlight this post!  
Unread 27-02-2013, 22:12
kylelanman's Avatar
kylelanman kylelanman is offline
Programming Mentor
AKA: Kyle
FRC #2481 (Roboteers)
Team Role: Mentor
 
Join Date: Feb 2008
Rookie Year: 2007
Location: Tremont Il
Posts: 186
kylelanman is a name known to allkylelanman is a name known to allkylelanman is a name known to allkylelanman is a name known to allkylelanman is a name known to allkylelanman is a name known to all
Re: Serious crashing issues

According to what the driver station says you are crashing when entering autonomous. I didn't look through the entire code base but I did notice at least one problem with how your autonomous is setup.

The way the autonomous should be setup is with a state machine. The loop is intended to run fast. That is ever 20ms the loop runs when it receives data from the driver station. You should only need to feed the watch dog one time in the loop. Additionally you need to remove all your delays. All the waits you have are causing the robot to time out and use up all the CPU.

It would look something like this. This has not been compiled and may contain minor syntax errors and possible logic errors. The idea is to give you an idea of how a state machine is setup. If you need additional assistance let us know.

Code:
Timer autoTimer;
int autoState = 0;
int fireCount = 0;

autoTimer.start();

while (IsAutonomous() && IsEnabled()) {
	if (autoState == 0) {
		myShooter1.Set(-1);
		myShooter2.Set(-1);
		if (autoTimer.Get() > intPause) {
			state++;
			autoTimer.Reset();
		}	
	}

	if (autoState == 1) {
		s[2]->Set(true);
		if (autoTimer.Get() > WaitDash) {
			autoState++;
			autoTimer.Reset();
		}				
	}

	if (autoState == 2) {
		s[2]->Set(false);
		if (autoTimer.Get() > 3) {
			if (++fireCount == FireDash) {
				autoState++;
			} else {
				autoState=1;
			}
			autoTimer.Reset();
		}				
	}
	if (autoState == 3) {
		myShooter1.Set(0);
		myShooter2.Set(0);
	}
	GetWatchdog().Feed();
}
__________________
"May the coms be with you"

Is this a "programming error" or a "programmer error"?


Last edited by kylelanman : 27-02-2013 at 22:15. Reason: Add additional comments content.
Reply With Quote