I have had problems with my autonomous as I can best describe changing the code. For example at the beginning of the code the robot is supposed to lift the arms, put them down. Then inhale the cube we have for 1-2 seconds. But sometimes it will not do this and just start driving while the arms and intake is running. This makes our robot cross the line and we will lose autonomous. I have looked through the code a thousand times and I have no idea what is happening.
Here is my code.
#include "vex.h"
vex::competition Competition;
vex::motor LeftMotor = vex::motor( vex::PORT10 );
vex::motor RightMotor = vex::motor( vex::PORT1, true );
vex::motor BackLeftMotor = vex::motor( vex::PORT9 );
vex::motor BackRightMotor = vex::motor( vex::PORT2, true );
vex::motor Intake = vex::motor(vex::PORT7, true );
vex::motor Intake2 = vex::motor(vex::PORT4,false);
vex::motor LiftMotor = vex::motor(vex::PORT8,false );
vex::motor ArmMotor = vex::motor(vex::PORT12, true);
vex::controller Controller1 = vex::controller(vex::controllerType::primary);
vex::controller Controler2 = vex::controller(vex::controllerType::partner);
void wait(float mSec){
vex::task::sleep(mSec);
}
int driveControlTask(){
while (Competition.isAutonomous()!=1){
LeftMotor.spin(vex::directionType::fwd, Controller1.Axis3.value() + Controller1.Axis1.value() + Controller1.Axis4.value(), vex::velocityUnits::pct);
RightMotor.spin(vex::directionType::fwd, Controller1.Axis3.value() - Controller1.Axis1.value() - Controller1.Axis4.value(), vex::velocityUnits::pct);
BackLeftMotor.spin(vex::directionType::fwd, Controller1.Axis3.value() + Controller1.Axis1.value() - Controller1.Axis4.value(), vex::velocityUnits::pct);
BackRightMotor.spin(vex::directionType::fwd, Controller1.Axis3.value() - Controller1.Axis1.value() + Controller1.Axis4.value(), vex::velocityUnits::pct);
wait(10);
} return(0);
}
void partnercontroller()
{
if(Controler2.ButtonR1.pressing() == true)
{
ArmMotor.spin(vex::directionType::fwd,-50,vex::velocityUnits::pct);
}
else if(Controler2.ButtonR2.pressing() == true)
{
ArmMotor.spin(vex::directionType::fwd,50,vex::velocityUnits::pct);
}
else
{
ArmMotor.stop(vex::brakeType::hold);
}
if(Controler2.ButtonL1.pressing() == true)
{
LiftMotor.spin(vex::directionType::fwd,-60,vex::velocityUnits::pct);
}
else if(Controler2.ButtonL2.pressing() == true)
{
LiftMotor.spin(vex::directionType::fwd,40,vex::velocityUnits::pct);
}
else
{
LiftMotor.stop(vex::brakeType::hold);
}
}
void Intakecontrol()
{
if(Controler2.ButtonA.pressing() == true)
{
Intake.spin(vex::directionType::fwd,100,vex::velocityUnits::pct);
Intake2.spin(vex::directionType::fwd,100, vex::velocityUnits::pct);
}
else if(Controler2.ButtonY.pressing() == true)
{
Intake.spin(vex::directionType::fwd,-100,vex::velocityUnits::pct);
Intake2.spin(vex::directionType::fwd,-100, vex::velocityUnits::pct);
}
else
{
Intake2.stop(vex::brakeType::brake);
Intake.stop(vex::brakeType::brake);
}
vex::task::sleep(15);
}
//////////////////
// LCD Commands //
//////////////////
int sq1StartX = 0;
int sq1SizeX = 80;
int sq1EndX = sq1StartX + sq1SizeX;
int sq1StartY = 10;
int sq1SizeY = 80;
int sq1EndY = sq1StartY + sq1SizeY;
int sq2StartX = 100;
int sq2SizeX = 80;
int sq2EndX = sq2StartX + sq2SizeX;
int sq2StartY = 10;
int sq2SizeY = 80;
int sq2EndY = sq2StartY + sq2SizeY;
int sq3StartX = 200;
int sq3SizeX = 80;
int sq3EndX = sq3StartX + sq3SizeX;
int sq3StartY = 10;
int sq3SizeY = 80;
int sq3EndY = sq3StartY + sq3SizeY;
int sq4StartX = 300;
int sq4SizeX = 80;
int sq4EndX = sq4StartX + sq4SizeX;
int sq4StartY = 10;
int sq4SizeY = 80;
int sq4EndY = sq4StartY + sq4SizeY;
int sq5StartX = 0;
int sq5SizeX = 80;
int sq5EndX = sq5StartX + sq5SizeX;
int sq5StartY = 100;
int sq5SizeY = 80;
int sq5EndY = sq5StartY + sq5SizeY;
int sq6StartX = 100;
int sq6SizeX = 80;
int sq6EndX = sq6StartX + sq6SizeX;
int sq6StartY = 100;
int sq6SizeY = 80;
int sq6EndY = sq6StartY + sq6SizeY;
int sq7StartX = 200;
int sq7SizeX = 80;
int sq7EndX = sq7StartX + sq7SizeX;
int sq7StartY = 100;
int sq7SizeY = 80;
int sq7EndY = sq7StartY + sq7SizeY;
int sq8StartX = 300;
int sq8SizeX = 80;
int sq8EndX = sq8StartX + sq8SizeX;
int sq8StartY = 100;
int sq8SizeY = 80;
int sq8EndY = sq8StartY + sq8SizeY;
int selected = 0;
void colorChanger(bool selection){
if (selection == true){Brain.Screen.setFillColor(vex::color::green);}
else {Brain.Screen.setFillColor(vex::color::purple);}
}
//Make sure lettering is to the correct square
//Make all autonomouses into voids and put them into the autonomos task
//
int LCD(){
Brain.Screen.setPenColor(vex::color::white);
Brain.Screen.setFillColor(vex::color::purple);
while (true){
if (selected == 1){colorChanger(true);} else {colorChanger(false);}
Brain.Screen.drawRectangle(sq1StartX, sq1StartY, sq1SizeX, sq1SizeY);
if (selected == 2){colorChanger(true);} else {colorChanger(false);}
Brain.Screen.drawRectangle(sq2StartX, sq2StartY, sq2SizeX, sq2SizeY);
if (selected == 3){colorChanger(true);} else {colorChanger(false);}
Brain.Screen.drawRectangle(sq3StartX, sq3StartY, sq3SizeX, sq3SizeY);
if (selected == 4){colorChanger(true);} else {colorChanger(false);}
Brain.Screen.drawRectangle(sq4StartX, sq4StartY, sq4SizeX, sq4SizeY);
if (selected == 5){colorChanger(true);} else {colorChanger(false);}
Brain.Screen.drawRectangle(sq5StartX, sq5StartY, sq5SizeX, sq5SizeY);
if (selected == 6){colorChanger(true);} else {colorChanger(false);}
Brain.Screen.drawRectangle(sq6StartX, sq6StartY, sq6SizeX, sq6SizeY);
if (selected == 7){colorChanger(true);} else {colorChanger(false);}
Brain.Screen.drawRectangle(sq7StartX, sq7StartY, sq7SizeX, sq7SizeY);
if (selected == 8){colorChanger(true);} else {colorChanger(false);}
Brain.Screen.drawRectangle(sq8StartX, sq8StartY, sq8SizeX, sq8SizeY);
int xPressed = Brain.Screen.xPosition();
int yPressed = Brain.Screen.yPosition();
if (Brain.Screen.pressing()){
if (xPressed > sq1StartX && xPressed < sq1EndX && yPressed > sq1StartY && yPressed < sq1EndY){selected = 1;}
if (xPressed > sq2StartX && xPressed < sq2EndX && yPressed > sq2StartY && yPressed < sq2EndY){selected = 2;}
if (xPressed > sq3StartX && xPressed < sq3EndX && yPressed > sq3StartY && yPressed < sq3EndY){selected = 3;}
if (xPressed > sq4StartX && xPressed < sq4EndX && yPressed > sq4StartY && yPressed < sq4EndY){selected = 4;}
if (xPressed > sq5StartX && xPressed < sq5EndX && yPressed > sq5StartY && yPressed < sq5EndY){selected = 5;}
if (xPressed > sq6StartX && xPressed < sq6EndX && yPressed > sq6StartY && yPressed < sq6EndY){selected = 6;}
if (xPressed > sq7StartX && xPressed < sq7EndX && yPressed > sq7StartY && yPressed < sq7EndY){selected = 7;}
if (xPressed > sq8StartX && xPressed < sq8EndX && yPressed > sq8StartY && yPressed < sq8EndY){selected = 8;}
Brain.Screen.setFillColor(vex::color::transparent);
Brain.Screen.printAt(sq1StartX,sq1StartY+20,true,"Blue");
Brain.Screen.printAt(sq1StartX,sq1StartY+40,true,"Left");
Brain.Screen.printAt(sq2StartX,sq2StartY+20,true,"Blue");
Brain.Screen.printAt(sq2StartX,sq2StartY+40,true,"Right");
Brain.Screen.printAt(sq3StartX,sq3StartY+20,true,"Red");
Brain.Screen.printAt(sq3StartX,sq3StartY+40,true,"Left");
Brain.Screen.printAt(sq4StartX,sq4StartY+20,true,"Red");
Brain.Screen.printAt(sq4StartX,sq4StartY+40,true,"Right");
Brain.Screen.printAt(sq5StartX,sq5StartY+20,true,"One");
Brain.Screen.printAt(sq5StartX,sq5StartY+40,true,"Cube");
Brain.Screen.printAt(sq6StartX,sq6StartY+20,true,"Skills");
Brain.Screen.printAt(sq6StartX,sq6StartY+40,true,"");
Brain.Screen.printAt(sq7StartX,sq7StartY+20,true,"SixCube");
Brain.Screen.printAt(sq7StartX,sq7StartY+40,true,"Blue");
Brain.Screen.printAt(sq8StartX,sq8StartY+20,true,"SixCube");
Brain.Screen.printAt(sq8StartX,sq8StartY+40,true,"Red");
Brain.Screen.render();
}
wait(10);
} return(0);
}
void pre_auton( void ) {
// All activities that occur before the competition starts
// Example: clearing encoders, setting servo positions, ...
vex::task LCDL(LCD);
}
void BlueLeft(){
LeftMotor.setVelocity( 41, vex::velocityUnits::pct );
RightMotor.setVelocity( 41, vex::velocityUnits::pct );
BackLeftMotor.setVelocity( 41, vex::velocityUnits::pct );
BackRightMotor.setVelocity( 41, vex::velocityUnits::pct );
Intake2.setVelocity(100, vex::velocityUnits:: pct);
Intake.setVelocity(100, vex::velocityUnits::pct );
LiftMotor.setVelocity( 40, vex::velocityUnits::pct );
ArmMotor.setVelocity(100, vex::velocityUnits::pct ) ;
ArmMotor.spin( vex::directionType::fwd);
vex::task::sleep( 500 );
ArmMotor.stop();
ArmMotor.spin( vex::directionType::rev);
vex::task::sleep( 500 );
ArmMotor.stop();
Intake.spin( vex::directionType::fwd );
Intake2.spin( vex::directionType::fwd );
vex::task::sleep( 1000 );
Intake.stop();
Intake2.stop();
LeftMotor.spin( vex::directionType::fwd );// Forward Intake into cubes
RightMotor.spin( vex::directionType::fwd );
BackLeftMotor.spin( vex::directionType::fwd );
BackRightMotor.spin( vex::directionType::fwd );
Intake.spin( vex::directionType::fwd );
Intake2.spin( vex::directionType::fwd );
vex::task::sleep( 3000 );
Intake.stop();
Intake2.stop();
LeftMotor.stop();
RightMotor.stop();
BackLeftMotor.stop();
BackRightMotor.stop();
LeftMotor.spin( vex::directionType::rev );
RightMotor.spin( vex::directionType::rev );
BackLeftMotor.spin( vex::directionType::rev );
BackRightMotor.spin( vex::directionType::rev );
Intake.spin( vex::directionType::fwd );
Intake2.spin( vex::directionType::fwd );
vex::task::sleep( 2085 );
Intake.stop();
Intake2.stop();
LeftMotor.stop();
RightMotor.stop();
BackLeftMotor.stop();
BackRightMotor.stop();
LeftMotor.spin( vex::directionType::rev );
RightMotor.spin( vex::directionType::fwd );
BackLeftMotor.spin( vex::directionType::rev );
BackRightMotor.spin( vex::directionType::fwd );
vex::task::sleep( 1750 );
LeftMotor.stop();
RightMotor.stop();
BackLeftMotor.stop();
BackRightMotor.stop();
LeftMotor.spin( vex::directionType::fwd );
RightMotor.spin( vex::directionType::fwd );
BackLeftMotor.spin( vex::directionType::fwd );
BackRightMotor.spin( vex::directionType::fwd );
vex::task::sleep( 975);
LeftMotor.stop();
RightMotor.stop();
BackLeftMotor.stop();
BackRightMotor.stop();
Intake.spin( vex::directionType::rev );
Intake2.spin( vex::directionType::rev );
vex::task::sleep(200);
Intake.stop();
Intake2.stop();
LiftMotor.stop();
LiftMotor.spin(vex::directionType::fwd);
vex::task::sleep(4000);
LiftMotor.stop();
LeftMotor.spin( vex::directionType::fwd );
RightMotor.spin( vex::directionType::fwd );
BackLeftMotor.spin( vex::directionType::fwd );
BackRightMotor.spin( vex::directionType::fwd );
vex::task::sleep(50);
LeftMotor.stop();
RightMotor.stop();
BackLeftMotor.stop();
BackRightMotor.stop();
Intake.spin( vex::directionType::rev );
Intake2.spin( vex::directionType::rev );
vex::task::sleep( 600 );
Intake.stop();
Intake2.stop();
Intake.spin( vex::directionType::rev );
Intake2.spin( vex::directionType::rev );
LiftMotor.spin( vex::directionType::rev );
LeftMotor.spin( vex::directionType::rev );
RightMotor.spin( vex::directionType::rev );
BackLeftMotor.spin( vex::directionType::rev );
BackRightMotor.spin( vex::directionType::rev );
vex::task::sleep( 300 );
LeftMotor.stop();
RightMotor.stop();
BackLeftMotor.stop();
BackRightMotor.stop();
Intake.stop();
Intake2.stop();
LiftMotor.stop();
}
void BlueRight(){
LeftMotor.setVelocity( 100, vex::velocityUnits::pct );
RightMotor.setVelocity( 100, vex::velocityUnits::pct );
BackLeftMotor.setVelocity( 100, vex::velocityUnits::pct );
BackRightMotor.setVelocity( 100, vex::velocityUnits::pct );
Intake2.setVelocity(100, vex::velocityUnits:: pct);
Intake.setVelocity(100, vex::velocityUnits::pct );
LiftMotor.setVelocity(100, vex::velocityUnits::pct );
ArmMotor.setVelocity(100, vex::velocityUnits::pct ) ;
LeftMotor.spin( vex::directionType::fwd );// Forward Intake into cubes
RightMotor.spin( vex::directionType::fwd );
BackLeftMotor.spin( vex::directionType::fwd );
BackRightMotor.spin( vex::directionType::fwd );
Intake.spin( vex::directionType::fwd );
Intake2.spin( vex::directionType::fwd );
vex::task::sleep( 400 );
Intake.stop();
Intake2.stop();
LeftMotor.stop();
RightMotor.stop();
BackLeftMotor.stop();
BackRightMotor.stop();
Intake.spin( vex::directionType::rev );
Intake2.spin( vex::directionType::rev );
vex::task::sleep( 500 );
Intake.stop();
Intake2.stop();
LeftMotor.spin( vex::directionType::fwd );// Forward Intake into cubes
RightMotor.spin( vex::directionType::fwd );
BackLeftMotor.spin( vex::directionType::fwd );
BackRightMotor.spin( vex::directionType::fwd );
Intake.spin( vex::directionType::rev );
Intake2.spin( vex::directionType::rev );
vex::task::sleep( 300 );
Intake.stop();
Intake2.stop();
LeftMotor.stop();
RightMotor.stop();
BackLeftMotor.stop();
BackRightMotor.stop();
LeftMotor.spin( vex::directionType::rev );// Forward Intake into cubes
RightMotor.spin( vex::directionType::rev );
BackLeftMotor.spin( vex::directionType::rev );
BackRightMotor.spin( vex::directionType::rev );
Intake.spin( vex::directionType::rev );
Intake2.spin( vex::directionType::rev );
vex::task::sleep( 300 );
Intake.stop();
Intake2.stop();
LeftMotor.stop();
RightMotor.stop();
BackLeftMotor.stop();
BackRightMotor.stop();
}
void RedLeft(){
LeftMotor.setVelocity( 41, vex::velocityUnits::pct );
RightMotor.setVelocity( 41, vex::velocityUnits::pct );
BackLeftMotor.setVelocity( 41, vex::velocityUnits::pct );
BackRightMotor.setVelocity( 41, vex::velocityUnits::pct );
Intake2.setVelocity(100, vex::velocityUnits:: pct);
Intake.setVelocity(100, vex::velocityUnits::pct );
LiftMotor.setVelocity( 40, vex::velocityUnits::pct );
ArmMotor.setVelocity(100, vex::velocityUnits::pct ) ;
ArmMotor.spin( vex::directionType::fwd);
vex::task::sleep( 500 );
ArmMotor.stop();
ArmMotor.spin( vex::directionType::rev);
vex::task::sleep( 500 );
ArmMotor.stop();
Intake.spin( vex::directionType::fwd );
Intake2.spin( vex::directionType::fwd );
vex::task::sleep( 1000 );
Intake.stop();
Intake2.stop();
LeftMotor.spin( vex::directionType::fwd );// Forward Intake into cubes
RightMotor.spin( vex::directionType::fwd );
BackLeftMotor.spin( vex::directionType::fwd );
BackRightMotor.spin( vex::directionType::fwd );
Intake.spin( vex::directionType::fwd );
Intake2.spin( vex::directionType::fwd );
vex::task::sleep( 3000 );
Intake.stop();
Intake2.stop();
LeftMotor.stop();
RightMotor.stop();
BackLeftMotor.stop();
BackRightMotor.stop();
LeftMotor.spin( vex::directionType::rev );
RightMotor.spin( vex::directionType::rev );
BackLeftMotor.spin( vex::directionType::rev );
BackRightMotor.spin( vex::directionType::rev );
Intake.spin( vex::directionType::fwd );
Intake2.spin( vex::directionType::fwd );
vex::task::sleep( 2085 );
Intake.stop();
Intake2.stop();
LeftMotor.stop();
RightMotor.stop();
BackLeftMotor.stop();
BackRightMotor.stop();
LeftMotor.spin( vex::directionType::fwd );
RightMotor.spin( vex::directionType::rev );
BackLeftMotor.spin( vex::directionType::fwd );
BackRightMotor.spin( vex::directionType::rev );
vex::task::sleep( 1750 );
LeftMotor.stop();
RightMotor.stop();
BackLeftMotor.stop();
BackRightMotor.stop();
LeftMotor.spin( vex::directionType::fwd );
RightMotor.spin( vex::directionType::fwd );
BackLeftMotor.spin( vex::directionType::fwd );
BackRightMotor.spin( vex::directionType::fwd );
vex::task::sleep( 975);
LeftMotor.stop();
RightMotor.stop();
BackLeftMotor.stop();
BackRightMotor.stop();
Intake.spin( vex::directionType::rev );
Intake2.spin( vex::directionType::rev );
vex::task::sleep(200);
Intake.stop();
Intake2.stop();
LiftMotor.stop();
LiftMotor.spin(vex::directionType::fwd);
vex::task::sleep(4000);
LiftMotor.stop();
LeftMotor.spin( vex::directionType::fwd );
RightMotor.spin( vex::directionType::fwd );
BackLeftMotor.spin( vex::directionType::fwd );
BackRightMotor.spin( vex::directionType::fwd );
vex::task::sleep(50);
LeftMotor.stop();
RightMotor.stop();
BackLeftMotor.stop();
BackRightMotor.stop();
Intake.spin( vex::directionType::rev );
Intake2.spin( vex::directionType::rev );
vex::task::sleep( 600 );
Intake.stop();
Intake2.stop();
Intake.spin( vex::directionType::rev );
Intake2.spin( vex::directionType::rev );
LiftMotor.spin( vex::directionType::rev );
LeftMotor.spin( vex::directionType::rev );
RightMotor.spin( vex::directionType::rev );
BackLeftMotor.spin( vex::directionType::rev );
BackRightMotor.spin( vex::directionType::rev );
vex::task::sleep( 300 );
LeftMotor.stop();
RightMotor.stop();
BackLeftMotor.stop();
BackRightMotor.stop();
Intake.stop();
Intake2.stop();
LiftMotor.stop();
}
void RedRight(){
LeftMotor.setVelocity( 50, vex::velocityUnits::pct );
RightMotor.setVelocity( 50, vex::velocityUnits::pct );
BackLeftMotor.setVelocity( 50, vex::velocityUnits::pct );
BackRightMotor.setVelocity(50, vex::velocityUnits::pct );
Intake2.setVelocity(100, vex::velocityUnits:: pct);
Intake.setVelocity(100, vex::velocityUnits::pct );
LiftMotor.setVelocity( 60, vex::velocityUnits::pct );
ArmMotor.setVelocity(100, vex::velocityUnits::pct ) ;
Intake.spin( vex::directionType::fwd );
Intake2.spin( vex::directionType::fwd );
vex::task::sleep( 1000 );
Intake.stop();
Intake2.stop();
LeftMotor.spin( vex::directionType::fwd );// Forward Intake into cubes
RightMotor.spin( vex::directionType::fwd );
BackLeftMotor.spin( vex::directionType::fwd );
BackRightMotor.spin( vex::directionType::fwd );
Intake.spin( vex::directionType::fwd );
Intake2.spin( vex::directionType::fwd );
vex::task::sleep( 1700 );
LeftMotor.spin( vex::directionType::rev );
RightMotor.spin( vex::directionType::rev );
BackLeftMotor.spin( vex::directionType::rev );
BackRightMotor.spin( vex::directionType::rev );
Intake.spin( vex::directionType::fwd );
Intake2.spin( vex::directionType::fwd );
vex::task::sleep( 1200 );
Intake.stop();
Intake2.stop();
LeftMotor.stop();
RightMotor.stop();
BackLeftMotor.stop();
BackRightMotor.stop();
LeftMotor.spin( vex::directionType::fwd );
RightMotor.spin( vex::directionType::rev );
BackLeftMotor.spin( vex::directionType::fwd );
BackRightMotor.spin( vex::directionType::rev );
vex::task::sleep( 1400 );
LeftMotor.stop();
RightMotor.stop();
BackLeftMotor.stop();
BackRightMotor.stop();
LeftMotor.spin( vex::directionType::fwd );
RightMotor.spin( vex::directionType::fwd );
BackLeftMotor.spin( vex::directionType::fwd );
BackRightMotor.spin( vex::directionType::fwd );
vex::task::sleep( 975);
LeftMotor.stop();
RightMotor.stop();
BackLeftMotor.stop();
BackRightMotor.stop();
Intake.spin( vex::directionType::rev );
Intake2.spin( vex::directionType::rev );
vex::task::sleep(200);
Intake.stop();
Intake2.stop();
LiftMotor.spin( vex::directionType::fwd );
vex::task::sleep(3000);
LiftMotor.stop();
Intake.spin( vex::directionType::rev );
Intake2.spin( vex::directionType::rev );
vex::task::sleep( 500 );
Intake.stop();
Intake2.stop();
LeftMotor.spin( vex::directionType::rev );
RightMotor.spin( vex::directionType::rev );
BackLeftMotor.spin( vex::directionType::rev );
BackRightMotor.spin( vex::directionType::rev );
Intake.spin( vex::directionType::rev );
Intake2.spin( vex::directionType::rev );
vex::task::sleep( 1000 );
Intake.stop();
Intake2.stop();
LeftMotor.stop();
RightMotor.stop();
BackLeftMotor.stop();
BackRightMotor.stop();
}
void OneCube(){
LeftMotor.setVelocity( 100, vex::velocityUnits::pct );
RightMotor.setVelocity( 100, vex::velocityUnits::pct );
BackLeftMotor.setVelocity( 100, vex::velocityUnits::pct );
BackRightMotor.setVelocity( 100, vex::velocityUnits::pct );
Intake2.setVelocity(100, vex::velocityUnits:: pct);
Intake.setVelocity(100, vex::velocityUnits::pct );
LiftMotor.setVelocity(100, vex::velocityUnits::pct );
ArmMotor.setVelocity(100, vex::velocityUnits::pct ) ;
LeftMotor.spin( vex::directionType::fwd );// Forward Intake into cubes
RightMotor.spin( vex::directionType::fwd );
BackLeftMotor.spin( vex::directionType::fwd );
BackRightMotor.spin( vex::directionType::fwd );
Intake.spin( vex::directionType::fwd );
Intake2.spin( vex::directionType::fwd );
vex::task::sleep( 400 );
Intake.stop();
Intake2.stop();
LeftMotor.stop();
RightMotor.stop();
BackLeftMotor.stop();
BackRightMotor.stop();
Intake.spin( vex::directionType::rev );
Intake2.spin( vex::directionType::rev );
vex::task::sleep( 500 );
Intake.stop();
Intake2.stop();
LeftMotor.spin( vex::directionType::fwd );// Forward Intake into cubes
RightMotor.spin( vex::directionType::fwd );
BackLeftMotor.spin( vex::directionType::fwd );
BackRightMotor.spin( vex::directionType::fwd );
Intake.spin( vex::directionType::rev );
Intake2.spin( vex::directionType::rev );
vex::task::sleep( 300 );
Intake.stop();
Intake2.stop();
LeftMotor.stop();
RightMotor.stop();
BackLeftMotor.stop();
BackRightMotor.stop();
LeftMotor.spin( vex::directionType::rev );// Forward Intake into cubes
RightMotor.spin( vex::directionType::rev );
BackLeftMotor.spin( vex::directionType::rev );
BackRightMotor.spin( vex::directionType::rev );
Intake.spin( vex::directionType::rev );
Intake2.spin( vex::directionType::rev );
vex::task::sleep( 300 );
Intake.stop();
Intake2.stop();
LeftMotor.stop();
RightMotor.stop();
BackLeftMotor.stop();
BackRightMotor.stop();
}
void Skills(){
}
void SixCubeBlue(){
LeftMotor.setVelocity( 41, vex::velocityUnits::pct );
RightMotor.setVelocity( 41, vex::velocityUnits::pct );
BackLeftMotor.setVelocity( 41, vex::velocityUnits::pct );
BackRightMotor.setVelocity( 41, vex::velocityUnits::pct );
Intake2.setVelocity(100, vex::velocityUnits:: pct);
Intake.setVelocity(100, vex::velocityUnits::pct );
LiftMotor.setVelocity( 40, vex::velocityUnits::pct );
ArmMotor.setVelocity(100, vex::velocityUnits::pct ) ;
LeftMotor.spin(vex::directionType::fwd);
RightMotor.spin(vex::directionType::fwd);
BackLeftMotor.spin(vex::directionType::fwd);
BackRightMotor.spin(vex::directionType::fwd);
Intake.spin(vex::directionType::fwd);
Intake2.spin(vex::directionType::fwd);
vex::task::sleep(2500);
LeftMotor.stop();
RightMotor.stop();
BackLeftMotor.stop();
BackRightMotor.stop();
vex::task::sleep(500);
LeftMotor.spin(vex::directionType::fwd);
RightMotor.spin(vex::directionType::rev);
BackLeftMotor.spin(vex::directionType::fwd);
BackRightMotor.spin(vex::directionType::rev);
vex::task::sleep(400);
LeftMotor.stop();
RightMotor.stop();
BackLeftMotor.stop();
BackRightMotor.stop();
Intake.stop();
Intake2.stop();
vex::task::sleep(0);
LeftMotor.spin(vex::directionType::rev);
RightMotor.spin(vex::directionType::rev);
BackLeftMotor.spin(vex::directionType::rev);
BackRightMotor.spin(vex::directionType::rev);
vex::task::sleep(2300);
LeftMotor.stop();
RightMotor.stop();
BackLeftMotor.stop();
BackRightMotor.stop();
vex::task::sleep(0);
LeftMotor.spin(vex::directionType::rev);
RightMotor.spin(vex::directionType::fwd);
BackLeftMotor.spin(vex::directionType::rev);
BackRightMotor.spin(vex::directionType::fwd);
vex::task::sleep(490);
LeftMotor.stop();
RightMotor.stop();
BackLeftMotor.stop();
BackRightMotor.stop();
vex::task::sleep(0);
Intake.spin( vex::directionType::fwd );
Intake2.spin( vex::directionType::fwd );
vex::task::sleep( 1000 );
Intake.stop();
Intake2.stop();
LeftMotor.spin( vex::directionType::fwd );// Forward Intake into cubes
RightMotor.spin( vex::directionType::fwd );
BackLeftMotor.spin( vex::directionType::fwd );
BackRightMotor.spin( vex::directionType::fwd );
Intake.spin( vex::directionType::fwd );
Intake2.spin( vex::directionType::fwd );
vex::task::sleep( 3000 );
Intake.stop();
Intake2.stop();
LeftMotor.stop();
RightMotor.stop();
BackLeftMotor.stop();
BackRightMotor.stop();
LeftMotor.spin( vex::directionType::rev );
RightMotor.spin( vex::directionType::rev );
BackLeftMotor.spin( vex::directionType::rev );
BackRightMotor.spin( vex::directionType::rev );
Intake.spin( vex::directionType::fwd );
Intake2.spin( vex::directionType::fwd );
vex::task::sleep( 2085 );
Intake.stop();
Intake2.stop();
LeftMotor.stop();
RightMotor.stop();
BackLeftMotor.stop();
BackRightMotor.stop();
}
void SixCubeRed(){
LeftMotor.setVelocity( 41, vex::velocityUnits::pct );
RightMotor.setVelocity( 41, vex::velocityUnits::pct );
BackLeftMotor.setVelocity( 41, vex::velocityUnits::pct );
BackRightMotor.setVelocity( 41, vex::velocityUnits::pct );
Intake2.setVelocity(100, vex::velocityUnits:: pct);
Intake.setVelocity(100, vex::velocityUnits::pct );
LiftMotor.setVelocity( 40, vex::velocityUnits::pct );
ArmMotor.setVelocity(100, vex::velocityUnits::pct ) ;
LeftMotor.spin(vex::directionType::fwd);
RightMotor.spin(vex::directionType::fwd);
BackLeftMotor.spin(vex::directionType::fwd);
BackRightMotor.spin(vex::directionType::fwd);
Intake.spin(vex::directionType::fwd);
Intake2.spin(vex::directionType::fwd);
vex::task::sleep(2500);
LeftMotor.stop();
RightMotor.stop();
BackLeftMotor.stop();
BackRightMotor.stop();
vex::task::sleep(500);
LeftMotor.spin(vex::directionType::rev);
RightMotor.spin(vex::directionType::fwd);
BackLeftMotor.spin(vex::directionType::rev);
BackRightMotor.spin(vex::directionType::fwd);
vex::task::sleep(400);
LeftMotor.stop();
RightMotor.stop();
BackLeftMotor.stop();
BackRightMotor.stop();
Intake.stop();
Intake2.stop();
vex::task::sleep(0);
LeftMotor.spin(vex::directionType::rev);
RightMotor.spin(vex::directionType::rev);
BackLeftMotor.spin(vex::directionType::rev);
BackRightMotor.spin(vex::directionType::rev);
vex::task::sleep(2300);
LeftMotor.stop();
RightMotor.stop();
BackLeftMotor.stop();
BackRightMotor.stop();
vex::task::sleep(0);
LeftMotor.spin(vex::directionType::fwd);
RightMotor.spin(vex::directionType::rev);
BackLeftMotor.spin(vex::directionType::fwd);
BackRightMotor.spin(vex::directionType::rev);
vex::task::sleep(490);
LeftMotor.stop();
RightMotor.stop();
BackLeftMotor.stop();
BackRightMotor.stop();
vex::task::sleep(0);
Intake.spin( vex::directionType::fwd );
Intake2.spin( vex::directionType::fwd );
vex::task::sleep( 1000 );
Intake.stop();
Intake2.stop();
LeftMotor.spin( vex::directionType::fwd );// Forward Intake into cubes
RightMotor.spin( vex::directionType::fwd );
BackLeftMotor.spin( vex::directionType::fwd );
BackRightMotor.spin( vex::directionType::fwd );
Intake.spin( vex::directionType::fwd );
Intake2.spin( vex::directionType::fwd );
vex::task::sleep( 3000 );
Intake.stop();
Intake2.stop();
LeftMotor.stop();
RightMotor.stop();
BackLeftMotor.stop();
BackRightMotor.stop();
LeftMotor.spin( vex::directionType::rev );
RightMotor.spin( vex::directionType::rev );
BackLeftMotor.spin( vex::directionType::rev );
BackRightMotor.spin( vex::directionType::rev );
Intake.spin( vex::directionType::fwd );
Intake2.spin( vex::directionType::fwd );
vex::task::sleep( 2085 );
Intake.stop();
Intake2.stop();
LeftMotor.stop();
RightMotor.stop();
BackLeftMotor.stop();
BackRightMotor.stop();
}
void autonomous( void ) {
if (selected == 1){BlueLeft();}
if (selected == 2){BlueRight();}
if (selected == 3){RedLeft();}
if (selected == 4){RedRight();}
if (selected == 5){OneCube();}
if (selected == 6){Skills();}
if (selected == 7){SixCubeBlue();}
if (selected == 8){SixCubeRed();}
}
void usercontrol( void ) {
vex::task driveControl(driveControlTask);
while (1) {
partnercontroller();
Intakecontrol();
// This is the main execution loop for the user control program.
// Each time through the loop your program should update motor + servo
// values based on feedback from the joysticks.
// ........................................................................
// Insert user code here. This is where you use the joystick values to
// update your motors, etc.
// ........................................................................
vex::task::sleep(20); //Sleep the task for a short amount of time to prevent wasted resources.
}
}
//
// Main will set up the competition functions and callbacks.
//
int main() {
//Run the pre-autonomous function.
pre_auton();
//Set up callbacks for autonomous and driver control periods.
Competition.autonomous( autonomous );
Competition.drivercontrol( usercontrol );
//Prevent main from exiting with an infinite loop.
while(1) {
vex::task::sleep(100);//Sleep the task for a short amount of time to prevent wasted resources.
}
}
edit: code tags added by mods