Skip to content

Commit

Permalink
Added back 2nd order kinematics to angle motors and enabled it within…
Browse files Browse the repository at this point in the history
… the SparkMaxSwerve.setReference function.

Signed-off-by: thenetworkgrinch <[email protected]>
  • Loading branch information
thenetworkgrinch committed Mar 27, 2023
1 parent 1dd0795 commit fb4556f
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/main/java/swervelib/motors/SparkMaxSwerve.java
Original file line number Diff line number Diff line change
Expand Up @@ -293,20 +293,31 @@ public void set(double percentOutput)
@Override
public void setReference(double setpoint, double feedforward)
{
boolean possibleBurnOutIssue = true;
int pidSlot =
isDriveMotor ? SparkMAX_slotIdx.Velocity.ordinal() : SparkMAX_slotIdx.Position.ordinal();
if (isDriveMotor)
if (possibleBurnOutIssue)
{
pid.setReference(
setpoint,
ControlType.kVelocity,
isDriveMotor ? ControlType.kVelocity : ControlType.kPosition,
pidSlot,
feedforward);
} else
{
pid.setReference(
setpoint,
ControlType.kPosition);
if (isDriveMotor)
{
pid.setReference(
setpoint,
ControlType.kVelocity,
pidSlot,
feedforward);
} else
{
pid.setReference(
setpoint,
ControlType.kPosition);
}
}
}

Expand Down

0 comments on commit fb4556f

Please sign in to comment.