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.InvertType;
|
|
|
|
|
import com.ctre.phoenix.motorcontrol.NeutralMode;
|
|
|
|
|
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-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;
|
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-27 08:54:56 -06:00
|
|
|
public WPI_TalonSRX m_leftFrontMotor = new WPI_TalonSRX(DriveConstants.DRIVE_LEFT_FRONT_CAN_ID);
|
|
|
|
|
public WPI_TalonSRX m_rightFrontMotor = new WPI_TalonSRX(DriveConstants.DRIVE_RIGHT_FRONT_CAN_ID);
|
|
|
|
|
public WPI_TalonSRX m_leftBackMotor = new WPI_TalonSRX(DriveConstants.DRIVE_LEFT_BACK_CAN_ID);
|
|
|
|
|
public WPI_TalonSRX m_rightBackMotor = new WPI_TalonSRX(DriveConstants.DRIVE_RIGHT_BACK_CAN_ID);
|
|
|
|
|
public DifferentialDrive m_driveTrain = new DifferentialDrive(m_leftFrontMotor, m_rightFrontMotor);
|
|
|
|
|
|
2019-08-07 18:48:49 -06:00
|
|
|
|
|
|
|
|
|
2020-01-05 20:27:01 -07:00
|
|
|
/**
|
|
|
|
|
* Add your docs here.
|
|
|
|
|
*/
|
2019-08-07 18:48:49 -06:00
|
|
|
public Drive(){
|
|
|
|
|
/* factory default values */
|
|
|
|
|
m_leftFrontMotor.configFactoryDefault();
|
|
|
|
|
m_rightFrontMotor.configFactoryDefault();
|
|
|
|
|
m_leftBackMotor.configFactoryDefault();
|
|
|
|
|
m_rightBackMotor.configFactoryDefault();
|
|
|
|
|
|
|
|
|
|
/* set back motors as followers */
|
|
|
|
|
m_leftBackMotor.follow(m_leftFrontMotor);
|
|
|
|
|
m_rightBackMotor.follow(m_rightFrontMotor);
|
|
|
|
|
|
|
|
|
|
/* set neutral mode */
|
|
|
|
|
m_leftFrontMotor.setNeutralMode(NeutralMode.Brake);
|
|
|
|
|
m_rightFrontMotor.setNeutralMode(NeutralMode.Brake);
|
|
|
|
|
m_leftFrontMotor.setNeutralMode(NeutralMode.Brake);
|
|
|
|
|
m_rightFrontMotor.setNeutralMode(NeutralMode.Brake);
|
|
|
|
|
|
|
|
|
|
/* flip input so forward becomes back, etc */
|
|
|
|
|
m_leftFrontMotor.setInverted(false);
|
|
|
|
|
m_rightFrontMotor.setInverted(false);
|
|
|
|
|
m_leftBackMotor.setInverted(InvertType.FollowMaster);
|
|
|
|
|
m_rightBackMotor.setInverted(InvertType.FollowMaster);
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-05 20:27:01 -07:00
|
|
|
/**
|
|
|
|
|
* Add your docs here.
|
|
|
|
|
*/
|
2019-12-20 12:53:02 -07:00
|
|
|
public void driveWithInput(double move, double steer){
|
|
|
|
|
m_driveTrain.arcadeDrive(move, steer);
|
|
|
|
|
}
|
2019-08-04 15:58:48 -06:00
|
|
|
}
|