|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Issues with the Gyro - Help
Hey!
We've been trying for hours to fix the issue with our Gyro and we're not sure whether it's a software issue or hardware issue. Here is our wiring (i only posted links since they are huge images): http://i.imgur.com/ChcTKaV.jpg http://i.imgur.com/6MXDKSq.jpg As we rotate our gyro, we're expecting the gyro pointer to move but it isn't: http://puu.sh/fcJgn/209d7ff45f.jpg (when we are connected to joystick/communication/code) This is our code snippet for the gyro to drive forward straight and to drive backwards straight. Btw, the gyro.reset(); is already called before this thread starts. Code:
public double gyroSensitivity = 0.05; // (voltage / 1000)
public void run() { // This method is executed only for DriveForward and
// DriveBackward
r.autonomousCounter = 0;
r.theRobot.setExpiration(0.1);
while ((Math.floor(r.autonomousCounter / r.loopsPerSecond)) <= DriveClass.seconds) {
if (RecycleRush.InTeleop) {
break;
}
if (forward) {
r.theRobot.drive(r.robotDriveSpeed, -r.gyro.getAngle() * r.gyroSensitivity);
} else if (!forward) {
r.theRobot.drive(-r.robotDriveSpeed, -r.gyro.getAngle() * r.gyroSensitivity);
}
Timer.delay(r.timerDelay);
}
r.theRobot.drive(0.0, 0.0);
}
We also made code to make it rotate while its stationary.... We made two methods, one of which we deprecated for now because we found simpler logic. Code:
public void DriveRotate(int rotateAngle) {
r.queueThread(new Runnable() {
public void run() {
r.gyro.reset();
while (r.gyro.getAngle() < rotateAngle) {
r.theRobot.drive(0.0, 1);
}
r.theRobot.drive(0.0, 0.0);
}
});
}
/* DEPRACATED METHOD
public void DriveRotate(int rotateAngle) {
r.queueThread(new Runnable() {
public void run() {
r.gyro.reset();
double angleHeader = r.gyro.getAngle(); // Initial Angle
while (Math.abs(angleHeader - r.gyro.getAngle()) <= Math.abs(rotateAngle)) { // Rotating
r.theRobot.drive(0.0, rotateAngle * r.gyroRotationSpeed);
DriverStation.reportError(r.gyro.getAngle() + "", true);
Timer.delay(r.timerDelay);
}
}
});
}*/
Code:
// Gyro - Handles Trajectory Paths
public int GyroChannel = 0;
public Gyro gyro = new Gyro(GyroChannel);
Last edited by TeamMarcies : 29-01-2015 at 17:11. |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|