You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 7, 2024. It is now read-only.
When simulating this code in WPILib, m_motorA is correctly updated in simulation while m_motorB does not get updated. Digging into the SparkMaxSimProfile.class code, it does the following when the simulation runs:
public void run() {
double period = this.getPeriod();
this._vel = this._spark.getEncoder().getVelocity();
double position = this._spark.getEncoder().getPosition();
double posFactor = this._spark.getEncoder().getPositionConversionFactor();
this._spark.getEncoder().setPosition(position + this._vel * period / 60000.0D * posFactor);
}
It doesn't look like setting a position setpoint is correctly updating the SparkMax in simulation. Will this be fixed in the 2023 RevLib? Another thing that would be helpful would be an API call in SparkMaxPIDController to get the calcuated PID output so that we can take the output and simulate the results manually.
The text was updated successfully, but these errors were encountered:
jonathandao0
changed the title
RevPhysicsSim Position Control doesn
RevPhysicsSim Position Control doesn't work
Sep 11, 2022
I don't believe the math that's used here to set the encoder position is correct at all. Where is the "60000.0" coming from?
You should just be doing this._spark.getEncoder().setPosition((position + this._vel * period) * posFactor).
Given this code example:
When simulating this code in WPILib, m_motorA is correctly updated in simulation while m_motorB does not get updated. Digging into the SparkMaxSimProfile.class code, it does the following when the simulation runs:
It doesn't look like setting a position setpoint is correctly updating the SparkMax in simulation. Will this be fixed in the 2023 RevLib? Another thing that would be helpful would be an API call in SparkMaxPIDController to get the calcuated PID output so that we can take the output and simulate the results manually.
The text was updated successfully, but these errors were encountered: