Check out this GitHub repository to see the python script and some more information about how to set up and use it in your own project. I tested this on Ubuntu 18.04 and macOS Catalina 10.15.5.
This python script parses a “constants.h” file with button assignments of the form
const auto INTAKE_BUTTON = okapi::ControllerDigital::R1;
to generate a markdown file of button assignments.
Motivation
This script is useful particularly when any of the following are true:
- the drivers are not involved in programming the robot
- there are multiple drivers for each robot
- two robots have different button assignments, and it is desired to have a readily available reference for button bindings for each robot (i.e. for VEX U teams)
Setup
Setting up your project structure to use the parse_key_bindings script is also pretty straightforward
- Create a directory called
docs
in your top level directory, and put the filecontroller.png
in this directory. - Create a file called
constants.h
and assign your button mappings inside of it (seeconstants_example.h
). - Add the lines
builddocs: path/to/constants.h
, andpython generic_parse_key_bindings.py
to the beginning of yourMakefile
, which is in the top level directory of your project folder (seeMakefile_example
). - Update
parse_key_bindings.py
with the requested information
Usage
To generate the documentation, type prosv5 make builddocs
at the root directory of your project. If you want the script to be run everytime you compile the project, you can create aliases in your .bashrc
(or equivalently .zshrc
, etc): alias pm='prosv5 make builddocs'
, alias pmu='pm && prosv5 upload'
, and alias pmut='pmu && prosv5 terminal'
.
Example of project that uses this script
See this github repository for an example of all the above used in a PROS project.