-
Notifications
You must be signed in to change notification settings - Fork 0
feat(commands): collector commands #21
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
base: master
Are you sure you want to change the base?
Changes from all commits
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,23 @@ | ||
| package org.frc5183.robot.commands.collector | ||
|
|
||
| import edu.wpi.first.wpilibj2.command.Command | ||
| import org.frc5183.robot.subsystems.collector.CollectorSubsystem | ||
|
|
||
| class DriveCollector( | ||
| val collector: CollectorSubsystem, | ||
| val input: () -> Double, | ||
| ) : Command() { | ||
| init { | ||
| addRequirements(collector) | ||
| } | ||
|
|
||
| override fun execute() { | ||
| collector.runIntake(input()) | ||
| } | ||
|
|
||
| override fun end(interrupted: Boolean) { | ||
| collector.stopIntake() | ||
| } | ||
|
|
||
| override fun isFinished(): Boolean = false | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| package org.frc5183.robot.commands.collector | ||
|
|
||
| import edu.wpi.first.wpilibj2.command.Command | ||
| import org.frc5183.robot.subsystems.collector.CollectorSubsystem | ||
| import org.frc5183.robot.subsystems.shooter.ShooterSubsystem | ||
|
|
||
| class IntakeCommand( | ||
| val collector: CollectorSubsystem, | ||
| ) : Command() { | ||
| init { | ||
| addRequirements(collector) | ||
| } | ||
|
|
||
| override fun initialize() { | ||
| collector.runIntake(1.0) | ||
| } | ||
|
|
||
| override fun end(interrupted: Boolean) { | ||
| collector.stopIntake() | ||
| } | ||
|
|
||
| override fun isFinished(): Boolean = false | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| package org.frc5183.robot.commands.collector | ||
|
|
||
| import edu.wpi.first.wpilibj2.command.Command | ||
| import org.frc5183.robot.subsystems.collector.CollectorSubsystem | ||
| import org.frc5183.robot.subsystems.shooter.ShooterSubsystem | ||
|
|
||
| class LowerCollector( | ||
| val collector: CollectorSubsystem, | ||
| ) : Command() { | ||
| init { | ||
| addRequirements(collector) | ||
| } | ||
|
|
||
| override fun initialize() { | ||
| collector.runArm(-1.0) | ||
| } | ||
|
|
||
| override fun end(interrupted: Boolean) { | ||
| collector.stopArm() | ||
| } | ||
|
|
||
| override fun isFinished(): Boolean = collector.atBottom | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| package org.frc5183.robot.commands.collector | ||
|
|
||
| import edu.wpi.first.wpilibj2.command.Command | ||
| import org.frc5183.robot.subsystems.collector.CollectorSubsystem | ||
| import org.frc5183.robot.subsystems.shooter.ShooterSubsystem | ||
|
|
||
| class RaiseCollector( | ||
| val collector: CollectorSubsystem, | ||
| ) : Command() { | ||
| init { | ||
| addRequirements(collector) | ||
| } | ||
|
|
||
| override fun initialize() { | ||
| collector.runArm(1.0) | ||
| } | ||
|
|
||
| override fun end(interrupted: Boolean) { | ||
| collector.stopArm() | ||
| } | ||
|
|
||
| override fun isFinished(): Boolean = collector.atTop | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package org.frc5183.robot.constants | ||
|
|
||
| import edu.wpi.first.units.measure.Angle | ||
|
|
||
| object Constants { | ||
| val COLLECTOR_ARM_TOP: Angle | ||
| val COLLECTOR_ARM_BOTTOM: Angle | ||
| val COLLECTOR_ARM_DELTA: Angle | ||
| } | ||
|
Comment on lines
+5
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Uninitialized In Kotlin, 🐛 Proposed fix: Initialize the constants with appropriate values object Constants {
- val COLLECTOR_ARM_TOP: Angle
- val COLLECTOR_ARM_BOTTOM: Angle
- val COLLECTOR_ARM_DELTA: Angle
+ val COLLECTOR_ARM_TOP: Angle = Units.Rotations.of(0.0) // TODO: Set actual top position
+ val COLLECTOR_ARM_BOTTOM: Angle = Units.Rotations.of(0.0) // TODO: Set actual bottom position
+ val COLLECTOR_ARM_DELTA: Angle = Units.Rotations.of(0.01) // TODO: Set actual tolerance
}You'll need to add the import: import edu.wpi.first.units.Units🤖 Prompt for AI Agents |
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,29 +1,22 @@ | ||||||||||||||||||||||||||||||||||||||||||||
| package org.frc5183.robot.constants | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| import edu.wpi.first.wpilibj2.command.Command | ||||||||||||||||||||||||||||||||||||||||||||
| import edu.wpi.first.wpilibj2.command.CommandScheduler | ||||||||||||||||||||||||||||||||||||||||||||
| import edu.wpi.first.wpilibj2.command.button.CommandXboxController | ||||||||||||||||||||||||||||||||||||||||||||
| import org.frc5183.robot.commands.drive.TeleopDriveCommand | ||||||||||||||||||||||||||||||||||||||||||||
| import org.frc5183.robot.subsystems.drive.SwerveDriveSubsystem | ||||||||||||||||||||||||||||||||||||||||||||
| import swervelib.SwerveInputStream | ||||||||||||||||||||||||||||||||||||||||||||
| import kotlin.math.absoluteValue | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| object Controls { | ||||||||||||||||||||||||||||||||||||||||||||
| val DRIVER_CONTROLLER: CommandXboxController = CommandXboxController(0) | ||||||||||||||||||||||||||||||||||||||||||||
| val OPERATOR_CONTROLLER: CommandXboxController = CommandXboxController(1) | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| lateinit var TELEOP_DRIVE_COMMAND: TeleopDriveCommand | ||||||||||||||||||||||||||||||||||||||||||||
| lateinit var DRIVE_COMMAND: Command | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| fun registerControls(drive: SwerveDriveSubsystem) { | ||||||||||||||||||||||||||||||||||||||||||||
| CommandScheduler.getInstance().activeButtonLoop.clear() | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| TELEOP_DRIVE_COMMAND = | ||||||||||||||||||||||||||||||||||||||||||||
| TeleopDriveCommand( | ||||||||||||||||||||||||||||||||||||||||||||
| drive, | ||||||||||||||||||||||||||||||||||||||||||||
| xInput = { if (DRIVER_CONTROLLER.leftX.absoluteValue < .2) 0.0 else DRIVER_CONTROLLER.leftX }, | ||||||||||||||||||||||||||||||||||||||||||||
| yInput = { if (DRIVER_CONTROLLER.leftY.absoluteValue < .2) 0.0 else DRIVER_CONTROLLER.leftY }, | ||||||||||||||||||||||||||||||||||||||||||||
| rotationInput = { 0.0 }, | ||||||||||||||||||||||||||||||||||||||||||||
| fieldRelative = false, | ||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| drive.defaultCommand = TELEOP_DRIVE_COMMAND | ||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+15
to
20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Line 20 references 🐛 Proposed fix- drive.defaultCommand = TELEOP_DRIVE_COMMAND
+ drive.defaultCommand = DRIVE_COMMAND📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unused import.
ShooterSubsystemis imported but never used in this class.🧹 Proposed fix
import edu.wpi.first.wpilibj2.command.Command import org.frc5183.robot.subsystems.collector.CollectorSubsystem -import org.frc5183.robot.subsystems.shooter.ShooterSubsystem📝 Committable suggestion
🤖 Prompt for AI Agents