Files
Robot-Essentials/src/main/java/frc4388/robot/subsystems/Drive.java
T

86 lines
2.6 KiB
Java
Raw Normal View History

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;
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();
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
/**
* Add your docs here.
*/
public Drive(WPI_TalonSRX leftFrontMotor, WPI_TalonSRX rightFrontMotor, WPI_TalonSRX leftBackMotor,
2020-03-28 22:45:44 -06:00
WPI_TalonSRX rightBackMotor, DifferentialDrive driveTrain, RobotGyro gyro) {
m_leftFrontMotor = leftFrontMotor;
m_rightFrontMotor = rightFrontMotor;
m_leftBackMotor = leftBackMotor;
m_rightBackMotor = rightBackMotor;
2020-03-28 22:45:44 -06:00
m_driveTrain = driveTrain;
m_gyro = gyro;
2019-08-07 18:48:49 -06:00
}
2020-03-27 12:20:22 -06:00
@Override
public void periodic() {
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();
}
}
/**
* Add your docs here.
*/
public void driveWithInput(double move, double steer) {
m_driveTrain.arcadeDrive(move, steer);
}
2020-03-27 12:20:22 -06:00
2020-03-28 22:45:44 -06:00
/**
* Add your docs here.
*/
public void tankDriveWithInput(double leftMove, double rightMove) {
m_leftFrontMotor.set(leftMove);
m_rightFrontMotor.set(rightMove);
}
/**
* Add your docs here.
*/
2020-03-27 12:20:22 -06:00
private void updateSmartDashboard() {
// Examples of the functionality of RobotGyro
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
}