James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 1 | // Provides a plot for debugging drivetrain-related issues. |
Philipp Schrader | 548aedf | 2023-02-17 20:09:13 -0800 | [diff] [blame] | 2 | import {AosPlotter} from '../../../aos/network/www/aos_plotter'; |
| 3 | import {ImuMessageHandler} from '../../../frc971/wpilib/imu_plot_utils'; |
| 4 | import * as proxy from '../../../aos/network/www/proxy'; |
| 5 | import {BLUE, BROWN, CYAN, GREEN, PINK, RED, WHITE} from '../../../aos/network/www/colors'; |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 6 | |
| 7 | import Connection = proxy.Connection; |
| 8 | |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 9 | const TIME = AosPlotter.TIME; |
| 10 | const DEFAULT_WIDTH = AosPlotter.DEFAULT_WIDTH; |
| 11 | const DEFAULT_HEIGHT = AosPlotter.DEFAULT_HEIGHT; |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 12 | |
| 13 | export function plotDrivetrain(conn: Connection, element: Element): void { |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 14 | const aosPlotter = new AosPlotter(conn); |
| 15 | |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 16 | const goal = aosPlotter.addMessageSource('/drivetrain', 'frc971.control_loops.drivetrain.Goal'); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 17 | const position = aosPlotter.addMessageSource("/drivetrain", |
| 18 | "frc971.control_loops.drivetrain.Position"); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 19 | const status = aosPlotter.addMessageSource( |
| 20 | '/drivetrain', 'frc971.control_loops.drivetrain.Status'); |
James Kuszmaul | 8cdc9f6 | 2023-03-12 14:01:14 -0700 | [diff] [blame] | 21 | const localizerOuput = aosPlotter.addMessageSource( |
| 22 | '/localizer', 'frc971.controls.LocalizerOutput'); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 23 | const output = aosPlotter.addMessageSource( |
| 24 | '/drivetrain', 'frc971.control_loops.drivetrain.Output'); |
James Kuszmaul | 4ddda33 | 2022-03-12 15:23:45 -0800 | [diff] [blame] | 25 | const gyroReading = aosPlotter.addMessageSource( |
| 26 | '/drivetrain', 'frc971.sensors.GyroReading'); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 27 | const imu = aosPlotter.addRawMessageSource( |
| 28 | '/drivetrain', 'frc971.IMUValuesBatch', |
| 29 | new ImuMessageHandler(conn.getSchema('frc971.IMUValuesBatch'))); |
| 30 | |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 31 | // Polydrivetrain (teleop control) plots |
| 32 | const teleopPlot = |
Austin Schuh | c2e9c50 | 2021-11-25 21:23:24 -0800 | [diff] [blame] | 33 | aosPlotter.addPlot(element, [DEFAULT_WIDTH, DEFAULT_HEIGHT / 2]); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 34 | teleopPlot.plot.getAxisLabels().setTitle('Drivetrain Teleop Goals'); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 35 | teleopPlot.plot.getAxisLabels().setXLabel(TIME); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 36 | teleopPlot.plot.getAxisLabels().setYLabel('bool, throttle/wheel values'); |
| 37 | teleopPlot.plot.setDefaultYRange([-1.1, 1.1]); |
| 38 | |
| 39 | const quickTurn = teleopPlot.addMessageLine(goal, ['quickturn']); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 40 | quickTurn.setColor(RED); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 41 | const throttle = teleopPlot.addMessageLine(goal, ['throttle']); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 42 | throttle.setColor(GREEN); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 43 | const wheel = teleopPlot.addMessageLine(goal, ['wheel']); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 44 | wheel.setColor(BLUE); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 45 | |
| 46 | // Drivetrain Control Mode |
| 47 | const modePlot = |
Austin Schuh | c2e9c50 | 2021-11-25 21:23:24 -0800 | [diff] [blame] | 48 | aosPlotter.addPlot(element, [DEFAULT_WIDTH, DEFAULT_HEIGHT / 2]); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 49 | // TODO(james): Actually add enum support. |
| 50 | modePlot.plot.getAxisLabels().setTitle( |
| 51 | 'Drivetrain Mode [POLYDRIVE, MOTION_PROFILE, ' + |
| 52 | 'SPLINE_FOLLOWER, LINE_FOLLOWER]'); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 53 | modePlot.plot.getAxisLabels().setXLabel(TIME); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 54 | modePlot.plot.getAxisLabels().setYLabel('ControllerType'); |
| 55 | modePlot.plot.setDefaultYRange([-0.1, 3.1]); |
| 56 | |
| 57 | const controllerType = modePlot.addMessageLine(goal, ['controller_type']); |
| 58 | controllerType.setDrawLine(false); |
| 59 | |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 60 | // Drivetrain Status estimated relative position |
Austin Schuh | c2e9c50 | 2021-11-25 21:23:24 -0800 | [diff] [blame] | 61 | const positionPlot = aosPlotter.addPlot(element); |
milind upadhyay | b81e6a4 | 2021-01-08 19:48:30 -0800 | [diff] [blame] | 62 | positionPlot.plot.getAxisLabels().setTitle("Estimated Relative Position " + |
| 63 | "of the Drivetrain"); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 64 | positionPlot.plot.getAxisLabels().setXLabel(TIME); |
milind upadhyay | b81e6a4 | 2021-01-08 19:48:30 -0800 | [diff] [blame] | 65 | positionPlot.plot.getAxisLabels().setYLabel("Relative Position (m)"); |
| 66 | const leftPosition = |
| 67 | positionPlot.addMessageLine(status, ["estimated_left_position"]); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 68 | leftPosition.setColor(RED); |
milind upadhyay | b81e6a4 | 2021-01-08 19:48:30 -0800 | [diff] [blame] | 69 | const rightPosition = |
| 70 | positionPlot.addMessageLine(status, ["estimated_right_position"]); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 71 | rightPosition.setColor(GREEN); |
milind upadhyay | b81e6a4 | 2021-01-08 19:48:30 -0800 | [diff] [blame] | 72 | const leftPositionGoal = |
| 73 | positionPlot.addMessageLine(status, ["profiled_left_position_goal"]); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 74 | leftPositionGoal.setColor(BLUE); |
milind upadhyay | b81e6a4 | 2021-01-08 19:48:30 -0800 | [diff] [blame] | 75 | const rightPositionGoal = |
| 76 | positionPlot.addMessageLine(status, ["profiled_right_position_goal"]); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 77 | rightPositionGoal.setColor(PINK); |
| 78 | const leftEncoder = positionPlot.addMessageLine(position, ["left_encoder"]); |
| 79 | leftEncoder.setColor(BROWN); |
| 80 | const rightEncoder = positionPlot.addMessageLine(position, ["right_encoder"]); |
| 81 | rightEncoder.setColor(CYAN); |
milind upadhyay | b81e6a4 | 2021-01-08 19:48:30 -0800 | [diff] [blame] | 82 | |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 83 | // Drivetrain Output Voltage |
Austin Schuh | c2e9c50 | 2021-11-25 21:23:24 -0800 | [diff] [blame] | 84 | const outputPlot = aosPlotter.addPlot(element); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 85 | outputPlot.plot.getAxisLabels().setTitle('Drivetrain Output'); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 86 | outputPlot.plot.getAxisLabels().setXLabel(TIME); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 87 | outputPlot.plot.getAxisLabels().setYLabel('Voltage (V)'); |
| 88 | |
| 89 | const leftVoltage = outputPlot.addMessageLine(output, ['left_voltage']); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 90 | leftVoltage.setColor(RED); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 91 | const rightVoltage = outputPlot.addMessageLine(output, ['right_voltage']); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 92 | rightVoltage.setColor(GREEN); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 93 | |
| 94 | // Voltage Errors |
Austin Schuh | c2e9c50 | 2021-11-25 21:23:24 -0800 | [diff] [blame] | 95 | const voltageErrors = aosPlotter.addPlot(element); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 96 | voltageErrors.plot.getAxisLabels().setTitle('Voltage Errors'); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 97 | voltageErrors.plot.getAxisLabels().setXLabel(TIME); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 98 | voltageErrors.plot.getAxisLabels().setYLabel('Voltage (V)'); |
| 99 | |
| 100 | const leftVoltageError = |
| 101 | voltageErrors.addMessageLine(status, ['left_voltage_error']); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 102 | leftVoltageError.setColor(RED); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 103 | const rightVoltageError = |
| 104 | voltageErrors.addMessageLine(status, ['right_voltage_error']); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 105 | rightVoltageError.setColor(GREEN); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 106 | |
| 107 | const ekfLeftVoltageError = |
| 108 | voltageErrors.addMessageLine(status, ['localizer', 'left_voltage_error']); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 109 | ekfLeftVoltageError.setColor(PINK); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 110 | const ekfRightVoltageError = voltageErrors.addMessageLine( |
| 111 | status, ['localizer', 'right_voltage_error']); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 112 | ekfRightVoltageError.setColor(CYAN); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 113 | |
| 114 | // Sundry components of the output voltages |
Austin Schuh | c2e9c50 | 2021-11-25 21:23:24 -0800 | [diff] [blame] | 115 | const otherVoltages = aosPlotter.addPlot(element); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 116 | otherVoltages.plot.getAxisLabels().setTitle('Other Voltage Components'); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 117 | otherVoltages.plot.getAxisLabels().setXLabel(TIME); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 118 | otherVoltages.plot.getAxisLabels().setYLabel('Voltage (V)'); |
| 119 | |
| 120 | const ffLeftVoltage = otherVoltages.addMessageLine( |
| 121 | status, ['poly_drive_logging', 'ff_left_voltage']); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 122 | ffLeftVoltage.setColor(RED); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 123 | ffLeftVoltage.setPointSize(0); |
| 124 | const ffRightVoltage = otherVoltages.addMessageLine( |
| 125 | status, ['poly_drive_logging', 'ff_right_voltage']); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 126 | ffRightVoltage.setColor(GREEN); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 127 | ffRightVoltage.setPointSize(0); |
| 128 | |
| 129 | const uncappedLeftVoltage = |
| 130 | otherVoltages.addMessageLine(status, ['uncapped_left_voltage']); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 131 | uncappedLeftVoltage.setColor(RED); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 132 | uncappedLeftVoltage.setDrawLine(false); |
| 133 | const uncappedRightVoltage = |
| 134 | otherVoltages.addMessageLine(status, ['uncapped_right_voltage']); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 135 | uncappedRightVoltage.setColor(GREEN); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 136 | uncappedRightVoltage.setDrawLine(false); |
| 137 | |
| 138 | // Drivetrain Velocities |
Austin Schuh | c2e9c50 | 2021-11-25 21:23:24 -0800 | [diff] [blame] | 139 | const velocityPlot = aosPlotter.addPlot(element); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 140 | velocityPlot.plot.getAxisLabels().setTitle('Velocity Plots'); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 141 | velocityPlot.plot.getAxisLabels().setXLabel(TIME); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 142 | velocityPlot.plot.getAxisLabels().setYLabel('Wheel Velocity (m/s)'); |
| 143 | |
| 144 | const ssLeftVelocityGoal = |
| 145 | velocityPlot.addMessageLine(status, ['profiled_left_velocity_goal']); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 146 | ssLeftVelocityGoal.setColor(PINK); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 147 | ssLeftVelocityGoal.setPointSize(0.0); |
| 148 | const ssRightVelocityGoal = |
| 149 | velocityPlot.addMessageLine(status, ['profiled_right_velocity_goal']); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 150 | ssRightVelocityGoal.setColor(CYAN); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 151 | ssRightVelocityGoal.setPointSize(0.0); |
| 152 | |
| 153 | const polyLeftVelocity = velocityPlot.addMessageLine( |
| 154 | status, ['poly_drive_logging', 'goal_left_velocity']); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 155 | polyLeftVelocity.setColor(PINK); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 156 | polyLeftVelocity.setDrawLine(false); |
| 157 | |
| 158 | const polyRightVelocity = velocityPlot.addMessageLine( |
| 159 | status, ['poly_drive_logging', 'goal_right_velocity']); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 160 | polyRightVelocity.setColor(CYAN); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 161 | polyRightVelocity.setDrawLine(false); |
| 162 | |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 163 | const leftVelocity = |
| 164 | velocityPlot.addMessageLine(status, ['estimated_left_velocity']); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 165 | leftVelocity.setColor(RED); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 166 | const rightVelocity = |
| 167 | velocityPlot.addMessageLine(status, ['estimated_right_velocity']); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 168 | rightVelocity.setColor(GREEN); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 169 | |
milind upadhyay | 6079d4f | 2021-01-24 13:59:57 -0800 | [diff] [blame] | 170 | const leftSpeed = velocityPlot.addMessageLine(position, ["left_speed"]); |
| 171 | leftSpeed.setColor(BLUE); |
| 172 | const rightSpeed = velocityPlot.addMessageLine(position, ["right_speed"]); |
| 173 | rightSpeed.setColor(BROWN); |
| 174 | |
| 175 | // Drivetrain trajectory and localizer velocities |
Austin Schuh | c2e9c50 | 2021-11-25 21:23:24 -0800 | [diff] [blame] | 176 | const velocityPlot2 = aosPlotter.addPlot(element); |
milind upadhyay | 6079d4f | 2021-01-24 13:59:57 -0800 | [diff] [blame] | 177 | velocityPlot2.plot.getAxisLabels().setTitle( |
| 178 | "Trajectory and Localizer Velocity Plots"); |
| 179 | velocityPlot2.plot.getAxisLabels().setXLabel(TIME); |
| 180 | velocityPlot2.plot.getAxisLabels().setYLabel('Wheel Velocity (m/s)'); |
| 181 | |
| 182 | const splineLeftVelocity = velocityPlot2.addMessageLine( |
| 183 | status, ['trajectory_logging', 'left_velocity']); |
| 184 | splineLeftVelocity.setColor(RED); |
| 185 | splineLeftVelocity.setDrawLine(false); |
| 186 | |
| 187 | const splineRightVelocity = velocityPlot2.addMessageLine( |
| 188 | status, ['trajectory_logging', 'right_velocity']); |
| 189 | splineRightVelocity.setColor(GREEN); |
| 190 | splineRightVelocity.setDrawLine(false); |
| 191 | |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 192 | const ekfLeftVelocity = |
milind upadhyay | 6079d4f | 2021-01-24 13:59:57 -0800 | [diff] [blame] | 193 | velocityPlot2.addMessageLine(status, ['localizer', 'left_velocity']); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 194 | ekfLeftVelocity.setColor(RED); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 195 | ekfLeftVelocity.setPointSize(0.0); |
| 196 | const ekfRightVelocity = |
milind upadhyay | 6079d4f | 2021-01-24 13:59:57 -0800 | [diff] [blame] | 197 | velocityPlot2.addMessageLine(status, ['localizer', 'right_velocity']); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 198 | ekfRightVelocity.setColor(GREEN); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 199 | ekfRightVelocity.setPointSize(0.0); |
| 200 | |
Austin Schuh | d99a3c4 | 2021-01-30 16:58:00 -0800 | [diff] [blame] | 201 | const splineVelocityOffset = velocityPlot2.addMessageLine( |
| 202 | status, ['localizer', 'longitudinal_velocity_offset']); |
| 203 | splineVelocityOffset.setColor(BROWN); |
| 204 | splineVelocityOffset.setPointSize(0.0); |
| 205 | |
| 206 | const splineLateralVelocity = velocityPlot2.addMessageLine( |
| 207 | status, ['localizer', 'lateral_velocity']); |
| 208 | splineLateralVelocity.setColor(PINK); |
| 209 | splineLateralVelocity.setPointSize(0.0); |
| 210 | |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 211 | // Heading |
Austin Schuh | c2e9c50 | 2021-11-25 21:23:24 -0800 | [diff] [blame] | 212 | const yawPlot = aosPlotter.addPlot(element); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 213 | yawPlot.plot.getAxisLabels().setTitle('Robot Yaw'); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 214 | yawPlot.plot.getAxisLabels().setXLabel(TIME); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 215 | yawPlot.plot.getAxisLabels().setYLabel('Yaw (rad)'); |
| 216 | |
| 217 | const splineYaw = |
| 218 | yawPlot.addMessageLine(status, ['trajectory_logging', 'theta']); |
| 219 | splineYaw.setDrawLine(false); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 220 | splineYaw.setColor(RED); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 221 | |
| 222 | const ekfYaw = yawPlot.addMessageLine(status, ['localizer', 'theta']); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 223 | ekfYaw.setColor(GREEN); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 224 | |
| 225 | const downEstimatorYaw = |
| 226 | yawPlot.addMessageLine(status, ['down_estimator', 'yaw']); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 227 | downEstimatorYaw.setColor(BLUE); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 228 | |
| 229 | // Pitch/Roll |
Austin Schuh | c2e9c50 | 2021-11-25 21:23:24 -0800 | [diff] [blame] | 230 | const orientationPlot = aosPlotter.addPlot(element); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 231 | orientationPlot.plot.getAxisLabels().setTitle('Orientation'); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 232 | orientationPlot.plot.getAxisLabels().setXLabel(TIME); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 233 | orientationPlot.plot.getAxisLabels().setYLabel('Angle (rad)'); |
| 234 | |
| 235 | const roll = orientationPlot.addMessageLine( |
| 236 | status, ['down_estimator', 'lateral_pitch']); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 237 | roll.setColor(RED); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 238 | roll.setLabel('roll'); |
| 239 | const pitch = orientationPlot.addMessageLine( |
| 240 | status, ['down_estimator', 'longitudinal_pitch']); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 241 | pitch.setColor(GREEN); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 242 | pitch.setLabel('pitch'); |
| 243 | |
| 244 | // Accelerometer/Gravity |
Austin Schuh | c2e9c50 | 2021-11-25 21:23:24 -0800 | [diff] [blame] | 245 | const accelPlot = aosPlotter.addPlot(element); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 246 | accelPlot.plot.getAxisLabels().setTitle('Accelerometer Readings'); |
| 247 | accelPlot.plot.getAxisLabels().setYLabel('Acceleration (g)'); |
| 248 | accelPlot.plot.getAxisLabels().setXLabel('Monotonic Reading Time (sec)'); |
| 249 | |
| 250 | const expectedAccelX = |
| 251 | accelPlot.addMessageLine(status, ['down_estimator', 'expected_accel_x']); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 252 | expectedAccelX.setColor(RED); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 253 | expectedAccelX.setPointSize(0); |
| 254 | const expectedAccelY = |
| 255 | accelPlot.addMessageLine(status, ['down_estimator', 'expected_accel_y']); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 256 | expectedAccelY.setColor(GREEN); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 257 | expectedAccelY.setPointSize(0); |
| 258 | const expectedAccelZ = |
| 259 | accelPlot.addMessageLine(status, ['down_estimator', 'expected_accel_z']); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 260 | expectedAccelZ.setColor(BLUE); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 261 | expectedAccelZ.setPointSize(0); |
| 262 | |
| 263 | const gravity_magnitude = |
| 264 | accelPlot.addMessageLine(status, ['down_estimator', 'gravity_magnitude']); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 265 | gravity_magnitude.setColor(WHITE); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 266 | gravity_magnitude.setPointSize(0); |
| 267 | |
| 268 | const accelX = accelPlot.addMessageLine(imu, ['accelerometer_x']); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 269 | accelX.setColor(RED); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 270 | accelX.setDrawLine(false); |
| 271 | const accelY = accelPlot.addMessageLine(imu, ['accelerometer_y']); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 272 | accelY.setColor(GREEN); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 273 | accelY.setDrawLine(false); |
| 274 | const accelZ = accelPlot.addMessageLine(imu, ['accelerometer_z']); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 275 | accelZ.setColor(BLUE); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 276 | accelZ.setDrawLine(false); |
| 277 | |
| 278 | // Absolute X Position |
Austin Schuh | c2e9c50 | 2021-11-25 21:23:24 -0800 | [diff] [blame] | 279 | const xPositionPlot = aosPlotter.addPlot(element); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 280 | xPositionPlot.plot.getAxisLabels().setTitle('X Position'); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 281 | xPositionPlot.plot.getAxisLabels().setXLabel(TIME); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 282 | xPositionPlot.plot.getAxisLabels().setYLabel('X Position (m)'); |
| 283 | |
James Kuszmaul | 8cdc9f6 | 2023-03-12 14:01:14 -0700 | [diff] [blame] | 284 | xPositionPlot.addMessageLine(status, ['x']).setColor(RED); |
| 285 | xPositionPlot.addMessageLine(status, ['trajectory_logging', 'x']) |
| 286 | .setColor(GREEN); |
| 287 | xPositionPlot.addMessageLine(localizerOuput, ['x']).setColor(BLUE); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 288 | |
| 289 | // Absolute Y Position |
Austin Schuh | c2e9c50 | 2021-11-25 21:23:24 -0800 | [diff] [blame] | 290 | const yPositionPlot = aosPlotter.addPlot(element); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 291 | yPositionPlot.plot.getAxisLabels().setTitle('Y Position'); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 292 | yPositionPlot.plot.getAxisLabels().setXLabel(TIME); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 293 | yPositionPlot.plot.getAxisLabels().setYLabel('Y Position (m)'); |
| 294 | |
James Kuszmaul | 8cdc9f6 | 2023-03-12 14:01:14 -0700 | [diff] [blame] | 295 | yPositionPlot.addMessageLine(status, ['y']).setColor(RED); |
| 296 | yPositionPlot.addMessageLine(status, ['trajectory_logging', 'y']) |
| 297 | .setColor(GREEN); |
| 298 | yPositionPlot.addMessageLine(localizerOuput, ['y']).setColor(BLUE); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 299 | |
| 300 | // Gyro |
Austin Schuh | c2e9c50 | 2021-11-25 21:23:24 -0800 | [diff] [blame] | 301 | const gyroPlot = aosPlotter.addPlot(element); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 302 | gyroPlot.plot.getAxisLabels().setTitle('Gyro Readings'); |
| 303 | gyroPlot.plot.getAxisLabels().setYLabel('Angular Velocity (rad / sec)'); |
| 304 | gyroPlot.plot.getAxisLabels().setXLabel('Monotonic Reading Time (sec)'); |
| 305 | |
| 306 | const gyroZeroX = |
| 307 | gyroPlot.addMessageLine(status, ['zeroing', 'gyro_x_average']); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 308 | gyroZeroX.setColor(RED); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 309 | gyroZeroX.setPointSize(0); |
| 310 | gyroZeroX.setLabel('Gyro X Zero'); |
| 311 | const gyroZeroY = |
| 312 | gyroPlot.addMessageLine(status, ['zeroing', 'gyro_y_average']); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 313 | gyroZeroY.setColor(GREEN); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 314 | gyroZeroY.setPointSize(0); |
| 315 | gyroZeroY.setLabel('Gyro Y Zero'); |
| 316 | const gyroZeroZ = |
| 317 | gyroPlot.addMessageLine(status, ['zeroing', 'gyro_z_average']); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 318 | gyroZeroZ.setColor(BLUE); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 319 | gyroZeroZ.setPointSize(0); |
| 320 | gyroZeroZ.setLabel('Gyro Z Zero'); |
| 321 | |
| 322 | const gyroX = gyroPlot.addMessageLine(imu, ['gyro_x']); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 323 | gyroX.setColor(RED); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 324 | const gyroY = gyroPlot.addMessageLine(imu, ['gyro_y']); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 325 | gyroY.setColor(GREEN); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 326 | const gyroZ = gyroPlot.addMessageLine(imu, ['gyro_z']); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 327 | gyroZ.setColor(BLUE); |
James Kuszmaul | 4ddda33 | 2022-03-12 15:23:45 -0800 | [diff] [blame] | 328 | gyroPlot.addMessageLine(gyroReading, ['velocity']).setColor(BLUE); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 329 | |
| 330 | // IMU States |
| 331 | const imuStatePlot = |
Austin Schuh | c2e9c50 | 2021-11-25 21:23:24 -0800 | [diff] [blame] | 332 | aosPlotter.addPlot(element, [DEFAULT_WIDTH, DEFAULT_HEIGHT / 2]); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 333 | imuStatePlot.plot.getAxisLabels().setTitle('IMU State'); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 334 | imuStatePlot.plot.getAxisLabels().setXLabel(TIME); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 335 | imuStatePlot.plot.setDefaultYRange([-0.1, 1.1]); |
| 336 | |
| 337 | const zeroedLine = imuStatePlot.addMessageLine(status, ['zeroing', 'zeroed']); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 338 | zeroedLine.setColor(RED); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 339 | zeroedLine.setDrawLine(false); |
| 340 | zeroedLine.setLabel('IMU Zeroed'); |
| 341 | const faultedLine = |
| 342 | imuStatePlot.addMessageLine(status, ['zeroing', 'faulted']); |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 343 | faultedLine.setColor(GREEN); |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 344 | faultedLine.setPointSize(0); |
| 345 | faultedLine.setLabel('IMU Faulted'); |
| 346 | } |