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