Adding a New Error Case¶
Error cases should be specific and are structured to operate on a single joint’s data.
error_codes.h¶
In the
ErrorCodesenum, create a name for your new error case. - This name should be placed below theNO_ERRORcase and above theERROR_CODE_LENGTHcase.
error_types.h¶
Create a new error type class (use the other error types as a reference).
The class should inherit from
ErrorTypeand must implement both acheckand ahandlefunction.The
checkfunction should: - ReturnTrueif your error has occurred. - ReturnFalseif it has not.Note
The
checkfunction only has access to theJointDataclass and is executed for every joint. If your error case requires its own data, add that data to theJointDataclass (in JointData.h).The
handlefunction decides what action to take when your error occurs, such as disabling the motors.
error_map.h¶
In
error_map.h, add a new key-value pair for your new error case. - Use the following format:{YOUR_ERROR_CASE_NAME_FROM_PART_ONE, new YourErrorTypeNameFromPartTwo()},
Done¶
Your new error case will now be:
- Checked by the run method in Joint.cpp (applied to the hip, knee, and ankle).
- Handled by your handle function when it occurs.
- Reported to the app appropriately.