Skip to content
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

Add elevator code #1

Open
wants to merge 38 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
bdf2d9d
Add elevator
Noga18 Dec 17, 2024
4afafea
Untrack BuildConstants
Emma03L Dec 19, 2024
7e1cb8a
Fix TunerConstants
Emma03L Dec 19, 2024
d167180
Change setHeight to use Distance instead of a double
Emma03L Dec 19, 2024
76f98f2
Add heightSetpoint input
Emma03L Dec 19, 2024
2886c8c
Apply motor configs
Emma03L Dec 19, 2024
07c0575
Change setPower to use the .set() function
Emma03L Dec 19, 2024
cdd1879
Fix units when updating carriageHeight and add SPROCKET_RADIUS constant
Emma03L Dec 19, 2024
a3fd246
Update motor id
Emma03L Dec 19, 2024
84f73b1
Turn functions in subsystem to commands and change their parameter types
Emma03L Dec 19, 2024
6f00c45
Add private val elevator
Emma03L Dec 20, 2024
7f59ab7
Add driverController
Emma03L Dec 20, 2024
a4bfdb2
Add Elevator initialize
Emma03L Dec 20, 2024
217a70c
Add elevator defaultCommand
Emma03L Dec 20, 2024
94bac3c
Add kD
Emma03L Dec 20, 2024
e47a2be
Change SPROCKET_RADIUS to Double
Emma03L Dec 20, 2024
a8bda3b
Add imports
Emma03L Dec 20, 2024
9dda8ce
Delete SensorToMechanismRatio
Emma03L Dec 20, 2024
5a9a963
Change setPosition to Commands run
Emma03L Dec 20, 2024
fb93a73
Calibrate PID
Emma03L Dec 20, 2024
e1821c1
spotlessApply
Noga18 Dec 31, 2024
928f61d
Add setHeight
Noga18 Dec 31, 2024
c6df3de
Add updateInputs
Noga18 Dec 31, 2024
ade931f
Delete reset
Noga18 Dec 31, 2024
353e036
Add setPower
Noga18 Dec 31, 2024
878cdfe
Add motor TalonFXSim
Noga18 Dec 31, 2024
16f7d54
Add motorPosititonRequest
Noga18 Dec 31, 2024
5413079
spotlessApply
Noga18 Dec 31, 2024
fe1d3e8
Change from whileTrue to onTrue
Noga18 Dec 31, 2024
48f8665
Remove comment
Noga18 Dec 31, 2024
67704f7
Merge remote-tracking branch 'origin/feature/elevator' into feature/e…
Noga18 Dec 31, 2024
9c568c7
Add ROTATIONS_TO_CENTIMETER
Noga18 Dec 31, 2024
0d6e205
SpotlessApply
Noga18 Dec 31, 2024
c94afc2
Change class name
Noga18 Dec 31, 2024
a45b181
Change Commands.run to run
Noga18 Dec 31, 2024
682c0e4
SpotlessApply
Noga18 Dec 31, 2024
a028318
Change Commands.run to run
Noga18 Jan 6, 2025
e7e5a59
Change carriageHeight in updateInputs
Noga18 Jan 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions src/main/kotlin/frc/robot/BuildConstants.java

This file was deleted.

24 changes: 16 additions & 8 deletions src/main/kotlin/frc/robot/RobotContainer.kt
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
package frc.robot

import com.pathplanner.lib.auto.NamedCommands
import edu.wpi.first.math.MathUtil
import edu.wpi.first.math.geometry.Pose2d
import edu.wpi.first.math.geometry.Rotation2d
import edu.wpi.first.units.Units
import edu.wpi.first.wpilibj2.command.Command
import edu.wpi.first.wpilibj2.command.Commands
import edu.wpi.first.wpilibj2.command.button.CommandXboxController
import frc.robot.ControllerInputs.driverController
import frc.robot.subsystems.drive.Drive
import frc.robot.subsystems.drive.DriveCommands
import frc.robot.subsystems.drive.getGyroIO
import frc.robot.subsystems.drive.getSwerveModuleIOs
import frc.robot.subsystems.elevator.Elevator
import frc.robot.subsystems.elevator.ElevatorIOReal

/**
* This class is where the bulk of the robot should be declared. Since Command-based is a
Expand All @@ -21,9 +22,12 @@ import frc.robot.subsystems.drive.getSwerveModuleIOs
*/
object RobotContainer {
private val swerveDrive: Drive
private val elevator: Elevator
private val testController = CommandXboxController(2)

init {
Elevator.initialize(ElevatorIOReal())
elevator = Elevator.getInstance()
swerveDrive = Drive(getGyroIO(), getSwerveModuleIOs())

registerAutoCommands()
Expand All @@ -32,12 +36,13 @@ object RobotContainer {
}

private fun configureDefaultCommands() {
swerveDrive.defaultCommand = DriveCommands.joystickDrive(
swerveDrive,
{ MathUtil.applyDeadband(driverController().leftY, 0.15) },
{ MathUtil.applyDeadband(driverController().leftX, 0.15) },
{ 0.7 * MathUtil.applyDeadband(-driverController().rightX, 0.15) }
)
// swerveDrive.defaultCommand = DriveCommands.joystickDrive(
// swerveDrive,
// { MathUtil.applyDeadband(driverController().leftY, 0.15) },
// { MathUtil.applyDeadband(driverController().leftX, 0.15) },
// { 0.7 * MathUtil.applyDeadband(-driverController().rightX, 0.15) }
// )
elevator.defaultCommand = elevator.setPower { driverController().rightTriggerAxis - driverController().leftTriggerAxis }
}

private fun configureButtonBindings() {
Expand All @@ -47,6 +52,9 @@ object RobotContainer {
}, swerveDrive)
.ignoringDisable(true)
)
driverController().a().onTrue(elevator.reset())
driverController().x().onTrue(elevator.setPosition(Units.Centimeter.of(50.0)))
driverController().b().whileTrue(elevator.setPosition(Units.Centimeter.of(100.0)))
}

fun getAutonomousCommand(): Command = Commands.none()
Expand Down
Loading