Issue with default command - "constructor is not defined"

We cannot figure out the correct modifier to put in with the subsystem. Not sure how to “define” the constructor in this situation.


Assuming you have already created a TankDrive.java command you need to add a constructor to it. Here is an example of that. I don’t know how you are calling the drive command so you may need to change the code to fit with your project.

public class TankDrive extends Command {
    private final DriveTrain m_driveTrain;
    private final Joystick m_joystick;

   //this is the constructor
    public TankDrive(DriveTrain driveTrain, Joystick joystick) {
        m_driveTrain = driveTrain;
        m_joystick = joystick;
        addRequirements(m_driveTrain);
    }

    @Override
    public void execute() {
        m_drivetrain.tankDrive(m_Joystick.getY(), m_Joystick.getX(), m_drivetrain));
    }

    // Other methods like isFinished()
}

Alternatively, if the command is just calling the Drivetrain’s drive method you can use a run command like this.

m_drivetrain.setDefaultCommand(
        new RunCommand(
            () ->
                m_drivetrain.tankDrive(m_Joystick.getY(), m_Joystick.getX(), m_drivetrain));