what would be the average gyro drift for a 2 minute match?
Next meeting we are going to test a basic form of this. I wrote up a basic drive:
PHP Code:
(In Telop, gy is a gyro, drive is a RobotDrive, stick is a Joystick)
double offset=0;
double offset=0;
while (IsOperatorControl())
{
//(1+cos(pi*x))/2; speed function
//-xx+2x; turn function, graph these at http://www.walterzorn.com/grapher/grapher_e.htm
GetWatchdog().Feed();
float speed=0;
float turn=0;
if (stick.GetX()!=0&&stick.GetY()!=0)//UN Preliminary check for are we moving. this might be unnesecary?
{
//get the diff in the gyro and joystick, making sure no overflow occurs, and normalizing to 0 to 359
offset=((int)((int)(stick.GetDirectionDegrees()-(((int)(gy.GetAngle()*360))%360))+360)%360);
//Detect the location, and change speed/turn multipliers
switch ((int)(offset/90))
{
case 0: //top right
speed=1;
turn=1;
break;
case 1: //bottom right
speed=-1;
turn=1;
break;
case 2: //bottom left
speed=-1;
turn=-1;
break;
case 3: //top left
speed=1;
turn=-1;
break;
default: //should never occur, print error?
speed=1;
turn=1;
break;
}
if (offset>180)//start folding into 90 range
{
offset=fabs(offset-360);//escape greedy %
}
//bring into normalized values in 0-90 then 0-1
offset=((int)offset%90)/90;
speed*=((1+cos(Pi*offset))/2)*stick.GetMagnitude();//multiply turn (switch from above) times function, times speed
turn*=(-(offset*offset)+(2*offset))*offset;//multiply turn (switch from above) times function, times dir
}
drive.ArcadeDrive(speed,turn,false);//DRIVE!
Wait(0.01); // wait for a motor update time (using victors)
}