Skip to content
This repository has been archived by the owner on Dec 19, 2024. It is now read-only.

Commit

Permalink
Began arm code
Browse files Browse the repository at this point in the history
  • Loading branch information
Taimorioka committed Nov 13, 2024
1 parent 60b3c19 commit d7ff7c1
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/frcteam3636/frc2024/CAN.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ enum class CTREMotorControllerId(val num: Int, val bus: String) {
BackLeftDrivingMotor(2, "*"),
BackRightDrivingMotor(3, "*"),
FrontRightDrivingMotor(4, "*"),
RightPivotMotor(10, "*"),
LeftPivotMotor(11, "*"),
RightArmMotor(10, "*"),
LeftArmMotor(11, "*"),
}

fun TalonFX(id: CTREMotorControllerId) = TalonFX(id.num, id.bus)
4 changes: 4 additions & 0 deletions src/main/java/com/frcteam3636/frc2024/subsystems/arm/Arm.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.frcteam3636.frc2024.subsystems.arm

object Arm {
}
72 changes: 72 additions & 0 deletions src/main/java/com/frcteam3636/frc2024/subsystems/arm/ArmIO.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package com.frcteam3636.frc2024.subsystems.arm
import edu.wpi.first.math.geometry.Rotation2d
import org.littletonrobotics.junction.LogTable
import org.littletonrobotics.junction.inputs.LoggableInputs
import com.frcteam3636.frc2024.CANSparkFlex
import com.frcteam3636.frc2024.CTREMotorControllerId
import com.frcteam3636.frc2024.REVMotorControllerId
import com.frcteam3636.frc2024.TalonFX
import com.revrobotics.CANSparkLowLevel
import edu.wpi.first.networktables.NetworkTableInstance
import edu.wpi.first.units.Angle
import edu.wpi.first.units.Measure
import edu.wpi.first.units.Units.Radians
import edu.wpi.first.wpilibj.DigitalInput
import edu.wpi.first.wpilibj.DutyCycleEncoder

interface ArmIO{
class ArmInputs : LoggableInputs {
var rightPosition = Radians.zero()
var leftPosition = Radians.zero()

var rightCurrent: Double = 0.0
var leftCurrent: Double = 0.0

var rightVelocity: Double = 0.0
var leftVelocity: Double = 0.0

override fun toLog(table: LogTable) {
table.put("Right Arm Motor Position", rightPosition)
table.put("Left Arm Motor Position", leftPosition)

table.put("Right Arm Motor Current", rightCurrent)
table.put("Left Arm Motor Current", leftCurrent)

table.put("Right Arm Motor Velocity", rightVelocity)
table.put("Left Arm Motor Velocity", leftVelocity)
}

override fun fromLog(table: LogTable) {
rightPosition = table.get("Right Arm Motor Position", rightPosition)
leftPosition = table.get("Left Arm Motor Position", leftPosition)

rightCurrent = table.get("Right Arm Motor Current", rightCurrent)
leftCurrent = table.get("Left Arm Motor Current", leftCurrent)

rightVelocity = table.get("Right Arm Motor Velocity", rightVelocity)
leftVelocity = table.get("Left Arm Motor Velocity", leftVelocity)
}
}

fun updateInputs(inputs: ArmInputs)

fun setPosition(position: Measure<Angle>)
}

class ArmIOReal: ArmIO{

private val leftMotor = TalonFX(CTREMotorControllerId.LeftArmMotor)

private val rightMotor = TalonFX(CTREMotorControllerId.RightArmMotor)

private val absoluteEncoder = DutyCycleEncoder(DigitalInput(7))

override fun updateInputs(inputs: ArmIO.ArmInputs) {
TODO("Not yet implemented")
}

override fun setPosition(position: Measure<Angle>) {
TODO("Not yet implemented")
}

}

0 comments on commit d7ff7c1

Please sign in to comment.