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