Coding Style Guide
Please note that if you have a good excuse to either break the rules or modify them, feel free to do it (and update this guide accordingly, if appropriate). Nothing is worse than rule that hurts productivity instead of improving it. In general, the main aim of this style is:
- Vertical and horizontal compression, fitting more code on a screen while keeping the code readable.
- Do not need to enforce line wrapping if clarity is impacted (i.e. Jacobians)
- Consistent indentation and formatting rules to ensure readability (4 space tabbing)
The codebase is coded in snake_
We have particular naming style for our orientations and positions that should be consistent throughout the project. In general rotation matrices are the only exception of a variable that starts with a capital letter. Both position and orientation variables should contain the frame of references.
Eigen::Matrix<double,3,3> R_ItoC; //=> SO(3) rotation from IMU to camera frame Eigen::Matrix<double,4,1> q_ItoC; //=> JPL quaternion rot from IMU to the camera Eigen::Vector3d p_IinC; //=> 3d position of the IMU frame in the camera frame Eigen::Vector3d p_FinG; //=> position of feature F in the global frame G
The code uses a simple print statement level logic that allows the user to enable and disable the verbosity. In general the user can specify the following (see ov_
- PrintLevel::ALL : All PRINT_XXXX will output to the console
- PrintLevel::DEBUG : "DEBUG", "INFO", "WARNING" and "ERROR" will be printed. "ALL" will be silenced
- PrintLevel::INFO : "INFO", "WARNING" and "ERROR" will be printed. "ALL" and "DEBUG" will be silenced
- PrintLevel::WARNING : "WARNING" and "ERROR" will be printed. "ALL", "DEBUG" and "INFO" will be silenced
- PrintLevel::ERROR : Only "ERROR" will be printed. All the rest are silenced
- PrintLevel::SILENT : All PRINT_XXXX will be silenced.
PRINT_ALL("the value is %.2f\n", variable); PRINT_DEBUG("the value is %.2f\n", variable); PRINT_INFO("the value is %.2f\n", variable); PRINT_WARNING("the value is %.2f\n", variable); PRINT_ERROR(RED "the value is %.2f\n" RESET, variable);