Getting Mutiple Functions to Run at the Same Time

I was wondering how I would be able to move the intake of the bot, using move_velocity if possible. While moving the tilter up.
I have code like
intakeLeft.move_velocity(50);
intakeRight.move_velocity(50;
tilter.move_distance(100);

So you need to add a false statement at the end of the first two lines to make them non blocking commands so they all start at the same time until the last line. The last line needs to remain true so it does stop at this point and doesn’t try and complete the step after at the same time. For example.
intakeLeft.move_velocity(50), false;
intakeRight.move_velocity(50), false;
tilter.move_distance(100);
Edit: I use vexcode and don’t have much experience with pros so if I‘m wrong anywhere, somebody call me out.

1 Like

move_velocity is non-blocking. It just set the motor to a velocity.

There is no member function move_distance() there is move_relative and move_absolute. Neither of which are blocking. The example code for each of these functions shows how to wait until the movement is done.

3 Likes

Thank_You ZackJo for the help

1 Like

Thank_You rpm for the help

The code will set the motor speed and then move onto the next line immediately with no waiting. So your current code should do the thing you want like both ZackJo and rpm said.

For future reference though, sometimes you need something to be blocked out while another thing runs and continues in the background. To do that, you would want to use Tasks.

1 Like

I don’t think PROS has a waitForCompletion parameter for the motors. Also, the move_velocity method is non-blocking by default, so OP’s code as is should work fine (as long as they stop their motors after that).

Okapi does have this function: waitUntilSettled()

1 Like

Okay, guess I’m just used to C++, my bad.

If anyone wants to see an example of it the last two use waitUntilSettled()