KOP Chassis Tutorial#

The KOP chassis is built with at least two motors and four wheels like this:

KOP Chassis

In this image, each side has three wheels powered by two motors. The motors allow the robot to move forward and backward, and by varying the speed between the two sides, you can make it turn.

You can program your KOP chassis in this method:

Software Installation:
SparkMax + NEO v1.1:

Software VendorDeps: REVLib

TalonSRX + CIM:

Software VendorDeps: Phoneix 5

TalonFX (kraken):

Software VendorDeps: Phoneix 6

Note

You don’t need to type out the entire name—just start typing, wait for the recommended words to appear, and hit Enter to fill it out and auto imported when needed.

OFFICAL DRIVE METHOD

Tip

It’s recommended to write your own drive method instead of using the official one, as it offers more flexibility and extensibility for your drive system.

Warning

Make sure to use either the official drive method or your own properly written one; otherwise, it could cause runtime errors.

import com.revrobotics.spark.SparkMax;
import com.revrobotics.spark.SparkBase.PersistMode;
import com.revrobotics.spark.SparkBase.ResetMode;
import com.revrobotics.spark.SparkLowLevel.MotorType;
import com.revrobotics.spark.config.SparkMaxConfig;
import com.revrobotics.spark.config.SparkBaseConfig.IdleMode;

import edu.wpi.first.wpilibj.drive.DifferentialDrive;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.robot.Constants.ChassisConstants;

//the file name must same with this
//              ^
//              |
public class NEOChassis extends SubsystemBase{
    public SparkMax LeftMotor, RightMotor; //Define the motors from the motor controller (define four motors if you use four)
    public SparkMaxConfig LeftConfig, RightConfig; //Define the configuration of the motors
    public DifferentialDrive drive;

    public NEOChassis(){
        //Initialize the item we just defined
        LeftMotor = new SparkMax(ChassisConstants.LeftMotorID, MotorType.kBrushless);//use kBrushless because the NEO v1.1 motor is the brushless motor
        RightMotor = new SparkMax(ChassisConstants.RightMotorID, MotorType.kBrushless);

        LeftConfig = new SparkMaxConfig();
        RightConfig = new SparkMaxConfig();


        LeftConfig
            .idleMode(IdleMode.kBrake)
            .inverted(false);
        RightConfig
            .idleMode(IdleMode.kBrake)
            .inverted(true); // You need to invert the motor; otherwise, it will spin in the wrong direction when driving straight.

        LeftMotor.configure(LeftConfig, ResetMode.kResetSafeParameters, PersistMode.kPersistParameters); //Apply the configurations
        RightMotor.configure(RightConfig, ResetMode.kResetSafeParameters, PersistMode.kPersistParameters);//Both choose yes for the less problems, it will factory reset the motor
        drive = new DifferentialDrive(LeftMotor, RightMotor);
    }

}

SELF WRITTEN

public class NEOChassis extends SubsystemBase{
    public SparkMax LeftMotor, RightMotor; //Define the motors from the motor controller (define four motors if you use four)
    public SparkMaxConfig LeftConfig, RightConfig; //Define the configuration of the motors

    public NEOChassis(){
        //Initialize the item we just defined
        LeftMotor = new SparkMax(ChassisConstants.LeftMotorID, MotorType.kBrushless);//use kBrushless because the NEO v1.1 motor is the brushless motor
        RightMotor = new SparkMax(ChassisConstants.RightMotorID, MotorType.kBrushless);

        LeftConfig = new SparkMaxConfig();
        RightConfig = new SparkMaxConfig();


        LeftConfig
            .idleMode(IdleMode.kBrake)
            .inverted(false);
        RightConfig
            .idleMode(IdleMode.kBrake)
            .inverted(true); // You need to invert the motor; otherwise, it will spin in the wrong direction when driving straight.

        LeftMotor.configure(LeftConfig, ResetMode.kResetSafeParameters, PersistMode.kPersistParameters); //Apply the configurations
        RightMotor.configure(RightConfig, ResetMode.kResetSafeParameters, PersistMode.kPersistParameters);//Both choose yes for the less problems, it will factory reset the motor
    }

    public void drive(double speed, double rotation){
        LeftMotor.set(speed+rotation);
        RightMotor.set(speed-rotation);
    }
}