Hello,
I wrote part of my autonomous program to use tasks because I want more than one move to happen simultaneously during part of the program. Everything works up to and including the 2 tasks. The problem is that the robot is not moving on to the commands that come after the startTask commands. It stops dead after the tasks are complete, but I want it to keep executing more commands after it completes the 2 tasks. I’ve pasted my code below. If anyone can tell me what’s wrong with it, I would be very appreciative.
Thanks!
task task1()
{
//back up to fence_Task1//
resetMotorEncoder(flMotor);
resetMotorEncoder(frMotor);
resetMotorEncoder(brMotor);
resetMotorEncoder(blMotor);
while(getMotorEncoder(flMotor) > -600)
{
motor[flMotor] = -127;
motor[blMotor] = -127;
motor[frMotor] = -127;
motor[brMotor] = -127;
motor[clawMotor] = 20;
}
motor[flMotor] = 0;
motor[blMotor] = 0;
motor[frMotor] = 0;
motor[brMotor] = 0;
}
task task2()
{
//lift cube//
SensorValue[liftEncoder] = 0;
while(SensorValue[liftEncoder] < 100)
{
motor[YMotor] = -127;
motor[Y2Motor] = 127;
motor[Y3Motor] = -127;
}
motor[YMotor] = 0;
motor[Y2Motor] = 0;
motor[Y3Motor] = 0;
}
task autonomous()
{
//Move away from wall//
resetMotorEncoder(flMotor);
resetMotorEncoder(frMotor);
resetMotorEncoder(brMotor);
resetMotorEncoder(blMotor);
while(getMotorEncoder(flMotor) < 750)
{
motor[flMotor] = 127;
motor[blMotor] = -80;
motor[frMotor] = -127;
motor[brMotor] = 80;
}
motor[flMotor] = 0;
motor[blMotor] = 0;
motor[frMotor] = 0;
motor[brMotor] = 0;
//open claw//
motor[clawMotor] = -127;
wait1Msec(500);
motor[clawMotor] = 0;
//raise claw to level//
SensorValue[liftEncoder] = 0;
while(SensorValue[liftEncoder] < 10)
{
motor[YMotor] = -127;
motor[Y2Motor] = 127;
motor[Y3Motor] = -127;
}
motor[YMotor] = 0;
motor[Y2Motor] = 0;
motor[Y3Motor] = 0;
wait1Msec(100);
//drive straight to cube//
resetMotorEncoder(flMotor);
resetMotorEncoder(frMotor);
resetMotorEncoder(brMotor);
resetMotorEncoder(blMotor);
while(getMotorEncoder(flMotor) < 800)
{
motor[flMotor] = 120;
motor[blMotor] = 120;
motor[frMotor] = 127;
motor[brMotor] = 127;
}
motor[flMotor] = 0;
motor[blMotor] = 0;
motor[frMotor] = 0;
motor[brMotor] = 0;
//close claw on cube//
motor[clawMotor] = 127;
wait1Msec(600);
motor[clawMotor] = 0;
//turn to line up with fence//
resetMotorEncoder(flMotor);
resetMotorEncoder(frMotor);
resetMotorEncoder(brMotor);
resetMotorEncoder(blMotor);
while(getMotorEncoder(flMotor) > -500)
{
motor[flMotor] = -127;
motor[blMotor] = -127;
motor[frMotor] = 127;
motor[brMotor] = 127;
motor[clawMotor] = 20;
}
motor[flMotor] = 0;
motor[blMotor] = 0;
motor[frMotor] = 0;
motor[brMotor] = 0;
//call task1//
startTask( task1 );
//call task2//
startTask( task2 );
//The robot stops here when it should be executing the commands below - Please help//
motor[clawMotor] = -127;
wait1Msec(1000);
motor[clawMotor] = 0;
}