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