|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Gyroscope Not Returning Degrees
We're programming a gyroscope on the robot and we're not getting a readout in degrees. The sensitivity is set to 0.007 (as referenced in the manual), the gyro is connected correctly and mounted on the robot. The readout we get is also not consistent because it decreases while stationary and we don't think it's drift. We tested sample code and read the manual but we're still having a problem.
|
|
#2
|
||||||
|
||||||
|
Re: Gyroscope Not Returning Degrees
How is it connected?
Quote:
Quote:
|
|
#3
|
|||
|
|||
|
Re: Gyroscope Not Returning Degrees
The rate header is connected to the analog breakout on port 1. We followed this guide from AndyMark.
Quote:
The code we're trying is from Team 2945, found on the fourms. We modified it a little. Code:
package com.github.manitourobotics.gyroscopetesting;
import edu.wpi.first.wpilibj.AnalogChannel;
import edu.wpi.first.wpilibj.Gyro;
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.command.Scheduler;
import edu.wpi.first.wpilibj.livewindow.LiveWindow;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
public class GyroscopeTesting extends IterativeRobot {
public void robotInit()
{
}
AnalogChannel gyroChannel = new AnalogChannel(1);
Gyro gyro = new Gyro(gyroChannel);
public void teleopInit()
{
gyro.reset();
}
public void teleopPeriodic()
{
gyro.setSensitivity(0.007);
double gyroAngle = gyro.getAngle();
SmartDashboard.putNumber("Gyro angle", gyroAngle);
System.out.println("Gyro Angle: " + gyroAngle);
Scheduler.getInstance().run();
}
}
Last edited by samn122 : 09-12-2013 at 21:50. |
|
#4
|
||||||
|
||||||
|
Re: Gyroscope Not Returning Degrees
What voltage do you measure with a multimeter between the rate pin and ground? It should be approximately 2.5v.
I like the LabVIEW gyro wiring diagram (attached), as it's a little more clear which wire goes where on the analog breakout. Last edited by Joe Ross : 09-12-2013 at 23:06. |
|
#5
|
||||
|
||||
|
Re: Gyroscope Not Returning Degrees
I don't have the wpilib source avaialble, so I can't check to see if this should make any difference at all, but is there a reason you're setting the sensitivity repeatedly (in teleop periodic)?
The following is essentially what we've done every year with the gyro: Code:
import edu.wpi.first.wpilibj.Gyro;
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.livewindow.LiveWindow;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
public class GyroscopeTesting extends IterativeRobot {
Gyro gyro;
public void robotInit() {
gyro = new Gyro(1);
gyro.setSensitivity(0.0070);
gyro.reset();
}
public void teleopInit() {
}
public void teleopPeriodic() {
double gyroAngle = gyro.getAngle();
SmartDashboard.putNumber("Gyro angle", gyroAngle);
System.out.println("Gyro Angle: " + gyroAngle);
}
}
|
|
#6
|
|||
|
|||
|
Re: Gyroscope Not Returning Degrees
Thanks for the replies! After testing the gyro with a multimeter and on another cRIO unit, we discovered that the analog breakout was faulty and replaced it with another one. The gyro is working and we're getting a responsive and usable readout.
|
|
#7
|
||||
|
||||
|
Re: Gyroscope Not Returning Degrees
Quote:
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|