Help with Task Programming

So I’m working on programs getting ready for worlds, and I have some questions about tasks.

  1. How do I create a task? Do I need to set up a void variable and then call it through a task function later, or is it something completely different?

  2. How do tasks work? Will a task essentially set up a branch of the program that the brain will completely at the same time as the rest of the program or, again, is it something completely different?

  3. Could I use a task to run, for instance, a lift leveling program during autonomous? To do this would I call the task at the start and then it will run through it while the autonomous is going on, or maybe put the task in a while loop somewhere in the autonomous section?

Im sorry in advance if these questions have been answered before. Every time I search for them I come up fruitless. Thanks!

you may want to read this discussion on ROBOTC tasks, however, I need to fix the links in that post, forum upgrade broke everything.

also, here’s some code I posted last week.

1 Like

This should be very helpful, although the direct transfer from robotC to VCS could present itself as a small bump in the process.

The VCS/VEXcode scheduler is very similar to the ROBOTC scheduler. There are some differences due to the fact that ROBOTC was running as a virtual machine and had more control over when exactly the task switching could occur, however, the concepts are very similar.

startTask( myTask ) becomes vex::task taskId( myTask )
wait1Msec(10) becomes task::sleep(10)
AbortTimeSlice() becomes task::yield()

and so on.

(and I fixed the broken links in the original topic)

9 Likes