Add Climber Potentiometer to Debugging Site
Signed-off-by: Niko Sohmers <nikolai@sohmers.com>
Change-Id: I804c82d57550e2b92d7879bbc490e7380ccc369c
diff --git a/y2024/www/field_handler.ts b/y2024/www/field_handler.ts
index 298615f..72a68d8 100644
--- a/y2024/www/field_handler.ts
+++ b/y2024/www/field_handler.ts
@@ -6,6 +6,7 @@
import {Position as DrivetrainPosition} from '../../frc971/control_loops/drivetrain/drivetrain_position_generated'
import {CANPosition as DrivetrainCANPosition} from '../../frc971/control_loops/drivetrain/drivetrain_can_position_generated'
import {Status as DrivetrainStatus} from '../../frc971/control_loops/drivetrain/drivetrain_status_generated'
+import {Position as SuperstructurePosition} from '../control_loops/superstructure/superstructure_position_generated'
import {SuperstructureState, IntakeRollerStatus, CatapultState, TransferRollerStatus, ExtendRollerStatus, ExtendStatus, NoteStatus, Status as SuperstructureStatus} from '../control_loops/superstructure/superstructure_status_generated'
import {LocalizerOutput} from '../../frc971/control_loops/drivetrain/localization/localizer_output_generated'
import {TargetMap} from '../../frc971/vision/target_map_generated'
@@ -32,6 +33,7 @@
private drivetrainPosition: DrivetrainPosition|null = null;
private drivetrainCANPosition: DrivetrainCANPosition|null = null;
private superstructureStatus: SuperstructureStatus|null = null;
+ private superstructurePosition: SuperstructurePosition|null = null;
// Image information indexed by timestamp (seconds since the epoch), so that
// we can stop displaying images after a certain amount of time.
@@ -105,6 +107,9 @@
private intakePivotAbs: HTMLElement =
(document.getElementById('intake_pivot_abs') as HTMLElement);
+ private climberPot: HTMLElement =
+ (document.getElementById('climber_pot') as HTMLElement);
+
private extend: HTMLElement =
(document.getElementById('extend') as HTMLElement);
private extendAbs: HTMLElement =
@@ -259,6 +264,11 @@
this.handleSuperstructureStatus(data)
});
this.connection.addHandler(
+ '/superstructure', "y2024.control_loops.superstructure.Positon",
+ (data) => {
+ this.handleSuperstructurePosition(data)
+ });
+ this.connection.addHandler(
'/aos', 'aos.message_bridge.ServerStatistics',
(data) => {this.handleServerStatistics(data)});
this.connection.addHandler(
@@ -321,6 +331,11 @@
this.superstructureStatus = SuperstructureStatus.getRootAsStatus(fbBuffer);
}
+ private handleSuperstructurePosition(data: Uint8Array): void {
+ const fbBuffer = new ByteBuffer(data);
+ this.superstructurePosition = SuperstructurePosition.getRootAsPosition(fbBuffer);
+ }
+
private populateNodeConnections(nodeName: string): void {
const row = document.createElement('div');
this.messageBridgeDiv.appendChild(row);
@@ -526,6 +541,10 @@
this.setBoolean(this.altitude_above_min_angle, this.superstructureStatus.shooter().altitudeAboveMinAngle())
+ if (this.superstructurePosition) {
+ this.climberPot.innerHTML = this.superstructurePosition.climber().encoder().toString();
+ }
+
if (this.superstructureStatus.shooter() &&
this.superstructureStatus.shooter().aimer()) {
this.turret_position.innerHTML = this.superstructureStatus.shooter()