Class DriveBase

java.lang.Object
edu.wpi.first.wpilibj2.command.SubsystemBase
frc.robot.subsystems.DriveBase
All Implemented Interfaces:
edu.wpi.first.wpilibj.Sendable, edu.wpi.first.wpilibj2.command.Subsystem

public class DriveBase
extends edu.wpi.first.wpilibj2.command.SubsystemBase
The drive base of the robot. Includes all drive train motor controllers as well as sensors such as gyros and encoders, and can use PID to set its motor speeds.
  • Field Summary

    Fields 
    Modifier and Type Field Description
    edu.wpi.first.wpilibj.drive.DifferentialDrive cheesyDrive  
    edu.wpi.first.wpilibj.ADXRS450_Gyro gyro  
    com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX leftFrontFollowerTalon  
    com.ctre.phoenix.motorcontrol.can.WPI_VictorSPX leftFrontFollowerVictor  
    com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX leftMiddleMaster  
    double leftMotorTicks  
    com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX leftRearFollowerTalon  
    com.ctre.phoenix.motorcontrol.can.WPI_VictorSPX leftRearFollowerVictor  
    com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX rightFrontFollowerTalon  
    com.ctre.phoenix.motorcontrol.can.WPI_VictorSPX rightFrontFollowerVictor  
    com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX rightMiddleMaster  
    double rightMotorTicks  
    com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX rightRearFollowerTalon  
    com.ctre.phoenix.motorcontrol.can.WPI_VictorSPX rightRearFollowerVictor  
  • Constructor Summary

    Constructors 
    Constructor Description
    DriveBase()  
  • Method Summary

    Modifier and Type Method Description
    double getGyroAngle()  
    double getLeftPosition()  
    double getRightPosition()  
    void initDefaultCommand()  
    void setMotors​(double left, double right)
    Sets drive train motors.
    void stopMotors()
    Sets drive train motors to zero, effectively stopping the bot.
    void zeroEncoderPosition()
    Resets the reference point used to calculate distance traveled.
    void zeroGyroAngle()
    Sets the gyro angle to zero.

    Methods inherited from class edu.wpi.first.wpilibj2.command.SubsystemBase

    addChild, getName, getSubsystem, initSendable, setName, setSubsystem

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface edu.wpi.first.wpilibj.Sendable

    addChild, setName, setName, setName

    Methods inherited from interface edu.wpi.first.wpilibj2.command.Subsystem

    getCurrentCommand, getDefaultCommand, periodic, register, setDefaultCommand, simulationPeriodic
  • Field Details

  • Constructor Details

  • Method Details

    • initDefaultCommand

      public void initDefaultCommand()
    • setMotors

      public void setMotors​(double left, double right)
      Sets drive train motors.
      Parameters:
      left - Left side motors' velocity (-1 to 1)
      right - Right side motors' velocity (-1 to 1)
    • stopMotors

      public void stopMotors()
      Sets drive train motors to zero, effectively stopping the bot.
    • getLeftPosition

      public double getLeftPosition()
      Returns:
      Left side position in ticks.
    • getRightPosition

      public double getRightPosition()
      Returns:
      Right side position in ticks.
    • getGyroAngle

      public double getGyroAngle()
      Returns:
      Angle at which the robot is positioned in degrees
    • zeroEncoderPosition

      public void zeroEncoderPosition()
      Resets the reference point used to calculate distance traveled. Does not physically change the encoder value.
    • zeroGyroAngle

      public void zeroGyroAngle()
      Sets the gyro angle to zero.