raccoon codegen
raccoon codegen
raccoon codegen --only defs
raccoon codegen --no-format
Generates the Python files in src/hardware/ from raccoon.project.yml and the config/*.yml files. It runs on your laptop and needs no connection to the robot. raccoon run
and raccoon upload
call it for you; you run it yourself to refresh IDE completion after editing the YAML.
What the generated files contain and why you never edit them is explained in Code Generator .
What it does
- Finds the project and loads its config.
- Validates the project, unless
--no-validateis set. A failed validation stops the command before anything is written. See validate . - Resolves the table map (
.ftmap) ifrobot.physical.table_mappoints to one. Only the v2 format is accepted. A missing or old-format file is an error. - Generates the files and formats them with
black. - Prints a table of the generated files.
Your project folder is added to the Python path, so your own types (for example a custom sensor class under src/hardware/) can be used in the config.
Options
| Option | Default | Description |
|---|---|---|
--only NAME | all | Generate only this file: defs or robot. Can be given several times |
--no-format | off | Skip the black formatting |
-o, --output-dir DIR | src/hardware/ | Write the files to another folder. A relative path is relative to the folder you run the command in |
--no-validate | off | Skip the validation before generating |
Examples
# Everything, after editing config/hardware.yml
raccoon codegen
# Only defs.py and defs.pyi
raccoon codegen --only defs
# Both files, without formatting (faster, harder to read)
raccoon codegen --only defs --only robot --no-format
# Look at the output without touching src/hardware/
raccoon codegen -o /tmp/hardware-preview
Errors
The command exits with code 1 and a message if
- you are not inside a project,
raccoon.project.ymlis not a mapping,- validation fails (use
--no-validateonly if you know why), - the table map file is missing or in the old format.
Unexpected errors are logged with a stack trace.