Thread: Autonomous Help
View Single Post
  #5   Spotlight this post!  
Unread 01-20-2015, 03:45 PM
curtis0gj curtis0gj is offline
Registered User
FRC #5033 (Beavertronics)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Canada
Posts: 121
curtis0gj will become famous soon enough
Re: Autonomous Help

Quote:
Originally Posted by notmattlythgoe View Post
I think I can give you a hand Curtis. Could you please list step by step what it is you want your autonomous mode to do?
Hi, thanks for the reply so basically what I am looking to do is make a 180 degree turn stop and drive straight forward for a set distance via encoder. However our team only has one encoder currently I don't know if this will be a problem. Today I figured out the turn finally and I added in the straight away however I am stuck in a loop I believe here's my current program
Code:
    public void autonomous() {
    	
    	gyro1.reset();
		
    	while(isAutonomous() && isEnabled())  {
    		
    		double angle = gyro1.getAngle();
    		
    		SmartDashboard.putNumber("angle", gyro1.getAngle());
    		
    		robot.drive(-0.15, 1);
    		Timer.delay(0.1);
    		
    		if(angle > 160) {
    			
    			robot.drive(0,0);
    			gyro1.reset();
    			Timer.delay(1.00);
    			
    			turnComplete = false;
    			break; 
    			
    			
    			
    			
    			}
    		}
    		turnComplete = true;
				gyro1.reset();
				while (turnComplete == true) {

						
						double angle2 = gyro1.getAngle(); // i think for driving i need a constant update of my angle
						//so i will place this inside my if loop and i name it angle2 so it's a different variable.
						robot.drive(-0.15, -angle2 * Kp); // driving straight in a line.
						Timer.delay(0.004);
						
						if(isAutonomous() && isDisabled())  {
							robot.drive(0,0);
							turnComplete = false;
							break;
						}
					
				
				}
				
				
			
    			}

Last edited by curtis0gj : 01-20-2015 at 04:01 PM.
Reply With Quote