HostSim FOC support: run loaded graph in simulator and add FOC runtime layout - #29
Open
datacrystals wants to merge 1 commit into
Open
HostSim FOC support: run loaded graph in simulator and add FOC runtime layout#29datacrystals wants to merge 1 commit into
datacrystals wants to merge 1 commit into
Conversation
…me layout - Add missing platform_api stubs so the FOC demo graph builds in HostSim: platform_get_motor_rpm, platform_phase_voltage_u/v/w, platform_get_throttle_valid, platform_digital_read/write, platform_can_send/rx. - Make run_spwm_live.sh/.ps1 accept --graph/--scenario so any graph can be emitted/built/run, defaulting to a matching scenario or default_motor.json. - Wire NodeGUI Build Simulation to pass the currently loaded graph to the launcher instead of hardcoding the SPWM demo graph. - Add a FOC runtime plot preset (cg_id_a/iq_a, cg_vd_v/vq_v, cg_iu_a/iv_a/iw_a) and auto-select it when cg_id_a telemetry is present.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes two blockers that prevented the FOC demo graph from actually running in HostSim:
Changes
HostSim platform API stubs (
Images/HostSim/include/platform_api.h,Images/HostSim/src/platform_api.cpp):platform_get_motor_rpmplatform_phase_voltage_u/v/wplatform_get_throttle_validplatform_digital_read/writeplatform_can_send/rxHostSim launcher scripts (
Images/HostSim/scripts/run_spwm_live.sh,.ps1):--graph/-Graphand--scenario/-Scenarioarguments._graphsuffix stripped), falling back todefault_motor.json.--graphstill runs the SPWM demo.NodeGUI Build Simulation (
Source/NodeGUI/src/MainWindow.cpp):Runtime plot layouts (
Source/NodeGUI/src/runtime/RuntimeTab.cpp/.h):cg_id_a/cg_iq_a,cg_vd_v/cg_vq_v,cg_iu_a/cg_iv_a/cg_iw_a.cg_id_atelemetry is present and applies the FOC layout; falls back to SPWM layout onduty_u.Verification
cmake --build build --target NodeGUIsucceeds.bash Images/HostSim/scripts/run_spwm_live.sh --no-gui --force-emitbash ... --graph Assets/Examples/foc_demo.json --no-gui --force-emitKnown limitations / follow-up work
HostSim is still a simplified SIL backend. The items below need to be addressed before this can be considered a true HAL-level SIL simulator:
Images/HostSim/src/plant/ngspice_plant.cppexists but is not wired as the default. FOC graphs should run against an ngspice inverter/motor netlist, not the built-in ODE motor model.platform_can_rxis currently a no-op. The simulator needs a way to inject control-start commands, throttle commands, and config writes so the firmware does not sit waiting for a control-start frame.Ctrl.ThrottleEnable, current limits) so valuable simulation time is not spent simulating idle startup.duty * vdc / 100, CAN no-ops). These need to be backed by the simulated plant/netlist./cc @hibyemy