Skip to main content
Version: 4.0.0-beta.1

Health Check

ez::health checks that the IMU, every drive motor, every configured odom tracker, and every device you've registered with device_add() is responding, before you rely on them in a match.

Functions

preflight()

Checks that the IMU, every drive motor, every configured odom tracker, and every device registered with device_add() responds. Prints each failure with its port and rumbles the controller when anything is wrong.

Safe to call from initialize() and again at the start of autonomous().

chassis your drive
controller the controller to rumble on failure

ez::health::Report preflight(ez::Drive& chassis, pros::Controller& controller);

device_add()

Registers a smart device (a motor that isn't on the drive, or a distance, rotation, or optical sensor - anything deriving from pros::Device) for inclusion in preflight() checks.

A null device is ignored, and a null name is reported as "unnamed device".

device the sensor or motor to watch
name a label used when it fails a check

void device_add(pros::Device* device, const char* name);

preflight_register()

Adds a "Health Check" page to the auton selector, so preflight() can be run from the brain instead of from code. Call this in initialize(), after ez::as::initialize().

This is only a convenience - preflight() is an ordinary function, so calling it from an opcontrol button works just as well, for example:

if (master.get_digital_new_press(DIGITAL_Y)) ez::health::preflight(chassis, master);

chassis your drive

void preflight_register(ez::Drive& chassis);

Report

preflight() returns a Report. Temperature is a warning rather than a failure, so motors_hot and motors_warm deliberately do not count against all_ok().

struct Report {
bool imu_ok = true;
int motors_bad = 0; // drive motors not responding
int motors_hot = 0; // drive motors hot enough to be losing power
int motors_warm = 0; // drive motors warm but still at full power
int trackers_bad = 0; // configured odom trackers not responding
int devices_bad = 0; // registered devices not responding
bool all_ok() const;
};