Block library
collimator.library
Abs
Bases: FeedthroughBlock
Output the absolute value of the input signal.
Input ports
None
Output ports
(0) The absolute value of the input signal.
Events
An event is triggered when the output changes from positive to negative or vice versa.
Source code in collimator/library/primitives.py
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
|
Adder
Bases: ReduceBlock
Computes the sum/difference of the input.
The add/subtract operation can be switched by setting the operators
parameter.
For example, a 3-input block specified as Adder(3, operators="+-+")
would add
the first and third inputs and subtract the second input.
Input ports
(0..n_in-1) The input signals to add/subtract.
Output ports
(0) The sum/difference of the input signals.
Source code in collimator/library/primitives.py
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
|
Arithmetic
Bases: ReduceBlock
Performs addition, subtraction, multiplication, and division on the input.
The arithmetic operation is determined by setting the operators
parameter.
For example, a 4-input block specified as Arithmetic(4, operators="+-*/")
would:
- Add the first input,
- Subtract the second input,
- Multiply the third input,
- Divide by the fourth input.
Input ports
(0..n_in-1) The input signals for the specified arithmetic operations.
Output ports
(0) The result of the specified arithmetic operations on the input signals.
Source code in collimator/library/primitives.py
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 |
|
BatteryCell
Bases: LeafSystem
Dynamic electro-checmical Li-ion cell model.
Based on Tremblay and Dessaint (2009).
By using appropriate parameters, the cell model can be used to model a battery pack with the assumption that the cells of the pack behave as a single unit.
Parameters E0, K, A, below are abstract parameters used in the model presented in the reference paper. As described in the reference paper, these parameters can be extracted from typical cell manufacturer datasheets; see section 3. Section 3 also provides a table of example values for these parameters.
Input ports
(0) The current (A) flowing through the cell. Positive is discharge.
Output ports
(0) The voltage across the cell terminals (V) (1) The state of charge of the cell (normalized between 0 and 1)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
E0
|
float
|
described as "battery constant voltage (V)" by the reference paper. |
3.366
|
K
|
float
|
described as "polarization constant (V/Ah)" by the reference paper. |
0.0076
|
Q
|
float
|
battery capacity in Ah |
2.3
|
R
|
float
|
internal resistance (Ohms) |
0.01
|
A
|
float
|
described as "exponential zone amplitude (V)" by the reference paper. |
0.26422
|
B
|
float
|
described as "exponential zone time constant inverse (1/Ah)" by the reference paper. |
26.5487
|
initial_SOC
|
float
|
initial state of charge, normalized between 0 and 1. |
1.0
|
Source code in collimator/library/battery_cell.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
|
Chirp
Bases: SourceBlock
Produces a signal like the linear method of
https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.chirp.html
Parameters:
Name | Type | Description | Default |
---|---|---|---|
f0
|
float
|
Frequency (Hz) at time t=phi. |
required |
f1
|
float
|
Frequency (Hz) at time t=stop_time. |
required |
stop_time
|
float
|
Time to end the signal (seconds). |
required |
phi
|
float
|
Phase offset (radians). |
0.0
|
Input ports
None
Output ports
(0) The chirp signal.
Source code in collimator/library/primitives.py
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 |
|
Clock
Bases: SourceBlock
Source block returning simulation time.
Input ports
None
Output ports
(0) The simulation time.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dtype
|
The data type of the output signal. The default is "None", which will default to the current default floating point precision |
None
|
Source code in collimator/library/primitives.py
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 |
|
Comparator
Bases: LeafSystem
Compare two signals using typical relational operators.
When using == and != operators, the block uses tolerances to determine if the expression is true or false.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
operator
|
one of ("==", "!=", ">=", ">", ">=", "<") |
None
|
|
atol
|
the absolute tolerance value used with "==" or "!=" |
1e-05
|
|
rtol
|
the relative tolerance value used with "==" or "!=" |
1e-08
|
Input Ports
(0) The left side operand (1) The right side operand
Output Ports
(0) The result of the comparison (boolean signal)
Events
An event is triggered when the output changes from true to false or vice versa.
Source code in collimator/library/primitives.py
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 |
|
Constant
Bases: LeafSystem
A source block that emits a constant value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
The constant value of the block. |
required |
Input ports
None
Output ports
(0) The constant value.
Source code in collimator/library/primitives.py
439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 |
|
ContinuousTimeInfiniteHorizonKalmanFilter
Bases: LeafSystem
Continuous-time Infinite Horizon Kalman Filter for the following system:
dot_x = A x + B u + G w
y = C x + D u + v
E(w) = E(v) = 0
E(ww') = Q
E(vv') = R
E(wv') = N = 0
Input ports
(0) u : continuous-time control vector (1) y : continuous-time measurement vector
Output ports
(1) x_hat : continuous-time state vector estimate
Parameters:
Name | Type | Description | Default |
---|---|---|---|
A
|
ndarray State transition matrix |
required | |
B
|
ndarray Input matrix |
required | |
C
|
ndarray Output matrix |
required | |
D
|
ndarray Feedthrough matrix |
required | |
G
|
ndarray Process noise matrix |
required | |
Q
|
ndarray Process noise covariance matrix |
required | |
R
|
ndarray Measurement noise covariance matrix |
required | |
x_hat_0
|
ndarray Initial state estimate |
required |
Source code in collimator/library/state_estimators/continuous_time_infinite_horizon_kalman_filter.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
|
for_continuous_plant(plant, x_eq, u_eq, Q, R, G=None, x_hat_bar_0=None, name=None)
staticmethod
Obtain a continuous-time Infinite Horizon Kalman Filter system for a continuous-time plant after linearization at equilibrium point (x_eq, u_eq)
The input plant contains the deterministic forms of the forward and observation operators:
dx/dt = f(x,u)
y = g(x,u)
Note: Only plants with one vector-valued input and one vector-valued output are currently supported. Furthermore, the plant LeafSystem/Diagram should have only one vector-valued integrator.
A plant with disturbances of the following form is then considered following form:
dx/dt = f(x,u) + G w
y = g(x,u) + v
where:
`w` represents the process noise,
`v` represents the measurement noise,
and
E(w) = E(v) = 0
E(ww') = Q
E(vv') = R
E(wv') = N = 0
This plant with disturbances is linearized (only f
and q
) around the
equilibrium point to obtain:
d/dt (x_bar) = A x_bar + B u_bar + G w --- (C1)
y_bar = C x_bar + D u_bar + v --- (C2)
where,
x_bar = x - x_eq
u_bar = u - u_eq
y_bar = y - y_bar
y_eq = g(x_eq, u_eq)
A continuous-time Kalman Filter estimator for the system of equations (C1) and
(C2) is returned. This filter is in the x_bar
, u_bar
, and y_bar
states.
The returned system will have
Input ports
(0) u_bar : continuous-time control vector relative to equilibrium point (1) y_bar : continuous-time measurement vector relative to equilibrium point
Output ports
(1) x_hat_bar : continuous-time state vector estimate relative to equilibrium point
Parameters:
Name | Type | Description | Default |
---|---|---|---|
plant
|
a |
required | |
x_eq
|
ndarray Equilibrium state vector for discretization |
required | |
u_eq
|
ndarray Equilibrium control vector for discretization |
required | |
Q
|
ndarray Process noise covariance matrix. |
required | |
R
|
ndarray Measurement noise covariance matrix. |
required | |
G
|
ndarray
Process noise matrix. If |
None
|
|
x_hat_bar_0
|
ndarray Initial state estimate relative to equilibrium point. If None, an identity matrix is assumed. |
None
|
Source code in collimator/library/state_estimators/continuous_time_infinite_horizon_kalman_filter.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
|
CoordinateRotation
Bases: LeafSystem
Computes the rotation of a 3D vector between coordinate systems.
Given sufficient information to construct a rotation matrix C_AB
from orthogonal
coordinate system B
to orthogonal coordinate system A
, along with an input
vector x_B
expressed in B
-axes, this block will compute the matrix-vector
product x_A = C_AB @ x_B
.
Note that depending on the type of rotation representation, this matrix may not be explicitly computed. The types of rotations supported are Quaternion, Euler Angles, and Direction Cosine Matrix (DCM).
By default, the rotations have the following convention:
-
Quaternion: The rotation is represented by a 4-component quaternion
q
. The rotation is carried out by the productp_A = q⁻¹ * p_B * q
, whereq⁻¹
is the quaternion inverse ofq
,*
is the quaternion product, andp_A
andp_B
are the quaternion extensions of the vectorsx_A
andx_B
, i.e.p_A = [0, x_A]
andp_B = [0, x_B]
. -
Roll-Pitch-Yaw (Euler Angles): The rotation is represented by the set of Euler angles ϕ (roll), θ (pitch), and ψ (yaw), in the "1-2-3" convention for intrinsic rotations. The resulting rotation matrix
C_AB(ϕ, θ, ψ)
is the same as the product of the three single-axis rotation matricesC_AB = Cz(ψ) * Cy(θ) * Cx(ϕ)
.For example, if
B
represents a fixed "world" frame with axesxyz
andA
is a body-fixed frame with axesXYZ
, thenC_AB
represents a rotation from the world frame to the body frame, in the following sequence:- Right-hand rotation about the world frame
x
-axis byϕ
(roll), resulting in the intermediate framex'y'z'
withx' = x
. - Right-hand rotation about the intermediate frame
y'
-axis byθ
(pitch), resulting in the intermediate framex''y''z''
withy'' = y'
. - Right-hand rotation about the intermediate frame
z''
-axis byψ
(yaw), resulting in the body frameXYZ
withz = z''
.
- Right-hand rotation about the world frame
-
Direction Cosine Matrix: The rotation is directly represented as a 3x3 matrix
C_AB
. The rotation is carried out by the matrix-vector productx_A = C_AB @ x_B
.
Input ports
(0): The input vector x_B
expressed in the B
-axes.
(1): (if enable_external_rotation_definition=True
) The rotation
representation (quaternion, Euler angles, or cosine matrix) that defines
the rotation from B
to A
(or A
to B
if inverse=True
).
Output ports
(0): The output vector x_A
expressed in the A
-axes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rotation_type
|
str
|
The type of rotation representation to use. Must be one of ("quaternion", "roll_pitch_yaw", "dcm"). |
required |
enable_external_rotation_definition
|
If |
True
|
|
inverse
|
If |
False
|
|
quaternion
|
Array
|
The quaternion representation of the rotation
if |
None
|
roll_pitch_yaw
|
Array
|
The Euler angles representation of the
rotation if |
None
|
direction_cosine_matrix
|
Array
|
The direction cosine matrix
representation of the rotation if |
None
|
Source code in collimator/library/rotations.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 |
|
CoordinateRotationConversion
Bases: LeafSystem
Converts between different representations of rotations.
See CoordinateRotation block documentation for descriptions of the different rotation representations supported. This block supports conversion between quaternion, roll-pitch-yaw (Euler angles), and direction cosine matrix (DCM).
Note that conversions are reversible in terms of the abstract rotation, although creating a quaternion from a direction cosine matrix (and therefore creating a quaternion from roll-pitch-yaw sequence) results in an arbitrary sign assignment.
Input ports
(0): The input rotation representation.
Output ports
(1): The output rotation representation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
conversion_type
|
str
|
The type of rotation conversion to perform. Must be one of ("quaternion_to_euler", "quaternion_to_dcm", "euler_to_quaternion", "euler_to_dcm", "dcm_to_quaternion", "dcm_to_euler") |
required |
Source code in collimator/library/rotations.py
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 |
|
CrossProduct
Bases: ReduceBlock
Compute the cross product between the inputs.
See NumPy docs for details: https://numpy.org/doc/stable/reference/generated/numpy.cross.html
Input ports
(0) The first input vector. (1) The second input vector.
Output ports
(0) The cross product of the inputs.
Source code in collimator/library/primitives.py
469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 |
|
CustomJaxBlock
Bases: LeafSystem
JAX implementation of the PythonScript block.
A few important notes and changes/limitations to this JAX implementation:
- For this block all code must be written using the JAX-supported subset of Python:
* Numerical operations should use jax.numpy = jnp
instead of numpy = np
* Standard control flow is not supported (if/else, for, while, etc.). Instead
use lax.cond
, lax.fori_loop
, lax.while_loop
, etc.
https://jax.readthedocs.io/en/latest/notebooks/Common_Gotchas_in_JAX.html#structured-control-flow-primitives
Where possible, NumPy-style operations like jnp.where
or jnp.select
should
be preferred to lax control flow primitives.
* Functions must be pure and arrays treated as immutable.
https://jax.readthedocs.io/en/latest/notebooks/Common_Gotchas_in_JAX.html#in-place-updates
Provided these assumptions hold, the code can be JIT compiled, differentiated,
run on GPU, etc.
- Variable scoping: the init_code
and step_code
are executed in the same scope,
so variables declared in the init_code
will be available in the step_code
and can be modified in that scope. Internally, everything declared in
init_code
is treated as a single state-like cache entry.
However, variables declared in the step_code
will NOT persist between
evaluations. Users should think of step_code
as a normal Python function
where locally declared variables will disappear on leaving the scope.
- Persistent variables (outputs and anything declared in init_code
) must have
static shapes and dtypes. This means that you cannot declare x = 0.0
in
init_code
and then later assign x = jnp.zeros(4)
in step_code
.
These changes mean that many older PythonScript blocks may not be backwards compatible.
Input ports
Variable number of input ports, one for each input variable declared in inputs
.
The order of the input ports is the same as the order of the input variables.
Output ports
Variable number of output ports, one for each output variable declared in outputs
.
The order of the output ports is the same as the order of the output variables.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dt
|
float
|
The discrete time step of the block, or None if the block is in agnostic time mode. |
None
|
init_script
|
str
|
A string containing Python code that will be executed
once when the block is initialized. This code can be used to declare
persistent variables that will be available in the |
''
|
user_statements
|
str
|
A string containing Python code that will be executed
once per time step (or per output port evaluation, in agnostic mode).
This code can use the persistent variables declared in |
''
|
finalize_script
|
str
|
A string containing Python code that will be executed
once when the block is finalized. This code can use the persistent
variables declared in |
''
|
accelerate_with_jax
|
bool
|
If True, the block will be JIT compiled. If False, the block will be executed in pure Python. This parameter exists for compatibility with UI options; when creating pure Python blocks from code (e.g. for testing), explicitly create the CustomPythonBlock class. |
True
|
time_mode
|
str
|
One of "discrete" or "agnostic". If "discrete", the block step code will be evaluated at peridodic intervals specified by "dt". If "agnostic", the block step code will be evaluated once per output port evaluation, and the block will not have a discrete time step. |
'discrete'
|
inputs
|
List[str]
|
A list of input variable names. The order of the input ports is the same as the order of the input variables. |
None
|
outputs
|
Mapping[str, Tuple[DTypeLike, ShapeLike]]
|
A dictionary mapping output variable names to a tuple of dtype and shape. The order of the output ports is the same as the order of the output variables. |
None
|
static_parameters
|
Mapping[str, Array]
|
A dictionary mapping parameter names to values. Parameters are treated as immutable and cannot be modified in the step code. Static parameters can't be used in ensemble simulations or optimization workflows. |
None
|
dynamic_parameters
|
Mapping[str, Array]
|
A dictionary mapping parameter names to values. Parameters are treated as immutable and cannot be modified in the step code. Dynamic parameters can be arrays or scalars, but must have static shapes and dtypes in order to support JIT compilation. |
None
|
Source code in collimator/library/custom.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 |
|
check_types(context, error_collector=None)
Test-compile the init and step code to check for errors.
Source code in collimator/library/custom.py
588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 |
|
CustomPythonBlock
Bases: CustomJaxBlock
Container for arbitrary user-defined Python code.
Implemented to support legacy PythonScript blocks.
Not traceable (no JIT compilation or autodiff). The internal implementation and behavior of this block differs vastly from the JAX-compatible block as this block stores state directly within the Python instance. Objects and modules can be kept as discrete state.
Note that in "agnostic" mode, the step code will be evaluated once per output port evaluation. Because locally defined environment variables (in the init script) are preserved between evaluations, any mutation of these variables will be preserved. This can lead to unexpected behavior and should be avoided. Stateful behavior should be implemented using discrete state variables instead.
Source code in collimator/library/custom.py
608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 |
|
DataSource
Bases: SourceBlock
Produces outputs from an imported .csv file.
The block's output(s) must be synchronized with simulation time. This can be achieved by two mechanisms:
-
Each data row in the file is accompanied by a time value. The time value for each row is provided as a column in the data file. For this option, the values in the time column must be strictly increasing, with no duplicates, from the first data row to the last. The block will check that this condition is satisfied at compile time. The column with the time values is identified by the column index. This option assumes the left most column is index 0, counting up to the right. to select this option, set Time samples as column to True, and provide the index of the column.
-
The time value for each data row is defined using a fixed time step between each row. For this option, the Sampling parameter defines the time step. The block then computes the time values for each data row starting with zero for the first row. Note that by definition, this results in a strictly increasing set. To select this option, set
time_samples_as_column
to False, and provide thesampling_interval
value.
When block output(s) are requested at a simulation time that falls between time values for adjacent data rows, there are two options for how the block should compute the interpolation:
-
Zero Order Hold: the block returns data from the row with the lower time value.
-
Linear: the block performs a linear interpolation between the lower and higher time value data rows.
There are several mechanism for selecting which data columns are included in the
block output(s). All options are applied using the data_columns
parameter:
-
Column name: enter a string that matches a column name in the header. For this option,
header_as_first_row
must be set to True. For this option, it is only possible to select a single column for the output. The block will output a scalar. -
Column index: enter an integer index for the desired column. This option again assumes the left most column is index 0, counting up to the right. This option assumes the same column index regardless of of whether
time_samples_as_column
is True or False, therefore it is possible to select the same column for time and output. With this option, the block will output a scalar. -
Slice: enter a slice used to identify a set of sequential columns to be used as the desired data for output. The slice works like a NumPy slice. For example, if the file has 10 columns,
3:8
will results in the block returning a vector of length 5, containing, in order, columns 3,4,5,6,7. Note that like NumPy, the second integer in the slice is excluded in the set of indices. Only positive integers are allowed for the slice (e.g.2:-1
,-3:-1
, and3:
are not allowed).
Presently, there is only one option for extrapolation beyond the end of data in the file. The block will have reached the end of data if the simulation time is greater than the time value for the last row of data. Once this occurs, the block output(s) will be the values in the last row of data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_name
|
str
|
The name of the imported file which contains the data. |
required |
header_as_first_row
|
bool
|
Check this box if the first row is meant to be a header. |
False
|
time_samples_as_column
|
bool
|
Check this box to select a column form the file to use as the time values. Uncheck it to provide time as a fixed time step between rows. |
False
|
time_column
|
str
|
Only used when |
'0'
|
sampling_interval
|
float
|
only used when |
1.0
|
data_columns
|
str
|
Enter name, index, or slice to select columns from the data file. |
'1'
|
extrapolation
|
str
|
the extrapolation method. One of "hold" or "zero". |
'hold'
|
interpolation
|
str
|
the interpolation method. One of "zero_order_hold" or "linear". |
'zero_order_hold'
|
Source code in collimator/library/data_source.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 |
|
__init__(file_name, data_columns='1', extrapolation='hold', header_as_first_row=False, interpolation='zero_order_hold', sampling_interval=1.0, time_column='0', time_samples_as_column=False, **kwargs)
Source code in collimator/library/data_source.py
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 |
|
DeadZone
Bases: FeedthroughBlock
Generates zero output within a specified range.
Applies the following function:
[ input, input < -half_range
output = | 0, -half_range <= input <= half_range
[ input input > half_range
Parameters:
Name | Type | Description | Default |
---|---|---|---|
half_range
|
The range of the dead zone. Must be > 0. |
1.0
|
Input ports
(0) The input signal.
Output ports
(0) The input signal modified by the dead zone.
Events
An event is triggered when the signal enters or exits the dead zone in either direction.
Source code in collimator/library/primitives.py
490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 |
|
Demultiplexer
Bases: LeafSystem
Split a vector signal into its components.
Input ports
(0) The vector signal to split.
Output ports
(0..n_out-1) The components of the input signal.
Source code in collimator/library/primitives.py
552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 |
|
Derivative
Bases: LTISystem
Causal estimate of the derivative of a signal in continuous time.
This is implemented as a state-space system with matrices (A, B, C, D), which are then used to create a (first-order) LTISystem. Note that this only supports single-input, single-output derivative blocks.
The derivative is implemented as a filter with a filter coefficient of N
,
which is used to construct the following proper transfer function:
H(s) = Ns / (s + N)
As N -> ∞, the transfer function approaches a pure differentiator. However, this system becomes increasingly stiff and difficult to integrate, so it is recommended to select a value of N based on the time scales of the system.
From the transfer function, scipy.signal.tf2ss
is used to convert to
state-space form and create an LTISystem.
Input ports
(0) u: Input (scalar)
Output ports
(0) y: Output (scalar), estimating the time derivative du/dt
Source code in collimator/library/linear_system.py
338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 |
|
DerivativeDiscrete
Bases: LeafSystem
Discrete approximation to the derivative of the input signal w.r.t. time.'
By default the block uses a simple backward difference approximation:
y[k] = (u[k] - u[k-1]) / dt
However, the block can also be configured to use a recursive filter for a
better approximation. In this case the filter coefficients are determined
by the filter_type
and filter_coefficient
parameters. The filter is
a pair of two-element arrays a
and b
and the filter equation is:
a0*y[k] + a1*y[k-1] = b0*u[k] + b1*u[k-1]
Denoting the filter_coefficient
parameter by N
, the following filters are
available:
- "none": The default, a simple finite difference approximation.
- "forward": A filtered forward Euler discretization. The filter is:
a = [1, (N*dt - 1)]
and b = [N, -N]
.
- "backward": A filtered backward Euler discretization. The filter is:
a = [(1 + N*dt), -1]
and b = [N, -N]
.
- "bilinear": A filtered bilinear transform discretization. The filter is:
a = [(2 + N*dt), (-2 + N*dt)]
and b = [2*N, -2*N]
.
Input ports
(0) The input signal.
Output ports
(0) The approximate derivative of the input signal.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dt
|
The time step of the discrete approximation. |
required | |
filter_type
|
One of "none", "forward", "backward", or "bilinear". This determines the type of filter used to approximate the derivative. The default is "none", corresponding to a simple backward difference approximation. |
'none'
|
|
filter_coefficient
|
The coefficient in the filter ( |
1.0
|
Source code in collimator/library/primitives.py
583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 |
|
initialize_static_data(context)
Infer the size and dtype of the internal states
Source code in collimator/library/primitives.py
681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 |
|
DirectShootingNMPC
Bases: NonlinearMPCIpopt
Implementation of nonlinear MPC with a direct shooting transcription and IPOPT as the NLP solver.
Input ports
(0) x_0 : current state vector. (1) x_ref : reference state trajectory for the nonlinear MPC. (2) u_ref : reference input trajectory for the nonlinear MPC.
Output ports
(1) u_opt : the optimal control input to be applied at the current time step as determined by the nonlinear MPC.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
plant
|
LeafSystem or Diagram The plant to be controlled. |
required | |
Q
|
Array State weighting matrix in the cost function. |
required | |
QN
|
Array Terminal state weighting matrix in the cost function. |
required | |
R
|
Array Control input weighting matrix in the cost function. |
required | |
N
|
int The prediction horizon, an integer specifying the number of steps to predict. Note: prediction and control horizons are identical for now. |
required | |
nh
|
int Number of minor steps to take within an RK4 major step. |
required | |
dt
|
float: Major time step, a scalar indicating the increment in time for each step in the prediction and control horizons. |
required | |
lb_u
|
Array Lower bound on the control input vector. |
None
|
|
ub_u
|
Array Upper bound on the control input vector. |
None
|
|
u_optvars_0
|
Array Initial guess for the control vector optimization variables in the NLP. |
None
|
Source code in collimator/library/nmpc/direct_shooting_ipopt_nmpc.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
|
DirectTranscriptionNMPC
Bases: NonlinearMPCIpopt
Implementation of nonlinear MPC with direct transcription and IPOPT as the NLP solver.
Input ports
(0) x_0 : current state vector. (1) x_ref : reference state trajectory for the nonlinear MPC. (2) u_ref : reference input trajectory for the nonlinear MPC.
Output ports
(1) u_opt : the optimal control input to be applied at the current time step as determined by the nonlinear MPC.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
plant
|
LeafSystem or Diagram The plant to be controlled. |
required | |
Q
|
Array State weighting matrix in the cost function. |
required | |
QN
|
Array Terminal state weighting matrix in the cost function. |
required | |
R
|
Array Control input weighting matrix in the cost function. |
required | |
N
|
int The prediction horizon, an integer specifying the number of steps to predict. Note: prediction and control horizons are identical for now. |
required | |
nh
|
int Number of minor steps to take within an RK4 major step. |
required | |
dt
|
float: Major time step, a scalar indicating the increment in time for each step in the prediction and control horizons. |
required | |
lb_x
|
Array Lower bound on the state vector. |
None
|
|
ub_x
|
Array Upper bound on the state vector. |
None
|
|
lb_u
|
Array Lower bound on the control input vector. |
None
|
|
ub_u
|
Array Upper bound on the control input vector. |
None
|
|
x_optvars_0
|
Array Initial guess for the state vector optimization variables in the NLP. |
None
|
|
u_optvars_0
|
Array Initial guess for the control vector optimization variables in the NLP. |
None
|
Source code in collimator/library/nmpc/direct_transcription_ipopt_nmpc.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
|
DiscreteClock
Bases: LeafSystem
Source block that produces the time sampled at a fixed rate.
The block maintains the most recently sampled time as a discrete state, provided to the output port during the following interval. Graphically, a discrete clock sampled at 100 Hz would have the following time series:
x(t) ●━
| ┆
.03 | ●━━━━○
| ┆
.02 | ●━━━━○
| ┆
.01 | ●━━━━○
| ┆
0 ●━━━━○----+----+----+-- t
0 .01 .02 .03 .04
The recorded states are the closed circles, which should be interpreted at index
n
as the value seen by all other blocks on the interval (t[n], t[n+1])
.
Input ports
None
Output ports
(0) The sampled time.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dt
|
The sampling period of the clock. |
required | |
start_time
|
The simulation time at which the clock starts. Defaults to 0. |
0
|
Source code in collimator/library/primitives.py
703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 |
|
DiscreteInitializer
Bases: LeafSystem
Discrete Initializer.
Outputs True for first discrete step, then outputs False there after. Or, outputs False for first discrete step, then outputs True there after. Practical for cases where it is necessary to have some signal fed initially by some initialization, but then after from else in the model.
Input ports
None
Output ports
(0) The dot product of the inputs.
Source code in collimator/library/primitives.py
757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 |
|
DiscreteTimeLinearQuadraticRegulator
Bases: LeafSystem
Linear Quadratic Regulator (LQR) for a discrete-time system: x[k+1] = A x[k] + B u[k]. Computes the optimal control input: u[k] = -K x[k], where u minimises the cost function over [0, ∞)]: J = ∑(x[k].T Q x[k] + u[k].T R u[k]).
Input ports
(0) x[k]: state vector of the system.
Output ports
(0) u[k]: optimal control vector.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
A
|
Array State matrix of the system. |
required | |
B
|
Array Input matrix of the system. |
required | |
Q
|
Array State cost matrix. |
required | |
R
|
Array Input cost matrix. |
required | |
dt
|
float Sampling period of the system. |
required |
Source code in collimator/library/lqr.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
|
DotProduct
Bases: ReduceBlock
Compute the dot product between the inputs.
This block dispatches to jax.numpy.dot
, so the semantics, broadcasting rules,
etc. are the same. See the JAX docs for details:
https://jax.readthedocs.io/en/latest/_autosummary/jax.numpy.dot.html
Input ports
(0) The first input vector. (1) The second input vector.
Output ports
(0) The dot product of the inputs.
Source code in collimator/library/primitives.py
798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 |
|
EdgeDetection
Bases: LeafSystem
Output is true only when the input signal changes in a specified way.
The block updates at a discrete rate, checking the boolean- or binary-valued input signal for changes. Available edge detection modes are: - "rising": Output is true when the input changes from False (0) to True (1). - "falling": Output is true when the input changes from True (1) to False (0). - "either": Output is true when the input changes in either direction
Input ports
(0) The input signal. Must be boolean or binary-valued.
Output ports
(0) The edge detection output signal. Boolean-valued.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dt
|
The sampling period of the block. |
required | |
edge_detection
|
One of "rising", "falling", or "either". Determines the type of edge detection performed by the block. |
required | |
initial_state
|
The initial value of the output signal. |
False
|
Source code in collimator/library/primitives.py
820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 |
|
Exponent
Bases: FeedthroughBlock
Compute the exponential of the input signal.
Input ports
(0) The input signal.
Output ports
(0) The exponential of the input signal.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
base
|
One of "exp" or "2". Determines the base of the exponential function. |
required |
Source code in collimator/library/primitives.py
950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 |
|
ExtendedKalmanFilter
Bases: KalmanFilterBase
Extended Kalman Filter (EKF) for the following system:
```
x[n+1] = f(x[n], u[n]) + G(t[n]) w[n]
y[n] = g(x[n], u[n]) + v[n]
E(w[n]) = E(v[n]) = 0
E(w[n]w'[n]) = Q(t[n], x[n], u[n])
E(v[n]v'[n] = R(t[n])
E(w[n]v'[n] = N(t[n]) = 0
```
f
and g
are discrete-time functions of state x[n]
and control u[n]
,
while Rand
Gare discrete-time functions of time
t[n].
Qis a discrete-time
function of
t[n], x[n], u[n]`. This last aspect is included for zero-order-hold
discretization of a continuous-time system
Input ports
(0) u[n] : control vector at timestep n (1) y[n] : measurement vector at timestep n
Output ports
(1) x_hat[n] : state vector estimate at timestep n
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dt
|
float Time step of the discrete-time system |
required | |
forward
|
Callable
A function with signature f(x[n], u[n]) -> x[n+1] that represents |
required | |
observation
|
Callable
A function with signature g(x[n], u[n]) -> y[n] that represents |
required | |
G_func
|
Callable
A function with signature G(t[n]) -> G[n] that represents |
required | |
Q_func
|
Callable
A function with signature Q(t[n], x[n], u[n]) -> Q[n] that represents |
required | |
R_func
|
Callable
A function with signature R(t[n]) -> R[n] that represents |
required | |
x_hat_0
|
ndarray Initial state estimate |
required | |
P_hat_0
|
ndarray Initial state covariance matrix estimate |
required |
Source code in collimator/library/state_estimators/extended_kalman_filter.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 |
|
for_continuous_plant(plant, dt, G_func, Q_func, R_func, x_hat_0, P_hat_0, discretization_method='euler', discretized_noise=False, name=None, ui_id=None)
staticmethod
Extended Kalman Filter system for a continuous-time plant.
The input plant contains the deterministic forms of the forward and observation operators:
dx/dt = f(x,u)
y = g(x,u)
Note: (i) Only plants with one vector-valued input and one vector-valued output are currently supported. Furthermore, the plant LeafSystem/Diagram should have only one vector-valued integrator; (ii) the user may pass a plant with disturbances (not recommended) as the input plant. In this case, the forward and observation evaluations will be corrupted by noise.
A plant with disturbances of the following form is then considered:
dx/dt = f(x,u) + G(t) w -- (C1)
y = g(x,u) + v -- (C2)
where:
`w` represents the process noise,
`v` represents the measurement noise,
and
E(w) = E(v) = 0
E(ww') = Q(t)
E(vv') = R(t)
E(wv') = N(t) = 0
This plant is discretized to obtain the following form:
x[n+1] = fd(x[n], u[n]) + Gd w[n] -- (D1)
y[n] = gd(x[n], u[n]) + v[n] -- (D2)
E(w[n]) = E(v[n]) = 0
E(w[n]w'[n]) = Qd
E(v[n]v'[n] = Rd
E(w[n]v'[n] = Nd = 0
The above discretization is performed either via the euler
or the zoh
method, and an Extended Kalman Filter estimator for the system of equations
(D1) and (D2) is returned.
Note: If discretized_noise
is True, then it is assumed that the user is
directly providing Gd, Qd and Rd. If False, then Qd and Rd are computed from
continuous-time Q, R, and G, and Gd is set to an Identity matrix.
The returned system will have:
Input ports
(0) u[n] : control vector at timestep n (1) y[n] : measurement vector at timestep n
Output ports
(1) x_hat[n] : state vector estimate at timestep n
Parameters:
Name | Type | Description | Default |
---|---|---|---|
plant
|
a |
required | |
dt
|
float Time step for the discretization. |
required | |
G_func
|
Callable
A function with signature G(t) -> G that represents |
required | |
Q_func
|
Callable
A function with signature Q(t) -> Q that represents |
required | |
R_func
|
Callable
A function with signature R(t) -> R that represents |
required | |
x_hat_0
|
ndarray Initial state estimate |
required | |
P_hat_0
|
ndarray
Initial state covariance matrix estimate. If |
required | |
discretization_method
|
str ("euler" or "zoh") Method to discretize the continuous-time plant. Default is "euler". |
'euler'
|
|
discretized_noise
|
bool
Whether the user is directly providing Gd, Qd and Rd. Default is False.
If True, |
False
|
Source code in collimator/library/state_estimators/extended_kalman_filter.py
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 |
|
from_operators(dt, forward, observation, G_func, Q_func, R_func, x_hat_0, P_hat_0, name=None, ui_id=None)
staticmethod
Extended Kalman Filter (UKF) for the following system:
x[n+1] = f(x[n], u[n]) + G(t[n]) w[n]
y[n] = g(x[n], u[n]) + v[n]
E(w[n]) = E(v[n]) = 0
E(w[n]w'[n]) = Q(t[n], x[n], u[n])
E(v[n]v'[n] = R(t[n])
E(w[n]v'[n] = N(t[n]) = 0
f
and g
are discrete-time functions of state x[n]
and control u[n]
,
while Q
and R
and G
are discrete-time functions of time t[n]
.
Input ports
(0) u[n] : control vector at timestep n (1) y[n] : measurement vector at timestep n
Output ports
(1) x_hat[n] : state vector estimate at timestep n
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dt
|
float Time step of the discrete-time system |
required | |
forward
|
Callable
A function with signature f(x[n], u[n]) -> x[n+1] that represents |
required | |
observation
|
Callable
A function with signature g(x[n], u[n]) -> y[n] that represents |
required | |
G_func
|
Callable
A function with signature G(t[n]) -> G[n] that represents |
required | |
Q_func
|
Callable
A function with signature Q(t[n]) -> Q[n] that represents
|
required | |
R_func
|
Callable
A function with signature R(t[n]) -> R[n] that represents |
required | |
x_hat_0
|
ndarray Initial state estimate |
required | |
P_hat_0
|
ndarray Initial state covariance matrix estimate |
required |
Source code in collimator/library/state_estimators/extended_kalman_filter.py
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 |
|
FeedthroughBlock
Bases: LeafSystem
Simple feedthrough blocks with a function of a single input
Source code in collimator/library/generic.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
|
FilterDiscrete
Bases: LeafSystem
Finite Impulse Response (FIR) filter.
Similar to https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.lfilter.html Note: does not implement the IIR filter.
Input ports
(0) The input signal.
Output ports
(0) The filtered signal.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
b_coefficients
|
Array of filter coefficients. |
required |
Source code in collimator/library/primitives.py
979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 |
|
FiniteHorizonLinearQuadraticRegulator
Bases: LeafSystem
Finite Horizon Linear Quadratic Regulator (LQR) for a continuous-time system. Solves the Riccati Differential Equation (RDE) to compute the optimal control for the following finitie horizon cost function over [t0, tf]:
Minimise cost J:
J = [x(tf) - xd(tf)].T Qf [x(tf) - xd(tf)]
+ ∫[(x(t) - xd(t)].T Q [(x(t) - xd(t)] dt
+ ∫[(u(t) - ud(t)].T R [(u(t) - ud(t)] dt
+ 2 ∫[(x(t) - xd(t)].T N [(u(t) - ud(t)] dt
subject to the constraints:
dx(t)/dt - dx0(t)/dt = A [x(t)-x0(t)] + B [u(t)-u0(t)] - c(t),
where, x(t) is the state vector, u(t) is the control vector, xd(t) is the desired state vector, ud(t) is the desired control vector, x0(t) is the nominal state vector, u0(t) is the nominal control vector, Q, R, and N are the state, input, and cross cost matrices, Qf is the final state cost matrix,
and A, B, and c are computed from linearisation of the plant df/dx = f(x, u)
around the nominal trajectory (x0(t), u0(t)).
A = df/dx(x0(t), u0(t), t)
B = df/du(x0(t), u0(t), t)
c = f(x0(t), u0(t), t) - dx0(t)/dt
The optimal control u
obtained by the solution of the above problem is output.
See Section 8.5.1 of https://underactuated.csail.mit.edu/lqr.html#finite_horizon
Parameters:
Name | Type | Description | Default |
---|---|---|---|
t0
|
float Initial time of the finite horizon. |
required | |
tf
|
float Final time of the finite horizon. |
required | |
plant
|
a |
required | |
Qf
|
Array Final state cost matrix. |
required | |
func_Q
|
Callable
A function that returns the state cost matrix Q at time |
required | |
func_R
|
Callable
A function that returns the input cost matrix R at time |
required | |
func_N
|
Callable
A function that returns the cross cost matrix N at time |
required | |
func_x_0
|
Callable
A function that returns the nominal state vector |
required | |
func_u_0
|
Callable
A function that returns the nominal control vector |
required | |
func_x_d
|
Callable
A function that returns the desired state vector |
None
|
|
func_u_d
|
Callable
A function that returns the desired control vector |
None
|
Source code in collimator/library/lqr.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 |
|
Gain
Bases: FeedthroughBlock
Multiply the input signal by a constant value.
Input ports
(0) The input signal.
Output ports
(0) The input signal multiplied by the gain: y = gain * u
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
gain
|
The value to scale the input signal by. |
required |
Source code in collimator/library/primitives.py
1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 |
|
HermiteSimpsonNMPC
Bases: NonlinearMPCIpopt
Implementation of nonlinear MPC with Hermite-Simpson collocation and IPOPT as the NLP solver.
Input ports
(0) x_0 : current state vector. (1) x_ref : reference state trajectory for the nonlinear MPC. (2) u_ref : reference input trajectory for the nonlinear MPC.
Output ports
(1) u_opt : the optimal control input to be applied at the current time step as determined by the nonlinear MPC.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
plant
|
LeafSystem or Diagram The plant to be controlled. |
required | |
Q
|
Array State weighting matrix in the cost function. |
required | |
QN
|
Array Terminal state weighting matrix in the cost function. |
required | |
R
|
Array Control input weighting matrix in the cost function. |
required | |
N
|
int The prediction horizon, an integer specifying the number of steps to predict. Note: prediction and control horizons are identical for now. |
required | |
dt
|
float: Major time step, a scalar indicating the increment in time for each step in the prediction and control horizons. |
required | |
lb_x
|
Array Lower bound on the state vector. |
None
|
|
ub_x
|
Array Upper bound on the state vector. |
None
|
|
lb_u
|
Array Lower bound on the control input vector. |
None
|
|
ub_u
|
Array Upper bound on the control input vector. |
None
|
|
include_terminal_x_as_constraint
|
bool If True, the terminal state is included as a constraint in the NLP. |
False
|
|
include_terminal_u_as_constraint
|
bool If True, the terminal control input is included as a constraint in the NLP. |
False
|
|
x_optvars_0
|
Array Initial guess for the state vector optimization variables in the NLP. |
None
|
|
u_optvars_0
|
Array Initial guess for the control vector optimization variables in the NLP. |
None
|
Source code in collimator/library/nmpc/hermite_simpson_ipopt_nmpc.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 |
|
IOPort
Bases: FeedthroughBlock
Simple class for organizing input/output ports for groups/submodels.
Since these are treated as standalone blocks in the UI rather than specific input/output ports exported to the parent model, it is more straightforward to represent them that way here as well.
This class represents a simple one-input, one-output feedthrough block where the feedthrough function is an identity. The input (resp. output) port can then be exported to the parent model to create an Inport (resp. Outport).
Source code in collimator/library/primitives.py
1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 |
|
IfThenElse
Bases: LeafSystem
Applies a conditional expression to the input signals.
Given inputs pred
, true_val
, and false_val
, the block computes:
y = true_val if pred else false_val
The true and false values may be any arrays, but must have the same shape and dtype.
Input ports
(0) The boolean predicate. (1) The true value. (2) The false value.
Output ports
(0) The result of the conditional expression. Shape and dtype will match the true and false values.
Events
An event is triggered when the output changes from true to false or vice versa.
Source code in collimator/library/primitives.py
1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 |
|
InfiniteHorizonKalmanFilter
Bases: KalmanFilterBase
Infinite Horizon Kalman Filter for the following system:
x[n+1] = A x[n] + B u[n] + G w[n]
y[n] = C x[n] + D u[n] + v[n]
E(w[n]) = E(v[n]) = 0
E(w[n]w'[n]) = Q
E(v[n]v'[n]) = R
E(w[n]v'[n]) = N = 0
Input ports
(0) u[n] : control vector at timestep n (1) y[n] : measurement vector at timestep n
Output ports
(1) x_hat[n] : state vector estimate at timestep n
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dt
|
float Time step of the discrete-time system |
required | |
A
|
ndarray State transition matrix |
required | |
B
|
ndarray Input matrix |
required | |
C
|
ndarray
Output matrix. If |
None
|
|
D
|
ndarray
Feedthrough matrix. If |
None
|
|
G
|
ndarray
Process noise matrix. If |
None
|
|
Q
|
ndarray
Process noise covariance matrix. If |
None
|
|
R
|
ndarray
Measurement noise covariance matrix. If |
None
|
|
x_hat_0
|
ndarray
Initial state estimate. If |
None
|
Source code in collimator/library/state_estimators/infinite_horizon_kalman_filter.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 |
|
for_continuous_plant(plant, x_eq, u_eq, dt, Q=None, R=None, G=None, x_hat_bar_0=None, discretization_method='zoh', discretized_noise=False, name=None, ui_id=None)
staticmethod
Obtain an Infinite Horizon Kalman Filter system for a continuous-time plant after linearization at equilibrium point (x_eq, u_eq)
The input plant contains the deterministic forms of the forward and observation operators:
dx/dt = f(x,u)
y = g(x,u)
Note: (i) Only plants with one vector-valued input and one vector-valued output
are currently supported. Furthermore, the plant LeafSystem/Diagram should have
only one vector-valued integrator. (ii) the user may pass a plant with
disturbances as the input plant. However, computation of y_eq
will be fraught
with disturbances.
A plant with disturbances of the following form is then considered following form:
dx/dt = f(x,u) + G w --- (C1)
y = g(x,u) + v --- (C2)
where:
`w` represents the process noise,
`v` represents the measurement noise,
and
E(w) = E(v) = 0
E(ww') = Q
E(vv') = R
E(wv') = N = 0
This plant with disturbances is linearized (only f
and g
) around the
equilibrium point to obtain:
d/dt (x_bar) = A x_bar + B u_bar + G w
y_bar = C x_bar + D u_bar + v
where,
x_bar = x - x_eq
u_bar = u - u_eq
y_bar = y - y_bar
y_eq = g(x_eq, u_eq)
The linearized plant is then discretized via euler
or zoh
method to obtain:
x_bar[n] = Ad x_bar[n] + Bd u_bar[n] + Gd w[n] --- (L1)
y_bar[n] = Cd x_bar[n] + Dd u_bar[n] + v[n] --- (L2)
E(w[n]) = E(v[n]) = 0
E(w[n]w'[n]) = Qd
E(v[n]v'[n]) = Rd
E(w[n]v'[n]) = Nd = 0
Note: If discretized_noise
is True, then it is assumed that the user is
providing Gd, Qd and Rd. If False, then Qd and Rd are computed from
continuous-time Q, R, and G, and Gd is set to Identity matrix.
An Infinite Horizon Kalman Filter estimator for the system of equations (L1)
and (L2) is returned. This filter is in the x_bar
, u_bar
, and y_bar
states.
This returned system will have
Input ports
(0) u_bar[n] : control vector at timestep n, relative to equilibrium (1) y_bar[n] : measurement vector at timestep n, relative to equilibrium
Output ports
(1) x_hat_bar[n] : state vector estimate at timestep n, relative to equilibrium
Parameters:
Name | Type | Description | Default |
---|---|---|---|
plant
|
a |
required | |
x_eq
|
ndarray Equilibrium state vector for discretization |
required | |
u_eq
|
ndarray Equilibrium control vector for discretization |
required | |
dt
|
float Time step for the discretization. |
required | |
Q
|
ndarray
Process noise covariance matrix. If |
None
|
|
R
|
ndarray
Measurement noise covariance matrix. If |
None
|
|
G
|
ndarray
Process noise matrix. If |
None
|
|
x_hat_bar_0
|
ndarray Initial state estimate relative to equilibrium. If None, an identity matrix is assumed. |
None
|
|
discretization_method
|
str ("euler" or "zoh") Method to discretize the continuous-time plant. Default is "euler". |
'zoh'
|
|
discretized_noise
|
bool
Whether the user is directly providing Gd, Qd and Rd. Default is False.
If True, |
False
|
Source code in collimator/library/state_estimators/infinite_horizon_kalman_filter.py
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 |
|
global_filter_for_continuous_plant(plant, x_eq, u_eq, dt, Q=None, R=None, G=None, x_hat_0=None, discretization_method='euler', discretized_noise=False, name=None, ui_id=None)
staticmethod
See docs for for_continuous_plant
, which returns the local infinite horizon
Kalman Filter. This method additionally converts the local Kalman Filter to a
global estimator. See docs for make_global_estimator_from_local
for details.
Source code in collimator/library/state_estimators/infinite_horizon_kalman_filter.py
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 |
|
Integrator
Bases: LeafSystem
Integrate the input signal in time.
The Integrator block is the main primitive for building continuous-time
models. It is a first-order integrator, implementing the following linear
time-invariant ordinary differential equation for input values u
and output
values y
:
ẋ = u
y = x
where x
is the state of the integrator. The integrator is initialized
with the value of the initial_state
parameter.
The Integrator block is also designed to detect "Zeno" behavior, where the reset events happen asymptotically closer together. This is a pathological case that can cause numerical issues in the simulation and should typically be avoided by introducing some physically realistic hysteresis into the model. However, in the event that Zeno behavior is unavoidable, the integrator will enter a "Zeno" state where the output is held constant until the trigger changes value to False. See the "bouncing ball" demo for a Zeno example.
Input ports
(0) The input signal. Must match the shape and dtype of the initial
continuous state.
(1) The reset trigger. Optional, only if enable_reset
is True.
(2) The reset value. Optional, only if enable_external_reset
is True.
(3) The hold trigger. Optional, only if 'enable_hold' is True.
Output ports
(0) The continuous state of the integrator.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
initial_state
|
The initial value of the integrator state. Can be any array, or even a nested structure of arrays, but the data type should be floating-point. |
required | |
enable_reset
|
If True, the integrator will reset its state to the initial value when the reset trigger is True. Adds an additional input port for the reset trigger. This signal should be boolean- or binary-valued. |
False
|
|
enable_external_reset
|
If True, the integrator will reset its state to the value provided by the reset value input port when the reset trigger is True. Otherwise, the integrator will reset to the initial value. Adds an additional input port for the reset value. This signal should match the shape and dtype of the initial continuous state. |
False
|
|
enable_limits
|
If True, the integrator will constrain its state and output to within the upper and lower limits. Either limit may be disbale by setting its value to None. |
False
|
|
enable_hold
|
If True, the integrator will hold integration when the hold trigger is True. |
False
|
|
reset_on_enter_zeno
|
If True, the integrator will reset its state to the initial value
when the integrator enters the Zeno state. This option is ignored unless
|
False
|
|
zeno_tolerance
|
The tolerance used to determine if the integrator is in the Zeno state.
If the time between events is less than this tolerance, then the
integrator is in the Zeno state. This option is ignored unless
|
1e-06
|
Events
An event is triggered when the "reset" port changes.
An event is triggered when the state hit one of the limits.
An event is triggered when the "hold" port changes.
Another guard is conditionally active when the integrator is in the Zeno state, and is triggered when the "reset" port changes from True to False. This event is used to exit the Zeno state and resume normal integration.
Source code in collimator/library/primitives.py
1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 |
|