So I have been trying to multitask in robotc. Multitasking such as making my robot drive and lift the lift at the same time in autonomous. But I can’t figure out how to do that. Any help will be appreciated.
Here is a simple example showing how to start two additional tasks during the autonomous period.
task drive() {
nMotorEncoder port1 ] = 0;
motor port1 ] = 100;
motor port10 ] = 100;
while( nMotorEncoder port1 ] < 1000 ) {
wait1Msec(25);
}
motor port1 ] = 0;
motor port10 ] = 0;
}
task claw() {
motor port2 ] = 100;
wait1Msec(1000);
motor port2 ] = 0;
}
task autonomous()
{
// ..........................................................................
// Insert user code here.
// ..........................................................................
// Remove this function call once you have "real" code.
AutonomousCodePlaceholderForTesting();
startTask( drive );
startTask( claw );
while(1) {
// do something else
wait1Msec(10);
}
}