Starting cortex tasks

Our girls are wanting to do some more advanced control for their lift mechanism this year (still on cortex). They are looking to use PID to control the lift position for both auton and driver control. We have a PID task written to control the motors, and know how to code the actual control for the buttons, but when we go to start the PID task, it only seems to compile and have no issues when the startTask is placed in the user control section. Since the control was desired in both auton and driver, we tried starting the task in either pre_auton or auton (with the bstoptasksbetweenmodes set to false) and it comes up with errors. It comes up with an error for Undefined variable for the task name , and at the line where the task is actually programmed, the error says duplicate definition for the task name. Its like the cortex thinks the task is a variable. Which doesn’t make sense since if I start the task in the user control, it works just fine with no errors.

Note - I’m without the code right now so I can’t post examples. If desired, I can get some posted when I get home.

I"m sure there is something more I don’t understand about task control in the controller, but anything pointing me to the issue would be helpful. I’m at a loss guiding them to a solution.

If it works in user control, there is no reason why it shouldn’t work in auton.

If you are getting compile error, could it be that task function is defined between auton() and userControl()? Then you need to move it all the way up.

If that doesn’t help then, please, post the code.


Weilin, that was it. It was defined in the wrong place. Its been so long since I programmed so much myself, I didn’t notice it.

1 Like

I am happy it worked for you!

1 Like