Skip to content

Commit 3706842

Browse files
committed
Last change of 2024 Offseason
1 parent 0eabdec commit 3706842

File tree

4 files changed

+11
-98
lines changed

4 files changed

+11
-98
lines changed

InertialNavigation.java

Lines changed: 0 additions & 77 deletions
This file was deleted.

Zwerve.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
*/
1212
public abstract class Zwerve extends Zubsystem implements ZmartDash {
1313
private static final double POS_FIX_KP = 0.2;
14-
private static final double ROTATION_OUTPUT = 2;
14+
private static final double ROTATION_OUTPUT = 1;
15+
private static final double ROTATION_OUTPUT_SLOW = 0.5;
16+
private static final double ROTATION_OUTPUT_FAST = 2;
1517
public final Vec2D shape;
1618
/**
1719
* Gyro.
@@ -136,7 +138,7 @@ public Zwerve go(Vec2D vel, double rot) {
136138
this.desired_yaw = curr_yaw;
137139
}
138140

139-
if (this.last_rot.get() < 0.5) {
141+
if (this.last_rot.get() < 0.2) {
140142
this.desired_yaw = curr_yaw;
141143
}
142144

@@ -145,7 +147,7 @@ public Zwerve go(Vec2D vel, double rot) {
145147
rot += error * POS_FIX_KP;
146148
}
147149

148-
this.prev.add(vel);
150+
this.prev.add(vel.rot(Math.PI));
149151
var sum = new Vec2D(0, 0);
150152
for (final var i : this.prev) {
151153
sum = sum.add(i);
@@ -159,7 +161,7 @@ public Zwerve go(Vec2D vel, double rot) {
159161
final var w = this.shape.y / 2;
160162
Vec2D[] v = { new Vec2D(l, w), new Vec2D(-l, w), new Vec2D(-l, -w), new Vec2D(l, -w) };
161163
for (var i = 0; i < 4; i++) {
162-
v[i] = v[i].rot(Math.PI / 2).with_r(rot*ROTATION_OUTPUT).add(vt);
164+
v[i] = v[i].rot(Math.PI / 2).with_r(rot * ROTATION_OUTPUT).add(vt);
163165
}
164166
for (int i = 0; i < 4; i++) {
165167
this.module[i].go(v[i].mul(this.output));
@@ -196,10 +198,10 @@ public Zwerve toggle_headless() {
196198
return this;
197199
}
198200

199-
public ZCommand drive(Axis x, Axis y, Axis rot, boolean useLimelight, double limelightForwardSpeed, double limelightRotateSpeed) {
201+
public ZCommand drive(Axis x, Axis y, Axis rot) {
200202
return new Zambda(this, () -> {
201-
final var vel = new Vec2D(useLimelight ? limelightForwardSpeed : x.get(), y.get());
202-
this.go(vel, useLimelight ? limelightRotateSpeed : rot.get());
203+
final var vel = new Vec2D(x.get(), y.get());
204+
this.go(vel, rot.get());
203205
});
204206
}
205207

hardware/Limelight.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public String key() {
3636
return "Limelight";
3737
}
3838

39-
// Copied from https://github.com/LimelightVision/limelight-examples/blob/main/java-wpilib/swerve-aim-and-range/src/main/java/frc/robot/LimelightHelpers.java
39+
// Copied from https://github.com/LimelightVision/limelightlib-wpijava/blob/main/LimelightHelpers.java
4040
private static class LimelightHelpers {
4141
private static final Map<String, DoubleArrayEntry> doubleArrayEntries = new ConcurrentHashMap<>();
4242
/**

hardware/Pigeon.java

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
package frc.libzodiac.hardware;
22

33
import com.ctre.phoenix6.hardware.Pigeon2;
4-
import frc.libzodiac.InertialNavigation.Gyro;
54
import frc.libzodiac.Util;
65
import frc.libzodiac.Zensor;
76
import frc.libzodiac.ZmartDash;
87
import frc.libzodiac.ui.Axis;
9-
import frc.libzodiac.util.Vec2D;
108

119
import java.security.InvalidParameterException;
1210

13-
public class Pigeon implements Gyro, Zensor, ZmartDash {
11+
public class Pigeon implements Zensor, ZmartDash {
1412
public final int can_id;
1513
protected Pigeon2 pigeon = null;
1614

@@ -55,14 +53,4 @@ public double get(String value) {
5553
public String key() {
5654
return "Pigeon(" + this.can_id + ")";
5755
}
58-
59-
@Override
60-
public double getYaw() {
61-
return this.get();
62-
}
63-
64-
@Override
65-
public Vec2D getAcceleration() {
66-
return new Vec2D(this.pigeon.getAccelerationX().refresh().getValue()-this.pigeon.getGravityVectorX().refresh().getValue(), this.pigeon.getAccelerationY().refresh().getValue()-this.pigeon.getGravityVectorY().refresh().getValue());
67-
}
6856
}

0 commit comments

Comments
 (0)