So we are trying to set up a gyro for a simple 180 command however we aren’t even getting any response from the gyro we have the data up into SmartDashboard and when we turn the bot we get nothing. However the dashboard even when disabled does occasionally drift a pixel so if its on the dashboard during a match at the end it’ll end up about 90 degrees from starting point.
What gyro are you using and how is it wired? From your code it looks like it should be an old analog gyro hooked up to analog input 0… these are little-used in recent years, digital gyros like the ADXRS45x series are far more common.
Yea we have one of the Analog FRC Gyros since its all we got. And its in the little gyro port thingy on the rio. Since we just need the yaw for turning it’ll be plenty.
I also suggest: reading through the doc page for the ADXRS450_Gyro class, looking up any additional documentation for the gyro and its interface, and making sure your code compiles.
The errors you see mean exactly what they say: the compiler has found three places where gyro was accessed as a member of the class driveTrain, instead of accessing it through an object of type driveTrain.
I strongly recommend renaming the “driveTrain” class to “DriveTrain”, as the latter follows the standard Java class naming practice, which is to capitalize the first letter of class names. “driveTrain” is capitalized as though it is a variable name.
In the Robot class (Robot.java), you don’t have access to the instance of driveTrain that was constructed in RobotContainer. However, you’re only using it to call the calibrate() method on the gyro object. Instead, this call should probably go in the constructor of driveTrain.
Same goes for the SmartDashboard.putData(driveTrain.gyro) call – it would be best done in the driveTrain constructor. Because ADXRS450_Gyro implements Sendable, it’s only necessary to call putData on it once.
In the Rotate command, you have access to the instance of driveTrain, named m_driveTrain. Instead of trying to reference the driveTrain class, m_driveTrain.gyro.getAngle() will give you the result you’re looking for.
I also recommend taking a look at this page, and the example projects linked from it:
I have an issue where the displayed gyro doesn’t do anything. However, the turn command rotates about 5 times and stops and the displayed gyro moves about 5-10 degrees.