Thread: Autonomous Help
View Single Post
  #3   Spotlight this post!  
Unread 01-19-2015, 07:53 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 curtis0gj View Post
I think I have solved this but I don't have a way of testing it until tomorrow, I think the issue is the double angle = gyro1.getAngle(); is in the while loop so it's just getting the angle over and over... But I still need help with setting up an encoder if anyone could help that would be great!
Quoting my self for a third time lol.... I spent a bit more time trying to setup the straight driving and what I did was created a new boolean and set it to true and made an if loop that it will enter if its == to true.
Code:
public void autonomous() {
    	
		double angle = gyro1.getAngle();
		
    	while(isAutonomous() && isEnabled())  {
    		
    		SmartDashboard.putNumber("angle", gyro1.getAngle());
    		
    		robot.drive(-0.20, 1);
    		
    		if(angle > 83) {
    			
    			robot.drive(0,0);
    			
    			break; 
    			
    			
    			}
    		
    		//do i need to reset my gryo? do i need to place my get angle here? 
    		

    			boolean turnCompleted = true;

				if(turnCompleted == 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(-1.0, -angle2*Kp); // driving straight in a line.
					Timer.delay(0.004);
					
			
    			}
				
    		}
    		}
If anyone has any ideas for improvement for this please let me know.
Reply With Quote