Sighs My brain’s really tired but my code is not working. Even though it looks perfectly fine with out any compile errors, my usercontrol code does not work. I haven’t tested auton yet because I didn’t make an auton yet but the usercontrol just doesn’t function. It’s probably not an engineering problem and probably just my code. But I can’t see what’s wrong with it. Maybe my eyes are tired… I didn’t use the PID yet so that shouldn’t be the problem…
this is the usercontrol code.
I can’t attach the full code because its too long? And I can’t attach .c as a file so I attached it in a .doc
task usercontrol()
{
// User control code here, inside the loop
while (true)
{
int manualcontrol;
/*--------------------------------------------------------------------------------------------------------------------------------*/
/* DR4B(1,0);
wait1Msec(1000);
float offsetLeft = SensorValue[leftDR4BPot];
float offsetRight = SensorValue[rightDR4BPot];
float wantedHeight = 0;
float restHeight = 0;
float coneHeight = 25; //needs to be set
float stationaryGoalHeight = 500; //needs to be set
float maxHeight = 950; //needs to be set
float manualcontrol;
DR4BTargetLeft = SensorValue[leftDR4BPot];
DR4BTargetRight = SensorValue[rightDR4BPot];
startTask(DR4BPID);
int DR4BcontrolState = 0;
*/
/*--------------------------------------------------------------------------------------------------------------------------------*/
while (true)
{
/*NOTES:
Main controller is Stacking and DR4B controls
Partner is Drive and MOGO
*/
/*--------------------------------------------------------------------------------------------------------------------------------*/
//DR4B
/* if(vexRT(Btn7U) == 1)//DR4B moves up 1 cone height
{
wantedHeight = coneHeight;
coneHeight = coneHeight + 1;
}
if(vexRT(Btn7D) == 1)//DR4B moves down 1 cone height
{
wantedHeight = coneHeight - 1;
}
else if(vexRT(Btn7L) == 1)//DR4B moves to stationary goal height
{
wantedHeight = stationaryGoalHeight;
}
else if(vexRT(Btn7R) == 1)//DR4B moves all the way down
{
wantedHeight = 0;
}
else if(vexRT(Btn5U) == 1)//Calculation of offset and wanted height making Target height
{
DR4BTargetLeft = wantedHeight + offsetLeft;
DR4BTargetRight = wantedHeight + offsetRight;
}
if(vexRT(Btn8R) == 1)//Recalibrate offset for when Potentiometer malfunctions
{
offsetLeft = SensorValue(leftDR4BPot);
offsetRight = SensorValue(rightDR4BPot);
}
*/
/*--------------------------------------------------------------------------------------------------------------------------------*/
//DR4B Manualcontrol
if(vexRT(Btn8L) == 1 && manualcontrol != 1)//Enable manual control
{
manualcontrol = 1;
}
if(vexRT(Btn8L) == 1 && manualcontrol == 1)//Disable manual control
{
manualcontrol = 0;
}
if(vexRT(Btn8U) == 1 && manualcontrol == 1)//Manual control DR4B moves up
{
motor[leftDR4B] = 90;
motor[rightDR4B] = 90;
}
else if(vexRT(Btn8D) == 1 && manualcontrol == 1)//Manual control DR4B moves down
{
motor[leftDR4B] = -90;
motor[rightDR4B] = -90;
}
else if(manualcontrol == 1 && (vexRT(Btn8D) == 0) && vexRT(Btn8U) == 0)
{
motor[leftDR4B] = 0;
motor[rightDR4B] = 0;
}
/*--------------------------------------------------------------------------------------------------------------------------------*/
//Stacking
/* if(vexRT(Btn6U) == 1)//Starts stacking process depending on arm encoder
{
stacking(1);
}
*/
/*--------------------------------------------------------------------------------------------------------------------------------*/
// Drive
rightDrive(vexRT(Ch2Xmtr2));//Right side drive responds to right joystick (PID code not used here)
leftDrive(vexRT(Ch3Xmtr2));//Left side driving responds to left joystick (PID code not used here)
/*--------------------------------------------------------------------------------------------------------------------------------*/
//MOGO
if(vexRT(Btn6UXmtr2) == 1)//MoGO lift moves up
{
moGo(1,0);
}
else if(vexRT(Btn6DXmtr2) == 1)//MoGo lift moves down
{
moGo(0,1);
}
else// else stay
{
moGo(0,0);
}
}
}
//UNAUTOMATED STACKING
/*--------------------------------------------------------------------------------------------------------------------------------*/
//Arm Control
if(vexRT(Btn7UXmtr2) == 1)
{
armControl(0,1);
}
else if(vexRT(Btn7DXmtr2) == 1)
{
armControl(1,0);
}
else
{
armControl(0,0);
}
/*--------------------------------------------------------------------------------------------------------------------------------*/
//Rollers
if(vexRT(Btn7LXmtr2) == 1)
{
motor[claw] = 90;
}
else if(vexRT(Btn7RXmtr2) == 1)
{
motor[claw] = -90;
}
else
{
motor[claw] = 0;
}
} /*--------------------------------------------------------------------------------------------------------------------------------*/
leroy code 3.0.docx (13 KB)