View Single Post
  #5   Spotlight this post!  
Unread 20-01-2010, 15:26
byteit101's Avatar
byteit101 byteit101 is offline
WPILib maintainer (WPI)
AKA: Patrick Plenefisch
no team (The Cat Attack (Formerly))
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Worcester
Posts: 699
byteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of light
Re: Semi-Omni-Arcade Drive

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 Telopgy is a gyrodrive is a RobotDrivestick 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)

__________________
Bubble Wrap: programmers rewards
Watchdog.Kill();
printf("Watchdog is Dead, Celebrate!");
How to make a self aware robot: while (∞) cout<<(sqrt(-∞)/-0);
Previously FRC 451 (The Cat Attack)
Now part of the class of 2016 at WPI & helping on WPILib