Add Climber Potentiometer to Debugging Site
Signed-off-by: Niko Sohmers <nikolai@sohmers.com>
Change-Id: I804c82d57550e2b92d7879bbc490e7380ccc369c
diff --git a/y2024/control_loops/superstructure/BUILD b/y2024/control_loops/superstructure/BUILD
index 946579b..6c67b26 100644
--- a/y2024/control_loops/superstructure/BUILD
+++ b/y2024/control_loops/superstructure/BUILD
@@ -57,6 +57,18 @@
],
)
+flatbuffer_ts_library(
+ name = "superstructure_position_ts_fbs",
+ srcs = [
+ "superstructure_position.fbs",
+ ],
+ deps = [
+ "//frc971/control_loops:control_loops_ts_fbs",
+ "//frc971/control_loops:profiled_subsystem_ts_fbs",
+ "//frc971/control_loops/drivetrain:drivetrain_can_position_ts_fbs",
+ ],
+)
+
static_flatbuffer(
name = "superstructure_can_position_fbs",
srcs = ["superstructure_can_position.fbs"],
diff --git a/y2024/www/BUILD b/y2024/www/BUILD
index b6b6b9b..8bc3755 100644
--- a/y2024/www/BUILD
+++ b/y2024/www/BUILD
@@ -38,6 +38,7 @@
"//frc971/control_loops/drivetrain:drivetrain_status_ts_fbs",
"//frc971/control_loops/drivetrain/localization:localizer_output_ts_fbs",
"//frc971/vision:target_map_ts_fbs",
+ "//y2024/control_loops/superstructure:superstructure_position_ts_fbs",
"//y2024/control_loops/superstructure:superstructure_status_ts_fbs",
"//y2024/localizer:status_ts_fbs",
"//y2024/localizer:visualization_ts_fbs",
diff --git a/y2024/www/field.html b/y2024/www/field.html
index a7809ae..d5eb5bf 100644
--- a/y2024/www/field.html
+++ b/y2024/www/field.html
@@ -163,6 +163,12 @@
<td id="intake_pivot_abs"> NA </td>
</tr>
<tr>
+ <th colspan="2">Climber</th>
+ </tr>
+ <tr>
+ <td>Pot Position</td>
+ <td id="climber_pot"> NA </td>
+ </tr>
<tr>
<th colspan="2">Extend</th>
</tr>
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()