-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A #2
A #2
Changes from all commits
78645cd
972faab
2841b95
6c4c746
9be744c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"java.configuration.updateBuildConfiguration": "automatic" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package frc.robot.subsystems | ||
|
||
import com.ctre.phoenix6.hardware.TalonFX | ||
import edu.wpi.first.wpilibj2.command.Command | ||
import edu.wpi.first.wpilibj2.command.Subsystem | ||
|
||
object ArmSubsystem : Subsystem { | ||
var motor: TalonFX | ||
override fun periodic() { | ||
// This method will be called once per scheduler run | ||
} | ||
|
||
init { | ||
// Initialize the arm subsystem | ||
motor = TalonFX(31) | ||
Check warning Code scanning / detekt Report magic numbers. Magic number is a numeric literal that is not defined as a constant and hence it's unclear what the purpose of this number is. It's better to declare such numbers as constants and give them a proper name. By default, -1, 0, 1, and 2 are not considered to be magic numbers. Warning
This expression contains a magic number. Consider defining it to a well named constant.
|
||
} | ||
|
||
fun extend(i: Double) { | ||
motor.set(-0.4 * i) | ||
Check warning Code scanning / detekt Report magic numbers. Magic number is a numeric literal that is not defined as a constant and hence it's unclear what the purpose of this number is. It's better to declare such numbers as constants and give them a proper name. By default, -1, 0, 1, and 2 are not considered to be magic numbers. Warning
This expression contains a magic number. Consider defining it to a well named constant.
|
||
} | ||
|
||
fun retract(i: Double) { | ||
motor.set(0.4 * i) | ||
Check warning Code scanning / detekt Report magic numbers. Magic number is a numeric literal that is not defined as a constant and hence it's unclear what the purpose of this number is. It's better to declare such numbers as constants and give them a proper name. By default, -1, 0, 1, and 2 are not considered to be magic numbers. Warning
This expression contains a magic number. Consider defining it to a well named constant.
|
||
} // i love programming | ||
|
||
fun getCommand(joystickTriggerValue: () -> Double): Command { | ||
return run { | ||
if (joystickTriggerValue.invoke() > 0.1) { | ||
Check warning Code scanning / detekt Report magic numbers. Magic number is a numeric literal that is not defined as a constant and hence it's unclear what the purpose of this number is. It's better to declare such numbers as constants and give them a proper name. By default, -1, 0, 1, and 2 are not considered to be magic numbers. Warning
This expression contains a magic number. Consider defining it to a well named constant.
|
||
extend(joystickTriggerValue.invoke()) | ||
} else if (joystickTriggerValue.invoke() < -0.1) { | ||
Check warning Code scanning / detekt Report magic numbers. Magic number is a numeric literal that is not defined as a constant and hence it's unclear what the purpose of this number is. It's better to declare such numbers as constants and give them a proper name. By default, -1, 0, 1, and 2 are not considered to be magic numbers. Warning
This expression contains a magic number. Consider defining it to a well named constant.
|
||
retract( | ||
-joystickTriggerValue.invoke(), | ||
) | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package frc.robot.subsystems.vision | ||
|
||
import edu.wpi.first.math.geometry.Rotation2d | ||
import edu.wpi.first.wpilibj2.command.SubsystemBase | ||
import org.photonvision.PhotonCamera | ||
import org.photonvision.targeting.PhotonTrackedTarget | ||
|
||
class VisionSubsystem : SubsystemBase() { | ||
private var camera: PhotonCamera = PhotonCamera("ShitCam") | ||
private lateinit var rot: Rotation2d | ||
private var countWithoutMeasurement: Int = 0 | ||
|
||
override fun periodic() { | ||
// This method will be called once per scheduler run | ||
var result = camera.getLatestResult() | ||
if (result.hasTargets()) { | ||
var target: PhotonTrackedTarget = result.getBestTarget() | ||
rot = Rotation2d.fromDegrees(target.yaw) | ||
countWithoutMeasurement = 0 | ||
} else { | ||
countWithoutMeasurement++ | ||
} | ||
|
||
if (countWithoutMeasurement > 25) { // method called every 20 ms, | ||
Check warning Code scanning / detekt Report magic numbers. Magic number is a numeric literal that is not defined as a constant and hence it's unclear what the purpose of this number is. It's better to declare such numbers as constants and give them a proper name. By default, -1, 0, 1, and 2 are not considered to be magic numbers. Warning
This expression contains a magic number. Consider defining it to a well named constant.
|
||
// 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 { | ||
return rot | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
{ | ||
"fileName": "photonlib.json", | ||
"name": "photonlib", | ||
"version": "v2024.3.1", | ||
"uuid": "515fe07e-bfc6-11fa-b3de-0242ac130004", | ||
"frcYear": "2024", | ||
"mavenUrls": [ | ||
"https://maven.photonvision.org/repository/internal", | ||
"https://maven.photonvision.org/repository/snapshots" | ||
], | ||
"jsonUrl": "https://maven.photonvision.org/repository/internal/org/photonvision/photonlib-json/1.0/photonlib-json-1.0.json", | ||
"jniDependencies": [], | ||
"cppDependencies": [ | ||
{ | ||
"groupId": "org.photonvision", | ||
"artifactId": "photonlib-cpp", | ||
"version": "v2024.3.1", | ||
"libName": "photonlib", | ||
"headerClassifier": "headers", | ||
"sharedLibrary": true, | ||
"skipInvalidPlatforms": true, | ||
"binaryPlatforms": [ | ||
"windowsx86-64", | ||
"linuxathena", | ||
"linuxx86-64", | ||
"osxuniversal" | ||
] | ||
}, | ||
{ | ||
"groupId": "org.photonvision", | ||
"artifactId": "photontargeting-cpp", | ||
"version": "v2024.3.1", | ||
"libName": "photontargeting", | ||
"headerClassifier": "headers", | ||
"sharedLibrary": true, | ||
"skipInvalidPlatforms": true, | ||
"binaryPlatforms": [ | ||
"windowsx86-64", | ||
"linuxathena", | ||
"linuxx86-64", | ||
"osxuniversal" | ||
] | ||
} | ||
], | ||
"javaDependencies": [ | ||
{ | ||
"groupId": "org.photonvision", | ||
"artifactId": "photonlib-java", | ||
"version": "v2024.3.1" | ||
}, | ||
{ | ||
"groupId": "org.photonvision", | ||
"artifactId": "photontargeting-java", | ||
"version": "v2024.3.1" | ||
} | ||
] | ||
} |
Check warning
Code scanning / detekt
Line detected that is longer than the defined maximum line length in the code style. Warning