pySimBlocks 0.1.0__py3-none-any.whl

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.
Files changed (262) hide show
  1. examples/advanced/hardware/block_diagram.py +162 -0
  2. examples/advanced/hardware/camera.py +93 -0
  3. examples/advanced/hardware/gui_emio.py +231 -0
  4. examples/advanced/hardware/lmi.py +69 -0
  5. examples/advanced/hardware/main.py +57 -0
  6. examples/advanced/hardware/parameters.py +54 -0
  7. examples/advanced/qp_problem/params.py +10 -0
  8. examples/advanced/qp_problem/run.py +14 -0
  9. examples/advanced/sofa/gui/finger/Finger.py +108 -0
  10. examples/advanced/sofa/gui/finger/FingerController.py +53 -0
  11. examples/advanced/sofa/gui/finger/parameters_auto.py +22 -0
  12. examples/advanced/sofa/gui/sofa_plant/run.py +14 -0
  13. examples/advanced/sofa/python/Finger.py +107 -0
  14. examples/advanced/sofa/python/FingerController.py +48 -0
  15. examples/advanced/sofa/python/closedloop.py +64 -0
  16. examples/advanced/sofa/python/openloop.py +58 -0
  17. examples/basics/algebraic_function/g.py +7 -0
  18. examples/basics/algebraic_function/run.py +14 -0
  19. examples/basics/dc_motor/gui/run.py +14 -0
  20. examples/basics/dc_motor/multiple_order.py +91 -0
  21. examples/basics/dc_motor/openloop.py +62 -0
  22. examples/basics/dc_motor/pi.py +99 -0
  23. examples/basics/dc_motor/pid.py +118 -0
  24. examples/basics/dc_motor/pid_block.py +82 -0
  25. examples/basics/dc_motor/pid_block_vs_manual.py +143 -0
  26. examples/basics/external/parameters.py +4 -0
  27. examples/basics/external/run.py +14 -0
  28. examples/basics/file_sources/temp.py +16 -0
  29. examples/basics/observer.py +76 -0
  30. examples/basics/state_feedback/gui/parameters.py +9 -0
  31. examples/basics/state_feedback/gui/run.py +14 -0
  32. examples/basics/state_feedback/state_feedback.py +102 -0
  33. examples/basics/state_space/linear/gui/run.py +14 -0
  34. examples/basics/state_space/linear/ss_block.py +89 -0
  35. examples/basics/state_space/linear/ss_manual.py +105 -0
  36. examples/basics/state_space/non_linear/nlss.py +47 -0
  37. examples/basics/state_space/non_linear/run.py +14 -0
  38. examples/basics/state_space/polytope/params.py +39 -0
  39. examples/basics/state_space/polytope/weights.py +12 -0
  40. examples/comparison/simulink/convert.py +29 -0
  41. examples/comparison/simulink/openloop.py +127 -0
  42. examples/comparison/simulink/pi.py +148 -0
  43. examples/comparison/simulink/pid.py +154 -0
  44. examples/comparison/simulink/pid_backward.py +155 -0
  45. examples/quick_start/filter.py +35 -0
  46. examples/quick_start/gui/run.py +14 -0
  47. examples/tutorials/tutorial_1_python/main.py +99 -0
  48. examples/tutorials/tutorial_3_sofa/finger/Finger.py +120 -0
  49. examples/tutorials/tutorial_3_sofa/finger/FingerController.py +37 -0
  50. pySimBlocks/__init__.py +35 -0
  51. pySimBlocks/blocks/__init__.py +68 -0
  52. pySimBlocks/blocks/controllers/__init__.py +27 -0
  53. pySimBlocks/blocks/controllers/pid.py +250 -0
  54. pySimBlocks/blocks/controllers/state_feedback.py +141 -0
  55. pySimBlocks/blocks/interfaces/__init__.py +27 -0
  56. pySimBlocks/blocks/interfaces/external_input.py +107 -0
  57. pySimBlocks/blocks/interfaces/external_output.py +113 -0
  58. pySimBlocks/blocks/observers/__init__.py +23 -0
  59. pySimBlocks/blocks/observers/luenberger.py +175 -0
  60. pySimBlocks/blocks/operators/__init__.py +47 -0
  61. pySimBlocks/blocks/operators/algebraic_function.py +258 -0
  62. pySimBlocks/blocks/operators/dead_zone.py +186 -0
  63. pySimBlocks/blocks/operators/delay.py +254 -0
  64. pySimBlocks/blocks/operators/demux.py +123 -0
  65. pySimBlocks/blocks/operators/discrete_derivator.py +237 -0
  66. pySimBlocks/blocks/operators/discrete_integrator.py +265 -0
  67. pySimBlocks/blocks/operators/gain.py +294 -0
  68. pySimBlocks/blocks/operators/mux.py +131 -0
  69. pySimBlocks/blocks/operators/product.py +194 -0
  70. pySimBlocks/blocks/operators/rate_limiter.py +214 -0
  71. pySimBlocks/blocks/operators/saturation.py +178 -0
  72. pySimBlocks/blocks/operators/sum.py +188 -0
  73. pySimBlocks/blocks/operators/zero_order_hold.py +141 -0
  74. pySimBlocks/blocks/optimizers/__init__.py +23 -0
  75. pySimBlocks/blocks/optimizers/quadratic_program.py +326 -0
  76. pySimBlocks/blocks/sources/__init__.py +37 -0
  77. pySimBlocks/blocks/sources/chirp.py +168 -0
  78. pySimBlocks/blocks/sources/constant.py +82 -0
  79. pySimBlocks/blocks/sources/file_source.py +294 -0
  80. pySimBlocks/blocks/sources/function_source.py +197 -0
  81. pySimBlocks/blocks/sources/ramp.py +99 -0
  82. pySimBlocks/blocks/sources/sinusoidal.py +113 -0
  83. pySimBlocks/blocks/sources/step.py +138 -0
  84. pySimBlocks/blocks/sources/white_noise.py +107 -0
  85. pySimBlocks/blocks/systems/__init__.py +27 -0
  86. pySimBlocks/blocks/systems/linear_state_space.py +180 -0
  87. pySimBlocks/blocks/systems/non_linear_state_space.py +309 -0
  88. pySimBlocks/blocks/systems/polytopic_state_space.py +193 -0
  89. pySimBlocks/blocks/systems/sofa/__init__.py +30 -0
  90. pySimBlocks/blocks/systems/sofa/sofa_controller.py +472 -0
  91. pySimBlocks/blocks/systems/sofa/sofa_exchange_i_o.py +120 -0
  92. pySimBlocks/blocks/systems/sofa/sofa_plant.py +306 -0
  93. pySimBlocks/cli.py +127 -0
  94. pySimBlocks/core/__init__.py +32 -0
  95. pySimBlocks/core/block.py +167 -0
  96. pySimBlocks/core/block_source.py +94 -0
  97. pySimBlocks/core/config.py +90 -0
  98. pySimBlocks/core/fixed_time_manager.py +46 -0
  99. pySimBlocks/core/model.py +250 -0
  100. pySimBlocks/core/scheduler.py +30 -0
  101. pySimBlocks/core/simulator.py +329 -0
  102. pySimBlocks/core/task.py +73 -0
  103. pySimBlocks/docs/blocks/controllers/pid.md +78 -0
  104. pySimBlocks/docs/blocks/controllers/state_feedback.md +60 -0
  105. pySimBlocks/docs/blocks/interfaces/external_input.md +39 -0
  106. pySimBlocks/docs/blocks/interfaces/external_output.md +39 -0
  107. pySimBlocks/docs/blocks/observers/luenberger.md +70 -0
  108. pySimBlocks/docs/blocks/operators/algebraic_function.md +76 -0
  109. pySimBlocks/docs/blocks/operators/dead_zone.md +67 -0
  110. pySimBlocks/docs/blocks/operators/delay.md +76 -0
  111. pySimBlocks/docs/blocks/operators/demux.md +64 -0
  112. pySimBlocks/docs/blocks/operators/discrete_derivator.md +61 -0
  113. pySimBlocks/docs/blocks/operators/discrete_integrator.md +87 -0
  114. pySimBlocks/docs/blocks/operators/gain.md +97 -0
  115. pySimBlocks/docs/blocks/operators/mux.md +64 -0
  116. pySimBlocks/docs/blocks/operators/product.md +51 -0
  117. pySimBlocks/docs/blocks/operators/rate_limiter.md +70 -0
  118. pySimBlocks/docs/blocks/operators/saturation.md +62 -0
  119. pySimBlocks/docs/blocks/operators/sum.md +49 -0
  120. pySimBlocks/docs/blocks/operators/zero_order_hold.md +61 -0
  121. pySimBlocks/docs/blocks/optimizers/quadratic_program.md +98 -0
  122. pySimBlocks/docs/blocks/sources/chirp.md +102 -0
  123. pySimBlocks/docs/blocks/sources/constant.md +53 -0
  124. pySimBlocks/docs/blocks/sources/file_source.md +51 -0
  125. pySimBlocks/docs/blocks/sources/function_source.md +52 -0
  126. pySimBlocks/docs/blocks/sources/ramp.md +58 -0
  127. pySimBlocks/docs/blocks/sources/sinusoidal.md +60 -0
  128. pySimBlocks/docs/blocks/sources/step.md +63 -0
  129. pySimBlocks/docs/blocks/sources/white_noise.md +58 -0
  130. pySimBlocks/docs/blocks/systems/linear_state_space.md +66 -0
  131. pySimBlocks/docs/blocks/systems/non_linear_state_space.md +90 -0
  132. pySimBlocks/docs/blocks/systems/polytopic_state_space.md +72 -0
  133. pySimBlocks/docs/blocks/systems/sofa/sofa_exchange_i_o.md +63 -0
  134. pySimBlocks/docs/blocks/systems/sofa/sofa_plant.md +62 -0
  135. pySimBlocks/gui/__init__.py +20 -0
  136. pySimBlocks/gui/addons/__init__.py +19 -0
  137. pySimBlocks/gui/addons/sofa/__init__.py +19 -0
  138. pySimBlocks/gui/addons/sofa/sofa_dialog.py +190 -0
  139. pySimBlocks/gui/addons/sofa/sofa_service.py +209 -0
  140. pySimBlocks/gui/blocks/block_dialog_session.py +47 -0
  141. pySimBlocks/gui/blocks/block_meta.py +408 -0
  142. pySimBlocks/gui/blocks/controllers/pid.py +116 -0
  143. pySimBlocks/gui/blocks/controllers/state_feedback.py +80 -0
  144. pySimBlocks/gui/blocks/interfaces/external_input.py +64 -0
  145. pySimBlocks/gui/blocks/interfaces/external_output.py +63 -0
  146. pySimBlocks/gui/blocks/observers/luenberger.py +108 -0
  147. pySimBlocks/gui/blocks/operators/algebraic_function.py +232 -0
  148. pySimBlocks/gui/blocks/operators/dead_zone.py +79 -0
  149. pySimBlocks/gui/blocks/operators/delay.py +79 -0
  150. pySimBlocks/gui/blocks/operators/demux.py +98 -0
  151. pySimBlocks/gui/blocks/operators/discrete_derivator.py +67 -0
  152. pySimBlocks/gui/blocks/operators/discrete_integrator.py +80 -0
  153. pySimBlocks/gui/blocks/operators/gain.py +79 -0
  154. pySimBlocks/gui/blocks/operators/mux.py +100 -0
  155. pySimBlocks/gui/blocks/operators/product.py +109 -0
  156. pySimBlocks/gui/blocks/operators/rate_limiter.py +79 -0
  157. pySimBlocks/gui/blocks/operators/saturation.py +72 -0
  158. pySimBlocks/gui/blocks/operators/sum.py +91 -0
  159. pySimBlocks/gui/blocks/operators/zero_order_hold.py +64 -0
  160. pySimBlocks/gui/blocks/optimizers/quadratic_program.py +128 -0
  161. pySimBlocks/gui/blocks/parameter_meta.py +34 -0
  162. pySimBlocks/gui/blocks/port_meta.py +31 -0
  163. pySimBlocks/gui/blocks/sources/chirp.py +146 -0
  164. pySimBlocks/gui/blocks/sources/constant.py +63 -0
  165. pySimBlocks/gui/blocks/sources/file_source.py +196 -0
  166. pySimBlocks/gui/blocks/sources/function_source.py +202 -0
  167. pySimBlocks/gui/blocks/sources/ramp.py +73 -0
  168. pySimBlocks/gui/blocks/sources/sinusoidal.py +81 -0
  169. pySimBlocks/gui/blocks/sources/step.py +83 -0
  170. pySimBlocks/gui/blocks/sources/white_noise.py +70 -0
  171. pySimBlocks/gui/blocks/systems/linear_state_space.py +102 -0
  172. pySimBlocks/gui/blocks/systems/non_linear_state_space.py +233 -0
  173. pySimBlocks/gui/blocks/systems/polytopic_state_space.py +109 -0
  174. pySimBlocks/gui/blocks/systems/sofa/sofa_exchange_i_o.py +221 -0
  175. pySimBlocks/gui/blocks/systems/sofa/sofa_plant.py +220 -0
  176. pySimBlocks/gui/dialogs/__init__.py +19 -0
  177. pySimBlocks/gui/dialogs/block_dialog.py +125 -0
  178. pySimBlocks/gui/dialogs/display_yaml_dialog.py +89 -0
  179. pySimBlocks/gui/dialogs/help_dialog.py +39 -0
  180. pySimBlocks/gui/dialogs/plot_dialog.py +230 -0
  181. pySimBlocks/gui/dialogs/settings/plots.py +187 -0
  182. pySimBlocks/gui/dialogs/settings/project.py +146 -0
  183. pySimBlocks/gui/dialogs/settings/simulation.py +137 -0
  184. pySimBlocks/gui/dialogs/settings_dialog.py +88 -0
  185. pySimBlocks/gui/dialogs/unsaved_dialog.py +92 -0
  186. pySimBlocks/gui/editor.py +49 -0
  187. pySimBlocks/gui/graphics/__init__.py +29 -0
  188. pySimBlocks/gui/graphics/block_item.py +289 -0
  189. pySimBlocks/gui/graphics/connection_item.py +266 -0
  190. pySimBlocks/gui/graphics/port_item.py +153 -0
  191. pySimBlocks/gui/graphics/theme.py +119 -0
  192. pySimBlocks/gui/main_window.py +162 -0
  193. pySimBlocks/gui/models/__init__.py +31 -0
  194. pySimBlocks/gui/models/block_instance.py +114 -0
  195. pySimBlocks/gui/models/connection_instance.py +43 -0
  196. pySimBlocks/gui/models/port_instance.py +52 -0
  197. pySimBlocks/gui/models/project_simulation_params.py +50 -0
  198. pySimBlocks/gui/models/project_state.py +114 -0
  199. pySimBlocks/gui/project_controller.py +302 -0
  200. pySimBlocks/gui/services/__init__.py +20 -0
  201. pySimBlocks/gui/services/project_loader.py +381 -0
  202. pySimBlocks/gui/services/project_saver.py +68 -0
  203. pySimBlocks/gui/services/simulation_runner.py +66 -0
  204. pySimBlocks/gui/services/yaml_tools.py +261 -0
  205. pySimBlocks/gui/widgets/__init__.py +19 -0
  206. pySimBlocks/gui/widgets/block_list.py +131 -0
  207. pySimBlocks/gui/widgets/diagram_view.py +312 -0
  208. pySimBlocks/gui/widgets/toolbar_view.py +161 -0
  209. pySimBlocks/project/__init__.py +35 -0
  210. pySimBlocks/project/build_model.py +92 -0
  211. pySimBlocks/project/generate_run_script.py +109 -0
  212. pySimBlocks/project/generate_sofa_controller.py +215 -0
  213. pySimBlocks/project/load_project_config.py +197 -0
  214. pySimBlocks/project/load_simulation_config.py +166 -0
  215. pySimBlocks/project/load_simulator.py +45 -0
  216. pySimBlocks/project/plot_from_config.py +174 -0
  217. pySimBlocks/project/pySimBlocks_blocks_index.yaml +106 -0
  218. pySimBlocks/real_time/__init__.py +23 -0
  219. pySimBlocks/real_time/real_time_runner.py +148 -0
  220. pySimBlocks/tools/__init__.py +19 -0
  221. pySimBlocks/tools/blocks_registry.py +141 -0
  222. pySimBlocks/tools/generate_blocks_index.py +124 -0
  223. pysimblocks-0.1.0.dist-info/METADATA +180 -0
  224. pysimblocks-0.1.0.dist-info/RECORD +262 -0
  225. pysimblocks-0.1.0.dist-info/WHEEL +5 -0
  226. pysimblocks-0.1.0.dist-info/entry_points.txt +2 -0
  227. pysimblocks-0.1.0.dist-info/licenses/LICENSE.md +165 -0
  228. pysimblocks-0.1.0.dist-info/top_level.txt +3 -0
  229. tests/blocks/controllers/test_pid.py +143 -0
  230. tests/blocks/controllers/test_state_feedback.py +193 -0
  231. tests/blocks/observers/test_luenberger.py +225 -0
  232. tests/blocks/operators/test_algebraic_function.py +230 -0
  233. tests/blocks/operators/test_dead_zone.py +106 -0
  234. tests/blocks/operators/test_delay.py +167 -0
  235. tests/blocks/operators/test_demux.py +111 -0
  236. tests/blocks/operators/test_discrete_derivator.py +160 -0
  237. tests/blocks/operators/test_discrete_integrator.py +149 -0
  238. tests/blocks/operators/test_gain.py +182 -0
  239. tests/blocks/operators/test_mux.py +101 -0
  240. tests/blocks/operators/test_product.py +171 -0
  241. tests/blocks/operators/test_rate_limiter.py +166 -0
  242. tests/blocks/operators/test_saturation.py +157 -0
  243. tests/blocks/operators/test_sum.py +183 -0
  244. tests/blocks/operators/test_zero_order_hold.py +106 -0
  245. tests/blocks/sources/test_chirp.py +157 -0
  246. tests/blocks/sources/test_constant.py +55 -0
  247. tests/blocks/sources/test_file_source.py +185 -0
  248. tests/blocks/sources/test_function_source.py +135 -0
  249. tests/blocks/sources/test_ramp.py +110 -0
  250. tests/blocks/sources/test_sinusoidal.py +113 -0
  251. tests/blocks/sources/test_step.py +76 -0
  252. tests/blocks/sources/test_white_noise.py +108 -0
  253. tests/blocks/systems/test_linear_state_space.py +135 -0
  254. tests/blocks/systems/test_polytopic_state_space.py +133 -0
  255. tests/core/test_core_errors_and_determinism.py +82 -0
  256. tests/core/test_core_multirate_tasks.py +88 -0
  257. tests/core/test_core_two_phase_and_propagation.py +132 -0
  258. tests/gui/main_window_open_test.py +162 -0
  259. tests/gui/test_block_meta_param_cache.py +16 -0
  260. tests/gui/test_file_source_meta.py +17 -0
  261. tests/gui/test_function_source_meta.py +28 -0
  262. tests/regression/test_simulink_dc_motor.py +217 -0
@@ -0,0 +1,70 @@
1
+ # RateLimiter
2
+
3
+ ## Summary
4
+
5
+ The **RateLimiter** block limits the rate of change of its output signal by
6
+ constraining how fast the output can increase or decrease between successive
7
+ time steps.
8
+
9
+ ---
10
+
11
+ ## Mathematical definition
12
+
13
+ The rate-limited output is computed as:
14
+
15
+ $$
16
+ \Delta u = u[k] - y[k-1]
17
+ $$
18
+
19
+ $$
20
+ y[k] = y[k-1] + \mathrm{clip}(\Delta u,\; s^{-} dt,\; s^{+} dt)
21
+ $$
22
+
23
+ where:
24
+ - $u[k]$ is the current input,
25
+ - $y[k-1]$ is the previous output,
26
+ - $s^{+}$ is the rising slope (maximum positive rate),
27
+ - $s^{-}$ is the falling slope (maximum negative rate),
28
+ - $dt$ is the simulation time step.
29
+
30
+ ---
31
+
32
+ ## Parameters
33
+
34
+ | Name | Type | Description | Optional |
35
+ |------------|-------------|-------------|-------------|
36
+ | `rising_slope` | scalar or vector or matrix | Maximum allowed positive rate of change. Default is no positive rate limit. | True |
37
+ | `falling_slope` | scalar or vector or matrix | Maximum allowed negative rate of change. Default is no negative rate limit. | True |
38
+ | `initial_output` | scalar or vector or matrix | | Initial output value used as $y[-1]$. If not provided, the initial output is set equal to the first input. | True |
39
+ | `sample_time` | float | Block sample time. If omitted, the global simulation time step is used. | True |
40
+
41
+ ---
42
+
43
+ ## Inputs
44
+
45
+ | Port | Description |
46
+ |------|------------|
47
+ | `in` | Input signal. |
48
+
49
+ ---
50
+
51
+ ## Outputs
52
+
53
+ | Port | Description |
54
+ |------|------------|
55
+ | `out` | Rate-limited output signal. |
56
+
57
+ ---
58
+
59
+ ## Notes
60
+
61
+ - The block has internal state.
62
+ - The block has direct feedthrough.
63
+ - Rate limits are applied component-wise.
64
+ - Scalar parameters are automatically broadcast.
65
+ - Absence of a rate limit in one direction is represented by an infinite slope.
66
+ - This block is equivalent to the Simulink **Rate Limiter** block.
67
+
68
+
69
+ ---
70
+ © 2026 Université de Lille & INRIA – Licensed under LGPL-3.0-or-later
@@ -0,0 +1,62 @@
1
+ # Saturation
2
+
3
+ ## Summary
4
+
5
+ The **Saturation** block applies element-wise saturation to its input signal,
6
+ limiting the output to specified lower and upper bounds.
7
+
8
+ ---
9
+
10
+ ## Mathematical definition
11
+
12
+ The saturated output is defined as:
13
+
14
+ $$
15
+ y[k] = \mathrm{clip}(u[k], u_{\min}, u_{\max})
16
+ $$
17
+
18
+ where:
19
+ - $u[k]$ is the input signal,
20
+ - $u_{\min}$ is the lower saturation bound,
21
+ - $u_{\max}$ is the upper saturation bound.
22
+
23
+ ---
24
+
25
+ ## Parameters
26
+
27
+ | Name | Type | Description | Optional |
28
+ |------------|-------------|-------------|-------------|
29
+ | `u_min` | scalar or vector o matrix | Lower saturation bound. If omitted, no lower bound is applied. | True |
30
+ | `u_max` | scalar or vector or matrix | Upper saturation bound. If omitted, no upper bound is applied. | True |
31
+ | `sample_time` | float | Block sample time. If omitted, the global simulation time step is used. | True |
32
+
33
+ ---
34
+
35
+ ## Inputs
36
+
37
+ | Port | Description |
38
+ |------|------------|
39
+ | `in` | Input signal. |
40
+
41
+ ---
42
+
43
+ ## Outputs
44
+
45
+ | Port | Description |
46
+ |------|------------|
47
+ | `out` | Saturated output signal. |
48
+
49
+ ---
50
+
51
+ ## Notes
52
+
53
+ - The block has no internal state.
54
+ - The block has direct feedthrough.
55
+ - Saturation is applied component-wise.
56
+ - Scalar bounds are automatically broadcast to match the input dimension.
57
+ - Absence of saturation is represented by infinite bounds.
58
+ - This block is equivalent to the Simulink **Saturation** block.
59
+
60
+
61
+ ---
62
+ © 2026 Université de Lille & INRIA – Licensed under LGPL-3.0-or-later
@@ -0,0 +1,49 @@
1
+ # Sum Block
2
+
3
+ ## Description
4
+
5
+ The **Sum** block computes a weighted sum of multiple input signals.
6
+
7
+ It implements:
8
+
9
+ $$ y = s_1 u_1 + s_2 u_2 + \dots + s_N u_N $$
10
+
11
+ where each coefficient $ s_i $ is either +1 or −1.
12
+
13
+ ---
14
+
15
+ ## Parameters
16
+
17
+ | Name | Type | Description | Optional |
18
+ |------------|-------------|-------------|-------------|
19
+ | `signs` | string | Sequence of '+' and '−' characters defining the sign for each input. | False |
20
+ | `sample_time` | float | Block sample time. If omitted, the global simulation time step is used. | True |
21
+
22
+
23
+ ---
24
+
25
+ ## Inputs
26
+
27
+ | Port | Description |
28
+ |------|------------|
29
+ | `in1 … inN` | Input signals to be summed. All inputs must have identical dimensions or scalar. |
30
+
31
+ ---
32
+
33
+ ## Outputs
34
+
35
+ | Port | Description |
36
+ |------|------------|
37
+ | `out` | Weighted sum of all input signals. |
38
+
39
+ ---
40
+
41
+ ## Notes
42
+
43
+ - The Sum block has no internal state.
44
+ - The number of input ports is determined by the length of `signs`.
45
+ - This block is equivalent to the Simulink **Sum** block.
46
+
47
+
48
+ ---
49
+ © 2026 Université de Lille & INRIA – Licensed under LGPL-3.0-or-later
@@ -0,0 +1,61 @@
1
+ # ZeroOrderHold
2
+
3
+ ## Summary
4
+
5
+ The **ZeroOrderHold** block samples an input signal at discrete instants and
6
+ holds the sampled value constant between sampling instants.
7
+
8
+ ---
9
+
10
+ ## Mathematical definition
11
+
12
+ Let $T_s$ be the sampling period. The output is defined as:
13
+
14
+ $$
15
+ y[k] = u[k_s]
16
+ $$
17
+
18
+ where $k_s$ denotes the most recent sampling instant such that the elapsed
19
+ time since $k_s$ is less than $T_s$.
20
+
21
+ Between two sampling instants, the output remains constant.
22
+
23
+ ---
24
+
25
+ ## Parameters
26
+
27
+ | Name | Type | Description | Optional |
28
+ |------------|-------------|-------------|-------------|
29
+ | `sample_time` | float | Block sample time. If omitted, the global simulation time step is used. | True |
30
+
31
+ ---
32
+
33
+ ## Inputs
34
+
35
+ | Port | Description |
36
+ |------|------------|
37
+ | `in` | Input signal to be sampled and held. |
38
+
39
+ ---
40
+
41
+ ## Outputs
42
+
43
+ | Port | Description |
44
+ |------|------------|
45
+ | `out` | Output signal that holds the last sampled value. |
46
+
47
+ ---
48
+
49
+ ## Notes
50
+
51
+ - The block has internal state.
52
+ - The block has direct feedthrough.
53
+ - The block models sampling and hold behavior only.
54
+ - It does not modify the simulator execution rate.
55
+ - The held value is updated when the elapsed time since the last sample
56
+ reaches the specified sampling period.
57
+ - This block is equivalent to the Simulink **Zero-Order Hold** block.
58
+
59
+
60
+ ---
61
+ © 2026 Université de Lille & INRIA – Licensed under LGPL-3.0-or-later
@@ -0,0 +1,98 @@
1
+ # QuadraticProgram Block
2
+
3
+ ## Description
4
+
5
+ The **QuadraticProgram** block solves a quadratic optimization problem at each simulation step.
6
+
7
+ It computes the solution of the following quadratic program:
8
+
9
+ $$
10
+ \begin{aligned}
11
+ \min_x \quad & \tfrac12 x^T P x + q^T x \\
12
+ \text{subject to} \quad
13
+ & Gx \le h \\
14
+ & Ax = b \\
15
+ & \ell \le x \le u
16
+ \end{aligned}
17
+ $$
18
+
19
+ where:
20
+ - $x$ is the decision variable,
21
+ - $P$ is the quadratic cost matrix,
22
+ - $q$ is the linear cost vector,
23
+ - $G, h$ define inequality constraints,
24
+ - $A, b$ define equality constraints,
25
+ - $\ell, u$ define lower and upper bounds.
26
+
27
+ All problem data are provided as inputs and may vary with time.
28
+
29
+ ---
30
+
31
+ ## Problem definition
32
+
33
+ The quadratic program solved by this block is fully time-varying:
34
+
35
+ - The cost function $(P, q)$ may change at each simulation step.
36
+ - Constraints $(G, h)$, $(A, b)$, and bounds $(\ell, u)$ are optional.
37
+ - If a constraint set is omitted, it is not enforced.
38
+
39
+ This block is suitable for:
40
+ - constrained control laws (e.g. saturated LQR),
41
+ - control allocation,
42
+ - one-step MPC formulations,
43
+ - projection-based controllers.
44
+
45
+ ---
46
+
47
+ ## Parameters
48
+
49
+ | Name | Type | Description | Optional |
50
+ |------|------|-------------|----------|
51
+ | `solver` | string | QP solver used internally via `qpsolvers` (e.g. `clarabel`). | True |
52
+
53
+ ---
54
+
55
+ ## Inputs
56
+
57
+ | Port | Description |
58
+ |------|------------|
59
+ | `P` | Quadratic cost matrix $(n \times n)$. Must be square and compatible with `size`. |
60
+ | `q` | Linear cost vector. Accepted shapes: $(n,)$ or $(n,1)$. |
61
+ | `G` | Inequality constraint matrix $(m \times n)$. Must be provided together with `h`. |
62
+ | `h` | Inequality constraint vector. Accepted shapes: $(m,)$ or $(m,1)$. |
63
+ | `A` | Equality constraint matrix $(p \times n)$. Must be provided together with `b`. |
64
+ | `b` | Equality constraint vector. Accepted shapes: $(p,)$ or $(p,1)$. |
65
+ | `lb` | Lower bound on decision variables. Accepted shapes: $(n,)$ or $(n,1)$. |
66
+ | `ub` | Upper bound on decision variables. Accepted shapes: $(n,)$ or $(n,1)$. |
67
+
68
+ ---
69
+
70
+ ## Outputs
71
+
72
+ | Port | Description |
73
+ |------|------------|
74
+ | `x` | Optimal solution of the quadratic program $(n \times 1)$. |
75
+ | `status` | Solver status code:<br>• `0`: optimal solution found<br>• `1`: problem infeasible<br>• `2`: solver or numerical error |
76
+ | `cost` | Optimal value of the quadratic cost function. |
77
+
78
+ ---
79
+
80
+ ## Execution semantics
81
+
82
+ - The block is **direct feedthrough**: outputs depend only on current inputs.
83
+ - The block is **stateless**: no internal dynamics or memory are stored.
84
+ - A new quadratic program is solved at each simulation step.
85
+
86
+ ---
87
+
88
+ ## Notes
89
+
90
+ - Dimensions of the problem is inferred by the first input `P` and must be consistent across all inputs and steps.
91
+ - All dimension checks are performed before calling the solver.
92
+ - If the problem is infeasible or the solver fails, the output `status` reflects the error and the output vector is safely set to zero.
93
+ - This block relies on the `qpsolvers` Python package for numerical optimization.
94
+ - This block is conceptually similar to optimization blocks used in Simulink-based MPC and constrained control designs.
95
+
96
+
97
+ ---
98
+ © 2026 Université de Lille & INRIA – Licensed under LGPL-3.0-or-later
@@ -0,0 +1,102 @@
1
+ # Chirp
2
+
3
+ ## Summary
4
+
5
+ The **Chirp** block generates a frequency-swept sinusoidal signal
6
+ (linear or logarithmic) with configurable amplitude, phase, offset,
7
+ start time, and duration.
8
+
9
+ ---
10
+
11
+ ## Mathematical definition
12
+
13
+ For each output component $i$:
14
+
15
+ $$
16
+ y_i(t) = A_i \sin(\phi_i(t)) + o_i
17
+ $$
18
+
19
+ with parameters:
20
+ - $A_i$: amplitude,
21
+ - $o_i$: offset,
22
+ - $\phi_i(t)$: chirp phase,
23
+ - $f_{0,i}$: initial frequency,
24
+ - $f_{1,i}$: final frequency,
25
+ - $T_i$: chirp duration,
26
+ - $t_{0,i}$: chirp start time,
27
+ - $\varphi_i$: initial phase.
28
+
29
+ Define:
30
+ $$
31
+ \tau_i = \max(0, t - t_{0,i}), \quad
32
+ \tau_{c,i} = \min(\tau_i, T_i)
33
+ $$
34
+
35
+ Linear mode:
36
+ $$
37
+ k_i = \frac{f_{1,i} - f_{0,i}}{T_i}
38
+ $$
39
+ $$
40
+ \phi_i(t) =
41
+ 2\pi\left(f_{0,i}\tau_{c,i} + \frac{1}{2}k_i\tau_{c,i}^2\right)
42
+ + 2\pi f_{1,i}\max(0, \tau_i - T_i)
43
+ + \varphi_i
44
+ $$
45
+
46
+ Log mode:
47
+ $$
48
+ r_i = \frac{f_{1,i}}{f_{0,i}}
49
+ $$
50
+ $$
51
+ \phi_i(t) =
52
+ \frac{2\pi f_{0,i}T_i}{\ln(r_i)}
53
+ \left(r_i^{\tau_{c,i}/T_i} - 1\right)
54
+ + 2\pi f_{1,i}\max(0, \tau_i - T_i)
55
+ + \varphi_i
56
+ $$
57
+
58
+ After duration, phase continuity is preserved and oscillation continues at $f_1$.
59
+
60
+ ---
61
+
62
+ ## Parameters
63
+
64
+ | Name | Type | Description | Optional |
65
+ |------------|-------------|-------------|-------------|
66
+ | `amplitude` | scalar or vector or matrix | Signal amplitude. Scalars are broadcast to all dimensions. | False |
67
+ | `f0` | scalar or vector or matrix | Initial frequency in Hertz. Scalars are broadcast. | False |
68
+ | `f1` | scalar or vector or matrix | Final frequency in Hertz. Scalars are broadcast. | False |
69
+ | `duration` | scalar or vector or matrix | Sweep duration in seconds. Must be strictly positive. Scalars are broadcast. | False |
70
+ | `start_time` | scalar or vector or matrix | Start time in seconds. Before this time, sweep is not active. Default is `0.0`. | True |
71
+ | `offset` | scalar or vector or matrix | Constant offset added to output. Default is `0.0`. | True |
72
+ | `phase` | scalar or vector or matrix | Initial phase in radians. Default is `0.0`. | True |
73
+ | `mode` | string | Sweep mode: `linear` or `log`. Default is `linear`. | True |
74
+ | `sample_time` | float | Block sample time. If omitted, the global simulation time step is used. | True |
75
+
76
+ ---
77
+
78
+ ## Inputs
79
+
80
+ This block has **no inputs**.
81
+
82
+ ---
83
+
84
+ ## Outputs
85
+
86
+ | Port | Description |
87
+ |------|------------|
88
+ | `out` | Chirp output signal. |
89
+
90
+ ---
91
+
92
+ ## Notes
93
+
94
+ - The block has no internal state.
95
+ - All array-like parameters must have compatible shapes.
96
+ - Scalar parameters are broadcast to the common signal shape.
97
+ - In `log` mode, `f0 > 0`, `f1 > 0`, and `f0 != f1` are required.
98
+ - The output keeps oscillating after `duration` at frequency `f1`.
99
+
100
+
101
+ ---
102
+ © 2026 Université de Lille & INRIA – Licensed under LGPL-3.0-or-later
@@ -0,0 +1,53 @@
1
+ # Constant
2
+
3
+ ## Summary
4
+
5
+ The **Constant** block generates a signal with a fixed value over time.
6
+ The output does not depend on time, system state, or any input signal.
7
+
8
+ ---
9
+
10
+ ## Mathematical definition
11
+
12
+ The block computes:
13
+
14
+ $$
15
+ y(t) = c
16
+ $$
17
+
18
+ where $c$ is a constant scalar or vector value.
19
+
20
+ ---
21
+
22
+ ## Parameters
23
+
24
+ | Name | Type | Description | Optional |
25
+ |------------|-------------|-------------|-------------|
26
+ | `value` | scalar or vector or matrix | Constant output value. Can be a scalar or vector. | False |
27
+ | `sample_time` | float | Block sample time. If omitted, the global simulation time step is used. | True |
28
+
29
+ ---
30
+
31
+ ## Inputs
32
+
33
+ This block has **no inputs**.
34
+
35
+ ---
36
+
37
+ ## Outputs
38
+
39
+ | Port | Description |
40
+ |------|------------|
41
+ | `out` | Constant output signal. |
42
+
43
+ ---
44
+
45
+ ## Notes
46
+
47
+ - The block has no internal state.
48
+ - The output value is copied at each simulation step.
49
+ - This block is typically used as a reference or bias source.
50
+
51
+
52
+ ---
53
+ © 2026 Université de Lille & INRIA – Licensed under LGPL-3.0-or-later
@@ -0,0 +1,51 @@
1
+ # FileSource Block
2
+
3
+ ## Description
4
+
5
+ The FileSource block loads a sequence of numeric samples from a file and outputs one sample per simulation step.
6
+
7
+ Supported file formats:
8
+ - `npz`
9
+ - `npy`
10
+ - `csv`
11
+
12
+ ---
13
+
14
+ ## Parameters
15
+
16
+ | Name | Type | Description | Optional |
17
+ |------|------|-------------|----------|
18
+ | `file_path` | str | Path to source file. | False |
19
+ | `key` | str | Mandatory for `*.npz` (array key) and `*.csv` (column name). Unused for `*.npy`. | True |
20
+ | `repeat` | bool | End-of-file behavior. If `false`, outputs zeros after the last sample. If `true`, restarts from the first sample. | True (default: `False`) |
21
+ | `use_time` | bool | If `true` (only for `*.npz` and `*.csv`), uses a `time` signal and applies ZOH: at time `t`, output sample at largest index `i` such that `T[i] <= t`. | True (default: `False`) |
22
+ | `sample_time` | float | Block sample time. If omitted, global simulation step is used. | True |
23
+
24
+ ---
25
+
26
+ ## Inputs
27
+
28
+ None.
29
+
30
+ ---
31
+
32
+ ## Outputs
33
+
34
+ | Port | Description |
35
+ |------|-------------|
36
+ | `out` | Current sample as a column vector. |
37
+
38
+ ---
39
+
40
+ ## Notes
41
+
42
+ - File format is inferred from `file_path` extension (`.npz`, `.npy`, `.csv`).
43
+ - `npz`: loaded array must be 1D or 2D.
44
+ - `npy`: loaded array must be 1D or 2D.
45
+ - `csv`: `key` selects one named numeric column, producing shape `(1,1)` at each step.
46
+ - With `use_time=true`, `time` must exist and be strictly increasing.
47
+ - `npz`: requires key `time`.
48
+ - `csv`: requires column `time`.
49
+
50
+ ---
51
+ © 2026 Université de Lille & INRIA - Licensed under LGPL-3.0-or-later
@@ -0,0 +1,52 @@
1
+ # FunctionSource
2
+
3
+ ## Summary
4
+
5
+ The **FunctionSource** block generates one or more signals from a user-defined Python function
6
+ without any input ports.
7
+
8
+ At each activation, it evaluates:
9
+
10
+ $$
11
+ y[k] = f(t_k, \Delta t_k)
12
+ $$
13
+
14
+ where $t_k$ is the current simulation time and $\Delta t_k$ is the elapsed time
15
+ since the previous activation.
16
+
17
+ ---
18
+
19
+ ## Parameters
20
+
21
+ | Name | Type | Description | Required |
22
+ |------|------|-------------|----------|
23
+ | `file_path` | string | Path to the Python file containing `f`. | Yes |
24
+ | `function_name` | string | Name of the function to call inside the file. | Yes |
25
+ | `output_keys` | list[string] | Names of the output ports. The function must return a dict with exactly these keys. | Yes |
26
+ | `sample_time` | float | Execution period of the block. If omitted, the global simulation time step is used. | No |
27
+
28
+ ---
29
+
30
+ ## Inputs
31
+
32
+ This block has **no inputs**.
33
+
34
+ ---
35
+
36
+ ## Outputs
37
+
38
+ Outputs are dynamically defined by `output_keys`.
39
+
40
+ ---
41
+
42
+ ## Execution semantics
43
+
44
+ - The function signature must be exactly: `f(t, dt)`.
45
+ - The function must return a dict with keys exactly matching `output_keys`.
46
+ - Each returned value may be scalar, 1D, or 2D and is normalized to a 2D array.
47
+ - Output shape is frozen per output key after first evaluation and must stay constant.
48
+ - The block is stateless.
49
+
50
+
51
+ ---
52
+ © 2026 Université de Lille & INRIA – Licensed under LGPL-3.0-or-later
@@ -0,0 +1,58 @@
1
+ # Ramp
2
+
3
+ ## Summary
4
+
5
+ The **Ramp** block generates a ramp signal for each output dimension.
6
+ Each ramp starts at a specified time with a given slope and initial offset.
7
+
8
+ ---
9
+
10
+ ## Mathematical definition
11
+
12
+ For each output component $i$, the signal is defined as:
13
+
14
+ $$
15
+ y_i(t) = o_i + s_i \max(0, t - t_{0,i})
16
+ $$
17
+
18
+ where:
19
+ - $s_i$ is the slope,
20
+ - $t_{0,i}$ is the start time,
21
+ - $o_i$ is the initial offset.
22
+
23
+ ---
24
+
25
+ ## Parameters
26
+
27
+ | Name | Type | Description | Optional |
28
+ |------------|-------------|-------------|-------------|
29
+ | `slope` | scalar or vector or matrix | Ramp slope for each output dimension. Scalars are broadcast to all dimensions. | False |
30
+ | `start_time` | scalar or vector or matrix | Time at which the ramp starts. Default is zero. | True |
31
+ | `offset` | scalar or vector or matrix | Output value before the ramp starts. Default is zero. | True |
32
+ | `sample_time` | float | Block sample time. If omitted, the global simulation time step is used. | True |
33
+
34
+ ---
35
+
36
+ ## Inputs
37
+
38
+ This block has **no inputs**.
39
+
40
+ ---
41
+
42
+ ## Outputs
43
+
44
+ | Port | Description |
45
+ |------|------------|
46
+ | `out` | Constant output signal. |
47
+
48
+ ---
49
+
50
+ ## Notes
51
+
52
+ - The block has no internal state.
53
+ - Each output dimension may have a different slope and start time.
54
+ - Scalar parameters are automatically broadcast.
55
+
56
+
57
+ ---
58
+ © 2026 Université de Lille & INRIA – Licensed under LGPL-3.0-or-later