Skip to content

Commit

Permalink
style: format code with Ktlint
Browse files Browse the repository at this point in the history
This commit fixes the style issues introduced in 6c4c746 according to the output
from Ktlint.

Details: #2
  • Loading branch information
deepsource-autofix[bot] authored and TheGamer1002 committed Oct 25, 2024
1 parent 5c966c7 commit 296279b
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 35 deletions.
36 changes: 21 additions & 15 deletions src/main/java/frc/robot/generated/TunerConstants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ object TunerConstants {
CurrentLimitsConfigs() // Swerve azimuth does not require much torque output, so we can set a relatively low
// stator current limit to help avoid brownouts without impacting performance.
.withStatorCurrentLimit(60.0) // TODO originally 60
.withStatorCurrentLimitEnable(true)
.withStatorCurrentLimitEnable(true),
)
private val cancoderInitialConfigs = CANcoderConfiguration()

Expand All @@ -70,7 +70,6 @@ object TunerConstants {
private const val kCANbusName = "rio"
private const val kPigeonId = 30


// These are only used for simulation
private const val kSteerInertia = 0.00001
private const val kDriveInertia = 0.001
Expand Down Expand Up @@ -104,7 +103,6 @@ object TunerConstants {
.withSteerMotorInitialConfigs(steerInitialConfigs)
.withCANcoderInitialConfigs(cancoderInitialConfigs)


// Front Left
private const val kFrontLeftDriveMotorId = 6
private const val kFrontLeftSteerMotorId = 7
Expand Down Expand Up @@ -145,17 +143,16 @@ object TunerConstants {
private const val kBackRightXPosInches = -12.125
private const val kBackRightYPosInches = -12.125


private val FrontLeft: SwerveModuleConstants = ConstantCreator.createModuleConstants(
kFrontLeftSteerMotorId,
kFrontLeftDriveMotorId,
kFrontLeftEncoderId,
kFrontLeftEncoderOffset,
Units.inchesToMeters(
kFrontLeftXPosInches
kFrontLeftXPosInches,
),
Units.inchesToMeters(kFrontLeftYPosInches),
kInvertLeftSide
kInvertLeftSide,
)
.withSteerMotorInverted(kFrontLeftSteerInvert)
private val FrontRight: SwerveModuleConstants = ConstantCreator.createModuleConstants(
Expand All @@ -164,16 +161,22 @@ object TunerConstants {
kFrontRightEncoderId,
kFrontRightEncoderOffset,
Units.inchesToMeters(
kFrontRightXPosInches
kFrontRightXPosInches,
),
Units.inchesToMeters(kFrontRightYPosInches),
kInvertRightSide
kInvertRightSide,
)
.withSteerMotorInverted(kFrontRightSteerInvert)
private val BackLeft: SwerveModuleConstants = ConstantCreator.createModuleConstants(
kBackLeftSteerMotorId, kBackLeftDriveMotorId, kBackLeftEncoderId, kBackLeftEncoderOffset, Units.inchesToMeters(
kBackLeftXPosInches
), Units.inchesToMeters(kBackLeftYPosInches), kInvertLeftSide
kBackLeftSteerMotorId,
kBackLeftDriveMotorId,
kBackLeftEncoderId,
kBackLeftEncoderOffset,
Units.inchesToMeters(
kBackLeftXPosInches,
),
Units.inchesToMeters(kBackLeftYPosInches),
kInvertLeftSide,
)
.withSteerMotorInverted(kBackLeftSteerInvert)
private val BackRight: SwerveModuleConstants = ConstantCreator.createModuleConstants(
Expand All @@ -182,15 +185,18 @@ object TunerConstants {
kBackRightEncoderId,
kBackRightEncoderOffset,
Units.inchesToMeters(
kBackRightXPosInches
kBackRightXPosInches,
),
Units.inchesToMeters(kBackRightYPosInches),
kInvertRightSide
kInvertRightSide,
)
.withSteerMotorInverted(kBackRightSteerInvert)

val DriveTrain: CommandSwerveDrivetrain = CommandSwerveDrivetrain(
DrivetrainConstants, FrontLeft,
FrontRight, BackLeft, BackRight
DrivetrainConstants,
FrontLeft,
FrontRight,
BackLeft,
BackRight,
)
}
13 changes: 8 additions & 5 deletions src/main/java/frc/robot/subsystems/ArmSubsystem.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@ object ArmSubsystem : Subsystem {

fun getCommand(joystickTriggerValue: () -> Double): Command {
return run {
if (joystickTriggerValue.invoke() > 0.1) extend(joystickTriggerValue.invoke()) else if (joystickTriggerValue.invoke() < -0.1) retract(
-joystickTriggerValue.invoke()
)
if (joystickTriggerValue.invoke() > 0.1) {
extend(joystickTriggerValue.invoke())
} else if (joystickTriggerValue.invoke() < -0.1) {
retract(
-joystickTriggerValue.invoke(),
)
}
}

}
}
}
27 changes: 12 additions & 15 deletions src/main/java/frc/robot/subsystems/vision/VisionSubsystem.kt
Original file line number Diff line number Diff line change
@@ -1,37 +1,34 @@
package frc.robot.subsystems.vision

import edu.wpi.first.wpilibj2.command.SubsystemBase
import edu.wpi.first.math.geometry.Rotation2d
import edu.wpi.first.wpilibj2.command.SubsystemBase
import org.photonvision.PhotonCamera
import org.photonvision.PhotonUtils
import org.photonvision.targeting.PhotonTrackedTarget

class VisionSubsystem : SubsystemBase(){
private var camera : PhotonCamera = PhotonCamera("ShitCam")
class VisionSubsystem : SubsystemBase() {
private var camera: PhotonCamera = PhotonCamera("ShitCam")
private lateinit var rot: Rotation2d
private var countWithoutMeasurement: Int = 0


override fun periodic(){
override fun periodic() {
// This method will be called once per scheduler run
var result = camera.getLatestResult()
if(result.hasTargets()){
var target : PhotonTrackedTarget = result.getBestTarget()
if (result.hasTargets()) {
var target: PhotonTrackedTarget = result.getBestTarget()
rot = Rotation2d.fromDegrees(target.yaw)
countWithoutMeasurement = 0
} else countWithoutMeasurement++
} else {
countWithoutMeasurement++
}

if (countWithoutMeasurement > 25) { // method called every 20 ms,
// so 25 * 20 = 500 ms without a target before setting rotation to 0
rot = Rotation2d.fromDegrees(0.0)
}
}

//returns angle to nearest note relative to the front of the robot
fun getNearestRotation() : Rotation2d {

// returns angle to nearest note relative to the front of the robot
fun getNearestRotation(): Rotation2d {
return rot
}


}
}

0 comments on commit 296279b

Please sign in to comment.