Enabling PIDController Crashes Windriver

I’m attempting to use a PIDController for positioning the robot. I created a PIDSource class based on the camera, and a PIDOutput that goes to all four drive motors. All this is created in the robot constructor without a hitch (that I can see at least). I’m using CANJaguars and the IterativeRobot template.

The problem comes when I attempt to enable the PIDController in the AutonomousInit function. At that line, the program crashes and when Windriver attaches the debugger, it goes into the assembly code. I’ve followed it to the “strafeController.Enable();” line though, so I’m sure it’s that. It’s our first year of PID, so I’m still a little lost.

45         ShsAlignCam *alignCam;  
46         ShsStrafePID *strafer;  
47         PIDController *strafeController;  
96         camera(AxisCamera::GetInstance())  
97         {  
157                 alignCam = new ShsAlignCam();  
158                 strafer = new ShsStrafePID(leftFront, rightFront, leftBack, rightBack);  
159                 strafeController = new PIDController(1, 0.001, 0.0, alignCam, strafer);  
183         }  
 void AutonomousInit(void) {  
227                 strafeController->SetSetpoint(0);  
228                 strafeController->Enable();  
237         }  

Any ideas? Happy to answer questions if you have them.

Edit: Just realized what I typed in as the title. It crashes my program, not windriver. Windriver tells me that it crashed. I’m tired.

Another Edit: I’m going to call it a night due to the English paper due Monday hanging over my head. Here’s hoping that someone sees this by tomorrow and can help.

With the help from one of my mentors (who I was having trouble reaching last night), I figured out the problem. The camera PIDSource was probably taking to long to calculate it, so I extended the time on the PIDController and hashed down the PIDGet() function to just return the value (had some debugging things in there like writing the color image and the binary image… woops).

THANK YOU for posting the fix rather than saying nothing. It’s a great example of GP.

No problem. Chief Delphi’s my main source of troubleshooting help (still left over from when we didn’t have any mentors who knew a thing about programming), and it always bugs me when I run into a thread that described my problem exactly, but never had a solution. Hopefully I’ll help some other people out and maybe they’ll post solutions to their own problems later. The programmers’ version of the Liberty Mutual commercial.