Go to Post Angry Teams will not get the field going any quicker trust me on that! - mtaman02 [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 23-01-2013, 18:29
team1631's Avatar
team1631 team1631 is offline
Registered User
FRC #1631 (Rockin Robots)
 
Join Date: Feb 2009
Rookie Year: 2005
Location: Henderson, NV
Posts: 9
team1631 is an unknown quantity at this point
Gyro Angle Problems

We are using a gyro to detect turn changes on the Robot for an aiming function. Currently, the gyro is in Digital IO slot 2 and appears to be correctly wired. However, when we ask for the getAngle values and spin the robot in circles, we get values of less than 1 in the positive and negative direction. Turning the robot a full 360 would increase the gyro angle by at most (.1). My understanding is that getAngle should return values far greater than this. How do we get the gyro to return proper angles?
Reply With Quote
  #2   Spotlight this post!  
Unread 23-01-2013, 18:55
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,572
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Gyro Angle Problems

Quote:
Originally Posted by team1631 View Post
Currently, the gyro is in Digital IO slot 2 and appears to be correctly wired.
The Gyro should be in Analog 1 or 2.
Reply With Quote
  #3   Spotlight this post!  
Unread 23-01-2013, 18:58
alexhenning alexhenning is offline
WPILib Developer
FRC #0348
 
Join Date: Apr 2010
Rookie Year: 2003
Location: MA
Posts: 49
alexhenning will become famous soon enough
Re: Gyro Angle Problems

Are you using RobotBuilder? If so, there is a bug I just found earlier today. The default sensitivity for the gyro is set to 1.25, but it really should be 0.007 volts/degree/second. The fix will be available in the next update, but in the mean time you can change it manually.
Reply With Quote
  #4   Spotlight this post!  
Unread 24-01-2013, 13:27
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

We tried both changes and the angle still goes up very very slow, only ranging between .7 and -.7
Reply With Quote
  #5   Spotlight this post!  
Unread 24-01-2013, 13:50
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,089
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Gyro Angle Problems

Quote:
Originally Posted by Gmercer View Post
We tried both changes and the angle still goes up very very slow, only ranging between .7 and -.7
Post your code and a picture of the gyro installation (including wiring at both ends).


Reply With Quote
  #6   Spotlight this post!  
Unread 24-01-2013, 14:07
EricVanWyk EricVanWyk is offline
Registered User
no team
 
Join Date: Jan 2007
Rookie Year: 2000
Location: Boston
Posts: 1,597
EricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond repute
Send a message via AIM to EricVanWyk
Re: Gyro Angle Problems

Quote:
Originally Posted by Gmercer View Post
We tried both changes and the angle still goes up very very slow, only ranging between .7 and -.7
Does it seem at all responsive to reality? In other words, does the response have the right shape but the wrong magnitude, or is it just wandering on its own? Graphing the values will answer this question quickly.

If it is a magnitude issue, change the sensitivity.

If it is just wandering, recheck your wiring.
Reply With Quote
  #7   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
  #8   Spotlight this post!  
Unread 26-01-2013, 14:40
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,089
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Gyro Angle Problems

Quote:
Originally Posted by Gmercer View Post
We tried both changes and the angle still goes up very very slow, only ranging between .7 and -.7
Quote:
Originally Posted by Gmercer View Post
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
Are you describing the same problem, or did something happen between the above two posts that you haven't mentioned??


Reply With Quote
  #9   Spotlight this post!  
Unread 26-01-2013, 14:50
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

I gyro still stays at a very small angle, i had just modified the code a lot to fix some logical problems. ill upload some pictures to this post showing what i see with the gyro.

http://dl.dropbox.com/u/78573135/IMAG0067.jpg
http://dl.dropbox.com/u/78573135/IMAG0068.jpg
The second photo is after doing a complete turn around, though the value only went back by -.1

I'm using a school wifi system right now so i don't have access to image sites, sorry!


EDIT: at this point i think the gyro might have been installed wrong, could anyone link a PDF on how to correctly install a gyro? i can't seem to find one.

Last edited by Gmercer : 26-01-2013 at 15:12.
Reply With Quote
  #10   Spotlight this post!  
Unread 26-01-2013, 15:42
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,089
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Gyro Angle Problems

Quote:
Originally Posted by Gmercer View Post
could anyone link a PDF on how to correctly install a gyro? i can't seem to find one.
Follow these steps:

1) go to andymark.com

2) type "gyro" in the search box and press ENTER

3) click on the link that says "Dual Use Gyro and Accelerometer Sensor Board (am-2067)"

4) on that page, click on the tab named "Files & Documents"

5) click on the link "Wiring diagram"

6) scroll to the bottom of the page


Reply With Quote
  #11   Spotlight this post!  
Unread 01-02-2013, 13:35
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

What is the range of values the getAngle function will return? The gyro updates correctly, but starts at a very small angle and only increment by maybe .15 at a time.

If we have an example angle of 6.8 degrees, and the gyro stays at such a small number, the robot goes into a death spin until reaching 6.8 degrees(which is a long time).
Reply With Quote
  #12   Spotlight this post!  
Unread 01-02-2013, 13:40
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,089
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Gyro Angle Problems

Quote:
Originally Posted by Gmercer View Post
What is the range of values the getAngle function will return?
follow these steps:

1) Go to the folder on your development PC where the WPILib Java source code files are kept.

2) Open the file named "gyro.java"

3) Search for "getAngle"

4) Read the method header comments


Reply With Quote
  #13   Spotlight this post!  
Unread 01-02-2013, 13:53
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,572
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Gyro Angle Problems

Quote:
Originally Posted by Gmercer View Post
What is the range of values the getAngle function will return? The gyro updates correctly, but starts at a very small angle and only increment by maybe .15 at a time.

If we have an example angle of 6.8 degrees, and the gyro stays at such a small number, the robot goes into a death spin until reaching 6.8 degrees(which is a long time).
getAngle requires that the sensitivity of the gyro is set correctly with the setSensitivity method. For the ADW22307 gyro available on FIRST Choice, the sensitivity is 0.007 V/°/s. If you are using a different gyro, you will need to find the sensitivity from the data sheet of the gyro.

If you are using Robot Builder version 619 or earlier, there is a bug that defaults the sensitivity to 1.25 V/°/s. See the post by Alex Henning above. This would cause an issue similar to what you saw. It would take approximately 3.4 full revolutions before the robot measured 6.8 degrees. You should make sure that the sensitivity matches your gyro.

Edit: sorry, I see that you are setting sensitivity. I'll leave this here in case it helps someone in the future.

With a DMM, what is the voltage on the rate and +5v pins of the gyro?

Last edited by Joe Ross : 01-02-2013 at 14:23.
Reply With Quote
  #14   Spotlight this post!  
Unread 01-02-2013, 15:30
omalleyj omalleyj is offline
Registered User
AKA: Jim O'Malley
FRC #1279 (Cold Fusion)
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2008
Location: New Jersey
Posts: 132
omalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to behold
Re: Gyro Angle Problems

First, don't print useless "I'm here" messages at the maximum loop rate! The first one conveys information all the rest consume bandwidth. (check your logs for when the spinning slows I would not be surprised if your prints are gradually backing up and consuming all your CPU and/or bandwidth)

Second, If your code stays in a while loop forever it means you are not meeting the exit criterea. Period. In this case that almost certainly means your spinning in the wrong direction, or +/- .75 degrees is smaller than the distance covered at 25% power in 6 tenths of a second. (how did you come up with .6 as the magic amount of time between checks?)

Third, never create a loop that can run forever! Create a counter or timer that guarantees you'll exit after, say, 5 seconds, or 10 iterations, or something. If your gyro gets unplugged or damaged you will sit and spin. (been there)
Reply With Quote
  #15   Spotlight this post!  
Unread 02-02-2013, 13:24
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

Noticed something about the setup, wondering if anyone can explain it...

I plugged the gyro into the analog breakout and set everything up correctly, until i just realized the analog has never had a power cord to it(i feel very stupid). But how was the gyro returning values to us when the analog was never powered to begin with?
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 11:40.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi