Memory Permission Error V5 Vex Code Pro

So I have been getting this error every time I try to use a program that I downloaded onto the v5 brain. I checked if it was the cortex. Nope. Checked if it was the computer. Nope. Checked if it was the cord. Nope. I am very confused. I even copy and pasted my whole program onto a new project and tried again and still got it. I don’t know what is happing but I kinda need help.image

IIRC this is a memory leak in your code, it would be helpful if you could post your program here (remembering to wrap it in [code]...[/code] tags for formatting).

4 Likes

yea, it’s an issue with the code, usually a bad pointer or trying to use an instance of a class before it’s been created.

5 Likes

Could I personally just maybe just send it to one of you. I rather not someone just go on this thread and plug and play.

  1. nobody is gonna steal broken code

  2. I volunteer as code reviewer

12 Likes

Well I can’t even post it right now because the WiFi is out and the code is on my computer. If you are confused I am on my phone with cell service

Excuses… excuses…

Once my internet goes back up I will post it

Oh and you saying, broken code. I probably just deleted something on accident or something and had no idea. And you saying people wouldn’t steal it. Well when it is fixed they code. But I mean it is pretty simple so not a big deal.

#include "vex.h"
vex::competition    Competition;

vex::motor LeftMotor = vex::motor( vex::PORT11 );
vex::motor RightMotor = vex::motor( vex::PORT20,true );
vex::motor BackLeftMotor = vex::motor( vex::PORT12 );
vex::motor BackRightMotor = vex::motor( vex::PORT19,true );
vex::motor Intake = vex::motor(vex::PORT17,true );
vex::motor Intake2 = vex::motor(vex::PORT14,false);
vex::motor Index = vex::motor(vex::PORT18,true );
vex::motor Index2 = vex::motor(vex::PORT13,false);  
//vex::motor_group Indexer = vex::motor_group(Index,Index2);
vex::controller Controller1 = vex::controller(vex::controllerType::primary);
vex::controller Controler2 = vex::controller(vex::controllerType::partner);
vex::limit LimitSwitchA = vex::limit(Brain.ThreeWirePort.A);
vex::limit LimitSwitchB = vex::limit(Brain.ThreeWirePort.B);

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(),  vex::velocityUnits::pct);
RightMotor.spin(vex::directionType::fwd, Controller1.Axis3.value() - Controller1.Axis1.value(), vex::velocityUnits::pct);
BackLeftMotor.spin(vex::directionType::fwd, Controller1.Axis3.value() + Controller1.Axis1.value(), vex::velocityUnits::pct);
BackRightMotor.spin(vex::directionType::fwd, Controller1.Axis3.value() - Controller1.Axis1.value(), vex::velocityUnits::pct);
wait(10);

} return(0);
}

  void Indexcontroll()
{
   if(Controller1.ButtonR1.pressing() == true)
{
Index.spin(vex::directionType::fwd,-100,vex::velocityUnits::pct);
Index2.spin(vex::directionType::fwd,-100,vex::velocityUnits::pct);
}

  else if(Controler2.ButtonR2.pressing() == true)
{
Index.spin(vex::directionType::fwd,100,vex::velocityUnits::pct);
Index2.spin(vex::directionType::fwd,100,vex::velocityUnits::pct);
}

  else  
{
Index.stop(vex::brakeType::brake);
Index2.stop(vex::brakeType::brake);
}
   
}

void Intakecontrol()
{
  if(Controller1.ButtonL1.pressing() == true)
{
Intake.spin(vex::directionType::fwd,100,vex::velocityUnits::pct);
Intake2.spin(vex::directionType::fwd,100, vex::velocityUnits::pct);
}
  else if(Controler2.ButtonL2.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::coast);
Intake.stop(vex::brakeType::coast);
}
     
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,"BL/RR");
      Brain.Screen.printAt(sq1StartX,sq1StartY+40,true,"Sort");
           
      Brain.Screen.printAt(sq2StartX,sq2StartY+20,true,"BR/RL");
      Brain.Screen.printAt(sq2StartX,sq2StartY+40,true,"Sort");
           
      Brain.Screen.printAt(sq3StartX,sq3StartY+20,true,"BL/RR");
      Brain.Screen.printAt(sq3StartX,sq3StartY+40,true,"2Goal");
           
      Brain.Screen.printAt(sq4StartX,sq4StartY+20,true,"BR/RL");
      Brain.Screen.printAt(sq4StartX,sq4StartY+40,true,"2Goal");
           
      Brain.Screen.printAt(sq5StartX,sq5StartY+20,true,"One");
      Brain.Screen.printAt(sq5StartX,sq5StartY+40,true,"Ball");
           
      Brain.Screen.printAt(sq6StartX,sq6StartY+20,true,"Skills");
      Brain.Screen.printAt(sq6StartX,sq6StartY+40,true,"");
           
      Brain.Screen.printAt(sq7StartX,sq7StartY+20,true,"BL/RR");
      Brain.Screen.printAt(sq7StartX,sq7StartY+40,true,"Center");     
           
      Brain.Screen.printAt(sq8StartX,sq8StartY+20,true,"BR/RL");
      Brain.Screen.printAt(sq8StartX,sq8StartY+40,true,"Center");

        Brain.Screen.render();
}
wait(10);
} return(0);
}
     
     

void pre_auton( void ) {
  vexcodeInit();
// All activities that occur before the competition starts
// Example: clearing encoders, setting servo positions, ...
  vex::task LCDL(LCD);
}   
  void BL_RR_Sort(){//Blue Left, Red Right, Sorts corner goal

LeftMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);//Drives forward and picks up ball
RightMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false); 
BackLeftMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);
BackRightMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);
Intake.rotateFor(4000, vex::rotationUnits::raw, 100, vex::velocityUnits::pct,false);
Intake2.rotateFor(4000, vex::rotationUnits::raw, 100, vex::velocityUnits::pct,true);

LeftMotor.rotateFor(-900, vex::rotationUnits::raw, 70, vex::velocityUnits::pct,false);//Angles towards goal
RightMotor.rotateFor(900, vex::rotationUnits::raw, 70, vex::velocityUnits::pct,false);
BackLeftMotor.rotateFor(-900, vex::rotationUnits::raw, 70, vex::velocityUnits::pct,false);
BackRightMotor.rotateFor(900, vex::rotationUnits::raw, 70, vex::velocityUnits::pct,true);

LeftMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);//Drives into goal to score/descore
RightMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false); 
BackLeftMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);
BackRightMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);
Intake.rotateFor(4000, vex::rotationUnits::raw, 100, vex::velocityUnits::pct,false);
Intake2.rotateFor(4000, vex::rotationUnits::raw, 100, vex::velocityUnits::pct,true);

Intake.rotateFor(4000, vex::rotationUnits::raw, 100, vex::velocityUnits::pct,false);//score/descores
Intake2.rotateFor(4000, vex::rotationUnits::raw, 100, vex::velocityUnits::pct,false);
Index.rotateFor(1800, vex::rotationUnits::raw, 100 , vex::velocityUnits::pct,false);
Index2.rotateFor(1800, vex::rotationUnits::raw, 100 , vex::velocityUnits::pct,true);

LeftMotor.rotateFor(-900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);//Backs away from goal
RightMotor.rotateFor(-900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false); 
BackLeftMotor.rotateFor(-900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);
BackRightMotor.rotateFor(-900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);
Intake.rotateFor(-4000, vex::rotationUnits::raw, 100, vex::velocityUnits::pct,false);
Intake2.rotateFor(-4000, vex::rotationUnits::raw, 100, vex::velocityUnits::pct,true);

}

  void BR_RL_Sort(){//Blue Right, Red Left, sort corner goal

LeftMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);//Drives forward and picks up ball
RightMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false); 
BackLeftMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);
BackRightMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);
Intake.rotateFor(4000, vex::rotationUnits::raw, 100, vex::velocityUnits::pct,false);
Intake2.rotateFor(4000, vex::rotationUnits::raw, 100, vex::velocityUnits::pct,true);

LeftMotor.rotateFor(900, vex::rotationUnits::raw, 70, vex::velocityUnits::pct,false);//Angles towards goal
RightMotor.rotateFor(-900, vex::rotationUnits::raw, 70, vex::velocityUnits::pct,false);
BackLeftMotor.rotateFor(900, vex::rotationUnits::raw, 70, vex::velocityUnits::pct,false);
BackRightMotor.rotateFor(-900, vex::rotationUnits::raw, 70, vex::velocityUnits::pct,true);

LeftMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);//Drives into goal to score/descore
RightMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false); 
BackLeftMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);
BackRightMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);
Intake.rotateFor(4000, vex::rotationUnits::raw, 100, vex::velocityUnits::pct,false);
Intake2.rotateFor(4000, vex::rotationUnits::raw, 100, vex::velocityUnits::pct,true);

Intake.rotateFor(4000, vex::rotationUnits::raw, 100, vex::velocityUnits::pct,false);//score/descores
Intake2.rotateFor(4000, vex::rotationUnits::raw, 100, vex::velocityUnits::pct,false);
Index.rotateFor(1800, vex::rotationUnits::raw, 100 , vex::velocityUnits::pct,false);
Index2.rotateFor(1800, vex::rotationUnits::raw, 100 , vex::velocityUnits::pct,true);

LeftMotor.rotateFor(-900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);//Backs away from goal
RightMotor.rotateFor(-900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false); 
BackLeftMotor.rotateFor(-900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);
BackRightMotor.rotateFor(-900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);
Intake.rotateFor(-4000, vex::rotationUnits::raw, 100, vex::velocityUnits::pct,false);
Intake2.rotateFor(-4000, vex::rotationUnits::raw, 100, vex::velocityUnits::pct,true);
        
}

  void BL_RR_2G(){//Blue Left, Red Right, scores in corner and center goal

LeftMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);//Drives forward into goal
RightMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false); 
BackLeftMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);
BackRightMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,true);

Index.rotateFor(1800, vex::rotationUnits::raw, 100 , vex::velocityUnits::pct,false);//scores
Index2.rotateFor(1800, vex::rotationUnits::raw, 100 , vex::velocityUnits::pct,true);

LeftMotor.rotateFor(-900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);//Backs away from goal
RightMotor.rotateFor(-900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false); 
BackLeftMotor.rotateFor(-900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);
BackRightMotor.rotateFor(-900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);
Intake.rotateFor(-4000, vex::rotationUnits::raw, 100, vex::velocityUnits::pct,false);
Intake2.rotateFor(-4000, vex::rotationUnits::raw, 100, vex::velocityUnits::pct,true);

LeftMotor.rotateFor(900, vex::rotationUnits::raw, 70, vex::velocityUnits::pct,false);//Angles back towards wall
RightMotor.rotateFor(-900, vex::rotationUnits::raw, 70, vex::velocityUnits::pct,false);
BackLeftMotor.rotateFor(900, vex::rotationUnits::raw, 70, vex::velocityUnits::pct,false);
BackRightMotor.rotateFor(-900, vex::rotationUnits::raw, 70, vex::velocityUnits::pct,true);

LeftMotor.rotateFor(-900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);//Backs into wall
RightMotor.rotateFor(-900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false); 
BackLeftMotor.rotateFor(-900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);
BackRightMotor.rotateFor(-900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,true);

LeftMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);//Drives forward from wall
RightMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false); 
BackLeftMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);
BackRightMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,true);

LeftMotor.rotateFor(900, vex::rotationUnits::raw, 70, vex::velocityUnits::pct,false);//Angles toward ball
RightMotor.rotateFor(-900, vex::rotationUnits::raw, 70, vex::velocityUnits::pct,false);
BackLeftMotor.rotateFor(900, vex::rotationUnits::raw, 70, vex::velocityUnits::pct,false);
BackRightMotor.rotateFor(-900, vex::rotationUnits::raw, 70, vex::velocityUnits::pct,true);

LeftMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);//Drives forward to ball and intakes
RightMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false); 
BackLeftMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);
BackRightMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);
Intake.rotateFor(-4000, vex::rotationUnits::raw, 100, vex::velocityUnits::pct,false);
Intake2.rotateFor(-4000, vex::rotationUnits::raw, 100, vex::velocityUnits::pct,true);

LeftMotor.rotateFor(900, vex::rotationUnits::raw, 70, vex::velocityUnits::pct,false);//Angles toward goal and sets ball.
RightMotor.rotateFor(-900, vex::rotationUnits::raw, 70, vex::velocityUnits::pct,false);
BackLeftMotor.rotateFor(900, vex::rotationUnits::raw, 70, vex::velocityUnits::pct,false);
BackRightMotor.rotateFor(-900, vex::rotationUnits::raw, 70, vex::velocityUnits::pct,false);
Index.rotateFor(1800, vex::rotationUnits::raw, 100 , vex::velocityUnits::pct,false);
Index2.rotateFor(1800, vex::rotationUnits::raw, 100 , vex::velocityUnits::pct,true);

Index.rotateFor(1800, vex::rotationUnits::raw, 100 , vex::velocityUnits::pct,false);//scores
Index2.rotateFor(1800, vex::rotationUnits::raw, 100 , vex::velocityUnits::pct,true);

LeftMotor.rotateFor(-900, vex::rotationUnits::raw, 100, vex::velocityUnits::pct,false);//Backs away from goal.
RightMotor.rotateFor(-900, vex::rotationUnits::raw, 100, vex::velocityUnits::pct,false); 
BackLeftMotor.rotateFor(-900, vex::rotationUnits::raw, 100, vex::velocityUnits::pct,false);
BackRightMotor.rotateFor(-900, vex::rotationUnits::raw, 100, vex::velocityUnits::pct,true);

}

  void BR_RL_2G(){//Blue Right, Red Left, scores corner and center goal

LeftMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);//Drives forward into goal
RightMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false); 
BackLeftMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);
BackRightMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,true);

Index.rotateFor(1800, vex::rotationUnits::raw, 100 , vex::velocityUnits::pct,false);//scores
Index2.rotateFor(1800, vex::rotationUnits::raw, 100 , vex::velocityUnits::pct,true);

LeftMotor.rotateFor(-900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);//Backs away from goal
RightMotor.rotateFor(-900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false); 
BackLeftMotor.rotateFor(-900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);
BackRightMotor.rotateFor(-900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);
Intake.rotateFor(-4000, vex::rotationUnits::raw, 100, vex::velocityUnits::pct,false);
Intake2.rotateFor(-4000, vex::rotationUnits::raw, 100, vex::velocityUnits::pct,true);

LeftMotor.rotateFor(-900, vex::rotationUnits::raw, 70, vex::velocityUnits::pct,false);//Angles back towards wall
RightMotor.rotateFor(900, vex::rotationUnits::raw, 70, vex::velocityUnits::pct,false);
BackLeftMotor.rotateFor(-900, vex::rotationUnits::raw, 70, vex::velocityUnits::pct,false);
BackRightMotor.rotateFor(900, vex::rotationUnits::raw, 70, vex::velocityUnits::pct,true);

LeftMotor.rotateFor(-900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);//Backs into wall
RightMotor.rotateFor(-900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false); 
BackLeftMotor.rotateFor(-900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);
BackRightMotor.rotateFor(-900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,true);

LeftMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);//Drives forward from wall
RightMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false); 
BackLeftMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);
BackRightMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,true);

LeftMotor.rotateFor(-900, vex::rotationUnits::raw, 70, vex::velocityUnits::pct,false);//Angles toward ball
RightMotor.rotateFor(900, vex::rotationUnits::raw, 70, vex::velocityUnits::pct,false);
BackLeftMotor.rotateFor(-900, vex::rotationUnits::raw, 70, vex::velocityUnits::pct,false);
BackRightMotor.rotateFor(900, vex::rotationUnits::raw, 70, vex::velocityUnits::pct,true);

LeftMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);//Drives forward to ball and intakes
RightMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false); 
BackLeftMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);
BackRightMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);
Intake.rotateFor(4000, vex::rotationUnits::raw, 100, vex::velocityUnits::pct,false);
Intake2.rotateFor(4000, vex::rotationUnits::raw, 100, vex::velocityUnits::pct,true);

LeftMotor.rotateFor(900, vex::rotationUnits::raw, 70, vex::velocityUnits::pct,false);//Angles toward goal and sets ball.
RightMotor.rotateFor(-900, vex::rotationUnits::raw, 70, vex::velocityUnits::pct,false);
BackLeftMotor.rotateFor(900, vex::rotationUnits::raw, 70, vex::velocityUnits::pct,false);
BackRightMotor.rotateFor(-900, vex::rotationUnits::raw, 70, vex::velocityUnits::pct,false);
Index.rotateFor(1800, vex::rotationUnits::raw, 100 , vex::velocityUnits::pct,false);
Index2.rotateFor(1800, vex::rotationUnits::raw, 100 , vex::velocityUnits::pct,true);

Index.rotateFor(1800, vex::rotationUnits::raw, 100 , vex::velocityUnits::pct,false);//scores
Index2.rotateFor(1800, vex::rotationUnits::raw, 100 , vex::velocityUnits::pct,true);

LeftMotor.rotateFor(-900, vex::rotationUnits::raw, 100, vex::velocityUnits::pct,false);//Backs away from goal.
RightMotor.rotateFor(-900, vex::rotationUnits::raw, 100, vex::velocityUnits::pct,false); 
BackLeftMotor.rotateFor(-900, vex::rotationUnits::raw, 100, vex::velocityUnits::pct,false);
BackRightMotor.rotateFor(-900, vex::rotationUnits::raw, 100, vex::velocityUnits::pct,true);
     
}

  void Skills(){


}

  void OneBall(){

        
}

  void BL_RR_CG(){//Blue Left, Red Right, scores in corner and back center goal

LeftMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);//Drives forward and picks up ball
RightMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false); 
BackLeftMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);
BackRightMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);
Intake.rotateFor(4000, vex::rotationUnits::raw, 100, vex::velocityUnits::pct,false);
Intake2.rotateFor(4000, vex::rotationUnits::raw, 100, vex::velocityUnits::pct,true);

LeftMotor.rotateFor(-900, vex::rotationUnits::raw, 70, vex::velocityUnits::pct,false);//Angles towards goal
RightMotor.rotateFor(900, vex::rotationUnits::raw, 70, vex::velocityUnits::pct,false);
BackLeftMotor.rotateFor(-900, vex::rotationUnits::raw, 70, vex::velocityUnits::pct,false);
BackRightMotor.rotateFor(900, vex::rotationUnits::raw, 70, vex::velocityUnits::pct,true);

LeftMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);//Drives forward into goal
RightMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false); 
BackLeftMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);
BackRightMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,true);

Index.rotateFor(1800, vex::rotationUnits::raw, 100 , vex::velocityUnits::pct,false);//Scores
Index2.rotateFor(1800, vex::rotationUnits::raw, 100 , vex::velocityUnits::pct,true);

LeftMotor.rotateFor(-900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);//Back out of goal
RightMotor.rotateFor(-900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false); 
BackLeftMotor.rotateFor(-900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);
BackRightMotor.rotateFor(-900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,true);

LeftMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);//Turns back side towards wall
RightMotor.rotateFor(-900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false); 
BackLeftMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);
BackRightMotor.rotateFor(-900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,true);

LeftMotor.rotateFor(-900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);//Backs into wall
RightMotor.rotateFor(-900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false); 
BackLeftMotor.rotateFor(-900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);
BackRightMotor.rotateFor(-900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,true);

LeftMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);//Drive forward to pick up ball on
RightMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false); //line and intakes it
BackLeftMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);
BackRightMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,true);
Intake.rotateFor(4000, vex::rotationUnits::raw, 100, vex::velocityUnits::pct,false);
Intake2.rotateFor(4000, vex::rotationUnits::raw, 100, vex::velocityUnits::pct,true);

}

  void BR_RL_CG(){//Blue Right, Red Left, scores in corner and back center goal.

LeftMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);//Drives forward and picks up ball
RightMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false); 
BackLeftMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);
BackRightMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);
Intake.rotateFor(4000, vex::rotationUnits::raw, 100, vex::velocityUnits::pct,false);
Intake2.rotateFor(4000, vex::rotationUnits::raw, 100, vex::velocityUnits::pct,true);

LeftMotor.rotateFor(900, vex::rotationUnits::raw, 70, vex::velocityUnits::pct,false);//Angles towards goal
RightMotor.rotateFor(-900, vex::rotationUnits::raw, 70, vex::velocityUnits::pct,false);
BackLeftMotor.rotateFor(900, vex::rotationUnits::raw, 70, vex::velocityUnits::pct,false);
BackRightMotor.rotateFor(-900, vex::rotationUnits::raw, 70, vex::velocityUnits::pct,true);

LeftMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);//Drives forward into goal
RightMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false); 
BackLeftMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);
BackRightMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,true);

Index.rotateFor(1800, vex::rotationUnits::raw, 100 , vex::velocityUnits::pct,false);//Scores
Index2.rotateFor(1800, vex::rotationUnits::raw, 100 , vex::velocityUnits::pct,true);

LeftMotor.rotateFor(-900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);//Back out of goal
RightMotor.rotateFor(-900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false); 
BackLeftMotor.rotateFor(-900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);
BackRightMotor.rotateFor(-900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,true);

LeftMotor.rotateFor(-900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);//Turns back side towards wall
RightMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false); 
BackLeftMotor.rotateFor(-900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);
BackRightMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,true);

LeftMotor.rotateFor(-900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);//Backs into wall
RightMotor.rotateFor(-900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false); 
BackLeftMotor.rotateFor(-900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);
BackRightMotor.rotateFor(-900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,true);

LeftMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);//Drive forward to pick up ball on
RightMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false); //line and intakes it
BackLeftMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,false);
BackRightMotor.rotateFor(900, vex::rotationUnits::raw, 50, vex::velocityUnits::pct,true);
Intake.rotateFor(4000, vex::rotationUnits::raw, 100, vex::velocityUnits::pct,false);
Intake2.rotateFor(4000, vex::rotationUnits::raw, 100, vex::velocityUnits::pct,true);


}

void autonomous( void ) {
  if (selected == 1){BL_RR_Sort();}
  if (selected == 2){BR_RL_Sort();}
  if (selected == 3){BL_RR_2G();}
  if (selected == 4){BR_RL_2G();}
  if (selected == 5){OneBall();}
  if (selected == 6){Skills();} 
  if (selected == 7){BL_RR_CG();}
  if (selected == 8){BR_RL_CG();}
}

void usercontrol( void ) {
vex::task driveControl(driveControlTask);

while (1) {
Indexcontroll();
  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.
}

}
1 Like

If it’s a VEXcode V5 project, export the project and attach the zip file here (or send it to me by DM)
If it’s a VEXcode project (blocks or C++), perhaps attach the project file here.

or, if it’s really simple, just cut&paste the code in between code tags

[code]
your code here
[/code]
edit: ok, you figured it out while I was typing :slight_smile:

2 Likes

It’s probably this

vex::limit LimitSwitchA = vex::limit(Brain.ThreeWirePort.A);
vex::limit LimitSwitchB = vex::limit(Brain.ThreeWirePort.B);

often the issue is that brain is not created when main.cpp constructors run

3 Likes

see this

2 Likes

Ok, Yah I am trying to learn how to use sensors this year and forgot I even put that in there.

So how could I fix that problem or properly code it

Did you read the post I linked ?

triport ThreeWirePort = vex::triport( vex::PORT22 );
vex::limit LimitSwitchA = vex::limit(ThreeWirePort.A);
vex::limit LimitSwitchB = vex::limit(ThreeWirePort.B);

the underlying issue is that main.cpp runs its constructors (ie. makes the devices etc.) before robot-config.cpp (an unfortunate choice of name on someones part, we should have started it with a letter < m), although the order things run is not defined and so could technically be different.

1 Like

Well I did read it but I was not smart and typed before I even looked at it. Sorry about that. But I am confused on why you would put a actual port on the top line of code/above the limit switches. Because I am not using a triport extension

triport ThreeWirePort = vex::triport( vex::PORT22 );

This creates an instance of a 3wire expander. We have one inside the V5 brain , that’s the one on PORT22. You can now buy them and attach to any external port.

When the brain instance is created we do this as a convenience for you as well. So when you use Brain.ThreeWirePort that’s an instance we made automatically, but if the brain instance has not been created then Brain.ThreeWirePort is also not available.

Once you have an instance of a 3wire expander you can create switches, potentiometers etc. using specific ports on that device called A, B etc.

so these lines

vex::limit LimitSwitchA = vex::limit(ThreeWirePort.A);
vex::limit LimitSwitchB = vex::limit(ThreeWirePort.B);

make the limit switches using ports A and B.

4 Likes

Ok I think I understand now. My only thing is do I have to “link” the ports together with port 22 or can it be any.

The V5 brain has 21 external smartport connectors, they are the ones you attach motors etc. to.
The A-H ports on the side of the V5 brain are part of a 3wire expander that is connected to an internal hidden port22, so you have to specify that as the port you use

(unless your switches really are connected to one of these)

Anyway, has it fixed your memory permission error ? This was just the first thing I saw, there may be other issues.

1 Like