pySimBlocks.blocks.systems.sofa.sofa_plant¶
- pySimBlocks.blocks.systems.sofa.sofa_plant.sofa_worker(conn, scene_file, input_keys, output_keys, sample_time, block_name)[source]¶
Worker function executed in a subprocess to run the SOFA simulation.
- class pySimBlocks.blocks.systems.sofa.sofa_plant.SofaPlant(name: str, scene_file: str, input_keys: list[str], output_keys: list[str], slider_params: Dict[str, List[float]] | None = None, sample_time: float | None = None)[source]¶
Bases:
BlockSOFA-based dynamic plant block.
Executes a SOFA simulation as a dynamic system driven by pySimBlocks. SOFA runs in a separate subprocess. At each control step, inputs are sent to the worker process, the SOFA scene advances by one step, and updated outputs are returned.
- scene_file¶
Resolved path to the SOFA scene file.
- input_keys¶
Names of input ports sent to SOFA at each step.
- output_keys¶
Names of output ports received from SOFA at each step.
- slider_params¶
Optional ImGui slider configuration, mapping
"BlockName.attr"to[min, max]bounds.
- direct_feedthrough = False¶
True if outputs depend directly on inputs.
- need_first = True¶
- classmethod adapt_params(params: Dict[str, Any], params_dir: Path | None = None) Dict[str, Any][source]¶
Resolve a relative
scene_filepath against the project directory.- Parameters:
params – Raw parameter dict loaded from the YAML project file.
params_dir – Directory of the project file, for resolving relative paths. Must not be None.
- Returns:
Parameter dict with
scene_fileresolved to an absolute path.- Raises:
ValueError – If
params_diris None orscene_fileis missing fromparams.
- initialize(t0: float) None[source]¶
Start the SOFA worker process and receive initial outputs.
- Parameters:
t0 – Initial simulation time in seconds.
- Raises:
RuntimeError – If the SOFA worker reports an error during startup.
- output_update(t: float, dt: float) None[source]¶
Forward the committed state outputs to the output ports.
- Parameters:
t – Current simulation time in seconds.
dt – Current time step in seconds.