-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
plus syntax changes stake --> state and OPEN_LOOP_REQUEST --> OPEN_LOOP
- Loading branch information
Showing
4 changed files
with
64 additions
and
13 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
src/main/kotlin/com/team4099/robot2023/config/constants/IntakeConstants.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/main/kotlin/com/team4099/robot2023/subsystems/intake/IntakeIOSim.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.team4099.robot2023.subsystems.intake | ||
|
||
import com.team4099.lib.math.clamp | ||
import com.team4099.robot2023.config.constants.Constants | ||
import com.team4099.robot2023.config.constants.IntakeConstants | ||
import edu.wpi.first.math.system.plant.DCMotor | ||
import edu.wpi.first.wpilibj.simulation.FlywheelSim | ||
import org.team4099.lib.units.base.amps | ||
import org.team4099.lib.units.base.celsius | ||
import org.team4099.lib.units.base.inSeconds | ||
import org.team4099.lib.units.derived.ElectricalPotential | ||
import org.team4099.lib.units.derived.inVolts | ||
import org.team4099.lib.units.derived.rotations | ||
import org.team4099.lib.units.derived.volts | ||
import org.team4099.lib.units.perMinute | ||
|
||
class IntakeIOSim : IntakeIO { | ||
private val rollerSim: FlywheelSim = FlywheelSim( | ||
DCMotor.getNEO(1), | ||
IntakeConstants.ROLLER_GEAR_RATIO, | ||
IntakeConstants.ROLLER_INERTIA | ||
) | ||
|
||
init{} | ||
|
||
override fun updateInputs(inputs: IntakeIO.IntakeIOInputs) { | ||
|
||
rollerSim.update(Constants.Universal.LOOP_PERIOD_TIME.inSeconds) | ||
|
||
inputs.rollerVelocity = rollerSim.getAngularVelocityRPM().rotations.perMinute | ||
inputs.rollerAppliedVoltage = 0.volts | ||
inputs.rollerSupplyCurrent = 0.amps | ||
inputs.rollerStatorCurrent = rollerSim.currentDrawAmps.amps | ||
inputs.rollerTemp = 0.0.celsius | ||
|
||
inputs.isSimulated = true | ||
} | ||
|
||
override fun setRollerVoltage(voltage: ElectricalPotential) { | ||
rollerSim.setInputVoltage( | ||
clamp( | ||
voltage, | ||
-IntakeConstants.VOLTAGE_COMPENSATION, | ||
IntakeConstants.VOLTAGE_COMPENSATION | ||
) | ||
.inVolts | ||
) | ||
} | ||
} |