View Single Post
  #2   Spotlight this post!  
Unread 02-20-2015, 03:21 PM
GeeTwo's Avatar
GeeTwo GeeTwo is offline
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,539
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
Re: Gyro Turning in Auto Mode

Quote:
Originally Posted by tomy View Post
We trying to manipulate the kp so that we turn slow at the beginning then increase the speed of rotation when we approach the angle we want. It works kinda of just spins way to fast at the beginning of the rotate. Suggestions?

Code:
	
if(stage_one_complete){
		gyro.Reset();
		while(IsAutonomous() && IsEnabled() ){
			float angle = gyro.GetAngle();

			if(angle > + 70){
				kp = 0.005;
			}else if(angle < + 70){
				kp = 0.02;
			}

			myRobot.MecanumDrive_Cartesian( 0, 0, ((angle + 82) * kp), 0);
			timer ++;
			Wait (0.004);

			if(timer > 400){
				myRobot.MecanumDrive_Cartesian(0, 0, 0, 0);
				stage_one_complete = false;
				stage_two_complete = true;
				break;
			}
		}
	}
The first thing I notice is that you're resetting the gyro in the method. Unless you're using sampleRobot, the gyro will get reset again and again.

Also, in the first if statement, you did not cover the angle == 70 case; you'd probably be better off with a simple else. You also give it a larger number at the beginning, which is what I would expect that you want, but does not agree with the description at the top. Try changing the > to a < in the if and see if that's what you wanted.
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.
Reply With Quote