Can you use super() for MecanumControllerCommand

Hello, I need to know wether or not you can use the super() method as being used for a sub-class of MecanumControllerCommand.

Lets say you want to define a command.

public class FollowTrajectory extends MecannumControllerCommand {


So, could you use the super method in its constructor

public class FollowTrajectory extends MecannumControllerCommand {
public FollowTrajectory()
super(*Some sub-class parameters..*)

I will have a sub question under this.

Not only can you, but it’s mandatory. Java subclasses require a superclass constructor call. If you don’t do it yourself, it inserts a no-arg one for you. If no no-arg superclass constructor exists, it fails to compile.


Ok, thanks.

This is my sub response:
I have been gettings errors in relation to the MecannumControllerCommand class. Under MecanumControllerCommand (WPILib API 2021.2.2), I am using the 2nd overriden constructor. For the 3rd and second to last paramters, I am getting this compiler error.
The target type of this expression must be a functional interface
I am unsure why? I am going to need some help on this.

That means that you basically pass in a method that returns a value or accepts a value. What does your code currently look like?

This is what it looks like

public FollowTrajectory() {






           new PIDController(AutoConstants.P_X_CONTROLLER, 0, 0),

           new PIDController(AutoConstants.P_Y_CONTROLLER, 0, 0),

           new ProfiledPIDController(AutoConstants.P_THETA_CONTROLLER, 0, 0, AutoConstants .CONSTRAINTS),


           RobotContainer.train.frontLeftController.setPID(DriveConstants.P_FRONT_LEFT_VEL, 0, 0),

           RobotContainer.train.backLeftController.setPID(DriveConstants.P_BACK_LEFT_VEL, 0, 0),

           RobotContainer.train.frontRightController.setPID(DriveConstants.P_FRONT_RIGHT_VEL, 0, 0),

           RobotContainer.train.backRightController.setPID(DriveConstants.P_BACK_RIGHT_VEL, 0, 0),





Here is also the setCurrentSpeeds and setSpeeds methods

public MecanumDriveWheelSpeeds getCurrentWheelSpeeds() {

   return new MecanumDriveWheelSpeeds(






public void setSpeeds() {

   final double frontLeftFeedForward = DriveConstants.FEED_FORWARD.calculate(wheelSpeeds.frontLeftMetersPerSecond);

   final double frontRightFeedForward = DriveConstants.FEED_FORWARD.calculate(wheelSpeeds.frontRightMetersPerSecond);

   final double backLeftFeedForward = DriveConstants.FEED_FORWARD.calculate(wheelSpeeds.rearLeftMetersPerSecond);

   final double backRightFeedForward = DriveConstants.FEED_FORWARD.calculate(wheelSpeeds.rearRightMetersPerSecond);

   final double frontlefVoltage = frontLeftController.calculate(lefEncoder1.getRate(), wheelSpeeds.frontLeftMetersPerSecond);

   final double frontrigVoltage = frontRightController.calculate(rigEncoder1.getRate(), wheelSpeeds.frontRightMetersPerSecond);

   final double backlefVoltage = backLeftController.calculate(lefEncoder2.getRate(), wheelSpeeds.rearLeftMetersPerSecond);

   final double backrigVoltage = backRightController.calculate(rigEncoder2.getRate(), wheelSpeeds.rearRightMetersPerSecond);

   lefTalonSRX.setVoltage(frontlefVoltage + frontLeftFeedForward);

   lefTalonSRX2.setVoltage(frontrigVoltage + frontRightFeedForward);

   rigTalonSRX.setVoltage(backlefVoltage + backLeftFeedForward);

   rigTalonSRX2.setVoltage(backrigVoltage + backRightFeedForward);


Third to last in that super call should be a method that returns a MecanumControllerWheelSppeds
And second to last should be a method that accepts a MecanumControllerWheelVoltages.

I know that, I forgot to replace that. but that still does not fix the problem

See my edit

No, it still does not seem to fix the problem. Here is another couple errors that I have now.

The method getCurrentWheelSpeeds() is undefined for the type FollowTrajectoryJava(67108964)
The target type of this expression must be a functional interfaceJava(553648781)

Should be Robot.train::getCurrentWheelSpeeds

Okay, that works, but this but the 2nd to last gives me an error.

RobotContainer.train::setSpeeds(MecanumDriveMotorVoltages volts)
The target type of this expression must be a functional interfaceJava(553648781)

If you haven’t changed that method from when you posted it, it needs an input parameter for wheelSpeeds.

For what method

SetSpeeds. It’s not defined to have the input list you’re giving it.


Ok, but the super implintaition of this is giving me an error.
The constructor MecanumControllerCommand(Trajectory, Supplier<Pose2d>, SimpleMotorFeedforward, MecanumDriveKinematics, PIDController, PIDController, ProfiledPIDController, double, void, void, void, void, MecanumDriveWheelSpeeds, void, DriveTrain) is undefinedJava(134217858)

Can you post your code to someplace like GitHub? I’m having trouble keeping track of what it looks like now.

OK thats fine