I have been having trouble getting my PIDcommand to work, it just keeps saying that “The constructor PIDCommand(PIDController, IntakeSubSys::getVelocity, double, DoubleConsumer, IntakeSubSys) is undefinedJava(134217858)”. I am trying to follow the example [here]allwpilib/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gyrodrivecommands/commands/TurnToAngle.java at main · wpilibsuite/allwpilib · GitHub I am not very experienced but I generally know how to figure stuff out as i go, but this one has stumped me. if i could get some help trouble shooting the problem that would be great.
I am not worried about the fact that I don’t need a PID on my intake. It is mainly an exercize so that i know how to do this for other things.
here is my subsystem:
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package frc.robot.subsystems;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.robot.Constants;
import frc.robot.Constants.intakeConstants;
import com.revrobotics.CANSparkMax;
import com.revrobotics.CANSparkLowLevel.MotorType;
import java.util.function.DoubleSupplier;
]
public class IntakeSubSys extends SubsystemBase {
CANSparkMax nSparkMax = new CANSparkMax(Constants.shooterConstants.kNeoCANPort, MotorType.kBrushless);
/** Creates a new IntakeSubSys. */
public IntakeSubSys() {
}
public void runAtSpeed(double velocity) {
nSparkMax.set(velocity);
}
public double getVelocity() {
//DoubleSupplier sup = () -> nSparkMax.getEncoder().getVelocity();
return nSparkMax.getEncoder().getVelocity();
}
}
and here is my PIDcommand:
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package frc.robot.commands;
import edu.wpi.first.math.controller.PIDController;
import edu.wpi.first.wpilibj2.command.PIDCommand;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.robot.Constants.intakeConstants;
import frc.robot.subsystems.IntakeSubSys;
// NOTE: Consider using this command inline, rather than writing a subclass. For more
// information, see:
// https://docs.wpilib.org/en/stable/docs/software/commandbased/convenience-features.html
public class IntakeSpeedCMD extends PIDCommand {
/** Creates a new IntakeSpeedCMD. */
public IntakeSpeedCMD(double targetSpeed, IntakeSubSys subsystem) {
super(
// The controller that the command will use
new PIDController(intakeConstants.kP, intakeConstants.kI, intakeConstants.kD),
// This should return the measurement
IntakeSubSys::getVelocity,
// This should return the setpoint (can also be a constant)
targetSpeed,
// This uses the output
output -> subsystem.runAtSpeed(output),
subsystem);
}
// Returns true when the command should end.
@Override
public boolean isFinished() {
return false;
}
}