View Single Post
  #4   Spotlight this post!  
Unread 26-01-2013, 14:32
Gmercer Gmercer is offline
Registered User
None #1631
 
Join Date: Jan 2013
Location: Las Vegas
Posts: 15
Gmercer is an unknown quantity at this point
Re: Gyro Angle Problems

At the moment when the shoot function is called the robot goes into a death spin and rapidly rotates for a bit, then slows down but still locks me from moving using the joysticks. I've found that the robot gets stuck in the aiming loop and is never able to get out of it, but for some reason it will stop turning the robot and just sit in the loop doing nothing afterwards. Here is any code that includes the gyro's:

Robot Template function:
Code:
    public RobotTemplate() {
        watchD = this.getWatchdog();
        //kills the watchdog
        watchD.setEnabled(false);
        //run the compressor
        comp1.start();
        //start with all arms retracted
        Arm1.retract();
        Arm2.retract();
        Arm3.retract();
        Arm4.retract();
        gShoot.reset();
        gShoot.setSensitivity(.007);
        camera = AxisCamera.getInstance("10.16.31.11");
        SmartDashboard.putString("Made it out~", "BEFORE BUTTON");
    }
data function(called in main loop to update dashboard)
Code:
 public void data() {
        //put smartdashboard values
        SmartDashboard.putNumber("Left Motor", Y);
        SmartDashboard.putNumber("Right Motor", Y * backward);
        SmartDashboard.putBoolean("Compressor Running: ", comp1.enabled());
        SmartDashboard.putNumber("gyro angle", gShoot.getAngle());
        //SmartDashboard.putString("Taken Picture", ".............");
        //SmartDashboard.putNumber("gyro angle", gShoot.getAngle());
    }
Shoot function(i think this is the source of my problem)
Code:
    public void shoot(final double finalAngle) {
        //declare and start a timer, used for smooth transition between sections
        gShoot.reset();
        Timer t_aim = new Timer();
        t_aim.start();
        //while the difference in absolute values of gyro angle and finalangle is greater than .75
        while (gShoot.getAngle() > (finalAngle + .75) || gShoot.getAngle() < (finalAngle - .75) && !joy2.getRawButton(1)){
            SmartDashboard.putString("Made it out~", "ITS IN THE LOOP");
            if(t_aim.get() > .6) {
                t_aim.reset();
                t_aim.start();
                if(gShoot.getAngle() < finalAngle){
                    //I have no idea which way to turn the robot. Change positive and negative.
                    jag1.set(.25);
                    jag2.set(.25);
                    jag3.set(.25);
                    jag4.set(.25);
                }
                else if(gShoot.getAngle() > finalAngle){
                    //I have no idea which way to turn the robot. Change positive and negative.
                    jag1.set(-.25);
                    jag2.set(-.25);
                    jag3.set(-.25);
                    jag4.set(-.25);
                }
            }
        }
        SmartDashboard.putString("Made it out~", "ITS OUT OF THE LOOP");
        //stopping the jaguars after the angle is correct
        jag1.set(0);
        jag2.set(0);
        jag3.set(0);
        jag4.set(0);
        
    }
The value in Finalangle on average ranges from -30 degrees to 30 degrees, and i used the jags in all combinations with negative and possible, i wouldnt think it is the jags. Any help is really appreciated!
Reply With Quote