This project uses automated code formatters to maintain consistent code style.
On Ubuntu/Debian:
sudo apt install clang-format python3-autopep8On macOS:
brew install clang-format
pip3 install autopep8Run the formatting script:
./format_code.shThis will automatically format:
- C++ files (
*.cpp,*.hpp) using clang-format - Python files (
*.py) using autopep8
Format a specific C++ file:
clang-format -i --style=file src/tinymovr_system.cppFormat a specific Python file:
autopep8 --in-place --max-line-length 100 launch/tinymovr_diffbot_demo.launch.pyTo automatically format before each commit:
# Create pre-commit hook
cat > .git/hooks/pre-commit << 'EOF'
#!/bin/bash
./format_code.sh
git add -u
EOF
chmod +x .git/hooks/pre-commitThe CI pipeline uses:
- clang-format: Checks C++ formatting (ROS 2 style, 100 char line limit)
- flake8: Checks Python style
External libraries (tinymovr protocol, socketcan_cpp) are excluded from linting.
- Line length: 100 characters maximum
- Indentation: 2 spaces (no tabs)
- Braces: Required for all control statements
- Style guide: Based on Google C++ Style Guide with ROS 2 modifications
See .clang-format for complete configuration.