Skip to content

Commit 3a99c1c

Browse files
committed
Elevator Tuning; faster
1 parent 0a083c6 commit 3a99c1c

8 files changed

Lines changed: 32 additions & 30 deletions

File tree

.DataLogTool/datalogtool.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"download": {
3+
"deleteAfter": false,
4+
"localDir": "C:\\Users\\ewood\\Desktop",
5+
"serverTeam": "619"
6+
},
7+
"output": {
8+
"outputFolder": "C:\\Users\\ewood\\Desktop"
9+
}
10+
}

src/main/java/frc/robot/Constants.java

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ public static final class ElevatorConstants {
206206
public static final double wristMotorReduction = 1.0;
207207

208208

209-
public static final double maxVelocityMetersPerSec = 1.0; // Arbitrary
210-
public static final double maxAccelerationMetersPerSecSqrd = 1.5;
209+
public static final double maxVelocityMetersPerSec = 2.0; // Arbitrary
210+
public static final double maxAccelerationMetersPerSecSqrd = 4.0;
211211

212212

213213

@@ -235,29 +235,16 @@ public static final class ElevatorConstants {
235235
public static final double maxHeightEncoderVal = 68.75753021240234;
236236

237237

238-
239-
240-
241-
242-
243-
244-
245-
246-
247-
248-
249-
250-
251238
public static final double encoderZeroOffsetRotations = 0;
252239

253-
public static final double kpElevator = 9;
240+
public static final double kpElevator = 11.5;
254241
public static final double kiElevator = 0.0;
255242
public static final double kdElevator = 0.0;
256243

257244
public static final double ksFeedforward = 0.3;
258-
public static final double kvFeedforward = 4.4;
245+
public static final double kvFeedforward = 4.81;
259246

260-
public static final double feedforwardGravity = 0.40;
247+
public static final double feedforwardGravity = 0.29;
261248

262249
public static final DCMotor elevatorGearbox = DCMotor.getNeoVortex(2);
263250

src/main/java/frc/robot/Robot.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313

1414
package frc.robot;
1515

16+
import edu.wpi.first.networktables.NetworkTableInstance;
17+
import edu.wpi.first.util.datalog.StringLogEntry;
18+
import edu.wpi.first.wpilibj.DataLogManager;
1619
import edu.wpi.first.wpilibj.Threads;
1720
import edu.wpi.first.wpilibj2.command.Command;
1821
import edu.wpi.first.wpilibj2.command.CommandScheduler;
@@ -78,9 +81,9 @@ public Robot() {
7881

7982
//Uncomment if NT errors are occuring weirdly
8083

81-
// StringLogEntry entry = new StringLogEntry(DataLogManager.getLog(), "/ntlog");
82-
// NetworkTableInstance.getDefault().addLogger(0, 100,
83-
// event -> entry.append(event.logMessage.filename + ":" + event.logMessage.line + ":" + event.logMessage.message));
84+
StringLogEntry entry = new StringLogEntry(DataLogManager.getLog(), "/ntlog");
85+
NetworkTableInstance.getDefault().addLogger(0, 100,
86+
event -> entry.append(event.logMessage.filename + ":" + event.logMessage.line + ":" + event.logMessage.message));
8487
// Initialize URCL
8588
Logger.registerURCL(URCL.startExternal());
8689

src/main/java/frc/robot/RobotContainer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,8 @@ private Command robotGoToHeightCommandCreator(ElevatorHeight height){
240240
}else{
241241
command = Commands.sequence(
242242
new WristGoToPositionCommand(wrist, WristAngleRad.L2L3),
243-
new ElevatorGoToPositionPositionCommand(elevator, height),
244-
new WristGoToPositionCommand(wrist, getEndWristAngleForGivenElevatorHeight(height))
243+
new ElevatorGoToPositionPositionCommand(elevator, height)
244+
//new WristGoToPositionCommand(wrist, getEndWristAngleForGivenElevatorHeight(height))
245245
).withInterruptBehavior(InterruptionBehavior.kCancelSelf);
246246
}
247247

src/main/java/frc/robot/subsystems/Elevator/Elevator.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ public void periodic(){
7777
double voltage = elevatorController.calculate(getPositionMeters());
7878

7979
inputs.elevatorSetpointPositionMeters = elevatorController.getSetpoint().position;
80+
inputs.elevatorSetpointVelocityMPS = elevatorController.getSetpoint().velocity;
8081

8182

8283
if(inputs.elevatorSetpointPositionMeters > Constants.ElevatorConstants.minHeightMeters + 0.02){

src/main/java/frc/robot/subsystems/Elevator/ElevatorIO.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public static class ElevatorIOInputs {
1313
public double elevatorSetpointPositionMeters = 0.0;
1414
public double elevatorHeightMeters = ElevatorHeight.HOME.heightMeters;
1515
public double elevatorVelocityMPS = 0;
16+
public double elevatorSetpointVelocityMPS = 0;
1617

1718
public double elevatorGoalMeters = ElevatorHeight.HOME.heightMeters;
1819
public ElevatorHeight elevatorGoalEnum = ElevatorHeight.HOME;

src/main/java/frc/robot/subsystems/Elevator/ElevatorIOReal.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ private double encoderValToHeightMeters(double encoderVal){
9999

100100
private double encoderVelToVelocityMetersPerSec(double encoderVel){
101101
return (encoderVel / Constants.ElevatorConstants.maxHeightEncoderVal) *
102-
(Constants.ElevatorConstants.maxHeightMeters - Constants.ElevatorConstants.minHeightMeters);
102+
(Constants.ElevatorConstants.maxHeightMeters - Constants.ElevatorConstants.minHeightMeters) / 60.0;
103103
}
104104

105105

src/main/java/frc/robot/subsystems/drive/SparkOdometryThread.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ public class SparkOdometryThread {
3434
private final List<SparkBase> sparks = new ArrayList<>();
3535
private final List<DoubleSupplier> sparkSignals = new ArrayList<>();
3636
private final List<DoubleSupplier> genericSignals = new ArrayList<>();
37-
private final List<Queue<Double>> sparkQueues = new ArrayList<>();
38-
private final List<Queue<Double>> genericQueues = new ArrayList<>();
39-
private final List<Queue<Double>> timestampQueues = new ArrayList<>();
37+
private final List<ArrayBlockingQueue<Double>> sparkQueues = new ArrayList<>();
38+
private final List<ArrayBlockingQueue<Double>> genericQueues = new ArrayList<>();
39+
private final List<ArrayBlockingQueue<Double>> timestampQueues = new ArrayList<>();
4040

4141
private static SparkOdometryThread instance = null;
4242
private Notifier notifier = new Notifier(this::run);
@@ -60,7 +60,7 @@ public void start() {
6060

6161
/** Registers a Spark signal to be read from the thread. */
6262
public Queue<Double> registerSignal(SparkBase spark, DoubleSupplier signal) {
63-
Queue<Double> queue = new ArrayBlockingQueue<>(20);
63+
ArrayBlockingQueue<Double> queue = new ArrayBlockingQueue<>(20);
6464
Drive.odometryLock.lock();
6565
try {
6666
sparks.add(spark);
@@ -74,7 +74,7 @@ public Queue<Double> registerSignal(SparkBase spark, DoubleSupplier signal) {
7474

7575
/** Registers a generic signal to be read from the thread. */
7676
public Queue<Double> registerSignal(DoubleSupplier signal) {
77-
Queue<Double> queue = new ArrayBlockingQueue<>(20);
77+
ArrayBlockingQueue<Double> queue = new ArrayBlockingQueue<>(20);
7878
Drive.odometryLock.lock();
7979
try {
8080
genericSignals.add(signal);
@@ -87,7 +87,7 @@ public Queue<Double> registerSignal(DoubleSupplier signal) {
8787

8888
/** Returns a new queue that returns timestamp values for each sample. */
8989
public Queue<Double> makeTimestampQueue() {
90-
Queue<Double> queue = new ArrayBlockingQueue<>(20);
90+
ArrayBlockingQueue<Double> queue = new ArrayBlockingQueue<>(20);
9191
Drive.odometryLock.lock();
9292
try {
9393
timestampQueues.add(queue);

0 commit comments

Comments
 (0)