Skip to content

Commit

Permalink
add FOC support
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewChoulas committed Nov 12, 2023
1 parent dfb9730 commit 9cbb6ed
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import org.team4099.lib.units.perSecond
import kotlin.math.sqrt

object DrivetrainConstants {
const val FOC_ENABLED = false
const val MINIMIZE_SKEW = false

const val WHEEL_COUNT = 4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class SwerveModuleIOFalcon(
}

override fun setSteeringSetpoint(angle: Angle) {
steeringFalcon.setControl(PositionDutyCycle(steeringSensor.positionToRawUnits(angle)))
steeringFalcon.setControl(PositionDutyCycle(steeringSensor.positionToRawUnits(angle), DrivetrainConstants.FOC_ENABLED, 0.0, 0, false))
}

override fun setClosedLoop(
Expand All @@ -197,7 +197,7 @@ class SwerveModuleIOFalcon(
val feedforward = DrivetrainConstants.PID.DRIVE_KS * speed.sign
driveFalcon.setControl(
VelocityDutyCycle(
driveSensor.velocityToRawUnits(speed), false, feedforward.inVolts / 12.0, 0, false
driveSensor.velocityToRawUnits(speed), DrivetrainConstants.FOC_ENABLED, feedforward.inVolts / 12.0, 0, false
)
)

Expand All @@ -211,7 +211,7 @@ class SwerveModuleIOFalcon(
* @param speed: Desired speed
*/
override fun setOpenLoop(steering: Angle, speed: LinearVelocity) {
driveFalcon.setControl(DutyCycleOut(speed / DrivetrainConstants.DRIVE_SETPOINT_MAX))
driveFalcon.setControl(DutyCycleOut(speed / DrivetrainConstants.DRIVE_SETPOINT_MAX, DrivetrainConstants.FOC_ENABLED, false))
setSteeringSetpoint(steering)
}

Expand Down

0 comments on commit 9cbb6ed

Please sign in to comment.