I am new to Java programming, so bear with me. I have written a subsystem command for a PID shooter, which is all error free. I then tried to map the command to a button in RobotContainer, and I get an error where I map the command to a joystick button. The error says “The method whenActive(Command) in the type Trigger is not applicable for the arguments (ShooterStart)Java(67108979).” Any help would be appreciated! Code is copied below.
package frc.robot;
import edu.wpi.first.wpilibj.GenericHID;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.XboxController;
import edu.wpi.first.wpilibj.buttons.JoystickButton;
import frc.robot.commands.CG_Fire;
import frc.robot.commands.ShooterStart;
import frc.robot.commands.TankDrive;
import frc.robot.subsystems.DriveTrain;
import frc.robot.subsystems.Shooter;
import edu.wpi.first.wpilibj2.command.Command;
/**
-
This class is where the bulk of the robot should be declared. Since Command-based is a
-
“declarative” paradigm, very little robot logic should actually be handled in the {@link Robot}
-
periodic methods (other than the scheduler calls). Instead, the structure of the robot
-
(including subsystems, commands, and button mappings) should be declared here.
*/
public class RobotContainer {
// The robot’s subsystems and commands are defined here…
private final DriveTrain m_drivetrain = new DriveTrain();
public static Shooter shooter = new Shooter();
private final TankDrive m_autoCommand = new TankDrive(null, null, m_drivetrain);
private final ShooterStart shooterstart = new ShooterStart(5400);
private final Joystick rightJoystick = new Joystick(Constants.RIGHTJOYSTICK_ID);
/**
- The container for the robot. Contains subsystems, OI devices, and commands.
*/
public RobotContainer() {
// Configure the button bindings
configureButtonBindings();
}
/**
-
Use this method to define your button->command mappings. Buttons can be created by
-
instantiating a {@link GenericHID} or one of its subclasses ({@link
-
edu.wpi.first.wpilibj.Joystick} or {@link XboxController}), and then passing it to a
-
{@link edu.wpi.first.wpilibj2.command.button.JoystickButton}.
*/
private void configureButtonBindings() {
final JoystickButton rightTriggerButton = new JoystickButton(rightJoystick, 1);
rightTriggerButton.whenActive(shooterstart);
}