✳

# Agnostic Blocks

The following blocks are defined as having a agnostic time_mode

The following blocks are assigned to either Continuous or Discrete time_modes during model compilation. These block may have events associated with them

Outputs the absolute value of the input signal.

- Data Types
- double

Computes the sum total of all the inputs based on their input operations: add or subtract.

- Data Types
- double

Produces a signal like https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.chirp.html

- Parameters
- F0: the frequency at time = Phi.
- F1: the Frequency at the blocks stop time.
- Stop time: the time at which the frequency is F1. After Stop time, the frequency is constant at F1.
- Phi: the delay between time = 0 and when the signal frequency is F0. Before Phi, the frequency is F0.

- Data Types
- double

Returns the simulations time.

- Data Types
- double

Compare two signals using typical relational operators.

When using

`==`

and `!=`

operators, the block uses tolerances to determine if the expression is true or false. This is not ideal, and Collimator is looking to improve on this.- Parameters
- Operator:
`==`

,`!=`

,`≥`

,`>`

,`≤`

,`<`

- Atol: the absolute tolerance value used when either
`==`

or`!=`

- Rtol: the relative tolerance value used when either
`==`

or`!=`

- Inputs
- left hand side operand
- right hand side operand

- Outputs
- boolean signal

- Data Types
- double, boolean

- Events
- an event is triggered when the output becomes true.

A source block that emits a constant value.

- Parameters
- Constant value

- Data Types
- double, boolean

Computes the rotation of a vector in 3D vector space from one coordinate system to another.

All parameters must be computed assuming angle units are

`radians`

.- Parameters
- Rotation Type.
- Enable external rotation definition: check this to expose inport for providing the values that define the rotation. e.g. if the type selected in DCM, one port for the 3x3 matrix will be exposed. Uncheck to provide the rotation definition as input parameters.
- Quaternion parameters: w, x, y, z
- Rotation Angles parameters: alpha, beta, gamma
- DCM parameters: DCM matrix, the 3x3 rotation matrix

- Inputs:
- input vector: 3x1 vector
- Quaternion inputs: w, x, y, z
- Rotation Angles inputs: alpha, beta, gamma
- DCM inputs: DCM matrix, the 3x3 rotation matrix

- Outputs:
- output vector: 3x1 vector

- Data Types
- double

Computes the conversion between two different types of rotations.

Types of Conversions supported:

- quaternion to rotation angles
- rotation angles to quaternion

Conversions are reversible.

- Parameters
- Rotation Conversion Type.

- Inputs:
- input rotation definition, depends on the conversion selected:
- Quaternion inputs: w, x, y, z
- Rotation Angles inputs: alpha, beta, gamma

- Outputs:
- output rotation definition, depends on the conversion selected:
- Quaternion inputs: w, x, y, z
- Rotation Angles inputs: alpha, beta, gamma

- Data Types
- double

- Parameters
- Frequency: the number of oscillations (cycles) that occur each second of time
- Amplitude: the peak deviation of the function from bias value.
- Phase: specifies (in radians) where in its cycle the oscillation is at time = 0.
- Bias: the offset from zero where the center of oscillations is located.

- Data Types
- double

The blocks output(s) must be synchronized with simulation time. This can be achieved by two mechanisms:

- 1.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. Collimator 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. - 2.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. At compile time, Collimator 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 the`Sampling`

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:

- 1.Zero Order Hold: the block returns data from the row with the lower time value.
- 2.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: - 1.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. - 2.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. - 3.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`

, and`3:`

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
- File name: the name of the uploaded file which contains the data.
- Header as first row: check this box if the first row is meant to be a header.
- Time samples as column: 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.
- Time column: only visible when
`Time samples as column`

is checked. This is the index of the column to be used as time. - Sampling: only visible when Time samples as column is unchecked. Provide the fixed time step value here.

- Data columns: enter name, index, or slice to select columns from the data file.
- Extrapolation: the extrapolation method.
- Interpolation: the interpolation method.

- Data Types
- double

Applies the following function:

- input < -half_range: output = input
- input ≥ -half_range and input ≤ -half_range: output = 0
- input > half_range: output = input
- Parameters
- Half range:

- Data Types
- double

- Events
- This block will eventually have 4 events associated with it.
- Entering the half range from the lower side.
- Exiting the half range on the lower side.
- Entering the half range on the upper side.
- Exiting the half range on the upper side.

Computes the derivative of the input signal as:

$y(n) = {u(t) - u(Tprev) \over t - Tprev}$

Where

`Tprev`

is the last time the block was called for output update.- Data Types
- double

Automotive dynamometer drive schedules (a.k.a. drive cycles) are common test cases in automotive. Examples of popular and/or regulated drive cycles can be found at these resources:

The block optionally outputs upper and lower limits representing the acceptable tolerance as specified in https://www.ecfr.gov/current/title-40/chapter-I/subchapter-U/part-1066/subpart-E/section-1066.425.

- Parameters
- Cycle: the name of the cycle.
- Output limits: check this box to have the block also output the limit signals.

- Data Types
- double

Output is true when input signal experiences a transition matching the selected transitions set.

- Parameters
- Edge detection: the type of edge to detect.
- Rising: signal transition from low to high.
- Falling: signal transition from high to low.
- Either: signal transition from low to high or high to low.

- Initial state: An edge detection detects a change in a signal, so it needs an
`old value`

to compare against the`new value`

, this is the initial value of`old value`

, when t=0 and there has not been an old value yet.

- Data Types
- Boolean

- Events
- This block will eventually have an event associated with its outport, a major step is triggered when its outport is true.

Applies the input signal as a power of the base value parameter.

- Parameters
- Base: the value that is raised to the power of the input signal.

- Data Types
- double

Multiplies the input signal by a constant value.

- Parameters
- Gain

- Data Types
- double

Applies an If_Then_Else operation as detailed here https://en.wikipedia.org/wiki/Conditional_(computer_programming)

- Inputs
- If: this ports receives the Boolean expression
- Then: this value is passed to the output when the If input is True.
- Else: this value is passed to the output when the If input is False.

- Data Types
- double, Boolean

- Events
- This block will eventually have an event associated with its If inport, triggering an major step when the input changes.

This is a constant block that outputs the RGB pixels from a static image (

`.jpg`

or `.png`

) as matrices of `double`

values.- Parameters
`File name`

: The image (jpg, png) to use as source data`Normalize`

: When`True`

, the R, G, B color values will be normalized to the range`[0, 1]`

. When`False`

, the values will be integers in the range`[0, 255]`

.

- Outputs
`R`

,`G`

,`B`

: each color channel gets extracted into its own (`height, width)`

matrix (h rows, w columns)

This block is meant to be used in conjunction with

`PythonScript`

blocks that run computer vision or other image processing operations on the pixels from a static image. Below, we present two options to convert R,G,B channel matrices into objects compatible with some commonly used Python libraries (namely: `cv2`

and `torch)`

.import cv2

import numpy as np

def cv2_from_inputs(R, G, B):

height = R.shape[0]

width = R.shape[1]

image = np.zeros((height, width, 3), dtype=np.uint8)

image[:,:,0] = R

image[:,:,1] = G

image[:,:,2] = B

return image

image = cv2_from_inputs(R, G, B)

import torch

import numpy as np

image = np.array([R, G, B], dtype=np.float32)

tensor = torch.from_numpy(image)

tensor = tensor.unsqueeze(0)

Returns the logarithm of the input signal.

- Parameters
- Base: the base value of the logarithm operation.

- Data Types
- double

OR, AND, NAND, NOR, XOR can have many inputs, NOT may only have one input.

- Parameters
- Function: OR, AND, NOT, NAND, NOR, XOR

- Data Types
- Boolean

- Events
- This block will eventually have an event associated with its outport, triggering an major step when the output changes.

Implements a non-linear relationship between the input and the output not dissimilar to https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.interp1d.html

- Parameters
- Input Array: A vector of values provided in the format [x,y,z]. If these are provided unsorted, Collimator will create a sorted list of pairs of (input_element, output_element), and sort the pairs in ascending order of the input_element of each pair. The input array must not contain duplicate values. The input array must contain more than one value.
- Output Array: A vector of values provided in the format [a,b,c]. The length of the output array much match the length of the input array.
- Interpolation: The method used to compute the output value from the input value and the arrays. Flat means that if the input value is between elements n and n+1 of the input_array, the output is set to the nth element of the output_array. Nearest means that if the input value is between elements n and n+1 of the input array, but closer to the n+1 element, the output is set to the n+1 element of the output array. Linear means linear interpolation is used to compute the output value.

- Data Types
- double

Implements a non-linear relationship between the two input values and the output which is not dissimilar to https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.interp2d.html

- Parameters
- Input x array: A vector of values provided in the format [x,y,z]. These must be provided sorted in ascending order. The input x a array must have more than one element.
- Input y array: A vector of values provided in the format [x,y,z]. These must be provided sorted in ascending order. The input y a array must have more than one element.
- Output table: An NxM array where N is the dimension of the input x array, and M is the dimension of the input y array. For example:
- input x array: [0, 1, 2]
- input y array: [0, 1]
- output table array: [[0,1],[2,3],[4,5]]

Or:- input x array: [0, 1]
- input y array: [0, 1, 2]
- output table array: [[0,1, 2],[2,3,4]]

- Interpolation: The method used to compute the output value from the input value and the arrays. Linear means linear interpolation is used to compute the output value. Only linear is presently supported.

- Data Types
- double

Perform operations on matrices and vectors.

When the function is

`Extraction`

, the block will extract the nth element from the last dimension of the input value. For example, if the input value is a matrix [[1,2],[3,4]], and the Extraction operation has Index == 0, the output value would be a vector [1,2]. Passing this vector [1,2] to a second Extraction operation with Index ==1, the output value would be 2.As the example shows, the Extraction operation indexes from 0.

- Outputs
- array or scalar depending on
`function`

- Data Types
- double
- 1 and 2 dimensional arrays

- Limitations
- Inverse only works for square matrices
- Extraction only works one dimension at a time. Extraction on a matrix results in extracting a row vector, it cannot extract a column vector from the matrix. For example, for a 2x2 matrix, to extract the [1,1] element, first extract the [1] row, then use a second extract block to extract the [1] element of the row. To extract a column, first use Transpose, then extract the index you want, as this will extract a row, but the row was a column before the Transpose operation.

Returns the extremum of all the input signals.

- Parameters
- Operator: whether the extremum is a minimum or a maximum.

- Data Types
- double

Adds a constant value to the input signal.

- Parameters
- Offset

- Data Types
- double

Raises the inputs signal to a constant power.

- Parameters
- Exponent

- Data Types
- double

Computes the product/quotient total of all the inputs based on their input operations: multiply or divide.

- Data Types
- double

This block bins the inputs values into discrete ranges defined by the quantizing interval.

- Parameters
- Interval

- Data Types
- double

Computes the derivative of the output signal as:

$rate = {u(t) - y(Tprev) \over t - Tprev}$

Where

`Tprev`

is the last time the block was called for output update.When

`rate`

is greater than the `upper limit`

, the output is:$y(t)=(t - Tprev)*upper limit + y(Tprev)$

When

`rate`

is less than the `lower limit`

, the output is:$y(t)=(t - Tprev)*lower limit + y(Tprev)$

- Parameters
- Enable dynamic upper limit: check this to use an inport to the block as the source of the upper limit.
- Upper limit.
- Enable dynamic lower limit: check this to use an inport to the block as the source of the lower limit.
- Lower limit.

- Data Types
- double

Returns the reciprocal of the input signal

- Data Types
- double

This block behaves like a simple state machine. Applies the following function:

- time = 0: state = intial_state
- input ≥ On_threshold: state = On_value
- input ≤ Off_threshold: state = Off_value
- input < On_threshold and input > Off_threshold: state is unchanged
- Parameters
- On_threshold
- Off_threshold
- On_value
- Off_value
- intial_state

- Data Types
- double

- Events
- This block will eventually have 2 events associated with it.

Note, when dynamic limits are enabled, the upper limit will take precedence over the lower limit such that if the upper limit is less than the lower limit, the output is the upper limit value. This applies regardless of whether one or both limits are dynamic, but does not apply when neither is dynamic, because when neither is dynamic, if the upper is less than the lower, Collimator returns an error.

- Parameters
- Enable dynamic upper limit: check this to use an inport to the block as the source of the upper limit.
- Upper limit: when input is greater than upper limit, output is equal to upper limit.
- Enable dynamic lower limit: check this to use an inport to the block as the source of the lower limit.
- Lower limit: when input is less than lower limit, output is equal to lower limit.

- Data Types
- double

- Events
- This block will eventually have 4 events associated with it.
- Entering the saturation zone from the lower side.
- Exiting the saturation zone on the lower side.
- Entering the saturation zone on the upper side.
- Exiting the saturation zone on the upper side.

Produces a signal like https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.sawtooth.html

- Parameters
- Amplitude: the value of signal at its highest point.
- Frequency: let the period be the time between sequential falling edges of the signal. The frequency is 1/period.
- Phase delay:

- Events
- Sawtooth has a periodic event associated with it such that major steps are triggered at each falling edge.

returns the square root of the inputs signal.

- Data Types
- double

- Parameters
- Frequency: the number of oscillations (cycles) that occur each second of time
- Amplitude: the peak deviation of the function from bias value.
- Phase: specifies (in radians) where in its cycle the oscillation is at time = 0.
- Bias: the offset from zero where the center of oscillations is located.

- Data Types
- double

When input is true, stops the simulation at the end of the next major/minor step, which ever occurs first.

- Data Types
- boolean

Returns the result of applying a trigonometric function using the inputs signal as input to the function, e.g. output = sin(input)

- Parameters
- Function: trigonometric operation to apply. Presently supports: sin, cos, tan.

- Data Types
- double

Create a vector from the set of input signals.

All inputs must have the same type, e.g. double, Boolean, etc.

- Inputs
- Presently limited to 7 inputs.

- Outputs
- the vector.

- Data Types
- double, Boolean

Extract elements from a vector signal and outputs individual signals.

- Inputs
- A vector signal

- Outputs
- Must be equal to the number of elements in the input vector signal.

- Data Types
- double

- Events
- none

Applies the following function:

- time < Start_time: output = Start_value
- input ≥ Start_time: output = Slope * (time - Start_value)
- Parameters
- Slope
- Start value
- Start time

- Data Types
- double

Applies the following function:

- time < Step_time: output = Start_value
- input ≥ Step_time: output = End_value
- Parameters
- Start value
- End value
- Step time

- Data Types
- double

- Events
- This block has an event associated with Step time.

****

Last modified 1mo ago