PID Shooter system Error

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);

}

What is ShooterStart? Can you post the code for that?

Here is the ShooterStart command.

package frc.robot.commands;

import com.ctre.phoenix.motorcontrol.ControlMode;

import edu.wpi.first.wpilibj2.command.CommandBase;

import frc.robot.Constants;

import frc.robot.RobotContainer;

public class ShooterStart extends CommandBase {

double rpm = 0;

/**

 * Creates a new ShooterStart.

 */

public ShooterStart(double rpm) {

    addRequirements(RobotContainer.shooter);

    this.rpm = rpm;

    // Use addRequirements() here to declare subsystem dependencies.

}

// Called when the command is initially scheduled.

@Override

public void initialize() {

    RobotContainer.shooter.setRampRate(true);

    System.out.println("===================");

}

// Called every time the scheduler runs while the command is scheduled.

@Override

public void execute() {

// RobotContainer.shooter.set(ControlMode.PercentOutput, 0.57);

       RobotContainer.shooter.set(ControlMode.Velocity,rpm /10 /60 * Constants.SHOOTER_PULSES_PER_ROTATION);

    System.out.println("shooter," + rpm + "," + RobotContainer.shooter.getRPM());

    if (RobotContainer.shooter.getRPM() > 1500){

        RobotContainer.shooter.setRampRate(false);

    }

}

// Called once the command ends or is interrupted.

@Override

public void end(boolean interrupted) {

    RobotContainer.shooter.set(ControlMode.PercentOutput, 0);

}

// Returns true when the command should end.

@Override

public boolean isFinished() {

    return RobotContainer.shooter.getRPM() >= 7000;

}

}

You’re attempting to use the JoystickButton class from the old command framework with a command from the new command framework. This will not work.

Delete the WPILibOldCommands from your vendordeps folder and fix the imports accordingly.

That worked. Thank you so much!

Glad it worked!

In the future, please wrap your code blocks in triple backticks for proper formatting:

```java
your code here
```