|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
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?
|
|
#2
|
||||||
|
||||||
|
Re: Gyro Angle Problems
The Gyro should be in Analog 1 or 2.
|
|
#3
|
|||
|
|||
|
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.
|
|
#4
|
|||
|
|||
|
Re: Gyro Angle Problems
We tried both changes and the angle still goes up very very slow, only ranging between .7 and -.7
|
|
#5
|
||||
|
||||
|
Re: Gyro Angle Problems
Quote:
|
|
#6
|
|||
|
|||
|
Re: Gyro Angle Problems
Quote:
If it is a magnitude issue, change the sensitivity. If it is just wandering, recheck your wiring. |
|
#7
|
|||
|
|||
|
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");
}
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());
}
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);
}
|
|
#8
|
||||
|
||||
|
Re: Gyro Angle Problems
Quote:
Quote:
|
|
#9
|
|||
|
|||
|
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. |
|
#10
|
||||
|
||||
|
Re: Gyro Angle Problems
Quote:
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 |
|
#11
|
|||
|
|||
|
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). |
|
#12
|
||||
|
||||
|
Re: Gyro Angle Problems
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 |
|
#13
|
||||||
|
||||||
|
Re: Gyro Angle Problems
Quote:
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. |
|
#14
|
|||
|
|||
|
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) |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|