Skip to content

Commit

Permalink
override configure method to inject conversion factors into canencoder
Browse files Browse the repository at this point in the history
  • Loading branch information
ktvuwhs committed Jan 7, 2025
1 parent 52942b1 commit cf2d7eb
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.revrobotics.spark.SparkBase;
import com.revrobotics.REVLibError;
import com.revrobotics.spark.SparkLowLevel.MotorType;
import com.revrobotics.spark.config.SparkBaseConfig;
import com.revrobotics.spark.config.SparkMaxConfig;

/**
Expand Down Expand Up @@ -52,6 +53,15 @@ public void set(double percent) {
}
}

@Override
public REVLibError configure(SparkBaseConfig config, SparkBase.ResetMode resetMode, SparkBase.PersistMode persistMode) {
super.configure(config, resetMode, persistMode);
m_encoder.setPositionConversionFactor(super.configAccessor.encoder.getPositionConversionFactor());
m_encoder.setVelocityConversionFactor(super.configAccessor.encoder.getVelocityConversionFactor());
m_encoder.setInverted(super.configAccessor.encoder.getInverted());
return REVLibError.kOk;
}

/**
* Sets the neutralDeadband of the real and simulated motors
*
Expand Down Expand Up @@ -87,7 +97,7 @@ public com.autodesk.synthesis.revrobotics.SparkAbsoluteEncoder getAbsoluteEncode
}

public com.autodesk.synthesis.revrobotics.RelativeEncoder getEncoderSim() {
return new RelativeEncoder(this);
return new RelativeEncoder(this.m_encoder);
}

/**
Expand Down

0 comments on commit cf2d7eb

Please sign in to comment.