X-Git-Url: http://challenge-bot.com/repos/?a=blobdiff_plain;f=src%2Forg%2Fusfirst%2Ffrc%2Fteam3501%2Frobot%2FRobot.java;h=425e6704ae5e2170bcefe31c57d7899047c86ea4;hb=1e039ebdf71f746dd2fb21f7bcf811d4d80ac3fa;hp=8d69370ed8702c5db2ab20d5105bfe1fc7f120c0;hpb=191c43e3ebd037ac152f1470c79c52f7b7627a89;p=3501%2Fstronghold-2016 diff --git a/src/org/usfirst/frc/team3501/robot/Robot.java b/src/org/usfirst/frc/team3501/robot/Robot.java index 8d69370e..425e6704 100644 --- a/src/org/usfirst/frc/team3501/robot/Robot.java +++ b/src/org/usfirst/frc/team3501/robot/Robot.java @@ -1,5 +1,6 @@ package org.usfirst.frc.team3501.robot; +import org.usfirst.frc.team3501.robot.AnotherGyroClass.Rotation; import org.usfirst.frc.team3501.robot.Constants.Defense; import org.usfirst.frc.team3501.robot.subsystems.DefenseArm; import org.usfirst.frc.team3501.robot.subsystems.DriveTrain; @@ -19,6 +20,7 @@ public class Robot extends IterativeRobot { public static Shooter shooter; public static Scaler scaler; + double then; public static IntakeArm intakeArm; public static DefenseArm defenseArm; @@ -29,17 +31,19 @@ public class Robot extends IterativeRobot { positionFourDefense, positionFiveDefense; // Gyro stuff - private final static double NANOSECONDS_PER_SECOND = 1000000000; short rawValue; public GyroClass gyro; + double now; double degreesIncreased; double degrees; + Rotation rotation; + @Override public void robotInit() { // driveTrain = new DriveTrain(); - gyro = new GyroClass(I2C.Port.kOnboard, (byte) 0x68); + gyro = new GyroClass(I2C.Port.kOnboard, gyro.ITG3200_ADDRESS_AD0_LOW); // oi = new OI(); shooter = new Shooter(); @@ -151,6 +155,39 @@ public class Robot extends IterativeRobot { @Override public void teleopPeriodic() { Scheduler.getInstance().run(); + + } + + public double getZAxisDegreesPerSeconds() { + double rawValue = (double) gyro.getRotationZ() / 14.375; + return rawValue; + } + + public void initializeGyro() { + degrees = 0; + then = System.nanoTime() / 1000000000.0; + gyro.reset(); + gyro.initialize(); + System.out.println("Testing Gyro Init"); + } + + public void addZAxisDegrees() { + double degreesRead = getZAxisDegreesPerSeconds(); + now = System.nanoTime(); + now = now / (1000000000.0); + double differenceInTime = now - then; + then = now; + degreesIncreased = differenceInTime * degreesRead; + + // 0.0 = register + // + 1.0 is the formula constant + // + degrees += degreesIncreased; + + } + + public double getDegrees() { + return degrees; } }