Skip to content

DSFE Architecture Refactor: Batch Parallelisation, GUI and Core seperation, and general QoL (anti-smell 😄) updates#76

Merged
SaltyJoss merged 27 commits intoMainfrom
Dev
Feb 23, 2026
Merged

DSFE Architecture Refactor: Batch Parallelisation, GUI and Core seperation, and general QoL (anti-smell 😄) updates#76
SaltyJoss merged 27 commits intoMainfrom
Dev

Conversation

@SaltyJoss
Copy link
Owner

This pull request introduces batch mode support to the simulation engine, adds new batch-related source and header files, and makes several improvements to utility functions and build configuration. The most important changes are the addition of batch execution infrastructure, enhancements to math utility functions, and updates to project build settings to support new features.

Batch mode infrastructure:

  • Added new batch mode entry point runBatchMode in BatchMain.cpp, enabling automated study runs with configurable integration methods and timesteps.
  • Introduced BatchArgs.h and BatchEntry.h headers to define batch argument structures and function prototypes for batch execution. [1] [2]
  • Updated project files to include batch-related source and headers, and added filter categories for organization. [1] [2] [3] [4] [5]

Math utility improvements:

  • Converted all utility functions in Utils.h to inline for improved performance and linkage, and added new angle wrapping functions (wrapToPi, wrapRad). [1] [2] [3] [4]
  • Removed obsolete warning suppression pragma from Utils.h.

Build configuration updates:

  • Updated include directories in Engine.vcxproj to support new batch mode and Eigen library integration. [1] [2]

Documentation:

  • Revised the todo list in README.md to use markdown checkboxes and reflect progress on the full-matrix rigid-body model.

Disclaimer:
I used githubs copilot to generate the summary for this merge, as I really did not want to write up all the changes when I spent a fair amount of time writing the commits for each one!
I you need more information, feel free to contact me (@SaltyJoss), or check the a specific commit from this update!!

SaltyJoss and others added 27 commits February 18, 2026 16:20
Add/full rigid body dynamics - moving from diagonal to full model
Updated the Todo List with checkboxes and corrected a strikethrough item.
Revise Todo List format and item status
* feat: move robot kinematic and dynamic logic to seperate headers and compiler files respectively

* fixes: fixed previous files to correctly function with new abstraction

NOTES:
- This whole refactor allowed me to reduce the size of robot system and actually create a better pipeline for the physics/mathematics backend.
- In the future I aim to move most methods to mathlib, with general logic applicable to various systems, but until I safely KNOW how to do that, I decided thsi was still a good way to abstract the actual robotic system physics logic from the visual/simulator

* fixes: fixed previous files to correctly function with new abstraction

NOTES:
- This whole refactor allowed me to reduce the size of robot system and actually create a better pipeline for the physics/mathematics backend.
- In the future I aim to move most methods to mathlib, with general logic applicable to various systems, but until I safely KNOW how to do that, I decided thsi was still a good way to abstract the actual robotic system physics logic from the visual/simulator
* feat: move robot kinematic and dynamic logic to seperate headers and compiler files respectively

* fixes: fixed previous files to correctly function with new abstraction

NOTES:
- This whole refactor allowed me to reduce the size of robot system and actually create a better pipeline for the physics/mathematics backend.
- In the future I aim to move most methods to mathlib, with general logic applicable to various systems, but until I safely KNOW how to do that, I decided thsi was still a good way to abstract the actual robotic system physics logic from the visual/simulator

* fixes: fixed previous files to correctly function with new abstraction

NOTES:
- This whole refactor allowed me to reduce the size of robot system and actually create a better pipeline for the physics/mathematics backend.
- In the future I aim to move most methods to mathlib, with general logic applicable to various systems, but until I safely KNOW how to do that, I decided thsi was still a good way to abstract the actual robotic system physics logic from the visual/simulator

* refactor: moved all core simulator methods, logic, variables, and pointers into SimulationCore.cpp, making SimManage focused on actually MANAGING the simulator.

TODO:
- Move visual logic into new file (im thinking SceneRenderer.cpp/.h)
    * Tried this, but currently very heavy and needs fixing, will sort after this semester ends

* fixes
NOTES:
- Renamed joint state and reference variables for clarity (`thetaRad` -> `q`, `omegaRad_s` -> `qd`)
- Moved and integrated `eTorqueMode` enum into `RobotModel`
- Added energy, work, and power metrics to `RobotMetrics` and logging
- Updated telemetry, CSV export, and GUI to use new names and metrics
- Improved clamp event plots and results window UI
- Updated mouse capture logic and build system files
- Removed all references to old joint state names
NOTES:
- The idea is to introduce a thread-safe, double-buffered internal logging system for joint metrics, I am so fed up of the current logger.
- Added JointLogEntry struct, push_entry, and validate methods to MetricLogger.
- Implemented claimExportLogBuffer, useInternalLogBuffer, and reserveInternalLogBuffers to manage buffer swapping and allocation. (assisted by forums and AI to correct minor mistakes)
- Updated simulation loop to use internal buffers by default, with support for external buffers if needed.
NOTES:
- IntroduceD Interactive/Synchronous run modes to SimulationCore WITH dynamical sizing log and reference buffers based on mode to prevent OOM (new acronym learnt) errors.
- Moved joint log buffer management into the robot system, with export and clearing handled via new interfaces.
- Refactored exportLogsToHDF5 for validation, timing, and robust logging.
- Added buffer size validation to exportRefsToHDF5.

TODO:
- Now implementing batch parallelisation
    * I WANT TO VERY CLEAR -> this does not affect my current dissertation, but I really cannot be bothered waiting for all my tests to finish because my thread util is 100%.
NOTES:
- Major refactor to decouple simulation core from GUI by introducing ISimulationCore, a headless API for scripting and batch operation.
    * This has taken ~7hours, learnt a lot though!!
- Added StudyRunner for parallel/batch simulation runs and BatchMain for CLI batch mode.
- Interpreter contexts now use ISimulationCore*, enabling headless scripting!
- Moveded MeshLoader and VertexHolder to Assets namespace -> updated all mesh/vertex code accordingly.
- Addeded integration method enum header.

TODO:
- Go through and MAKE SURE it is working (it loads, but cannot verify right now, commit is to save progress)
NOTES:
- Major refactor for thread-safe parallel simulation and integrator comparison
- Batch mode now uses hardware concurrency, times runs, and sorts results.
- StudyRunner and GUI now launch async simulation tasks, poll results, and handle exceptions robustly.
- Integrator comparison runs each method in parallel, results are sorted and displayed when ready.
- Added thread-safe result handling in SimManager and ControlPanel.
- SSAO kernel generation uses C++ RNG for reproducibility.
- Script integrator replacement uses regex for reliability.
- Improved OpenGL resource cleanup and modularity.
- UI is more responsive; background runs do not block main thread.

TODO:
- Make parallelisation Universal
refactor: refactored robot joint state naming and add energy metrics
NOTES:
- Added StudyRunner to SimManager for batch/background studies.
- Introduced thread-safe result handling and integration method querying in ISimulationCore.
- Refactored CommandScriptEditor to use StudyRunner for background runs.
- Tweaked telemetry and comparison results collection in ControlPanel (I want to spend some time fixing the entire class honestly, but after).
- "Standardised" simulation core factory usage and cleaned up declarations (I think there is a lot of work to be done here though).

TODO:
- Get parallelisation working with runs on gui.
NOTES:
- Refactored SimulationCore to manage RobotSystem, PhysicsSystem, TrajectoryManager, and object container with std::unique_ptr for improved memory safety and automatic cleanup.
- Updated factory and setter/getter methods accordingly (just to allow for batch runs using these systems).
- Added ENGINE_API to paths functions for DLL compatibility.
- BatchMain.cpp now initialises paths and includes expanded batch script and debug logging.

TODO:
- Fixed HDF5 to be thread-safe, it currently is not.
- Run tests, and finish report, I HAVE LOTS OF NOTES

DISCLAIMER:
- Some changes in this commit were assisted using AI, as I am finding this interesting but also difficult, NOTES HAVE BEEN MADE SO I CAN LEARN :)
NOTES:
- Add DataManager destructor/finalise() for explicit cleanup of HDF5 writers
- Include thread ID and ms timestamp in HDF5 filenames to avoid collisions
- Add debug helpers and print statements for shutdown tracing
- Protect HDF5 file creation with a mutex for thread safety
- In batch mode, force single worker thread for determinism
- Ensure simulation stops and data is flushed on script completion
- Minor code/comment cleanups and improved timestamp formatting
NOTES:
- Introduced BatchArgs struct for batch mode argument handling.
- Refactored BatchMain.cpp/Main.cpp for improved parsing and validation.
- Batch mode now actually supports flexible sweeps of timesteps and integrators, with output tags generated from run parameters.
- HDF5 file naming updated to use run tags (HONESTLY WORTH IT).
- Project files updated to include BatchArgs.h.
- BatchEntry.h now accepts BatchArgs.
- Batch mode is now user-friendly.
NOTES:
- Refactored SimulationCore to allow construction with either internally owned subsystems or externally provided references.
- Added separate unique_ptr and raw pointer members to enable flexible integration as a standalone core or within a larger system that manages subsystems externally.

TODO:
- Find cause of "invalid delete" error upon close, MSVC debug heap detects then invalid delte and triggers a debug break, but its midnight and im tired, and it still works soooo.
NOTES:
- Refactored SimulationCore to allow construction with either internally owned subsystems or externally provided references.
- Added separate unique_ptr and raw pointer members to enable flexible integration as a standalone core or within a larger system that manages subsystems externally.

TODO:
- Find cause of "invalid delete" error upon close, MSVC debug heap detects then invalid delte and triggers a debug break, but its midnight and im tired, and it still works soooo.

ALTERNATIVELY:
- Believe I found a fix, amending previous commit
@SaltyJoss SaltyJoss self-assigned this Feb 23, 2026
@SaltyJoss SaltyJoss added documentation Improvements or additions to documentation enhancement New feature or request labels Feb 23, 2026
@SaltyJoss SaltyJoss added the fixes fixing existing issues label Feb 23, 2026
@SaltyJoss SaltyJoss merged commit d1dc1b6 into Main Feb 23, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request fixes fixing existing issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant