Code for Auton

Can someone please check my code? I am at a competition right now. I am trying to push a cube into the goal zone and come back. I am trying to make a good auton.

Thanks

//Left Front
LFM.spin(vex::directionType::fwd,200,vex::velocityUnits::rpm);
LFM.rotateFor(5,vex::timeUnits::sec,200,vex::velocityUnits::pct);

//Right front
    RFM.spin(vex::directionType::fwd,200,vex::velocityUnits::rpm);
RFM.rotateFor(5,vex::timeUnits::sec,200,vex::velocityUnits::pct);

//BackLeft
    LBM.spin(vex::directionType::fwd,200,vex::velocityUnits::rpm);
LBM.rotateFor(5,vex::timeUnits::sec,200,vex::velocityUnits::pct);

//Back Right

 RBM.spin(vex::directionType::fwd,200,vex::velocityUnits::rpm);
RBM.rotateFor(5,vex::timeUnits::sec,200,vex::velocityUnits::pct);


//The followng code is for reverse
    //Left Front
 LFM.spin(vex::directionType::rev,200,vex::velocityUnits::rpm);
LFM.rotateFor(15,vex::timeUnits::sec,200,vex::velocityUnits::pct);

//Right front
    RFM.spin(vex::directionType::rev,200,vex::velocityUnits::rpm);
RFM.rotateFor(15,vex::timeUnits::sec,200,vex::velocityUnits::pct);

//BackLeft
    LBM.spin(vex::directionType::rev,200,vex::velocityUnits::rpm);
LBM.rotateFor(15,vex::timeUnits::sec,200,vex::velocityUnits::pct);

//Back Right

 RBM.spin(vex::directionType::rev,200,vex::velocityUnits::rpm);
RBM.rotateFor(15,vex::timeUnits::sec,200,vex::velocityUnits::pct);

You really need to tell us more about what is or isn’t happening or what you want it to do…

why do you tell the motor to spin right before you tell it to rotate for…
also you mix pct and rpm units

With our original code, my team said that it was working but it wasn’t going all the way back and it wasn’t going far enough to push the cube into the goal zone.

I am trying to push a cube into the goal zone.

well you use rotateFor for each motor without the false parameter so only one motor is spinning at a time

1 Like