I have been fighting with this issue for hours, every time I add a new thing to my code previous ones fail. For example I want my robot to put two triballs to the front of the net before pushing them inside, but when I add driving back after pushing It doesn’t even push. New lines make previous lines false
#include "vex.h"
#include "math.h"
using namespace vex;
bool direction = 0, zottiri = 0, LeftOpen = true, RightOpen = true;
double pi = 3.14159265359;
int Brain_precision = 0, Console_precision = 0, Vision10_objectIndex = 0, rotate = 90;
controller console = controller();
motor leftMotorA(PORT20, ratio18_1, false);
motor leftMotorB(PORT3, ratio18_1, false);
motor Intake(PORT17, ratio18_1, false);
motor_group LeftDriveSmart(leftMotorA, leftMotorB);
motor rightMotorA(PORT4, ratio18_1, false);
motor rightMotorB(PORT5, ratio18_1, false);
motor_group RightDriveSmart( rightMotorB, rightMotorA);
motor_group AllDriveSmart(leftMotorA,leftMotorB,rightMotorA,rightMotorB);
motor catapultA(PORT7, ratio18_1, false);
motor catapultB(PORT18, ratio18_1, false);
motor Blok(PORT16, ratio18_1, false);
double radius = 0.1016 * pi;
void RotateDrive(double rotation)
{
LeftDriveSmart.spinFor(reverse,rotation*pi,degrees,100, velocityUnits::pct, false);
RightDriveSmart.spinFor(reverse,rotation*pi, degrees, 100,velocityUnits::pct, true);
}
void Drive(double distance)
{
RightDriveSmart.spinFor(forward,distance/radius*360,degrees,100, velocityUnits::pct, false);
LeftDriveSmart.spinFor(reverse,distance/radius*360, degrees, 100,velocityUnits::pct, true);
}
void (LeftGas)(void) {LeftOpen = !LeftOpen; LeftOut.set(LeftOpen);}
void (RightGas)(void){RightOpen = !RightOpen; RightOut.set(RightOpen);}
void (AllGas)(void){
RightOpen = !RightOpen;
LeftOpen = !LeftOpen;
RightOut.set(RightOpen);
LeftOut.set(LeftOpen);
}
// A global instance of competition
competition Competition;
void pre_auton(void) {
// Initializing Robot Configuration. DO NOT REMOVE!
vexcodeInit();
// All activities that occur before the competition starts
// Example: clearing encoders, setting servo positions, ...
}
/*---------------------------------------------------------------------------*/
/* */
/* Autonomous Task */
/* */
/* This task is used to control your robot during the autonomous phase of */
/* a VEX Competition. */
/* */
/* You must modify the code to add your own robot specific commands here. */
/*---------------------------------------------------------------------------*/
void autonomous(void) {
LeftOut.set(false);
RightOut.set(false);
Blok.spinFor(reverse,90,degrees,100, velocityUnits::pct, false);
Intake.spinFor(forward,90,degrees,100,velocityUnits::pct, true);
wait(0.05,seconds);
Drive(0.92);
RotateDrive(50);
Intake.spinFor(reverse,180,degrees,35,velocityUnits::pct,true);
Drive(-0.03);
RotateDrive(-57);
Drive(0.2);
Intake.spinFor(forward,180,degrees,100,velocityUnits::pct,true);
RotateDrive(91);
LeftOut.set(true);
Intake.spin(reverse,100,percent);
Drive(0.31);
LeftOut.set(false);
wait(0.1,seconds);
Intake.stop(hold);
Drive(-0.2);
RotateDrive(120);
LeftOut.set(false);
Vision10.takeSnapshot(Vision10__BALL);
while (!(Vision10.objects[Vision10_objectIndex].centerX > 160 and Vision10.objects[Vision10_objectIndex].centerX < 180))
{
RotateDrive(5);
rotate = rotate + 5;
Vision10.takeSnapshot(Vision10__BALL);
}
Intake.spin(forward,100,percent);
Drive(0.23);
Drive(-0.5);
Intake.stop(hold);
RotateDrive(-1 * rotate);
RightDriveSmart.spinFor(forward,0.2/radius*360,degrees,100, velocityUnits::pct, false);
LeftDriveSmart.spinFor(reverse,0.2/radius*360, degrees, 100,velocityUnits::pct, true);
Intake.spinFor(reverse,180,degrees,100,velocityUnits::pct,false);
wait (0.2,seconds);
rotate = 100;
Drive(-0.1);
RotateDrive(-120);
while (!(Vision10.objects[Vision10_objectIndex].centerX > 160 and Vision10.objects[Vision10_objectIndex].centerX < 180))
{
RotateDrive(-5);
rotate = rotate + 5;
Vision10.takeSnapshot(Vision10__BALL);
}
Drive(0.2);
}