Autonomous run forward and back

Hi all! I have a competition in a few hours and am wondering if you can spare me your autonomous code (if you want to). If so, I can base it off of that. Thanks!

Based off the title, I’m assuming that you just need an auton that can run forwards and backwards. In that case, I recommend you base it off of one of the clawbot examples (pictures shown below). If you do need more help in making your auton, feel free to PM me.
image 'image

3 Likes

here is some pseudocode showing how I like to make my autons:

void drive = (distance, speed){
     //set drive motors to move distance at speed
     //wait until the motors are finished moving, plus a little extra time to let the motors come to rest.
};

then in my actually auton looks like this:

drive(24,50);
startIntake();
turn(45,50);
drive(12,50);
turn(180,50);
stopIntake();
drive(36,50);
tiltUp();
tiltDown();
drive(-6,100);

now, idk if this is a “good” way to make an auton, but that’s how I like to do it. you just have to tune your main functions, and you can make your robot do anything you want, with relative ease. I’m still a novice coder, so to make my functions, I had to take a look at some sample programs, the most useful for me was drive for distance.