HOW TO write a multitasking ot multithreading program?

I use PROS to write programs and I want to write a code that can use two or more functions at the same time. For example, duiring the autonomous period, the robot can move and also select the rings of alliance color. Just like the function in VEXcode Pro, thread.join() or thread.detech()
Is there any solutions???

Pros has a tasking system for this purpose. Here are the docs: Multitasking — PROS for V5 3.8.0 documentation

Here is some example code:

void myfunction() {
   pros::lcd::print(1, "Task executed!");
}

void initialize() {
   //Starts myfunction as a task
   pros::Task mytask(myfunction);
}

Hope this helps!

1 Like