Move to Position not reversing

So i have a command with the SparkMax inbuilt encoder to moveToSetPoint but it doesnt go in reverse. It wouldnt be too much of an issue but it need it to reverse for auton.

public class MoveToPosition extends CommandBase {
// Create an object for the Manipulator
private final Manipulator m_manipulator;

// Create DoubleSuppliers for the setpoint and power
private final DoubleSupplier m_setpoint, m_power;

/** Creates a new MoveToPosition. */
public MoveToPosition(Manipulator manipulator, DoubleSupplier setpoint, DoubleSupplier power) {
// Use the Manipulator subsystem to gain access to its commands
m_manipulator = manipulator;

// Set the setpoint and power
m_setpoint = setpoint;
m_power = power;

// Use addRequirements() here to declare subsystem dependencies.
addRequirements(manipulator);
}

// Called when the command is initially scheduled.
@Override
public void initialize() {
// Reset the encoder
m_manipulator.resetliftEncoder();
}

// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {
// Call the moveToSetpoint method
m_manipulator.moveToSetpoint(m_setpoint.getAsDouble(), m_power.getAsDouble());
}

// Called once the command ends or is interrupted.
@Override
public void end(boolean interrupted) {
m_manipulator.stopArm();
}

// Returns true when the command should end.
@Override
public boolean isFinished() {
return false;
}
}

We’d also need to know your PID’s configuration. I’m also curious what your m_power variable is being used for.

PID is untuned since its just a basic wench mechanism that doesnt need to be too accurate. and the m_power is unused right now but it will be basically speed so like

auton blah (
m_spark, m_setpoint, m_power,

this is an implement i have actually

m_manipulator.moveToSetpoint(130, 0.5);

130 = setpoint
.5 = power

ok, but why are you specifying both setpoint and power together? Setting a speed and using PID are generally two exclusive actions. You can switch between PID and speeds, but you can’t use them together. The whole point of PID is that it controls the speed of your output automatically using your PID(F) Constants.

Also, what about your max and min outputs? Basically could you post at least your entire subsystem class. Preferably you’d post your entire code to like a GitHub Repo so we could view the code in it entirety to try and track down issues.

heres the git https://github.com/frc5517/RapidReact

and i dont really know much about the PID so someone who know more about that helped with that (basically did it all because time limits) so I basically just implemented it as needed and the power is the speed of which it goes to setpoint so at the moment unless if i removed it there was a button on Operator that used the lift full speed but before the match we needed to set the lift to a certain height for autonomous and I did that as a spare button on operator but half speed for safety

So your moveToSetpoint method isn’t using PID at all. Just moving at the given speed until it is greater than or equal to your setpoint, then stopping.

You’d use the setReference method of your PID Controller object liftPID to tell the SparkMAX to go to a setpoint.

so I would do something like liftPID.setReference(setpoint, power);??

The SparkMaxPIDController JavaDocs
https://codedocs.revrobotics.com/java/com/revrobotics/sparkmaxpidcontroller#setReference(double,com.revrobotics.CANSparkMax.ControlType)

The REV Spark Max Position Closed-Loop Control Example

so this
image

I would simulate it but the Spark doesn’t wanna work simulated

yep, that line would engage the PID controller to go to a position of 10.

so it would also reverse then?

Provided your PID output range is set to allow reversed outputs (which it was according to the Git Repo) it should. Of course your results will depend on your PID tuning.

Alright thanks I unfortunately wont be able to test it until the morning though.

So will i have to setup the PIDF variables?

Yep, as it is you don’t have any gain set for any of the PIDF Components.

You generally start with increasing the Proportional gain (kP) until you are either happy with the result or you start getting oscillations, then you add Derivative (kD) to smooth out the Oscillations to get to a quick steady state, and finally you add Integral (kI) to help deal with if the steady state isn’t quite at your setpoint.

Both of our Position PIDs this year worked well enough with only Proportional control, so we didn’t bother adding any Integral or Derivative gain (leaving them at zero).

Alright yea hopefully it isnt too long a deal since I dont really know much bout PID so itll be my first attempt at tuning

I personally found much of the Wikipedia article pretty good at explaining many of the concepts at a reasonably entry level.

The getReference setup is doing nothing.