-
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.
Did work on IO and IONeo for shooter also changed global mainpulator …
…constants to be for shooter
- Loading branch information
Showing
4 changed files
with
56 additions
and
6 deletions.
There are no files selected for viewing
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
11 changes: 11 additions & 0 deletions
11
src/main/kotlin/com/team4099/robot2023/config/constants/ShooterConstants.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,11 @@ | ||
package com.team4099.robot2023.config.constants | ||
|
||
import org.team4099.lib.units.base.amps | ||
import org.team4099.lib.units.derived.volts | ||
import org.team4099.lib.units.derived.gearRatio | ||
|
||
object ShooterConstants { | ||
val ROLLER_GEAR_RATIO = 0.0.gearRatio | ||
val ROLLER_VOLTAGE_COMPENSATION = 0.0.volts | ||
val ROLLER_STATOR_CURRENT_LIMIT = 0.0.amps | ||
} |
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
42 changes: 40 additions & 2 deletions
42
src/main/kotlin/com/team4099/robot2023/subsystems/Shooter/ShooterIONeo.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 |
---|---|---|
@@ -1,5 +1,43 @@ | ||
package com.team4099.robot2023.subsystems.Shooter | ||
|
||
class ShooterIONeo { | ||
val | ||
import com.revrobotics.CANSparkMax | ||
import com.revrobotics.CANSparkMaxLowLevel | ||
import com.team4099.robot2023.config.constants.Constants | ||
import com.team4099.robot2023.config.constants.ShooterConstants | ||
import org.team4099.lib.units.base.amps | ||
import org.team4099.lib.units.base.celsius | ||
import org.team4099.lib.units.base.inAmperes | ||
import org.team4099.lib.units.derived.inVolts | ||
import org.team4099.lib.units.derived.volts | ||
import org.team4099.lib.units.sparkMaxAngularMechanismSensor | ||
import kotlin.math.absoluteValue | ||
|
||
object ShooterIONeo : ShooterIO{ | ||
private val rollerSparkMax = CANSparkMax(Constants.Shooter.ROLLER_MOTOR_ID, CANSparkMaxLowLevel.MotorType.kBrushless) | ||
private val rollerSensor = sparkMaxAngularMechanismSensor( rollerSparkMax, | ||
ShooterConstants.ROLLER_GEAR_RATIO.asDrivenOverDriving, | ||
ShooterConstants.ROLLER_VOLTAGE_COMPENSATION | ||
) | ||
init{ | ||
//reset the motors | ||
rollerSparkMax.restoreFactoryDefaults() | ||
rollerSparkMax.clearFaults() | ||
|
||
//voltage and current limits | ||
rollerSparkMax.enableVoltageCompensation(ShooterConstants.ROLLER_VOLTAGE_COMPENSATION.inVolts) | ||
rollerSparkMax.setSmartCurrentLimit(ShooterConstants.ROLLER_STATOR_CURRENT_LIMIT.inAmperes.toInt()) | ||
} | ||
|
||
override fun updateInputs (inputs: ShooterIO.ShooterIOInputs){ | ||
inputs.rollerVelocity = rollerSensor.velocity | ||
inputs.rollerAppliedVoltage = rollerSparkMax.busVoltage.volts * rollerSparkMax.appliedOutput | ||
inputs.rollerStatorCurrent = rollerSparkMax.outputCurrent.amps | ||
// BatteryVoltage * SupplyCurrent = AppliedVoltage * StatorCurrent | ||
// AppliedVoltage = percentOutput * BatteryVoltage | ||
// SupplyCurrent = (percentOutput * BatteryVoltage / BatteryVoltage) * StatorCurrent = | ||
// percentOutput * statorCurrent | ||
inputs.rollerSupplyCurrent = inputs.rollerStatorCurrent * rollerSparkMax.appliedOutput.absoluteValue | ||
inputs.rollerTempreature = rollerSparkMax.motorTemperature.celsius | ||
} | ||
|
||
} |