Skip to content

Commit 922483d

Browse files
authored
Publish rotation from Pigeon to NetworkTables (#3)
We were seeing weird positions from PhotonVision when testing on the practice field. The team was undsure what angle the pigeon was reporting, so we decided that we should publish that data to Network Tables. Co-authored-by: Arthur Hung
1 parent 2c1fb3c commit 922483d

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/main/java/com/team2813/subsystems/Drive.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ public class Drive extends SubsystemBase implements AutoCloseable {
106106
private final DoubleArrayPublisher modulePositionsPublisher;
107107
private final DoublePublisher ambiguityPublisher =
108108
NetworkTableInstance.getDefault().getDoubleTopic("Ambiguity").publish();
109+
private final StructPublisher<Rotation3d> anglePublisher;
109110

110111
/** This measurement is <em>IN INCHES</em> */
111112
private static final double WHEEL_RADIUS_IN = 1.537;
@@ -336,6 +337,7 @@ public Drive(
336337
networkTable.getStructArrayTopic("actual state", SwerveModuleState.struct).publish();
337338
currentPosePublisher = networkTable.getStructTopic("current pose", Pose2d.struct).publish();
338339
modulePositionsPublisher = networkTable.getDoubleArrayTopic("module positions").publish();
340+
anglePublisher = networkTable.getStructTopic("pigeon angle", Rotation3d.struct).publish();
339341

340342
setDefaultCommand(createDefaultCommand());
341343

@@ -540,9 +542,11 @@ public void periodic() {
540542
// Publish data to NetworkTables
541543
expectedStatePublisher.set(drivetrain.getState().ModuleTargets);
542544
actualStatePublisher.set(drivetrain.getState().ModuleStates);
545+
Rotation3d rotation = getRotation3d();
543546
if (config.usePnpDistanceTrigSolveStrategy) {
544-
photonPoseEstimator.addHeadingData(Timer.getTimestamp(), getRotation3d());
547+
photonPoseEstimator.addHeadingData(Timer.getTimestamp(), rotation);
545548
}
549+
anglePublisher.set(rotation);
546550
photonPoseEstimator.update(this::handlePhotonPose);
547551
// Thoughts about moving away from functional programing paradigm here to just simpler,
548552
// procedural programming, e.g.,

0 commit comments

Comments
 (0)