Quote:
Originally Posted by tomy
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.