Code Style
Coding standards for the AV2.
Python Style
We follow PEP 8 with some modifications:
Line length: 100 characters
Use type hints for public functions
Use docstrings for all public classes and methods
Formatting
Use black for automatic formatting:
black --line-length 100 .
Linting
Use flake8 for linting:
flake8 --max-line-length 100 .
Docstrings
Use NumPy style docstrings:
def compute_steering(self, waypoints, speed):
"""
Compute steering angle using pure pursuit.
Parameters
----------
waypoints : list of tuple
List of (x, y) waypoints in vehicle frame
speed : float
Current vehicle speed in m/s
Returns
-------
float
Steering angle in radians
"""
Type Hints
from typing import List, Tuple, Optional
def find_waypoint(
waypoints: List[Tuple[float, float]],
distance: float
) -> Optional[Tuple[float, float]]:
...
Naming Conventions
Classes:
PascalCaseFunctions/methods:
snake_caseConstants:
UPPER_SNAKE_CASEPrivate members:
_leading_underscore