RIT-VEX-U / Core

Standard library for the RIT VexU Robotics Team
https://rit-vex-u.github.io/Core/
MIT License
3 stars 4 forks source link

Sanity Check invalid Subsystem Parameters #78

Open max-49 opened 5 months ago

max-49 commented 5 months ago

Integer division vs double division

cowsed commented 5 months ago

when starting a new repo and youre robot config is all zeros, the robot can silently fault with division by zero errors and the brain gives no error report. If we assert that all parameters are valid, we can print out our own errors for these hard to track down errors

cowsed commented 5 months ago

We might want to write our own assert function that prints to the screen or controller in addition to stdout so its really hard to miss

cowsed commented 3 months ago

FOR THE NOTEBOOK ENTRY, YOU CAN COPY THIS FOR YOUR IDENTIFY THE PROBLEM. Do make sure to read it first though.

A VEX Robot is a highly configurable system. Each subsystem on the robot can have dozens of parameters that control its actions and, when any of these parameters are not initialized properly, the robot can behave erratically or even silently crash with a divide by zero error. In the excitement of getting new hardware to work with and under time pressure, it is easy to not fully initialize all subsystems - especially ones that are not under test at that point in time. As well, C++'s sometimes subtle casting rules can have a programmer unknowingly passing a zero when they instead meant to pass a fraction. To save programmers from pulling out hair in frustration, validity checks can be inserted on construction of these subsystems that warn for invalid or illogical parameters.

The following classes have been identified for validity checks: