Call Pre Auto Function Every Time Robot Goes into Disabled Mode


Recently, my team has had an issue with the competition switch, that if we start in driver control (or the competition cable is unplugged) and then the robot is disabled, pre_auton doesn’t run, causing nothing to be calibrated or the LCD code to run. How would it be possible to call pre_auton every time the robot switches into disabled mode? Would I have to edit the competition template and include file, or is there a better way to do this.


Preautonomous is a void function, so you could call it at the start of the user control task by putting


prior to the user control


. I don’t think this would cause any problems with competition control.

What environment are you using? PROS? ROBOTC? EasyC? ConVEX?

I am using ROBOTC

Sounds like something the ROBOTC guys need to advise on, there’s a specific subforum for that but I’ll just go ahead and summon @jpearman.

Proper tournament procedures is to plug in prior to turning the robot on. So you start in disabled.

I think you must be confused though. If you start in driver control your pre_auton function did run. It sounds like you are ending pre auton yourself even though you don’t seem to want to.

That makes sense, but is it possible to run pre-auton every time the robot switches into disabled, instead of just at the start.

Can you post your pre auton code?

I posted the relevant code here. I want to make it that if I start in driver control, the LCD Code doesn’t run, but then when the robot is disabled, pre_auton runs again, running the LCD Code.

Duly summoned.

You can do this but the code gets a little complicated. See demo 4 in this old thread.

O that is an interesting approach. I had read that thread back when it came out but hadn’t thought of it since.

I was going to recommend just moving the LCD selection to its own task. This code

removed from usercontrol. That way the competition code would still be used and the LCD would run through usercontrol and disabled.

They are effectively the same thing. A task in the backround to monitor stuff but I wouldn’t have wanted to bypass the ROBOTC competition control just to have to re-implement it.

When I wrote the code in this thread this was true.

I fixed that IIRC in the latest version of RobotC.

If I set

bStopTasksBetweenModes = false

, would I have to stop the autonomous task during user-control and the other way around (and both in pre_auton) @jpearman @tabor473