Pneumatics during autonomous

we can’t turn on the pneumatics during autonomous. Is there any sample code that opens pneumatics during autonomous?

Could you please share your code so that I or someone else can help you?

void autonomous(void) {
Drivetrain.driveFor(forward, 1700, mm, 80);
rightWing.set(true);
Drivetrain.turnFor(left, 45, degrees);
rightWing.set(false);
Drivetrain.driveFor(forward, 500, mm, 80);
}

a part of code

Nothing seems wrong with this but here are some general things that can not make this work:

  1. Hardware
  • Is your pnematics plumped correctly? and the pressure is going in the P side
  • Is it plugged into the right port?
  1. Code
  • Do you have any other sensors declared on the same three wire port? Like a sensor from last year or something (this happened to me)
  • Does your auton set up correctly?
  • The DriveTrain.turnFor might not be yielding or waiting for the next line and it might be setting to true and right to false

To make it easier you may need to set up a test program, something like this :

vex::brain       Brain;
vex::digital_out Pnematics(Brain.ThreeWirePort.A); // Change THIS TO THE PORT THAT YOU ARE USING
vex::controller Controller1(controllerType::primary);
// define your global instances of motors and other devices here

void autonFunction(){
    Pnematics.set(true); // Checks if it works in auton
    wait(1,sec);
    Pnematics.set(false);
}

void usercontrol(){
    while(true){
        if (Controller1.ButtonA.pressing()){ // Press A
 Pnematics.set(true); // Checks if it works in drive control setting
    wait(1,sec);
    Pnematics.set(false);
        }
        task::sleep(25);
    }
}
competition Competition;
int main() {
    Competition.autonomous(autonFunction);
    Competition.drivercontrol(usercontrol);
    // Remove the next 3 lines if needed 
    Pnematics.set(true); // Checks if it works at all
    wait(1,sec); 
    Pnematics.set(false);
    while(1) {
        this_thread::sleep_for(10);
    }
}

This way it helps narrow down if its hardware or code. I would also recommend trying if its the code something like this

Brain.Screen.setCursor(1,1)
Brain.Screen.print("Started turn")
Drivetrain.turnFor(left, 45, degrees);
Brain.Screen.setCursor(2,1)
Brain.Screen.print("ended turn")

and see if there is almost no delay from end and start turn (if you already have a display then you can just make a new program and try it or disable it)

1 Like