Class TalonSRXBrushedTankDrive

  • All Implemented Interfaces:
    edu.wpi.first.util.sendable.Sendable, edu.wpi.first.wpilibj2.command.Subsystem

    public class TalonSRXBrushedTankDrive
    extends TankDrive
    A TankDrive implementation using Talon SRX motor controllers to control brushed motors. Do not use this under any circumstances with brushless motors; this is designed for CIM, 775, Redline and other brushed motors only.
    • Field Detail

      • DEFAULT_RAMP_RATE

        public static final double DEFAULT_RAMP_RATE
        The default ramp rate, meaning the motors will take this long (in seconds) to accelerate to full speed to prevent damage to the motor or subsystems. In drivetrains, this also helps to prevent flip-overs from sudden acceleration.
        See Also:
        Constant Field Values
      • DEFAULT_CURRENT_LIMIT

        public static final int DEFAULT_CURRENT_LIMIT
        Limit the motors to the following AMPS to prevent brownouts, trips, or too much power being drawn when it really isn't needed. This is a nice safety feature.
        See Also:
        Constant Field Values
    • Constructor Detail

      • TalonSRXBrushedTankDrive

        public TalonSRXBrushedTankDrive​(CANMotorConfig leftLeaderConfig,
                                        CANMotorConfig rightLeaderConfig,
                                        CANMotorConfig leftFollowerConfig,
                                        CANMotorConfig rightFollowerConfig,
                                        edu.wpi.first.wpilibj.Encoder leftEncoder,
                                        edu.wpi.first.wpilibj.Encoder rightEncoder)
        Creates a new drivetrain from the provided motor and optionally provided encoders
        Parameters:
        leftLeaderConfig - configuration for the left leader motor controller
        rightLeaderConfig - configuration for the right leader motor controller
        leftFollowerConfig - configuration for the left follower motor controller
        rightFollowerConfig - configuration for the right follower motor controller
        leftEncoder - the encoder to be associated with the left side; must be in-phase where forward is positive
        rightEncoder - the encoder to be associated with the right side; must be in-phase where forward is positive
    • Method Detail

      • setAccelerationRampRate

        public void setAccelerationRampRate​(double maxAccRate)
        Description copied from class: TankDrive
        Sets the ramp rate for open loop control modes.

        This is the maximum rate at which the motor controller's output is allowed to change.

        Specified by:
        setAccelerationRampRate in class TankDrive
        Parameters:
        maxAccRate - Time in seconds to go from 0 to full throttle.
      • setCurrentLimit

        public void setCurrentLimit​(int currentInAmps)
        Description copied from class: TankDrive
        Sets the current limit in Amps.

        The motor controller will reduce the controller voltage output to avoid surpassing this limit. This limit is enabled by default and used for brushless only. This limit is highly recommended when brushless motors, but it also helps to avoid brownouts in any situation.

        Specified by:
        setCurrentLimit in class TankDrive
        Parameters:
        currentInAmps - The current limit in Amps.
      • setSidePIDGains

        public void setSidePIDGains​(PIDGains gains)
        Description copied from class: TankDrive
        Set the PID controller gains for both sides of the tank drive. Note that the actual effect will be determined by the motors used (Neos + Spark Max's have a lot more control because of their built-in encoder) but it tries to be fairly equal enough for a drivetrain to work.
        Specified by:
        setSidePIDGains in class TankDrive
        Parameters:
        gains - desired PID gains
      • resetOdometry

        public void resetOdometry()
        Description copied from class: TankDrive
        Reset the encoders and gyroscope readings.
        Specified by:
        resetOdometry in class TankDrive