So when clicking on this title your probably thinking we just aren’t programming our encoders correctly, but they have been working find in all of our recent tournaments and the program has not changed (this part at least) since.
The problem we are having is that the robot will only stop turning on some occasions, whilst the rest of the time it turns forever,
We notice that it infinitely turns when it has a mobile goal picked up, whilst when it doesn’t it doesn’t seem to have this issue.
The sensors are more than certainly working, as when driving forward to pick up a Mobile Goal they are always travelling the correct distance and stopping, i have had trouble fixing it, and nobody can seem to find a solution!
I will include the code below:
Note: We have tried lowering the power which makes it work slightly more often, but we need to run the motors at full power to be able to finish the program within the 15 second Autonomous.
Note: The point which seems to be the error is when the leftEncoder is turning until it reaches 1480 encoder ticks, (Line 91), note: this error occurs for both encoders. Help would be appreciated, Thanks in advance
#pragma config(Sensor, in1, Potentiometer, sensorPotentiometer)
#pragma config(Sensor, in2, Potentiometer2, sensorPotentiometer)
#pragma config(Sensor, dgtl1, leftEncoder, sensorQuadEncoder)
#pragma config(Sensor, dgtl3, rightEncoder, sensorQuadEncoder)
#pragma config(Sensor, dgtl5, bumper, sensorTouch)
#pragma config(Motor, port2, rightDrive, tmotorVex393_MC29, openLoop, driveRight)
#pragma config(Motor, port3, leftDrive, tmotorVex393_MC29, openLoop, driveLeft)
#pragma config(Motor, port4, PinionGear2, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port5, Claw, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port6, PinionGear1, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port7, Lift, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port8, Arm, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port9, Arm2, tmotorVex393_MC29, openLoop)
//!!Code automatically generated by ‘ROBOTC’ configuration wizard !!//
task one()
{
moveMotor(port8, 0.4, seconds, 100);
delay(100000);
}
task two()
{
moveMotor(port9, 0.4, seconds, 100);
delay(100000);
}
task three()
{
moveMotor(port4, 0.5, seconds, -100);
delay(1000);
backward(0.2, seconds, 100);
delay(100000);
}
task four()
{
moveMotor(port6, 0.5, seconds, -100);
moveMotor(port5, 0.5, seconds, -100);
delay(100000);
}
task five()
{
delay(400);
moveMotor(port8, 1, seconds, 100);
delay(100000);
}
task six()
{
delay(400);
moveMotor(port9, 1, seconds, 100);
delay(100000);
}
task main()
{
enableCompetitionMode();
repeat (forever) {
if (getCompetitionAutonomous() == true) {
startTask(one);
startTask(two);
SensorValue[rightEncoder] = 0;
SensorValue[leftEncoder] = 0;
while(SensorValue[leftEncoder] < 280)
{
motor[rightDrive] = 90;
motor[leftDrive] = 90;
}
stopAllMotors();
startTask(three);
startTask(four);
delay(1000);
startTask(five);
startTask(six);
delay(100);
moveMotor(port7, 1.9, seconds, -100);
while (SensorValue[bumper] == 0)
{
motor[Lift] = -80;
}
moveMotor(port7, 0.1, seconds, 100);
stopAllMotors();
forward(0.7, seconds, 100);
moveMotor(port7, 1.7, seconds, 100);
while (SensorValue[bumper] == 0)
{
motor[Lift] = 100;
}
stopAllMotors();
backward(0.75, seconds, 100);
stopAllMotors();
SensorValue[leftEncoder] = 0;
SensorValue[rightEncoder] = 0;
while(SensorValue[leftEncoder] < 1480)
{
//Buggy, Needs to be fixed, turning forever.
motor[rightDrive] = 0;
motor[leftDrive] = 80;
}
stopAllMotors();
forward(2, seconds, 100);
moveMotor(port7, 1.7, seconds, -100);
while(SensorValue[bumper] == 0)
{
motor[Lift] = -70;
}
stopAllMotors();
backward(0.45, seconds, 100);
moveMotor(port7, 2.4, seconds, 100);
delay(3000); // End of 15s auton
}
if (getCompetitionDriverControl() == true) {
arcadeControl(Ch2, Ch1, 100);
buttonControl(port7, Btn6U, Btn6D, 100);
buttonControl(port5, Btn7L, Btn7R, 100);
buttonControl(port6, Btn7U, Btn7D, 80);
buttonControl(port4, Btn7U, Btn7D, 80);
buttonControl(port10, Btn5U, Btn5D, 100);
buttonControl(port9, Btn5U, Btn5D, 100);
buttonControl(port8, Btn5U, Btn5D, 100);
}
}
}