Generating Code
As a code gen extension tailor-made for robotics, the workflow for generating code with Fid is quite different to what you may be used to with other copilots or coding agents. Fid is currently optimized specifically for generating sensor integrations and only supports C++.
Basic Code Gen
To start generating code with Fid, right click on a header file name in the VS Code explorer, or inside the contents of a header file, and select “Fid: Generate File Implementation” from the context menu. This will generate the implementation for your entire header file, informed by your knowledge base, and can be an effective workflow for quickly bringing up an entirely new integration.
Alternatively, if you already have some of your integration implemented, or you would like to iterate on a specific function, you can right click inside a function definition in your header file and select “Fid: Generate Single Function Implementation” from the context menu.
Configuring Build Feedback
Fid is most powerful when it can autonomously iterate with feedback from your build system, in order to validate the code that it generates. Fid should understand build errors from most common C++ compilers.
To enable this, open the settings view in Fid and expand the “Build” section. Click on “Command” to set your build command (e.g. make -j4
), and click on “Build Path” to set the path to your build directory. Finally, enable automatic builds by clicking on “Toggle auto-build”.
Now, whenever you generate code with Fid, it will automatically build your project and iterate to resolve any build errors that it encounters.
Configuring Tests
Fid also has the capability to take tests you have written and iterate with feedback from your build system to modify your code so that it can pass your tests.
To enable this, open the settings view in Fid and expand the “Tests” section. Click on “Command” to set your test command (e.g. ./intelRealSenseBoostTest
), click on ” Path” to set the path to your build directory. You can enable tests by clicking on “Run” and set tests to required by clicking on “Required”.
Setting tests to required will ensure that no tests after it run unless the required tests pass. Next, you can set the test type to Boost, Google, or leave it as None. Setting the test type will help Fid better parse your test results and provide more accurate feedback to the system. You can also move the tests up and down to change the order in which they will run by clicking on the up and down arrows.
Finally, to give Fid more context on what the contents of your test file are, set the source file to the test file you want to run.
Now, whenever you generate code with Fid, it will automatically test your project and iterate to resolve any errors that it encounters in order to better optimize your code for passing the necesary tests.