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