Can I create a new gyro object and call calibrate on that?

I can’t or don’t have the know how on how to calibrate a gyro object created in our drive subsystem on robot start up. I was wondering if i could create a new object in Robot and call calibrate on it due to there only being 1 gyro possible on the rio.

If the gyro is in your robot subsystem, create a new public method in the robot subsystem to re-calibrate that gyro, and then from the Robot code call this new method. You really want one object to point to the gyro at a time.

-Jim

so like

public void calibrateGyro() {
gyro.calibrate();
}
robotinit{

calibrateGyro ();
}

?

Almost. in robotinit {
it would be something like m_robot_drive.calibrateGyro();
}

where m_robot_drive is the driveSubsystem object. Several examples put the driveSubsystem in the RobotContainer.java, if you do, then you can do one of two things:

put a method in RobotContainer that calls m_robot_drive.calibrateGyro();

or, what I do is move driveSubsystem in Robot.java and pass it into RobotContainer.
https://github.com/JimWright4089/FIRSTRobots/tree/master/Code/RobotInABox/SimpleCommands/src/main/java/frc/robot

-Jim

Thanks, for others who read this make sure to put your object instead of void.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.