Hi! So in our autonomous, we have a function for scoring a ball in a goal called scoreBall. It is only programmed to move 2 motors, the secondary intake and the back roller. However, occasionally it will move our primary intakes as well, causing the robot to pick up a blue ball, which we do not want to do since we don’t have code to eject it. For reference, here is our code for the scoreBall function:
void scoreBall(double revolutions, double velocity){
secondIntake.spinFor(vex::directionType::fwd,revolutions,rotationUnits::rev,velocity,velocityUnits::pct);
backRoller.spinFor(vex::directionType::fwd,revolutions,rotationUnits::rev,velocity,velocityUnits::pct);
}
And here is the code in our autonomous, the last line is where the primary intakes sometimes move.
inertiaSensor.resetRotation();
//gets first ball
getBall(0.6, 60, 5, 100, 0.5, 75);
wait(500, msec);
//scores the preload in the first goal
turnLeft(0.95, 45);
wait(1000, msec);
moveForward(1.2, 40);
wait(1, sec);
scoreBall(1.5, 95);
If it helps, here is the code for moveForward, turnLeft, and getBall.
void moveForward(double revolutions, double velocity){
leftForward.setVelocity(velocity, velocityUnits::pct);
leftBack.setVelocity(velocity, velocityUnits::pct);
rightForward.setVelocity(velocity, velocityUnits::pct);
rightBack.setVelocity(velocity, velocityUnits::pct);
leftForward.startRotateFor(vex::directionType::fwd,revolutions, rotationUnits::rev);
leftBack.startRotateFor(vex::directionType::fwd,revolutions, rotationUnits::rev);
rightForward.startRotateFor(vex::directionType::fwd,revolutions, rotationUnits::rev);
rightBack.startRotateFor(vex::directionType::fwd,revolutions, rotationUnits::rev);
}
void turnLeft(double revolutions, double velocity){
leftForward.setVelocity(velocity, velocityUnits::pct);
leftBack.setVelocity(velocity, velocityUnits::pct);
rightForward.setVelocity(velocity, velocityUnits::pct);
rightBack.setVelocity(velocity, velocityUnits::pct);
leftForward.startRotateFor(vex::directionType::rev,revolutions,rotationUnits::rev);
leftBack.startRotateFor(vex::directionType::rev,revolutions,rotationUnits::rev);
rightForward.startRotateFor(vex::directionType::fwd,revolutions,rotationUnits::rev);
rightBack.startRotateFor(vex::directionType::fwd,revolutions,rotationUnits::rev);
}
void getBall(double revFWD, double velFWD, double revINT, double velINT, double revSEC, double velSEC){
intakeMotorLeft.setVelocity(velINT, velocityUnits::pct);
intakeMotorRight.setVelocity(velINT, velocityUnits::pct);
leftForward.setVelocity(velFWD, velocityUnits::pct);
leftBack.setVelocity(velFWD, velocityUnits::pct);
rightForward.setVelocity(velFWD, velocityUnits::pct);
rightBack.setVelocity(velFWD, velocityUnits::pct);
secondIntake.setVelocity(velSEC, velocityUnits::pct);
backRoller.setVelocity(velSEC, velocityUnits::pct);
intakeMotorLeft.startRotateFor(vex::directionType::fwd,revINT, rotationUnits::rev);
intakeMotorRight.startRotateFor(vex::directionType::fwd,revINT, rotationUnits::rev);
leftForward.startRotateFor(vex::directionType::fwd,revFWD, rotationUnits::rev);
leftBack.startRotateFor(vex::directionType::fwd,revFWD, rotationUnits::rev);
rightForward.startRotateFor(vex::directionType::fwd,revFWD, rotationUnits::rev);
rightBack.startRotateFor(vex::directionType::fwd,revFWD, rotationUnits::rev);
secondIntake.startRotateFor(vex::directionType::fwd,revSEC,rotationUnits::rev);
backRoller.startRotateFor(vex::directionType::fwd, revSEC, rotationUnits::rev);
}
The primary intakes moving when they’re not supposed to doesn’t happen commonly. I’d say it happens about 1 in every 10 times we run the code. I really don’t know why this happens, so any help would be appreciated!