-
Notifications
You must be signed in to change notification settings - Fork 2
Closed
Labels
problemThis doesn't seem rightThis doesn't seem right
Description
Plan
Remove all template
classes from RobotLibrary.
Compilation times for other projects using RobotLibrary were observed to take up to 19 seconds to compile. This is due to every class being defined as a template, meaning source code is not pre-compiled to save time:
24.07.11_Template_Build_Time.webm
[A post-hoc note: I didn't have a proper plan set out, so I took a lot of detours, and ran in to a lot of problems trying to make everything work!]
Do:
Observation | Thoughts, insights |
---|---|
I experienced a lot of linker errors. Had to remove the inline keyword scattered throughout header and source files. |
I did this thinking it might speed up code at runtime, but it was not applied consistently, nor tested. |
Changing these lines in the root/CMakeLists.txt file: target_link_libraries(${PROJECT_NAME} INTERFACE Control Math Model Trajectory) .. install(TARGETS ${PROJECT_NAME} Control Math Model Trajectory and this in the sublibrary CMakeLists.txt files: install(TARGETS Model EXPORT ModelTargets affects how the library is linked in other projects (i.e. RobotLibrary::RobotLibrary vs RobotLibrary::Model ). |
I was trying to make all the CMakeLists.txt files consistent, but the root CMake has to be carefully changed accordingly. |
Using pre-compiled headers hid a lot of problems. | I did this thinking it might improve compile times. |
The install location meant that other projects could not find the header files. E.g. usr/local/RobotLibrary/Control caused the compiler to fail. Using usr/local/RobotLibrary/ for all sublibraries worked. |
Sublibraries works fine for RobotLibrary itself, but it causes problems on the user end. |
ChatGPT was able to write CMake files quickly. | I had to start with simple requests and build up complexity, otherwise there were numerous issues. It's better to use ChatGPT early for writing code while the project is small and simple. |
Study
The compile time for RobotLibrary itself is increased:
robot_library_compile_time_before.webm
robot_library_compile_time_after.webm
but on the user-side it is much faster:
compile_time_after.webm
This is better on the user side, since RobotLibrary only needs to be compiled once. Any code that relies on it can be rapidly tested and debugged.
Act:
- An external repository for all the test code was made, and validated.
- All changes were merged in to master.
Some lessons learnt:
- Only use templates for fundamental classes that are generic as possible
- Templates for RobotLibrary would be nice, but they're not essential for the application.
- The QP solver as a template class is OK because it's 1 header file with short functions.
- Only alter 1 variable at a time, and study its results, before moving on
- Need a well defined PLAN
Metadata
Metadata
Assignees
Labels
problemThis doesn't seem rightThis doesn't seem right