pySimBlocks 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pysimblocks-0.1.0/LICENSE.md +165 -0
- pysimblocks-0.1.0/PKG-INFO +180 -0
- pysimblocks-0.1.0/README.md +145 -0
- pysimblocks-0.1.0/examples/advanced/hardware/block_diagram.py +162 -0
- pysimblocks-0.1.0/examples/advanced/hardware/camera.py +93 -0
- pysimblocks-0.1.0/examples/advanced/hardware/gui_emio.py +231 -0
- pysimblocks-0.1.0/examples/advanced/hardware/lmi.py +69 -0
- pysimblocks-0.1.0/examples/advanced/hardware/main.py +57 -0
- pysimblocks-0.1.0/examples/advanced/hardware/parameters.py +54 -0
- pysimblocks-0.1.0/examples/advanced/qp_problem/params.py +10 -0
- pysimblocks-0.1.0/examples/advanced/qp_problem/run.py +14 -0
- pysimblocks-0.1.0/examples/advanced/sofa/gui/finger/Finger.py +108 -0
- pysimblocks-0.1.0/examples/advanced/sofa/gui/finger/FingerController.py +53 -0
- pysimblocks-0.1.0/examples/advanced/sofa/gui/finger/parameters_auto.py +22 -0
- pysimblocks-0.1.0/examples/advanced/sofa/gui/sofa_plant/run.py +14 -0
- pysimblocks-0.1.0/examples/advanced/sofa/python/Finger.py +107 -0
- pysimblocks-0.1.0/examples/advanced/sofa/python/FingerController.py +48 -0
- pysimblocks-0.1.0/examples/advanced/sofa/python/closedloop.py +64 -0
- pysimblocks-0.1.0/examples/advanced/sofa/python/openloop.py +58 -0
- pysimblocks-0.1.0/examples/basics/algebraic_function/g.py +7 -0
- pysimblocks-0.1.0/examples/basics/algebraic_function/run.py +14 -0
- pysimblocks-0.1.0/examples/basics/dc_motor/gui/run.py +14 -0
- pysimblocks-0.1.0/examples/basics/dc_motor/multiple_order.py +91 -0
- pysimblocks-0.1.0/examples/basics/dc_motor/openloop.py +62 -0
- pysimblocks-0.1.0/examples/basics/dc_motor/pi.py +99 -0
- pysimblocks-0.1.0/examples/basics/dc_motor/pid.py +118 -0
- pysimblocks-0.1.0/examples/basics/dc_motor/pid_block.py +82 -0
- pysimblocks-0.1.0/examples/basics/dc_motor/pid_block_vs_manual.py +143 -0
- pysimblocks-0.1.0/examples/basics/external/parameters.py +4 -0
- pysimblocks-0.1.0/examples/basics/external/run.py +14 -0
- pysimblocks-0.1.0/examples/basics/file_sources/temp.py +16 -0
- pysimblocks-0.1.0/examples/basics/observer.py +76 -0
- pysimblocks-0.1.0/examples/basics/state_feedback/gui/parameters.py +9 -0
- pysimblocks-0.1.0/examples/basics/state_feedback/gui/run.py +14 -0
- pysimblocks-0.1.0/examples/basics/state_feedback/state_feedback.py +102 -0
- pysimblocks-0.1.0/examples/basics/state_space/linear/gui/run.py +14 -0
- pysimblocks-0.1.0/examples/basics/state_space/linear/ss_block.py +89 -0
- pysimblocks-0.1.0/examples/basics/state_space/linear/ss_manual.py +105 -0
- pysimblocks-0.1.0/examples/basics/state_space/non_linear/nlss.py +47 -0
- pysimblocks-0.1.0/examples/basics/state_space/non_linear/run.py +14 -0
- pysimblocks-0.1.0/examples/basics/state_space/polytope/params.py +39 -0
- pysimblocks-0.1.0/examples/basics/state_space/polytope/weights.py +12 -0
- pysimblocks-0.1.0/examples/comparison/simulink/convert.py +29 -0
- pysimblocks-0.1.0/examples/comparison/simulink/openloop.py +127 -0
- pysimblocks-0.1.0/examples/comparison/simulink/pi.py +148 -0
- pysimblocks-0.1.0/examples/comparison/simulink/pid.py +154 -0
- pysimblocks-0.1.0/examples/comparison/simulink/pid_backward.py +155 -0
- pysimblocks-0.1.0/examples/quick_start/filter.py +35 -0
- pysimblocks-0.1.0/examples/quick_start/gui/run.py +14 -0
- pysimblocks-0.1.0/examples/tutorials/tutorial_1_python/main.py +99 -0
- pysimblocks-0.1.0/examples/tutorials/tutorial_3_sofa/finger/Finger.py +120 -0
- pysimblocks-0.1.0/examples/tutorials/tutorial_3_sofa/finger/FingerController.py +37 -0
- pysimblocks-0.1.0/pySimBlocks/__init__.py +35 -0
- pysimblocks-0.1.0/pySimBlocks/blocks/__init__.py +68 -0
- pysimblocks-0.1.0/pySimBlocks/blocks/controllers/__init__.py +27 -0
- pysimblocks-0.1.0/pySimBlocks/blocks/controllers/pid.py +250 -0
- pysimblocks-0.1.0/pySimBlocks/blocks/controllers/state_feedback.py +141 -0
- pysimblocks-0.1.0/pySimBlocks/blocks/interfaces/__init__.py +27 -0
- pysimblocks-0.1.0/pySimBlocks/blocks/interfaces/external_input.py +107 -0
- pysimblocks-0.1.0/pySimBlocks/blocks/interfaces/external_output.py +113 -0
- pysimblocks-0.1.0/pySimBlocks/blocks/observers/__init__.py +23 -0
- pysimblocks-0.1.0/pySimBlocks/blocks/observers/luenberger.py +175 -0
- pysimblocks-0.1.0/pySimBlocks/blocks/operators/__init__.py +47 -0
- pysimblocks-0.1.0/pySimBlocks/blocks/operators/algebraic_function.py +258 -0
- pysimblocks-0.1.0/pySimBlocks/blocks/operators/dead_zone.py +186 -0
- pysimblocks-0.1.0/pySimBlocks/blocks/operators/delay.py +254 -0
- pysimblocks-0.1.0/pySimBlocks/blocks/operators/demux.py +123 -0
- pysimblocks-0.1.0/pySimBlocks/blocks/operators/discrete_derivator.py +237 -0
- pysimblocks-0.1.0/pySimBlocks/blocks/operators/discrete_integrator.py +265 -0
- pysimblocks-0.1.0/pySimBlocks/blocks/operators/gain.py +294 -0
- pysimblocks-0.1.0/pySimBlocks/blocks/operators/mux.py +131 -0
- pysimblocks-0.1.0/pySimBlocks/blocks/operators/product.py +194 -0
- pysimblocks-0.1.0/pySimBlocks/blocks/operators/rate_limiter.py +214 -0
- pysimblocks-0.1.0/pySimBlocks/blocks/operators/saturation.py +178 -0
- pysimblocks-0.1.0/pySimBlocks/blocks/operators/sum.py +188 -0
- pysimblocks-0.1.0/pySimBlocks/blocks/operators/zero_order_hold.py +141 -0
- pysimblocks-0.1.0/pySimBlocks/blocks/optimizers/__init__.py +23 -0
- pysimblocks-0.1.0/pySimBlocks/blocks/optimizers/quadratic_program.py +326 -0
- pysimblocks-0.1.0/pySimBlocks/blocks/sources/__init__.py +37 -0
- pysimblocks-0.1.0/pySimBlocks/blocks/sources/chirp.py +168 -0
- pysimblocks-0.1.0/pySimBlocks/blocks/sources/constant.py +82 -0
- pysimblocks-0.1.0/pySimBlocks/blocks/sources/file_source.py +294 -0
- pysimblocks-0.1.0/pySimBlocks/blocks/sources/function_source.py +197 -0
- pysimblocks-0.1.0/pySimBlocks/blocks/sources/ramp.py +99 -0
- pysimblocks-0.1.0/pySimBlocks/blocks/sources/sinusoidal.py +113 -0
- pysimblocks-0.1.0/pySimBlocks/blocks/sources/step.py +138 -0
- pysimblocks-0.1.0/pySimBlocks/blocks/sources/white_noise.py +107 -0
- pysimblocks-0.1.0/pySimBlocks/blocks/systems/__init__.py +27 -0
- pysimblocks-0.1.0/pySimBlocks/blocks/systems/linear_state_space.py +180 -0
- pysimblocks-0.1.0/pySimBlocks/blocks/systems/non_linear_state_space.py +309 -0
- pysimblocks-0.1.0/pySimBlocks/blocks/systems/polytopic_state_space.py +193 -0
- pysimblocks-0.1.0/pySimBlocks/blocks/systems/sofa/__init__.py +30 -0
- pysimblocks-0.1.0/pySimBlocks/blocks/systems/sofa/sofa_controller.py +472 -0
- pysimblocks-0.1.0/pySimBlocks/blocks/systems/sofa/sofa_exchange_i_o.py +120 -0
- pysimblocks-0.1.0/pySimBlocks/blocks/systems/sofa/sofa_plant.py +306 -0
- pysimblocks-0.1.0/pySimBlocks/cli.py +127 -0
- pysimblocks-0.1.0/pySimBlocks/core/__init__.py +32 -0
- pysimblocks-0.1.0/pySimBlocks/core/block.py +167 -0
- pysimblocks-0.1.0/pySimBlocks/core/block_source.py +94 -0
- pysimblocks-0.1.0/pySimBlocks/core/config.py +90 -0
- pysimblocks-0.1.0/pySimBlocks/core/fixed_time_manager.py +46 -0
- pysimblocks-0.1.0/pySimBlocks/core/model.py +250 -0
- pysimblocks-0.1.0/pySimBlocks/core/scheduler.py +30 -0
- pysimblocks-0.1.0/pySimBlocks/core/simulator.py +329 -0
- pysimblocks-0.1.0/pySimBlocks/core/task.py +73 -0
- pysimblocks-0.1.0/pySimBlocks/docs/blocks/controllers/pid.md +78 -0
- pysimblocks-0.1.0/pySimBlocks/docs/blocks/controllers/state_feedback.md +60 -0
- pysimblocks-0.1.0/pySimBlocks/docs/blocks/interfaces/external_input.md +39 -0
- pysimblocks-0.1.0/pySimBlocks/docs/blocks/interfaces/external_output.md +39 -0
- pysimblocks-0.1.0/pySimBlocks/docs/blocks/observers/luenberger.md +70 -0
- pysimblocks-0.1.0/pySimBlocks/docs/blocks/operators/algebraic_function.md +76 -0
- pysimblocks-0.1.0/pySimBlocks/docs/blocks/operators/dead_zone.md +67 -0
- pysimblocks-0.1.0/pySimBlocks/docs/blocks/operators/delay.md +76 -0
- pysimblocks-0.1.0/pySimBlocks/docs/blocks/operators/demux.md +64 -0
- pysimblocks-0.1.0/pySimBlocks/docs/blocks/operators/discrete_derivator.md +61 -0
- pysimblocks-0.1.0/pySimBlocks/docs/blocks/operators/discrete_integrator.md +87 -0
- pysimblocks-0.1.0/pySimBlocks/docs/blocks/operators/gain.md +97 -0
- pysimblocks-0.1.0/pySimBlocks/docs/blocks/operators/mux.md +64 -0
- pysimblocks-0.1.0/pySimBlocks/docs/blocks/operators/product.md +51 -0
- pysimblocks-0.1.0/pySimBlocks/docs/blocks/operators/rate_limiter.md +70 -0
- pysimblocks-0.1.0/pySimBlocks/docs/blocks/operators/saturation.md +62 -0
- pysimblocks-0.1.0/pySimBlocks/docs/blocks/operators/sum.md +49 -0
- pysimblocks-0.1.0/pySimBlocks/docs/blocks/operators/zero_order_hold.md +61 -0
- pysimblocks-0.1.0/pySimBlocks/docs/blocks/optimizers/quadratic_program.md +98 -0
- pysimblocks-0.1.0/pySimBlocks/docs/blocks/sources/chirp.md +102 -0
- pysimblocks-0.1.0/pySimBlocks/docs/blocks/sources/constant.md +53 -0
- pysimblocks-0.1.0/pySimBlocks/docs/blocks/sources/file_source.md +51 -0
- pysimblocks-0.1.0/pySimBlocks/docs/blocks/sources/function_source.md +52 -0
- pysimblocks-0.1.0/pySimBlocks/docs/blocks/sources/ramp.md +58 -0
- pysimblocks-0.1.0/pySimBlocks/docs/blocks/sources/sinusoidal.md +60 -0
- pysimblocks-0.1.0/pySimBlocks/docs/blocks/sources/step.md +63 -0
- pysimblocks-0.1.0/pySimBlocks/docs/blocks/sources/white_noise.md +58 -0
- pysimblocks-0.1.0/pySimBlocks/docs/blocks/systems/linear_state_space.md +66 -0
- pysimblocks-0.1.0/pySimBlocks/docs/blocks/systems/non_linear_state_space.md +90 -0
- pysimblocks-0.1.0/pySimBlocks/docs/blocks/systems/polytopic_state_space.md +72 -0
- pysimblocks-0.1.0/pySimBlocks/docs/blocks/systems/sofa/sofa_exchange_i_o.md +63 -0
- pysimblocks-0.1.0/pySimBlocks/docs/blocks/systems/sofa/sofa_plant.md +62 -0
- pysimblocks-0.1.0/pySimBlocks/gui/__init__.py +20 -0
- pysimblocks-0.1.0/pySimBlocks/gui/addons/__init__.py +19 -0
- pysimblocks-0.1.0/pySimBlocks/gui/addons/sofa/__init__.py +19 -0
- pysimblocks-0.1.0/pySimBlocks/gui/addons/sofa/sofa_dialog.py +190 -0
- pysimblocks-0.1.0/pySimBlocks/gui/addons/sofa/sofa_service.py +209 -0
- pysimblocks-0.1.0/pySimBlocks/gui/blocks/block_dialog_session.py +47 -0
- pysimblocks-0.1.0/pySimBlocks/gui/blocks/block_meta.py +408 -0
- pysimblocks-0.1.0/pySimBlocks/gui/blocks/controllers/pid.py +116 -0
- pysimblocks-0.1.0/pySimBlocks/gui/blocks/controllers/state_feedback.py +80 -0
- pysimblocks-0.1.0/pySimBlocks/gui/blocks/interfaces/external_input.py +64 -0
- pysimblocks-0.1.0/pySimBlocks/gui/blocks/interfaces/external_output.py +63 -0
- pysimblocks-0.1.0/pySimBlocks/gui/blocks/observers/luenberger.py +108 -0
- pysimblocks-0.1.0/pySimBlocks/gui/blocks/operators/algebraic_function.py +232 -0
- pysimblocks-0.1.0/pySimBlocks/gui/blocks/operators/dead_zone.py +79 -0
- pysimblocks-0.1.0/pySimBlocks/gui/blocks/operators/delay.py +79 -0
- pysimblocks-0.1.0/pySimBlocks/gui/blocks/operators/demux.py +98 -0
- pysimblocks-0.1.0/pySimBlocks/gui/blocks/operators/discrete_derivator.py +67 -0
- pysimblocks-0.1.0/pySimBlocks/gui/blocks/operators/discrete_integrator.py +80 -0
- pysimblocks-0.1.0/pySimBlocks/gui/blocks/operators/gain.py +79 -0
- pysimblocks-0.1.0/pySimBlocks/gui/blocks/operators/mux.py +100 -0
- pysimblocks-0.1.0/pySimBlocks/gui/blocks/operators/product.py +109 -0
- pysimblocks-0.1.0/pySimBlocks/gui/blocks/operators/rate_limiter.py +79 -0
- pysimblocks-0.1.0/pySimBlocks/gui/blocks/operators/saturation.py +72 -0
- pysimblocks-0.1.0/pySimBlocks/gui/blocks/operators/sum.py +91 -0
- pysimblocks-0.1.0/pySimBlocks/gui/blocks/operators/zero_order_hold.py +64 -0
- pysimblocks-0.1.0/pySimBlocks/gui/blocks/optimizers/quadratic_program.py +128 -0
- pysimblocks-0.1.0/pySimBlocks/gui/blocks/parameter_meta.py +34 -0
- pysimblocks-0.1.0/pySimBlocks/gui/blocks/port_meta.py +31 -0
- pysimblocks-0.1.0/pySimBlocks/gui/blocks/sources/chirp.py +146 -0
- pysimblocks-0.1.0/pySimBlocks/gui/blocks/sources/constant.py +63 -0
- pysimblocks-0.1.0/pySimBlocks/gui/blocks/sources/file_source.py +196 -0
- pysimblocks-0.1.0/pySimBlocks/gui/blocks/sources/function_source.py +202 -0
- pysimblocks-0.1.0/pySimBlocks/gui/blocks/sources/ramp.py +73 -0
- pysimblocks-0.1.0/pySimBlocks/gui/blocks/sources/sinusoidal.py +81 -0
- pysimblocks-0.1.0/pySimBlocks/gui/blocks/sources/step.py +83 -0
- pysimblocks-0.1.0/pySimBlocks/gui/blocks/sources/white_noise.py +70 -0
- pysimblocks-0.1.0/pySimBlocks/gui/blocks/systems/linear_state_space.py +102 -0
- pysimblocks-0.1.0/pySimBlocks/gui/blocks/systems/non_linear_state_space.py +233 -0
- pysimblocks-0.1.0/pySimBlocks/gui/blocks/systems/polytopic_state_space.py +109 -0
- pysimblocks-0.1.0/pySimBlocks/gui/blocks/systems/sofa/sofa_exchange_i_o.py +221 -0
- pysimblocks-0.1.0/pySimBlocks/gui/blocks/systems/sofa/sofa_plant.py +220 -0
- pysimblocks-0.1.0/pySimBlocks/gui/dialogs/__init__.py +19 -0
- pysimblocks-0.1.0/pySimBlocks/gui/dialogs/block_dialog.py +125 -0
- pysimblocks-0.1.0/pySimBlocks/gui/dialogs/display_yaml_dialog.py +89 -0
- pysimblocks-0.1.0/pySimBlocks/gui/dialogs/help_dialog.py +39 -0
- pysimblocks-0.1.0/pySimBlocks/gui/dialogs/plot_dialog.py +230 -0
- pysimblocks-0.1.0/pySimBlocks/gui/dialogs/settings/plots.py +187 -0
- pysimblocks-0.1.0/pySimBlocks/gui/dialogs/settings/project.py +146 -0
- pysimblocks-0.1.0/pySimBlocks/gui/dialogs/settings/simulation.py +137 -0
- pysimblocks-0.1.0/pySimBlocks/gui/dialogs/settings_dialog.py +88 -0
- pysimblocks-0.1.0/pySimBlocks/gui/dialogs/unsaved_dialog.py +92 -0
- pysimblocks-0.1.0/pySimBlocks/gui/editor.py +49 -0
- pysimblocks-0.1.0/pySimBlocks/gui/graphics/__init__.py +29 -0
- pysimblocks-0.1.0/pySimBlocks/gui/graphics/block_item.py +289 -0
- pysimblocks-0.1.0/pySimBlocks/gui/graphics/connection_item.py +266 -0
- pysimblocks-0.1.0/pySimBlocks/gui/graphics/port_item.py +153 -0
- pysimblocks-0.1.0/pySimBlocks/gui/graphics/theme.py +119 -0
- pysimblocks-0.1.0/pySimBlocks/gui/main_window.py +162 -0
- pysimblocks-0.1.0/pySimBlocks/gui/models/__init__.py +31 -0
- pysimblocks-0.1.0/pySimBlocks/gui/models/block_instance.py +114 -0
- pysimblocks-0.1.0/pySimBlocks/gui/models/connection_instance.py +43 -0
- pysimblocks-0.1.0/pySimBlocks/gui/models/port_instance.py +52 -0
- pysimblocks-0.1.0/pySimBlocks/gui/models/project_simulation_params.py +50 -0
- pysimblocks-0.1.0/pySimBlocks/gui/models/project_state.py +114 -0
- pysimblocks-0.1.0/pySimBlocks/gui/project_controller.py +302 -0
- pysimblocks-0.1.0/pySimBlocks/gui/services/__init__.py +20 -0
- pysimblocks-0.1.0/pySimBlocks/gui/services/project_loader.py +381 -0
- pysimblocks-0.1.0/pySimBlocks/gui/services/project_saver.py +68 -0
- pysimblocks-0.1.0/pySimBlocks/gui/services/simulation_runner.py +66 -0
- pysimblocks-0.1.0/pySimBlocks/gui/services/yaml_tools.py +261 -0
- pysimblocks-0.1.0/pySimBlocks/gui/widgets/__init__.py +19 -0
- pysimblocks-0.1.0/pySimBlocks/gui/widgets/block_list.py +131 -0
- pysimblocks-0.1.0/pySimBlocks/gui/widgets/diagram_view.py +312 -0
- pysimblocks-0.1.0/pySimBlocks/gui/widgets/toolbar_view.py +161 -0
- pysimblocks-0.1.0/pySimBlocks/project/__init__.py +35 -0
- pysimblocks-0.1.0/pySimBlocks/project/build_model.py +92 -0
- pysimblocks-0.1.0/pySimBlocks/project/generate_run_script.py +109 -0
- pysimblocks-0.1.0/pySimBlocks/project/generate_sofa_controller.py +215 -0
- pysimblocks-0.1.0/pySimBlocks/project/load_project_config.py +197 -0
- pysimblocks-0.1.0/pySimBlocks/project/load_simulation_config.py +166 -0
- pysimblocks-0.1.0/pySimBlocks/project/load_simulator.py +45 -0
- pysimblocks-0.1.0/pySimBlocks/project/plot_from_config.py +174 -0
- pysimblocks-0.1.0/pySimBlocks/project/pySimBlocks_blocks_index.yaml +106 -0
- pysimblocks-0.1.0/pySimBlocks/real_time/__init__.py +23 -0
- pysimblocks-0.1.0/pySimBlocks/real_time/real_time_runner.py +148 -0
- pysimblocks-0.1.0/pySimBlocks/tools/__init__.py +19 -0
- pysimblocks-0.1.0/pySimBlocks/tools/blocks_registry.py +141 -0
- pysimblocks-0.1.0/pySimBlocks/tools/generate_blocks_index.py +124 -0
- pysimblocks-0.1.0/pySimBlocks.egg-info/PKG-INFO +180 -0
- pysimblocks-0.1.0/pySimBlocks.egg-info/SOURCES.txt +265 -0
- pysimblocks-0.1.0/pySimBlocks.egg-info/dependency_links.txt +1 -0
- pysimblocks-0.1.0/pySimBlocks.egg-info/entry_points.txt +2 -0
- pysimblocks-0.1.0/pySimBlocks.egg-info/requires.txt +15 -0
- pysimblocks-0.1.0/pySimBlocks.egg-info/top_level.txt +7 -0
- pysimblocks-0.1.0/pyproject.toml +65 -0
- pysimblocks-0.1.0/setup.cfg +4 -0
- pysimblocks-0.1.0/tests/blocks/controllers/test_pid.py +143 -0
- pysimblocks-0.1.0/tests/blocks/controllers/test_state_feedback.py +193 -0
- pysimblocks-0.1.0/tests/blocks/observers/test_luenberger.py +225 -0
- pysimblocks-0.1.0/tests/blocks/operators/test_algebraic_function.py +230 -0
- pysimblocks-0.1.0/tests/blocks/operators/test_dead_zone.py +106 -0
- pysimblocks-0.1.0/tests/blocks/operators/test_delay.py +167 -0
- pysimblocks-0.1.0/tests/blocks/operators/test_demux.py +111 -0
- pysimblocks-0.1.0/tests/blocks/operators/test_discrete_derivator.py +160 -0
- pysimblocks-0.1.0/tests/blocks/operators/test_discrete_integrator.py +149 -0
- pysimblocks-0.1.0/tests/blocks/operators/test_gain.py +182 -0
- pysimblocks-0.1.0/tests/blocks/operators/test_mux.py +101 -0
- pysimblocks-0.1.0/tests/blocks/operators/test_product.py +171 -0
- pysimblocks-0.1.0/tests/blocks/operators/test_rate_limiter.py +166 -0
- pysimblocks-0.1.0/tests/blocks/operators/test_saturation.py +157 -0
- pysimblocks-0.1.0/tests/blocks/operators/test_sum.py +183 -0
- pysimblocks-0.1.0/tests/blocks/operators/test_zero_order_hold.py +106 -0
- pysimblocks-0.1.0/tests/blocks/sources/test_chirp.py +157 -0
- pysimblocks-0.1.0/tests/blocks/sources/test_constant.py +55 -0
- pysimblocks-0.1.0/tests/blocks/sources/test_file_source.py +185 -0
- pysimblocks-0.1.0/tests/blocks/sources/test_function_source.py +135 -0
- pysimblocks-0.1.0/tests/blocks/sources/test_ramp.py +110 -0
- pysimblocks-0.1.0/tests/blocks/sources/test_sinusoidal.py +113 -0
- pysimblocks-0.1.0/tests/blocks/sources/test_step.py +76 -0
- pysimblocks-0.1.0/tests/blocks/sources/test_white_noise.py +108 -0
- pysimblocks-0.1.0/tests/blocks/systems/test_linear_state_space.py +135 -0
- pysimblocks-0.1.0/tests/blocks/systems/test_polytopic_state_space.py +133 -0
- pysimblocks-0.1.0/tests/core/test_core_errors_and_determinism.py +82 -0
- pysimblocks-0.1.0/tests/core/test_core_multirate_tasks.py +88 -0
- pysimblocks-0.1.0/tests/core/test_core_two_phase_and_propagation.py +132 -0
- pysimblocks-0.1.0/tests/gui/main_window_open_test.py +162 -0
- pysimblocks-0.1.0/tests/gui/test_block_meta_param_cache.py +16 -0
- pysimblocks-0.1.0/tests/gui/test_file_source_meta.py +17 -0
- pysimblocks-0.1.0/tests/gui/test_function_source_meta.py +28 -0
- pysimblocks-0.1.0/tests/regression/test_simulink_dc_motor.py +217 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 29 June 2007
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
6
|
+
of this license document, but changing it is not allowed.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
|
11
|
+
License, supplemented by the additional permissions listed below.
|
|
12
|
+
|
|
13
|
+
0. Additional Definitions.
|
|
14
|
+
|
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
|
17
|
+
General Public License.
|
|
18
|
+
|
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
|
20
|
+
other than an Application or a Combined Work as defined below.
|
|
21
|
+
|
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
|
25
|
+
of using an interface provided by the Library.
|
|
26
|
+
|
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
|
28
|
+
Application with the Library. The particular version of the Library
|
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
|
30
|
+
Version".
|
|
31
|
+
|
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
|
35
|
+
based on the Application, and not on the Linked Version.
|
|
36
|
+
|
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
|
38
|
+
object code and/or source code for the Application, including any data
|
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
|
41
|
+
|
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
|
43
|
+
|
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
|
46
|
+
|
|
47
|
+
2. Conveying Modified Versions.
|
|
48
|
+
|
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
|
51
|
+
that uses the facility (other than as an argument passed when the
|
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
|
53
|
+
version:
|
|
54
|
+
|
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
|
56
|
+
ensure that, in the event an Application does not supply the
|
|
57
|
+
function or data, the facility still operates, and performs
|
|
58
|
+
whatever part of its purpose remains meaningful, or
|
|
59
|
+
|
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
|
61
|
+
this License applicable to that copy.
|
|
62
|
+
|
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
|
64
|
+
|
|
65
|
+
The object code form of an Application may incorporate material from
|
|
66
|
+
a header file that is part of the Library. You may convey such object
|
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
|
68
|
+
material is not limited to numerical parameters, data structure
|
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
|
71
|
+
|
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
|
73
|
+
Library is used in it and that the Library and its use are
|
|
74
|
+
covered by this License.
|
|
75
|
+
|
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
|
77
|
+
document.
|
|
78
|
+
|
|
79
|
+
4. Combined Works.
|
|
80
|
+
|
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
|
82
|
+
taken together, effectively do not restrict modification of the
|
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
|
85
|
+
the following:
|
|
86
|
+
|
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
|
88
|
+
the Library is used in it and that the Library and its use are
|
|
89
|
+
covered by this License.
|
|
90
|
+
|
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
|
92
|
+
document.
|
|
93
|
+
|
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
|
95
|
+
execution, include the copyright notice for the Library among
|
|
96
|
+
these notices, as well as a reference directing the user to the
|
|
97
|
+
copies of the GNU GPL and this license document.
|
|
98
|
+
|
|
99
|
+
d) Do one of the following:
|
|
100
|
+
|
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
|
102
|
+
License, and the Corresponding Application Code in a form
|
|
103
|
+
suitable for, and under terms that permit, the user to
|
|
104
|
+
recombine or relink the Application with a modified version of
|
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
|
107
|
+
Corresponding Source.
|
|
108
|
+
|
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
|
111
|
+
a copy of the Library already present on the user's computer
|
|
112
|
+
system, and (b) will operate properly with a modified version
|
|
113
|
+
of the Library that is interface-compatible with the Linked
|
|
114
|
+
Version.
|
|
115
|
+
|
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
|
117
|
+
be required to provide such information under section 6 of the
|
|
118
|
+
GNU GPL, and only to the extent that such information is
|
|
119
|
+
necessary to install and execute a modified version of the
|
|
120
|
+
Combined Work produced by recombining or relinking the
|
|
121
|
+
Application with a modified version of the Linked Version. (If
|
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
|
126
|
+
for conveying Corresponding Source.)
|
|
127
|
+
|
|
128
|
+
5. Combined Libraries.
|
|
129
|
+
|
|
130
|
+
You may place library facilities that are a work based on the
|
|
131
|
+
Library side by side in a single library together with other library
|
|
132
|
+
facilities that are not Applications and are not covered by this
|
|
133
|
+
License, and convey such a combined library under terms of your
|
|
134
|
+
choice, if you do both of the following:
|
|
135
|
+
|
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
|
137
|
+
on the Library, uncombined with any other library facilities,
|
|
138
|
+
conveyed under the terms of this License.
|
|
139
|
+
|
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
|
141
|
+
is a work based on the Library, and explaining where to find the
|
|
142
|
+
accompanying uncombined form of the same work.
|
|
143
|
+
|
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
|
145
|
+
|
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
|
148
|
+
versions will be similar in spirit to the present version, but may
|
|
149
|
+
differ in detail to address new problems or concerns.
|
|
150
|
+
|
|
151
|
+
Each version is given a distinguishing version number. If the
|
|
152
|
+
Library as you received it specifies that a certain numbered version
|
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
|
154
|
+
applies to it, you have the option of following the terms and
|
|
155
|
+
conditions either of that published version or of any later version
|
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
|
160
|
+
|
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
|
164
|
+
permanent authorization for you to choose that version for the
|
|
165
|
+
Library.
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pySimBlocks
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A block-diagram simulation environment with PySide6 editor
|
|
5
|
+
Author-email: Antoine Alessandrini <antoine.alessandrini@univ-lille.fr>
|
|
6
|
+
License-Expression: LGPL-3.0-or-later
|
|
7
|
+
Project-URL: Homepage, https://github.com/AlessandriniAntoine/pySimBlocks
|
|
8
|
+
Project-URL: Repository, https://github.com/AlessandriniAntoine/pySimBlocks
|
|
9
|
+
Project-URL: Issues, https://github.com/AlessandriniAntoine/pySimBlocks/issues
|
|
10
|
+
Keywords: simulation,block-diagram,control,discrete-time,pyside6
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: Intended Audience :: Education
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE.md
|
|
23
|
+
Requires-Dist: numpy
|
|
24
|
+
Requires-Dist: matplotlib
|
|
25
|
+
Requires-Dist: pyyaml
|
|
26
|
+
Requires-Dist: PySide6
|
|
27
|
+
Requires-Dist: typing_extensions; python_version < "3.11"
|
|
28
|
+
Provides-Extra: examples
|
|
29
|
+
Requires-Dist: control; extra == "examples"
|
|
30
|
+
Requires-Dist: qpsolvers[clarabel,osqp]; extra == "examples"
|
|
31
|
+
Provides-Extra: tests
|
|
32
|
+
Requires-Dist: pytest; extra == "tests"
|
|
33
|
+
Requires-Dist: pytest-qt; extra == "tests"
|
|
34
|
+
Dynamic: license-file
|
|
35
|
+
|
|
36
|
+
# pySimBlocks
|
|
37
|
+
|
|
38
|
+
A deterministic block-diagram simulation framework for discrete-time modeling,
|
|
39
|
+
co-simulation and research prototyping in Python.
|
|
40
|
+
|
|
41
|
+
pySimBlocks allows you to build, configure, and execute discrete-time systems
|
|
42
|
+
using either:
|
|
43
|
+
|
|
44
|
+
- A pure Python API
|
|
45
|
+
- A graphical editor (PySide6)
|
|
46
|
+
- YAML project configuration
|
|
47
|
+
- Optional SOFA and hardware integration
|
|
48
|
+
|
|
49
|
+

|
|
50
|
+
|
|
51
|
+
## Features
|
|
52
|
+
|
|
53
|
+
- Block-based modeling (Simulink-like)
|
|
54
|
+
- Deterministic discrete-time simulation engine
|
|
55
|
+
- PySide6 graphical editor
|
|
56
|
+
- YAML-based project serialization
|
|
57
|
+
- Exportable Python runner (`run.py`)
|
|
58
|
+
- Extensible block architecture
|
|
59
|
+
|
|
60
|
+
## Installation
|
|
61
|
+
|
|
62
|
+
### From GitHub
|
|
63
|
+
|
|
64
|
+
Install directly from GitHub using pip:
|
|
65
|
+
```
|
|
66
|
+
pip install git+https://github.com/AlessandriniAntoine/pySimBlocks
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Locally
|
|
70
|
+
|
|
71
|
+
Clone the repository and install locally:
|
|
72
|
+
```
|
|
73
|
+
git clone https://github.com/AlessandriniAntoine/pySimBlocks.git
|
|
74
|
+
cd pySimBlocks
|
|
75
|
+
pip install .
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Getting Started
|
|
79
|
+
|
|
80
|
+
### Quick Example
|
|
81
|
+
|
|
82
|
+
The following example models a simple first-order low-pass filter, defined by
|
|
83
|
+
the difference equation:
|
|
84
|
+
|
|
85
|
+
$$ y[k] = \alpha x[k] + (1-\alpha) y[k-1] $$
|
|
86
|
+
|
|
87
|
+
It can be implemented in pySimBlocks using the following code:
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
from pySimBlocks import Model, Simulator, SimulationConfig, PlotConfig
|
|
91
|
+
from pySimBlocks.blocks.operators import Gain, Sum, Delay
|
|
92
|
+
from pySimBlocks.blocks.sources import WhiteNoise
|
|
93
|
+
from pySimBlocks.project.plot_from_config import plot_from_config
|
|
94
|
+
|
|
95
|
+
# 1. Create the blocks
|
|
96
|
+
noise = WhiteNoise(name="noise", std=1.0)
|
|
97
|
+
delay = Delay(name="delay")
|
|
98
|
+
filtered = Sum("filtered", signs="++")
|
|
99
|
+
alpha_gain = Gain(name="alpha", gain=0.1)
|
|
100
|
+
complement = Gain(name="complement", gain=0.9)
|
|
101
|
+
|
|
102
|
+
# 2. Build the model
|
|
103
|
+
model = Model("Example")
|
|
104
|
+
for block in [noise, delay, filtered, alpha_gain, complement]:
|
|
105
|
+
model.add_block(block)
|
|
106
|
+
|
|
107
|
+
model.connect("noise", "out", "alpha", "in")
|
|
108
|
+
model.connect("delay", "out", "complement", "in")
|
|
109
|
+
model.connect("alpha", "out", "filtered", "in1")
|
|
110
|
+
model.connect("complement", "out", "filtered", "in2")
|
|
111
|
+
model.connect("filtered", "out", "delay", "in")
|
|
112
|
+
|
|
113
|
+
# 3. Simulate the model
|
|
114
|
+
sim_cfg = SimulationConfig(dt=0.05, T=30.)
|
|
115
|
+
sim = Simulator(model, sim_cfg)
|
|
116
|
+
logs = sim.run(logging=["noise.outputs.out", "filtered.outputs.out"])
|
|
117
|
+
|
|
118
|
+
# 4. Plot the results
|
|
119
|
+
plot_cfg = PlotConfig([
|
|
120
|
+
{"title": "Noisy signal vs Filtered",
|
|
121
|
+
"signals": ["noise.outputs.out", "filtered.outputs.out"],},
|
|
122
|
+
])
|
|
123
|
+
plot_from_config(logs, plot_cfg)
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
The resulting plot should look like this:
|
|
127
|
+
|
|
128
|
+

|
|
129
|
+
|
|
130
|
+
See [examples/quick_start/filter.py](./examples/quick_start/filter.py)
|
|
131
|
+
to run the example yourself.
|
|
132
|
+
|
|
133
|
+
### Graphical Editor
|
|
134
|
+
|
|
135
|
+
The exact same model can be constructed visually using the graphical editor (as
|
|
136
|
+
shown in the image above of this README).
|
|
137
|
+
|
|
138
|
+
To open the graphical editor, run:
|
|
139
|
+
```bash
|
|
140
|
+
pysimblocks gui examples/quick_start/gui
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
The quick-start GUI project is stored in a single
|
|
144
|
+
[examples/quick_start/gui/project.yaml](./examples/quick_start/gui/project.yaml) file.
|
|
145
|
+
|
|
146
|
+
### Learning Resources
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
#### Tutorials
|
|
150
|
+
|
|
151
|
+
Three step-by-step tutorials are available detailed in the
|
|
152
|
+
[guide](./docs/User_Guide/getting_started.md):
|
|
153
|
+
|
|
154
|
+
| | Tutorial | Description |
|
|
155
|
+
|---|---|---|
|
|
156
|
+
| 1 | [Python API](./docs/User_Guide/tutorial_1_python.md) | Build a closed-loop PI control system in pure Python |
|
|
157
|
+
| 2 | [GUI](./docs/User_Guide/tutorial_2_gui.md) | Build the same system visually with the graphical editor |
|
|
158
|
+
| 3 | [SOFA](./docs/User_Guide/tutorial_3_sofa.md) | Replace the plant with a SOFA physics simulation |
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
#### Other Examples
|
|
162
|
+
|
|
163
|
+
A collection of basic and advanced examples is available in the
|
|
164
|
+
[examples](./examples) directory, including:
|
|
165
|
+
|
|
166
|
+
- Control system demonstrations
|
|
167
|
+
- SOFA-based simulations (tested with SOFA v24.06 and later.)
|
|
168
|
+
- Hardware and real-time use cases
|
|
169
|
+
- Comparisons with external tools
|
|
170
|
+
|
|
171
|
+
See [examples/README.md](./examples/README.md) for an overview.
|
|
172
|
+
|
|
173
|
+
## Information
|
|
174
|
+
|
|
175
|
+
### License
|
|
176
|
+
|
|
177
|
+
pySimBlocks is licensed under [LGPL-3.0-or-later](./LICENSE.md).
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
© 2026 Université de Lille & INRIA – Licensed under LGPL-3.0-or-later
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# pySimBlocks
|
|
2
|
+
|
|
3
|
+
A deterministic block-diagram simulation framework for discrete-time modeling,
|
|
4
|
+
co-simulation and research prototyping in Python.
|
|
5
|
+
|
|
6
|
+
pySimBlocks allows you to build, configure, and execute discrete-time systems
|
|
7
|
+
using either:
|
|
8
|
+
|
|
9
|
+
- A pure Python API
|
|
10
|
+
- A graphical editor (PySide6)
|
|
11
|
+
- YAML project configuration
|
|
12
|
+
- Optional SOFA and hardware integration
|
|
13
|
+
|
|
14
|
+

|
|
15
|
+
|
|
16
|
+
## Features
|
|
17
|
+
|
|
18
|
+
- Block-based modeling (Simulink-like)
|
|
19
|
+
- Deterministic discrete-time simulation engine
|
|
20
|
+
- PySide6 graphical editor
|
|
21
|
+
- YAML-based project serialization
|
|
22
|
+
- Exportable Python runner (`run.py`)
|
|
23
|
+
- Extensible block architecture
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
### From GitHub
|
|
28
|
+
|
|
29
|
+
Install directly from GitHub using pip:
|
|
30
|
+
```
|
|
31
|
+
pip install git+https://github.com/AlessandriniAntoine/pySimBlocks
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Locally
|
|
35
|
+
|
|
36
|
+
Clone the repository and install locally:
|
|
37
|
+
```
|
|
38
|
+
git clone https://github.com/AlessandriniAntoine/pySimBlocks.git
|
|
39
|
+
cd pySimBlocks
|
|
40
|
+
pip install .
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Getting Started
|
|
44
|
+
|
|
45
|
+
### Quick Example
|
|
46
|
+
|
|
47
|
+
The following example models a simple first-order low-pass filter, defined by
|
|
48
|
+
the difference equation:
|
|
49
|
+
|
|
50
|
+
$$ y[k] = \alpha x[k] + (1-\alpha) y[k-1] $$
|
|
51
|
+
|
|
52
|
+
It can be implemented in pySimBlocks using the following code:
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
from pySimBlocks import Model, Simulator, SimulationConfig, PlotConfig
|
|
56
|
+
from pySimBlocks.blocks.operators import Gain, Sum, Delay
|
|
57
|
+
from pySimBlocks.blocks.sources import WhiteNoise
|
|
58
|
+
from pySimBlocks.project.plot_from_config import plot_from_config
|
|
59
|
+
|
|
60
|
+
# 1. Create the blocks
|
|
61
|
+
noise = WhiteNoise(name="noise", std=1.0)
|
|
62
|
+
delay = Delay(name="delay")
|
|
63
|
+
filtered = Sum("filtered", signs="++")
|
|
64
|
+
alpha_gain = Gain(name="alpha", gain=0.1)
|
|
65
|
+
complement = Gain(name="complement", gain=0.9)
|
|
66
|
+
|
|
67
|
+
# 2. Build the model
|
|
68
|
+
model = Model("Example")
|
|
69
|
+
for block in [noise, delay, filtered, alpha_gain, complement]:
|
|
70
|
+
model.add_block(block)
|
|
71
|
+
|
|
72
|
+
model.connect("noise", "out", "alpha", "in")
|
|
73
|
+
model.connect("delay", "out", "complement", "in")
|
|
74
|
+
model.connect("alpha", "out", "filtered", "in1")
|
|
75
|
+
model.connect("complement", "out", "filtered", "in2")
|
|
76
|
+
model.connect("filtered", "out", "delay", "in")
|
|
77
|
+
|
|
78
|
+
# 3. Simulate the model
|
|
79
|
+
sim_cfg = SimulationConfig(dt=0.05, T=30.)
|
|
80
|
+
sim = Simulator(model, sim_cfg)
|
|
81
|
+
logs = sim.run(logging=["noise.outputs.out", "filtered.outputs.out"])
|
|
82
|
+
|
|
83
|
+
# 4. Plot the results
|
|
84
|
+
plot_cfg = PlotConfig([
|
|
85
|
+
{"title": "Noisy signal vs Filtered",
|
|
86
|
+
"signals": ["noise.outputs.out", "filtered.outputs.out"],},
|
|
87
|
+
])
|
|
88
|
+
plot_from_config(logs, plot_cfg)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
The resulting plot should look like this:
|
|
92
|
+
|
|
93
|
+

|
|
94
|
+
|
|
95
|
+
See [examples/quick_start/filter.py](./examples/quick_start/filter.py)
|
|
96
|
+
to run the example yourself.
|
|
97
|
+
|
|
98
|
+
### Graphical Editor
|
|
99
|
+
|
|
100
|
+
The exact same model can be constructed visually using the graphical editor (as
|
|
101
|
+
shown in the image above of this README).
|
|
102
|
+
|
|
103
|
+
To open the graphical editor, run:
|
|
104
|
+
```bash
|
|
105
|
+
pysimblocks gui examples/quick_start/gui
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
The quick-start GUI project is stored in a single
|
|
109
|
+
[examples/quick_start/gui/project.yaml](./examples/quick_start/gui/project.yaml) file.
|
|
110
|
+
|
|
111
|
+
### Learning Resources
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
#### Tutorials
|
|
115
|
+
|
|
116
|
+
Three step-by-step tutorials are available detailed in the
|
|
117
|
+
[guide](./docs/User_Guide/getting_started.md):
|
|
118
|
+
|
|
119
|
+
| | Tutorial | Description |
|
|
120
|
+
|---|---|---|
|
|
121
|
+
| 1 | [Python API](./docs/User_Guide/tutorial_1_python.md) | Build a closed-loop PI control system in pure Python |
|
|
122
|
+
| 2 | [GUI](./docs/User_Guide/tutorial_2_gui.md) | Build the same system visually with the graphical editor |
|
|
123
|
+
| 3 | [SOFA](./docs/User_Guide/tutorial_3_sofa.md) | Replace the plant with a SOFA physics simulation |
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
#### Other Examples
|
|
127
|
+
|
|
128
|
+
A collection of basic and advanced examples is available in the
|
|
129
|
+
[examples](./examples) directory, including:
|
|
130
|
+
|
|
131
|
+
- Control system demonstrations
|
|
132
|
+
- SOFA-based simulations (tested with SOFA v24.06 and later.)
|
|
133
|
+
- Hardware and real-time use cases
|
|
134
|
+
- Comparisons with external tools
|
|
135
|
+
|
|
136
|
+
See [examples/README.md](./examples/README.md) for an overview.
|
|
137
|
+
|
|
138
|
+
## Information
|
|
139
|
+
|
|
140
|
+
### License
|
|
141
|
+
|
|
142
|
+
pySimBlocks is licensed under [LGPL-3.0-or-later](./LICENSE.md).
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
© 2026 Université de Lille & INRIA – Licensed under LGPL-3.0-or-later
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import time
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
import numpy as np
|
|
5
|
+
import parameters as prm
|
|
6
|
+
from emioapi import EmioMotors
|
|
7
|
+
|
|
8
|
+
from pySimBlocks.project import load_simulator_from_project
|
|
9
|
+
from pySimBlocks.real_time import RealTimeRunner
|
|
10
|
+
|
|
11
|
+
try:
|
|
12
|
+
BASE_DIR = Path(__file__).parent.resolve()
|
|
13
|
+
except Exception:
|
|
14
|
+
BASE_DIR = Path("")
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# ------------------------------------------------------------------------------
|
|
18
|
+
# Process
|
|
19
|
+
# ------------------------------------------------------------------------------
|
|
20
|
+
def process_block_diagram(shared_markers_pos, shared_ref_ol, shared_ref_cl,
|
|
21
|
+
shared_control_mode, shared_update,
|
|
22
|
+
event_frame, event_measure):
|
|
23
|
+
"""pySimBlocks runner process.
|
|
24
|
+
"""
|
|
25
|
+
init_angles = np.array([0.7, 0, 0.7, 0])
|
|
26
|
+
motors = setup_motors(init_angles)
|
|
27
|
+
|
|
28
|
+
# init pySimBlocks runner
|
|
29
|
+
runner = setup_block_diagram()
|
|
30
|
+
|
|
31
|
+
# Initialize variables
|
|
32
|
+
measure = np.zeros((prm.nb_markers * 2, 1))
|
|
33
|
+
ref_ol = np.zeros((2, 1))
|
|
34
|
+
ref_cl = np.zeros((2, 1))
|
|
35
|
+
control_mode = np.zeros((1, 1))
|
|
36
|
+
command = np.zeros((2, 1))
|
|
37
|
+
|
|
38
|
+
# Initial time for dt measurement
|
|
39
|
+
t = time.perf_counter()
|
|
40
|
+
dt_init = 1/60
|
|
41
|
+
dt_list = []
|
|
42
|
+
|
|
43
|
+
while True:
|
|
44
|
+
event_frame.wait()
|
|
45
|
+
event_frame.clear()
|
|
46
|
+
|
|
47
|
+
send_motors_command(motors, command, init_angles)
|
|
48
|
+
|
|
49
|
+
event_measure.wait()
|
|
50
|
+
event_measure.clear()
|
|
51
|
+
|
|
52
|
+
if dt_init is not None:
|
|
53
|
+
t = time.perf_counter()
|
|
54
|
+
dt = dt_init
|
|
55
|
+
dt_init = None
|
|
56
|
+
else:
|
|
57
|
+
t2 = time.perf_counter()
|
|
58
|
+
dt = t2 - t
|
|
59
|
+
t = t2
|
|
60
|
+
dt_list.append(dt)
|
|
61
|
+
|
|
62
|
+
# data from camera
|
|
63
|
+
with shared_markers_pos.get_lock():
|
|
64
|
+
measure[:, 0] = shared_markers_pos[:]
|
|
65
|
+
|
|
66
|
+
with shared_update.get_lock():
|
|
67
|
+
if shared_update.value:
|
|
68
|
+
with shared_ref_ol.get_lock():
|
|
69
|
+
ref_ol[:, 0] = shared_ref_ol[:]
|
|
70
|
+
with shared_ref_cl.get_lock():
|
|
71
|
+
ref_cl[:, 0] = shared_ref_cl[:]
|
|
72
|
+
with shared_control_mode.get_lock():
|
|
73
|
+
control_mode[0,0] = shared_control_mode.value
|
|
74
|
+
shared_update.value = False
|
|
75
|
+
|
|
76
|
+
outs = runner.tick(
|
|
77
|
+
inputs={
|
|
78
|
+
"Camera": measure,
|
|
79
|
+
"Ref_ol": ref_ol,
|
|
80
|
+
"Ref_cl": ref_cl,
|
|
81
|
+
"Mode": control_mode
|
|
82
|
+
},
|
|
83
|
+
dt=dt,
|
|
84
|
+
pace=False
|
|
85
|
+
)
|
|
86
|
+
command = outs["Cmd"]
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
# ------------------------------------------------------------------------------
|
|
90
|
+
# Helpers
|
|
91
|
+
# ------------------------------------------------------------------------------
|
|
92
|
+
def setup_block_diagram():
|
|
93
|
+
sim, _plot_cfg = load_simulator_from_project(BASE_DIR / "project.yaml")
|
|
94
|
+
runner = RealTimeRunner(
|
|
95
|
+
sim,
|
|
96
|
+
input_blocks=["Camera", "Ref_cl", "Ref_ol", "Mode"],
|
|
97
|
+
output_blocks=["Cmd"],
|
|
98
|
+
target_dt=1/60
|
|
99
|
+
)
|
|
100
|
+
runner.initialize()
|
|
101
|
+
return runner
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
# -------------------------------------------------------
|
|
105
|
+
def setup_motors(init_angles=[0, 0, 0, 0]):
|
|
106
|
+
motors = EmioMotors()
|
|
107
|
+
while not motors.open():
|
|
108
|
+
print("Waiting for motors to open...")
|
|
109
|
+
time.sleep(1)
|
|
110
|
+
print("Motors opened successfully.")
|
|
111
|
+
motors.position_p_gain = [2000, 800, 2000, 800]
|
|
112
|
+
motors.position_i_gain = [0, 0, 0, 0]
|
|
113
|
+
motors.position_d_gain = [50, 0, 50, 0]
|
|
114
|
+
time.sleep(1)
|
|
115
|
+
motors.angles = init_angles
|
|
116
|
+
return motors
|
|
117
|
+
|
|
118
|
+
# -------------------------------------------------------
|
|
119
|
+
def send_motors_command(motors, command, init_angles=np.array([0, 0, 0, 0])):
|
|
120
|
+
command = command.flatten()
|
|
121
|
+
motors.angles = [command[0] + init_angles[0], init_angles[1],
|
|
122
|
+
command[1] + init_angles[2], init_angles[3]]
|
|
123
|
+
|
|
124
|
+
# -------------------------------------------------------
|
|
125
|
+
def get_motors_position(motors, init_angles=np.array([0, 0, 0, 0])):
|
|
126
|
+
motors_pos = np.array(motors.angles) - init_angles
|
|
127
|
+
return motors_pos[[0, 2]].reshape((2, 1))
|
|
128
|
+
|
|
129
|
+
# ------------------------------------------------------------------------------
|
|
130
|
+
# BLOCK DIAGRAM FUNCTIONS
|
|
131
|
+
# ------------------------------------------------------------------------------
|
|
132
|
+
def select_cmd(t, dt, u_cl, u_ol, mode):
|
|
133
|
+
try:
|
|
134
|
+
mode = mode.item()
|
|
135
|
+
except Exception:
|
|
136
|
+
return {"u": np.zeros((2,1))}
|
|
137
|
+
|
|
138
|
+
if mode == 0:
|
|
139
|
+
return {"u": u_ol}
|
|
140
|
+
elif mode == 1:
|
|
141
|
+
return {"u": u_cl}
|
|
142
|
+
else:
|
|
143
|
+
return {"u": np.zeros((2,1))}
|
|
144
|
+
|
|
145
|
+
# -------------------------------------------------------
|
|
146
|
+
def filter_first_order(t, dt, u, u_prev):
|
|
147
|
+
"""Apply a first-order low-pass filter to the signal."""
|
|
148
|
+
if dt <= 0:
|
|
149
|
+
return {"u_filter" : np.zeros((2,1))}
|
|
150
|
+
cutoffFreq = 30. # Cutoff frequency in Hz
|
|
151
|
+
samplingFreq = 1 / dt
|
|
152
|
+
|
|
153
|
+
timeConstant = 1 / (2 * np.pi * cutoffFreq)
|
|
154
|
+
samplingPeriod = 1 / samplingFreq
|
|
155
|
+
alpha = samplingPeriod / (timeConstant + samplingPeriod)
|
|
156
|
+
uf = alpha * u + (1 - alpha) * u_prev
|
|
157
|
+
|
|
158
|
+
return {"u_filter" : uf}
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
if __name__ == "__main__":
|
|
162
|
+
setup_block_diagram()
|