Please Help with FRC ADXRS450 Gyro Board SPI Slot

Hi, I recently posted about coding autonomous without a gyro or any sensors for this years randomized autonomous. Good news, I found a gyro yesterday in our toolbox while packing up for our comp tomorrow.
I’ve read the wpilib screensteps but it only shows example for command based. Our bot is Iterative. I’ve also looked at http://first.wpi.edu/FRC/roborio/release/docs/java/ which has a page dedicated to this particular sensor. But it only says the following:

edu.wpi.first.wpilibj
Class ADXRS450_Gyro
java.lang.Object
edu.wpi.first.wpilibj.SendableBase
edu.wpi.first.wpilibj.SensorBase
edu.wpi.first.wpilibj.GyroBase
edu.wpi.first.wpilibj.ADXRS450_Gyro

All Implemented Interfaces:
Gyro, PIDSource, Sendable

public class ADXRS450_Gyro
extends GyroBase
implements Gyro, PIDSource, Sendable

Use a rate gyro to return the robots heading relative to a starting position. The Gyro class tracks the robots heading based on the starting position. As the robot rotates the new heading is computed by integrating the rate of rotation returned by the sensor. When the class is instantiated, it does a short calibration routine where it samples the gyro while at rest to determine the default offset. This is subtracted from each sample to determine the heading.
This class is for the digital ADXRS450 gyro sensor that connects via SPI." and this

And then this near the end

Constructor Summary→Constructors→Constructor and Description
ADXRS450_Gyro()
Constructor.

ADXRS450_Gyro(SPI.Port port)
Constructor.

Constructor Detail→ADXRS450_Gyro

ADXRS450_Gyro
public ADXRS450_Gyro(SPI.Port port)
Constructor.
Parameters:
port - The SPI port that the gyro is connected to

This completely has me lost and I’ve no clue where to start any help is greatly appreciated. Thanks

Also I’ve looked at the FRC programming done right website that I found and I’m not sure if the example it gave is something I could use in our code. Here’s the link: http://frc-pdr.readthedocs.io/en/latest/control/gyro.html

That example code is pretty good in terms of code control. You should construct the Gyro with no arguments (the no-argument constructor is designed to work with that board installed into the standard RoboRIO SPI port). You can get the gyroAngle in that example code by calling gyro.getAngle().

Ahhhh ok. Could you hep me start off?

To create the gyro object:

ADXRS450_Gyro gyro = new ADXRS450_Gyro();

To get the angle (just an example):

double currentAngle = gyro.getAngle();

Sorry for the late reply our comp had started on the 29 and I completely forgot about my thread after comp.

I have both of those In my code but what I need help with now is actually getting the bot to turn to an angle. Here is the code I have now


package org.usfirst.frc.team5734.robot;

import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.Talon;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.Spark;
import edu.wpi.first.wpilibj.SpeedControllerGroup;
import edu.wpi.first.wpilibj.drive.DifferentialDrive;
import edu.wpi.first.wpilibj.ADXRS450_Gyro;


public class RobotRevisedWithGyro extends IterativeRobot {
	private DifferentialDrive m_myRobot;
	private Joystick m_Stick;
	private Spark leftIntake, rightIntake;
	private Spark arm;
	private SpeedControllerGroup intake;
	private Timer timer = new Timer();
	private ADXRS450_Gyro Gyro = new ADXRS450_Gyro();
			
	private static final String kDefaultAuto = "Default";
	private static final String RightAuto = "RightAuto";
	private static final String leftAuto = "LeftAuto";
	private String m_autoSelected;
	
	//the following is unused but is for driving straight on arcade drive
		//private static final double kAngleSetpoint = 0.0;
		//private static final double kP = 0.005; // proportional turning constant

	@Override
	public void robotInit() {
		m_myRobot = new DifferentialDrive(new Talon(0), new Talon(1));
		arm = new Spark(4);
		m_Stick = new Joystick(0);
			//the following is unused as of 3/24/18
				leftIntake = new Spark(2);
				rightIntake = new Spark(3);
				rightIntake.setInverted(true);
				intake = new SpeedControllerGroup(leftIntake, rightIntake);
		Gyro = new ADXRS450_Gyro();
	}

	@Override
	public void autonomousInit() {
		//this part figures out which side to put the cube 
		String gameData;
		gameData = DriverStation.getInstance().getGameSpecificMessage();
		//verify message
		if(gameData.length() > 0){
			//to select an auto assign the string m_autoSelected to the string of the desired auto
			if(gameData.charAt(0) == 'L'){
				//tells the selected auto to choose the left one
				m_autoSelected=leftAuto; // chooses Left switch Auto
			}else{
				m_autoSelected=RightAuto; // chooses right switch Auto
			}
		}
		//start timer
		timer.start(); 
		double start = timer.get();
	}
	
	@Override
	public void autonomousPeriodic() {	//this runs the selected auto. 
		switch (m_autoSelected) {
			//the autonomous chooser. it compares  m_autoSelected to each case, then runs the code after the semicolon 
			//if the strings match. to add a new auto, make a new string, and make a case for it here 
			// make sure to end each case with break. 
		
			//the following left auto code is for not using sensors at all
		case leftAuto:	//this is where the left switch auto code goes.
		        if (timer.get() < 0.5) {					
						m_myRobot.tankDrive(-0.5,0.0);			//drive forward half speed for .5 second
					
					}else if (timer.get() < (0.5+0.5)){  	
						m_myRobot.tankDrive(0.0,-0.5);			//turn left half speed for .5 seconds
					
					}else if (timer.get() < (0.5+0.5+2)){
						m_myRobot.tankDrive(-0.5,0.0);			//drive forward half speed for 2 seconds
					
					}else if (timer.get() < (0.5+0.5+2+.05)){
						m_myRobot.tankDrive(0.0,0.5);			// turn right half speed for .5 seconds
						
				}
				
			//the following right auto code is for not using sensors at all
			case RightAuto:	// this is where the right switch auto code goes
				if (timer.get() < 0.5) {
					m_myRobot.tankDrive(-0.5,0.0); // drive forwards half speed for .5 second
				}else{
					m_myRobot.tankDrive(0.0, 0.0); // stop robot
				}
			
				if (timer.get() < 1.0) {
					m_myRobot.tankDrive(0.0, 0.5); // turn right half speed for 1 second
				}else{
					m_myRobot.tankDrive(0.0, 0.0); // stop robot
				}
				
				
			case kDefaultAuto:
			default:	// Put default auto code here
				if (timer.get() < 5.0) {
					m_myRobot.tankDrive(-0.5,0.0); //drive forward half speed for 5 seconds
				}else{
					m_myRobot.tankDrive(0.0, 0.0); // stop robot
				}
				break;
		}
	}
	@Override
	public void teleopPeriodic() {	//teleop code goes here
		
	//the following is the unused straight driving arcade drive code
			//double turningValue = (kAngleSetpoint - Gyro.getAngle()) * kP;
				//// Invert the direction of the turn if we are going backwards
			//turningValue = Math.copySign(turningValue, m_Stick.getY());
			//m_myRobot.tankDrive(m_Stick.getY(), turningValue);
			
			
			m_myRobot.tankDrive(-m_Stick.getRawAxis(1), -m_Stick.getRawAxis(5));
			
			if(m_Stick.getRawAxis(3) > 0.2){	//right trigger
				arm.set(1);
			}else if(m_Stick.getRawAxis(2) > 0.2){	//left trigger
				arm.set(-0.5);
			}else{
				arm.set(0);
			}
			
			//The following is unused now as of 3/24/18. This was for the intakes wheels.
				if(m_Stick.getRawButton(5)){	//A
					intake.set(0.9);
				}else if(m_Stick.getRawButton(6)){	//B
					intake.set(-0.9);
				}else{
					intake.set(0);}
			}
	}

How do I go about starting to code to make the robot turn using the gyro.

Well I have the Getangle in it. It’s in the ADXRS450_Gyro.class and when I import wpilib…ADXRS450_Gyro it includes this right?