Hi forum, I’m scratching my head trying to run a task function in the operator control.
Can you check the code if it is in the correct format to call the task.
From my initial test the task start and stop all the time.
Any suggestion will be appreciated.
Thanks
task usercontrol()
{
// User control code here, inside the loop
int ClawOpen;
int ClawClose;
int armRaiseM; // Arm raise middle
int armRaiseH; // Arm raise high
int armRaiseB; // Arm raise bottom
armPidRequestedValue = SensorValue( PotArm ); // Set initial position of arm
startTask( armPidController ); // Start arm PID task
while (true)
{
sLimit = SensorValue( ArmLimitSwitch );
aPot = SensorValue( PotArm );
//Display Arm angle
clearLCDLine(0);
clearLCDLine(1);
displayLCDCenteredString(0, "Driver Mode");
displayLCDNumber(1, 6, sLimit);
joyvalLR = vexRT Ch1 ]; //Get joystick value for left and right
joyvalFB = vexRT Ch2 ]; //Get joystick value for front and back
cubicForm( joyvalLR, 1);
cubicForm( joyvalFB, 2);
movBot ( rCubicFB, rCubicLR, rCubicSLR );
armRaiseB = vexRT Btn7D ]; // Get joystick value to put the arm at the bottom
armRaiseM = vexRT Btn7R ]; // Get joystic value to put the arm at middle position
armRaiseH = vexRT Btn7U ]; // Get joystic value to put the arm at high position
// --------------Joystick Preset-------------------//
if ( armRaiseB == 1 )
{
armPidRequestedValue = 750;
}
if ( armRaiseM == 1 )
{
armPidRequestedValue = 1200;
}
if ( armRaiseH == 1 )
{
armPidRequestedValue = 2500;
}
// --------------Joystick Preset-------------------//
// --------------Joystick Manual-------------------//
joyvalUD = vexRT Ch3 ]; // Get joystick value to raise and lower the arm
if ( (sLimit == 1 && vexRT Ch3 ] < 0 && aPot < 800) || (aPot > 2500 && vexRT Ch3 ] > 0))
{
motor port3 ] = 0; // RBA
motor port8 ] = 0; // LBA
motor port4 ] = 0; // LTA
motor port9 ] = 0; // RTA
}
else
{
motor port3 ] = vexRT Ch3 ]; // RBA
motor port8 ] = -(vexRT Ch3 ]); // LBA
motor port4 ] = vexRT Ch3 ]; // LTA
motor port9 ] = -(vexRT Ch3 ]); // RTA
}
// --------------Joystick Manual-------------------//
ClawOpen = vexRT Btn6D ]; // Get joystick value to open the claw
ClawClose = vexRT Btn6U ]; // Get joystic value to close the claw
if (ClawOpen == 1) // Open the Claw
{
SensorValue[ClawLeft] = 1;
SensorValue[ClawRight] = 1;
}
if (ClawClose == 1) // Close the Claw
{
SensorValue[ClawLeft] = 0;
SensorValue[ClawRight] = 0;
}
}
}