Python data processing blocks

qmt.Block()

Base class for online data processing blocks.

qmt.OriEstVQFBlock(Ts)

VQF orientation estimation algorithm.

qmt.OriEstMadgwickBlock(Ts)

Madgwicks's orientation estimation algorithm.

qmt.OriEstMahonyBlock(Ts)

Mahony's orientation estimation algorithm.

qmt.OriEstIMUBlock(Ts)

OriEstIMU orientation estimation algorithm.

qmt.LowpassFilterBlock(Ts[, fc, tau])

Second-order Butterworth low-pass filter block.

class qmt.Block[source]

Base class for online data processing blocks.

command(command)[source]

This function is called to handle commands, i.e., events that change the state of the block in a certain way.

Commands are always lists and the first entry is the command name. One common example for a command is ['reset']. The default implementation ignores all commands.

Parameters:

command – Command as list. The first element is a string with the command name. Optional further elements depend on the command.

Returns:

True if the command is handled by the block, False if the command was ignored

setParams(params)[source]

This function is called to update parameters, i.e., variables that influence how the input data is processed.

The default implementation updates the params property if a corresponding key already exists and raises a RuntimeError on other parameters (unless ignoreUnknownParams is set to True). If this is not enough, this function can be overridden to implement custom logic if parameters change.

Parameters:

params – dictionary with the parameters to update

Returns:

None

step(*args, **kwargs)[source]

Performs one data processing step.

The default implementation just returns None.

Parameters:
  • args – application-specific inputs

  • kwargs – application-specific inputs

Returns:

application-specific outputs

class qmt.OriEstVQFBlock(Ts)[source]

VQF orientation estimation algorithm.

See https://github.com/dlaidig/vqf, https://doi.org/10.1016/j.inffus.2022.10.014, and https://arxiv.org/abs/2203.17024 for more information about this algorithm.

This algorithm is also available as a function: qmt.oriEstVQF().

Parameters:

Ts – sampling time in seconds

command(command)[source]

This function is called to handle commands, i.e., events that change the state of the block in a certain way.

Commands are always lists and the first entry is the command name. One common example for a command is ['reset']. The default implementation ignores all commands.

Parameters:

command – Command as list. The first element is a string with the command name. Optional further elements depend on the command.

Returns:

True if the command is handled by the block, False if the command was ignored

setParams(params)[source]

This function is called to update parameters, i.e., variables that influence how the input data is processed.

The default implementation updates the params property if a corresponding key already exists and raises a RuntimeError on other parameters (unless ignoreUnknownParams is set to True). If this is not enough, this function can be overridden to implement custom logic if parameters change.

Parameters:

params – dictionary with the parameters to update

Returns:

None

step(gyr, acc, mag=None, debug=False)[source]

Performs one data processing step.

The default implementation just returns None.

Parameters:
  • args – application-specific inputs

  • kwargs – application-specific inputs

Returns:

application-specific outputs

class qmt.OriEstMadgwickBlock(Ts)[source]

Madgwicks’s orientation estimation algorithm.

See https://doi.org/10.1109/ICORR.2011.5975346 for more information about this algorithm. Based on the C++ implementation by Sebastian Madgwick, available at https://x-io.co.uk/open-source-imu-and-ahrs-algorithms/.

This algorithm is also available as a function: qmt.oriEstMadgwick().

Parameters:

Ts – sampling time in seconds

command(command)[source]

Supported commands:

  • [‘reset’]: resets the orientation estimation state

setParams(params)[source]

Supported parameters:

  • beta: algorithm gain

step(gyr, acc, mag, debug=False)[source]
Parameters:
  • gyr – gyroscope measurement [rad/s]

  • acc – accelerometer measurement [m/s^2]

  • mag – magnetometer measurement or None [any unit]

  • debug – enables debug output

Returns:

  • quat: orientation quaternion

  • debug: dict with debug values (only if debug==True)

class qmt.OriEstMahonyBlock(Ts)[source]

Mahony’s orientation estimation algorithm.

See https://dx.doi.org/10.1109/TAC.2008.923738 for more information about this algorithm. Based on the C++ implementation by Sebastian Madgwick, available at https://x-io.co.uk/open-source-imu-and-ahrs-algorithms/.

This algorithm is also available as a function: qmt.oriEstMahony().

Parameters:

Ts – sampling time in seconds

command(command)[source]

Supported commands:

  • [‘reset’]: resets the orientation estimation state

setParams(params)[source]

Supported parameters:

  • Kp: proportional gain

  • Ki: integral gain (for gyroscope bias estimation)

step(gyr, acc, mag, debug=False)[source]
Parameters:
  • gyr – gyroscope measurement [rad/s]

  • acc – accelerometer measurement [m/s^2]

  • mag – magnetometer measurement or None [any unit]

  • debug – enables debug output

Returns:

  • quat: orientation quaternion

  • debug: dict with debug values (only if debug==True)

class qmt.OriEstIMUBlock(Ts)[source]

OriEstIMU orientation estimation algorithm.

See https://dx.doi.org/10.1016/j.ifacol.2017.08.1534 for more information about this algorithm.

This algorithm is also available as a function: qmt.oriEstIMU().

Parameters:

Ts – sampling time in seconds

command(command)[source]

Supported commands:

  • [‘reset’]: resets the orientation estimation state

setParams(params)[source]

Supported parameters:

  • tauAcc: time constants for acc correction (50% time) [must be >0], [in seconds]

  • tauMag: time constants for mag correction (50% time) [must be >0], [in seconds]

  • zeta: bias estimation strength [no unit]

  • accRating: enables raw rating of accelerometer, set to 0 to disable

step(gyr, acc, mag, debug=False)[source]
Parameters:
  • gyr – gyroscope measurement [rad/s]

  • acc – accelerometer measurement [m/s^2]

  • mag – magnetometer measurement or None [any unit]

  • debug – enables debug output

Returns:

  • quat: orientation quaternion

  • debug: dict with debug values (only if debug==True)

class qmt.LowpassFilterBlock(Ts, fc=None, tau=None)[source]

Second-order Butterworth low-pass filter block.

This block uses the filter implementation of the VQF orientation estimation algorithm. The cutoff frequency can either directly be specified in Hz, or a time constant can be given. This time constant corresponds to the cutoff frequency as follows: \(f_\mathrm{c} = \frac{\sqrt{2}}{2\pi\tau}\).

For the first \(\tau\) seconds, the filter output is the mean of all previous samples, to ensure fast initial convergence.

Parameters:
  • Ts – sampling time in seconds

  • fc – cutoff frequency in Hz

  • tau – time constant in seconds (either fc or tau has to be None)

step(signal)[source]

Performs one data processing step.

The default implementation just returns None.

Parameters:
  • args – application-specific inputs

  • kwargs – application-specific inputs

Returns:

application-specific outputs