Coding Convention of S2E
Formatter
- We use ClangFormat for S2E.
- We selected
Googlebase style with small modifications. - Details are written in .clang-format.
- We selected
Naming Rules
-
Now discussing
- The following rules are follows until the new naming rule is decided.
- Several old files do not follow the rules.
- We are discussing follow the Google C++ Style Guide with small modifications.
-
File and directory Name
snake_case- C++ files should end in
.cpp, and header files should end in.hpp.
-
Macro (define)
- Snake case with capital case
SNAKE_CASE
-
Name of the class
CamelCase
-
Variable name
- Snake case with lower case
snake_case
-
Constant name (not a define but a constant)
- Add k at the beginning and the rest is CamelCase
kCamelCase
-
Member variables in the class
- Snake case with lower case end with
_ snake_case_
- Snake case with lower case end with
-
Methods (functions) in the class
CamelCase
-
The #define Guard
- Apply Google C++ Style Guide.
#pragma onceis prohibited
Documentation
- Use Doxygen
- Use Markdown for Doxygen
- Examples:
- https://developer.lsst.io/cpp/api-docs.html
Initialization files (.ini files)
- Comments
- Use //
Abbreviations
- Basically, we follows the Naming Rules in the Google Style Guide
- Single character abbreviations are prohibited.
- Examples:
q = quaternion,v = velocityare prohibited.
- Examples:
- We do not recommend to use abbreviations for one word cutting the word.
- Examples:
pos = position,quat = quaternionare not recommended. - The following abbreviations are available as exceptions since they are widely used in the math, science, and technology field.
max: maximummin: minimuminit: initial, initializecalc: calculate, calculation
- Examples:
- Abbreviation only file name is not recommended.
- Examples
ode.hppshould be written asordinary_differential_equation.hppgnssr.hppis not recommended, butgnss_receiver.hppis available since we can guess the abbreviation meaning from the context.
- Examples
- Write the full words in the comment when you use abbreviations.
- Available abbreviations are decided during review processes.
- Examples of available abbreviations with comments
EKF: Extended Kalman FilterGNSS: Global Navigation Satellite System
- Examples of available abbreviations with comments
- Abbreviations to show the frame and the unit are available.
- Examples of frame
i: Inertial frameb: Body fixed framec: Component fixed frameecef: Earth Centered Earth Fixed framelvlh: Local Vertical Local Horizontalrtn: Radial-Transverse-Normal
- Examples of unit:
Nm,rad/s,m/s2,degC
- Examples of frame
- Available abbreviations
S2E: Spacecraft Simulation EnvironmentAOCS: Attitude and Orbit Control SystemCDH: Command and Data Handling