| Content | Extension |
|---|---|
| Regular header | .h |
| Template-heavy header | .hpp |
| Template implementation | .ipp |
| Source file | .cpp |
Template bodies are placed in a .ipp file that is #included at the bottom of the corresponding header, keeping the header readable.
| Kind | Convention | Examples |
|---|---|---|
| Class | PascalCase | GaitController.h, LifecycleNode.cpp |
| State-machine state | st_ prefix, snake_case |
st_base.h, st_walking.cpp |
| Command (command pattern) | cmd_ prefix, snake_case |
cmd_record.h, cmd_pause.h |
| Interface | I prefix, PascalCase |
IKdlSolver.h, IGuiCommand.h |
| Utility / free function | snake_case | create_heartbeat_topic_name.h |
Use #pragma once instead of #ifndef/#define.
Every file begins with:
/**
* Copyright (c) YYYY-YYYY LXRobotics GmbH.
* Author: First Last <first.last@lxrobotics.com>
*/
Every header is divided into named sections separated by 90-character banner comments:
/**************************************************************************************
* SECTION NAME (i.e. INCLUDE, CLASS DECLARATION, FUNCTION DECLARATION, CTOR/DTOR, PUBLIC MEMBER FUNCTIONS ...
**************************************************************************************/
Within the INCLUDE section, headers appear in the following order:
<stdlib.h> …<memory>, <map>, <optional>, <expected>, …<rclcpp/…>, <mp-units/…>, KDL, Boost, …Names must be self-explanatory without requiring a comment.
| Entity | Convention | Examples |
|---|---|---|
| Class, struct | PascalCase | ComponentBase, OdometryEstimator |
| State class | st_ + snake_case |
st_base, st_walking |
| Command class | cmd_ + snake_case |
cmd_record, cmd_pause |
| Interface class | I + PascalCase |
IKdlSolver, IGuiCommand |
All method or function names use snake_case (i.e. on_update(), init_ctrl_loop_timer()).
is_condition_valid)_ prefix (i.e. _context, _ctrl_loop_timer)Constants use SCREAMING_SNAKE_CASE (i.e.CTRL_LOOP_RATE, MAX_HOLD_TIME).
Enum class iterators use PascalCase (i.e. Leg::LeftFront, Protocol::V2_0).
Namespaces are lower case and nested namespaces use C++17 syntax:
namespace l4xz::publisher {
// …
} /* l4xz::publisher */