Thread: Gyro Help
View Single Post
  #1   Spotlight this post!  
Unread 15-01-2015, 18:09
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
Gyro Help

Hi everyone this is my first year programming in First Robotics and I need some help programming a gyro in autonomus. My goal is to have our bot drive forward and make a sudden 90 degree turn. I have figured out how to make a sudden turn however, the bot does not stop and it continues to spin. Any help would be greatly appreciated.

Here's my code:

Code:
public void autonomous() {
    	
    	while (isAutonomous() && isEnabled()) {
    		
    		SmartDashboard.putNumber(" angle " , gyro1.getAngle());
    	
    		double angle = gyro1.getAngle() + 90;
    		
    		//robot.drive(-0.15, angle * Kp); this is for driving straight
    		robot.drive(-0.10, angle / 30); // the turn
    		gyro1.reset();

    		if(angle < 90) {

    			robot.stopMotor();
    			
    		}
    		 
    	}
    	}
Reply With Quote