Robot code crashing after a while?

For some reason, when I run my code, it works for a while, then just randomly stops. I get a thing saying that there isn’t any robot code running, but the little light on the DS says otherwise. I can switch modes and enable them with no issues, but still, the robot will not do anything. Aside from the crashes, everything works perfectly (Minus some potentiometer madness on our shooter tilt).

The source can be found here:

Two things to check to figure out what is crashing:

  1. Check the Free RAM on the Driver Station Chart tab, if this number is constantly decreasing to 0 while the robot is running your code leaks memory
  2. Make sure NetConsole is enabled using he imaging tool, then open NetConsole, boot the cRIO (so you know Netconsole is working) then see if your code is reporting an exception when it crashes
  3. If neither of the above is happening your code is likely hitting a semaphore deadlock. Running through the debugger may help locate it.

You might try disabling the watchdog, and see if that fixes it. If it does, then re-enable it and figure out where you’re forgetting to feed the watchdog.

  1. Ill try this tonight. If it is a memory leak, how would I fix this? (What would even cause this?)
  2. It is enabled (The Console Out switch, yes?) and I will check this tonight.
  3. I disabled the semaphores we have and am not starting the second task I have, so I dont think I have any semaphores to deadlock with.

I’m not getting any watchdog errors or messages or lights or anything, but if Ruffles’ suggestions don’t work, I will do this.

I changed a few things and the code worked fine… I think I was allocating a resource twice.