Skip to content

Commit

Permalink
Did work on IO and IONeo for shooter also changed global mainpulator …
Browse files Browse the repository at this point in the history
…constants to be for shooter
  • Loading branch information
SirBeans committed Jan 12, 2024
1 parent a1f5cc8 commit 1eb31a1
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,8 @@ object Constants {
const val PIGEON_2_ID = 1
}

object Manipulator {
const val INTAKE_MOTOR_ID = 51
const val ARM_MOTOR_ID = 52
object Shooter {
const val ROLLER_MOTOR_ID = 51
}

object Alert {
Expand Down
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
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ interface ShooterIO {
}
}

fun updateInputs(inputs: ShooterIOInputs)
fun updateInputs(inputs: ShooterIOInputs){

}
fun setRollerPower (voltage: ElectricalPotential){

}
Expand Down
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
}

}

0 comments on commit 1eb31a1

Please sign in to comment.