2019-08-04 15:58:48 -06:00
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
|
|
|
|
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
|
|
|
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
|
|
|
|
/* the project. */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
package frc4388.robot.subsystems;
|
|
|
|
|
|
2019-08-07 18:48:49 -06:00
|
|
|
import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX;
|
2020-01-05 18:59:50 -07:00
|
|
|
|
2019-08-07 18:48:49 -06:00
|
|
|
import edu.wpi.first.wpilibj.drive.DifferentialDrive;
|
2020-03-27 12:20:22 -06:00
|
|
|
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
|
2020-01-05 18:59:50 -07:00
|
|
|
import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
2020-01-05 17:35:52 -07:00
|
|
|
|
|
|
|
|
import frc4388.robot.Constants.DriveConstants;
|
2020-03-27 11:36:35 -06:00
|
|
|
import frc4388.utility.RobotGyro;
|
2020-03-27 12:20:22 -06:00
|
|
|
import frc4388.utility.RobotTime;
|
2019-08-04 15:58:48 -06:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add your docs here.
|
|
|
|
|
*/
|
2020-01-05 18:59:50 -07:00
|
|
|
public class Drive extends SubsystemBase {
|
2019-08-04 15:58:48 -06:00
|
|
|
// Put methods for controlling this subsystem
|
|
|
|
|
// here. Call these from Commands.
|
|
|
|
|
|
2020-03-28 21:42:08 -06:00
|
|
|
private RobotTime m_robotTime = RobotTime.getInstance();
|
|
|
|
|
|
2020-03-28 21:27:15 -06:00
|
|
|
private WPI_TalonSRX m_leftFrontMotor;
|
|
|
|
|
private WPI_TalonSRX m_rightFrontMotor;
|
|
|
|
|
private WPI_TalonSRX m_leftBackMotor;
|
|
|
|
|
private WPI_TalonSRX m_rightBackMotor;
|
|
|
|
|
private DifferentialDrive m_driveTrain;
|
|
|
|
|
private RobotGyro m_gyro;
|
2019-08-07 18:48:49 -06:00
|
|
|
|
2020-01-05 20:27:01 -07:00
|
|
|
/**
|
|
|
|
|
* Add your docs here.
|
|
|
|
|
*/
|
2020-03-28 21:27:15 -06:00
|
|
|
public Drive(WPI_TalonSRX leftFrontMotor, WPI_TalonSRX rightFrontMotor, WPI_TalonSRX leftBackMotor,
|
|
|
|
|
WPI_TalonSRX rightBackMotor, RobotGyro gyro) {
|
|
|
|
|
|
|
|
|
|
m_leftFrontMotor = leftFrontMotor;
|
|
|
|
|
m_rightFrontMotor = rightFrontMotor;
|
|
|
|
|
m_leftBackMotor = leftBackMotor;
|
|
|
|
|
m_rightBackMotor = rightBackMotor;
|
|
|
|
|
m_driveTrain = new DifferentialDrive(m_leftFrontMotor, m_rightFrontMotor);
|
|
|
|
|
m_gyro = gyro;
|
2019-08-07 18:48:49 -06:00
|
|
|
}
|
|
|
|
|
|
2020-03-27 12:20:22 -06:00
|
|
|
@Override
|
|
|
|
|
public void periodic() {
|
2020-03-27 12:32:46 -06:00
|
|
|
m_gyro.updatePigeonDeltas();
|
|
|
|
|
|
2020-03-28 21:42:08 -06:00
|
|
|
if (m_robotTime.m_frameNumber % DriveConstants.SMARTDASHBOARD_UPDATE_FRAME == 0) {
|
2020-03-27 12:20:22 -06:00
|
|
|
updateSmartDashboard();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-05 20:27:01 -07:00
|
|
|
/**
|
|
|
|
|
* Add your docs here.
|
|
|
|
|
*/
|
2020-03-28 21:27:15 -06:00
|
|
|
public void driveWithInput(double move, double steer) {
|
2019-12-20 12:53:02 -07:00
|
|
|
m_driveTrain.arcadeDrive(move, steer);
|
|
|
|
|
}
|
2020-03-27 12:20:22 -06:00
|
|
|
|
2020-03-28 21:27:15 -06:00
|
|
|
/**
|
|
|
|
|
* Add your docs here.
|
|
|
|
|
*/
|
2020-03-27 12:20:22 -06:00
|
|
|
private void updateSmartDashboard() {
|
|
|
|
|
|
|
|
|
|
// Examples of the functionality of RobotGyro
|
2020-03-28 21:27:15 -06:00
|
|
|
SmartDashboard.putBoolean("Is Gyro a Pigeon?", m_gyro.m_isGyroAPigeon);
|
|
|
|
|
SmartDashboard.putNumber("Turn Rate", m_gyro.getRate());
|
|
|
|
|
SmartDashboard.putNumber("Gyro Pitch", m_gyro.getPitch());
|
|
|
|
|
SmartDashboard.putData(m_gyro);
|
2020-03-27 12:20:22 -06:00
|
|
|
}
|
2019-08-04 15:58:48 -06:00
|
|
|
}
|