-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b8e6ad8
commit c76b7f8
Showing
9 changed files
with
589 additions
and
482 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 47 additions & 13 deletions
60
src/main/java/frc/robot/subsystems/elevator/Elevator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,74 @@ | ||
package frc.robot.subsystems.elevator; | ||
|
||
import edu.wpi.first.networktables.DoublePublisher; | ||
import edu.wpi.first.networktables.NetworkTable; | ||
import edu.wpi.first.networktables.NetworkTableInstance; | ||
import edu.wpi.first.wpilibj2.command.Command; | ||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
|
||
public class Elevator extends SubsystemBase { | ||
private final ElevatorIO m_io; | ||
private final double L1Setpoint = 100; | ||
private final double L2Setpoint = 5; | ||
private final double L3Setpoint = 0; | ||
private final double L4Setpoint = 0; | ||
private final NetworkTableInstance inst = NetworkTableInstance.getDefault(); | ||
private final NetworkTable elevatorTable = inst.getTable("Elevator"); | ||
private final DoublePublisher motorValPub= elevatorTable.getDoubleTopic("Motor Val").publish(); | ||
private final DoublePublisher motorVolPub= elevatorTable.getDoubleTopic("Motor Vol").publish(); | ||
private final DoublePublisher rotPub= elevatorTable.getDoubleTopic("Rotations").publish(); | ||
private final DoublePublisher setPub= elevatorTable.getDoubleTopic("Setpoint").publish(); | ||
|
||
final double m_gearRatio = 5/1 * 5/1 * 48/72; | ||
private final ElevatorIO m_io; | ||
private final double L1Setpoint = 29; | ||
private final double L2Setpoint = 32.5; | ||
private final double L3Setpoint = 51.5; | ||
private final double L4Setpoint = 76; | ||
//inch to rotations of the motor | ||
final double m_gearRatio = 0.5 * (1d / (1.75100 * Math.PI)) * ( 2d / 3d ) * 25; | ||
|
||
public Elevator(ElevatorIO io) { | ||
m_io = io; | ||
|
||
} | ||
|
||
public Command moveUp() { | ||
return this.run(() -> m_io.setVoltage(1)); | ||
return this.runOnce(() -> m_io.setVoltage(3)).withName("UP"); | ||
} | ||
|
||
public Command stop() { | ||
return this.run(() -> m_io.setVoltage(0)); | ||
return this.runOnce(() -> m_io.setVoltage(0)).withName("Stop"); | ||
} | ||
|
||
public Command moveDown() { | ||
return this.run(() -> m_io.setVoltage(-1)); | ||
return this.runOnce(() -> m_io.setVoltage(-3)).withName("Move Down"); | ||
} | ||
|
||
public Command goToL1(){ | ||
// return this.run(() -> m_io.gotosetpoint(L1Setpoint,m_gearRatio)); | ||
return this.run(() -> { | ||
// System.out.println("L1"); | ||
return this.runOnce(() -> { | ||
m_io.gotosetpoint(L1Setpoint, m_gearRatio); | ||
}); | ||
}).withName("L1"); | ||
} | ||
public Command goToL2(){ | ||
// return this.run(() -> m_io.gotosetpoint(L1Setpoint,m_gearRatio)); | ||
return this.runOnce(() -> { | ||
m_io.gotosetpoint(L2Setpoint, m_gearRatio); | ||
}).withName("L2"); | ||
} | ||
public Command goToL3(){ | ||
// return this.run(() -> m_io.gotosetpoint(L1Setpoint,m_gearRatio)); | ||
return this.runOnce(() -> { | ||
m_io.gotosetpoint(L3Setpoint, m_gearRatio); | ||
}).withName("L3"); | ||
} | ||
public Command goToL4(){ | ||
// return this.run(() -> m_io.gotosetpoint(L1Setpoint,m_gearRatio)); | ||
return this.runOnce(() -> { | ||
m_io.gotosetpoint(L4Setpoint, m_gearRatio); | ||
}).withName("L4"); | ||
} | ||
@Override | ||
public void periodic() { | ||
super.periodic(); | ||
motorValPub.set(m_io.getVelocity()); | ||
motorVolPub.set(m_io.getVoltage()); | ||
setPub.set(m_io.getSetpoint()); | ||
rotPub.set(m_io.getPosition()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"fileName": "PathplannerLib-2025.2.1.json", | ||
"name": "PathplannerLib", | ||
"version": "2025.2.1", | ||
"uuid": "1b42324f-17c6-4875-8e77-1c312bc8c786", | ||
"frcYear": "2025", | ||
"mavenUrls": [ | ||
"https://3015rangerrobotics.github.io/pathplannerlib/repo" | ||
], | ||
"jsonUrl": "https://3015rangerrobotics.github.io/pathplannerlib/PathplannerLib.json", | ||
"javaDependencies": [ | ||
{ | ||
"groupId": "com.pathplanner.lib", | ||
"artifactId": "PathplannerLib-java", | ||
"version": "2025.2.1" | ||
} | ||
], | ||
"jniDependencies": [], | ||
"cppDependencies": [ | ||
{ | ||
"groupId": "com.pathplanner.lib", | ||
"artifactId": "PathplannerLib-cpp", | ||
"version": "2025.2.1", | ||
"libName": "PathplannerLib", | ||
"headerClassifier": "headers", | ||
"sharedLibrary": false, | ||
"skipInvalidPlatforms": true, | ||
"binaryPlatforms": [ | ||
"windowsx86-64", | ||
"linuxx86-64", | ||
"osxuniversal", | ||
"linuxathena", | ||
"linuxarm32", | ||
"linuxarm64" | ||
] | ||
} | ||
] | ||
} |
Oops, something went wrong.