Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   Enabling PIDController Crashes Windriver (http://www.chiefdelphi.com/forums/showthread.php?t=92399)

CodeMonkeyMatt 19-02-2011 22:35

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.

Code:

45        ShsAlignCam *alignCam; 
46        ShsStrafePID *strafer; 
47        PIDController *strafeController; 
...
 BuiltinDefaultCode(void): 
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.

CodeMonkeyMatt 20-02-2011 18:26

Re: Enabling PIDController Crashes Windriver
 
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).

garyk 20-02-2011 19:12

Re: Enabling PIDController Crashes Windriver
 
Quote:

Originally Posted by CodeMonkeyMatt (Post 1027698)
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.

CodeMonkeyMatt 20-02-2011 19:21

Re: Enabling PIDController Crashes Windriver
 
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.


All times are GMT -5. The time now is 13:36.

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