Autonomous Problems


#1

Hi, I can’t get my autonomous to work here’s a picture any suggestions???
Automonous.PNG


#2

My first suggestion would be to be more specific about the nature of your problem. More information helps other people help you.


#3

Are you sure it doesn’t work? Does the robot seem like it’s just about to get started and then just stop? Your whole autonomous only runs for 0.3 seconds. And you’re trying to get the motors up to 50 rpm. That’s less than 1 revolution per second for only 0.3 seconds. Even if you could instantly get to maximum speed, the motors would only rotate 0.25 revolution in total. Since it can’t get to that maximum speed instantly, I would expect something in the ballpark of 0.1 revolution in total. So if you see the robot just starting to roll and immediately stopping, it works perfectly.

Separately, I’m not sure about the spaces between the colons and the namespace. I’ve never seen it written that way. For example, I’ve always seen directionType::fwd as opposed to directionType ::fwd. I don’t know if those spaces make a difference or not.


#4

The problem is not with the formatting however since you’re using v5 I highly suggest you replace the command with a “.startRotateFor()” command since it is a lot more accurate especially for autonomous. You also have to change the time from 0.3 seconds to 3 seconds by making it 3000 milliseconds rather than 300. The degrees on the .startRotateFor() can be made very precise with trial and error or you can also do math and take into account the size of you tires and the gear ratio and translate that into linear distance with degrees the degrees. This would be even more accurate but once again you can also just do trial and error. You can set it to rotate for say 1000 degrees which is about 2 feet depending on you the size of your robot.


#5

so I tried your methods and none of it worked. our autonomous switch works but I still don’t know the problem I tried rotate for and it doesn’t work, have any other ways to do this?? They would be much appreciated


#6

Here’s our Auton code, this may help you in how to set up an Auton code.

void autonomous() {
     //Setting Velocity Values (NO TOUCHIE)
Intake.setVelocity(90, velocityUnits::pct);
Intake2.setVelocity(100, velocityUnits::pct);
DeScore.setVelocity(100, velocityUnits::pct);
LeftShooterB.setVelocity(185, velocityUnits::rpm);
RightShooterB.setVelocity(185, velocityUnits::rpm);
RightDrive.setVelocity(90, velocityUnits::pct);
LeftDrive.setVelocity(90, velocityUnits::pct);
    //Autonomous Starts... NOW (Can touch but I don't advise it)
LeftDrive.stop(brakeType::brake);
RightDrive.stop(brakeType::brake);
sleep(1, timeUnits::msec);
    LeftShooterB.spin(directionType::fwd);
    RightShooterB.spin(directionType::fwd);
    Intake.spin(directionType::fwd);
sleep(3.5, timeUnits::sec);
    LeftShooterB.stop(brakeType::coast);
    RightShooterB.stop(brakeType::coast);
    Intake.stop(brakeType::brake);
sleep(1, timeUnits::msec); //Shooting HIGH Flag ^
    RightDrive.rotateFor(directionType::rev,.114,rotationUnits::rev,true);
    RightDrive.rotateFor(directionType::rev,3.3,rotationUnits::rev,false);
    LeftDrive.rotateFor(directionType::fwd,3.3,rotationUnits::rev,true);
sleep(200,timeUnits::msec); //Drives to LOW Flag^
    RightDrive.rotateFor(fwd,1.5,rotationUnits::rev,false);
    LeftDrive.rotateFor(directionType::rev,1.5,rotationUnits::rev,true);
sleep(500,timeUnits::msec); //Backs away from LOW flag^
    RightDrive.rotateFor(directionType::fwd,1.2,rotationUnits::rev,false);
    LeftDrive.rotateFor(directionType::fwd,1.2,rotationUnits::rev,true);
sleep(1,timeUnits::msec); //Turns to WAFFLE^
    RightDrive.rotateFor(directionType::rev,2.52,rotationUnits::rev,false);
    LeftDrive.rotateFor(fwd,2.52,rotationUnits::rev,true);
sleep(500,timeUnits::msec); //Goes at WAFFLE^
    LeftDrive.rotateFor(directionType::rev,1.1,rotationUnits::rev,false);
    RightDrive.rotateFor(directionType::fwd,1.1,rotationUnits::rev,true);
sleep(200,timeUnits::msec); //Turns to MID LOW Flag^
    RightDrive.rotateFor(directionType::rev,1.19,rotationUnits::rev,false);
    LeftDrive.rotateFor(fwd,1.19,rotationUnits::rev,true);
sleep(1,timeUnits::msec); //Hits MID LOW Flag^
    RightDrive.rotateFor(fwd,3.5,rotationUnits::rev,false);
    LeftDrive.rotateFor(directionType::rev,3.5,rotationUnits::rev,true);
sleep(1,timeUnits::msec); //Hits WAFFLE^
    RightDrive.rotateFor(directionType::fwd,1,rotationUnits::rev,true);
    RightDrive.rotateFor(directionType::rev,1,rotationUnits::rev,false);
    LeftDrive.rotateFor(fwd,1,rotationUnits::rev,true);
sleep(1,timeUnits::sec); //Drives away from the WAFFLE to allow fall^
//END AUTON TOTAL ~ 5 Points:1 High Flag, 2 Low Flag, 1 Low Waffle:
    
}

#7

I need help, when we first tried to get the controller to control the robot it wouldn’t work and after we put some programming on it it wouldn’t switch from autonomous period to driver control, now the lights are all green and nothings working. we are using easy c v5.


#8

Try deleting the space after “directionType” and “percentUnits” so it is “directionType::fwd” instead of “directionType ::fwd” That’s how we do it.