SpeedMotor converted to MotorController 2022

I’m trying to import our robot’s framework lib and I got into some issues with the new MotorController convention…
Where pidWrite() go to?
SpeedMotor Once inherited from PID or something like that…
I need a method that will be called before each PID write in any motor controller

1 Like

Maybe this wrapper class can implement that functionality: PIDMotorController (WPILib API 2022.1.1-rc-1-2-g22c4da1)

It does not exist for me :frowning:
I downloaded the “2022.1.1-rc-1” version so I could rewrite it as needed before the official release…/

But you are getting MotorController ? I am just asking to make sure you’ve updated the project to 2022. Sometime their are pains getting everything working.

I haven’t used PIDMotorController but since it is in the api on that rc it should be available to import. Make sure it is getting imported from pidwrappers I guess.

IDK why,
I think something went wrong creating the project…
the REV vendor library also give me some troubles:

The supplied phased action failed with an exception.
Could not resolve all dependencies for configuration ‘:compileClasspath’.
Using insecure protocols with repositories, without explicit opt-in, is unsupported. Switch Maven repository ‘WPI3f48eb8c-50fe-43a6-9cb7-44c86353c4cb_0Release(http://www.revrobotics.com/content/sw/max/sdk/maven/)’ to redirect to a secure protocol (like HTTPS) or allow insecure protocols. See UrlArtifactRepository - Gradle DSL Version 7.3.3 for more details.

Going forwards, the SPARK MAX API has been replaced by REVLib: https://github.com/REVrobotics/REV-Software-Binaries/releases/tag/revlib-2022.0.0

Note that there will be a new version of REVLib coming out within the next couple of days.

1 Like

PIDSource and PIDOutput were deprecated in 2020, and they’ll be removed in 2023. Just call the relevant getter directly and pass it into the PIDController, like so:

import com.revrobotics.CANSparkMax;
import edu.wpi.first.math.PIDController;
import edu.wpi.first.wpilibj.TimedRobot;
import edu.wpi.first.wpilibj.Encoder;

public class Robot extends TimedRobot {
  private Encoder encoder = new Encoder(1, 2);
  private static final kDistancePerPulse = ...;

  private CANSparkMax motor = new CANSparkMax(0);

  private static final kP = ...;
  private PIDController controller = new PIDController(kP, 0.0, 0.0, 0.01);

  public Robot() {

    // Run controller every 10 ms
    addPeriodic(() -> {
    }, 0.01);

  public teleopPeriodic() {
    // Set the controller setpoint here

Don’t use those. They’ll be deprecated before final release:

Those wrapper classes are only used by the old command-based vendordep to make RobotBuilder old command-based output easier to implement, and they’ll be removed along with old PIDController and old command-based in 2023. We’re only keeping the old PIDController around because updating old command-based to the new PIDController would be wasted effort.


This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.