Master Thesis Code
by Simon Moser
Loading...
Searching...
No Matches
JumpSensor Class Reference

JumpSensor is a simulation of the JUMP sensor of the ZurichMove Project. More...

+ Inheritance diagram for JumpSensor:

Public Member Functions

function JumpSensor (in args)
 JumpSensor is the constructor of the JUMP sensor.
 
function generate (in obj, in acc_true, in gyr_true, in ori_true, in options)
 generate generates sensor data from true data.
 
function generateFromTrajectory (in obj, in traj)
 generates data from a Trajectory object.
 
function getParams (in obj)
 returns the parameters of the JUMP sensor.
 

Private Member Functions

function createMpu (in obj)
 createMpu creates the MPU9250 sensor.
 
function createHig (in obj)
 createHig creates the ADXL375 sensor.
 
function getPressureFromAltitude (in obj, in alt, in tmp, in prs_sealvl)
 getPressureFromAltitude returns the pressure from the altitude.
 
function getSensorTemperature (in obj, in tmp_true)
 getSensorTemperature returns the sensor temperature.
 

Static Private Member Functions

static function getMisalignmentMatrix (in x, in y, in z, in sensitivity)
 getMisalignmentMatrix returns a misalignment matrix for the accelerometer or gyroscope.
 
static function rant (in lower, in upper, in nstd)
 rant returns a typical value in the sense of datasheet typical values.
 
static function generateNoise (in n, in N, in K, in B, in fs)
 generateNoise generates noise with the given parameters.
 

Private Attributes

Property accRange
 
Property gyroRange
 
Property sampleRate
 
Property sampleRatePressure
 
Property sampleRateMagnetometer
 
Property mpu
 
Property hig
 

Detailed Description

JumpSensor is a simulation of the JUMP sensor of the ZurichMove Project.

JumpSensor simulates one JUMP sensor of the ZurichMove Project. The JUMP sensor is a wearable sensor which can be used time synchronized with other JUMP sensors to track the movement of a person.

This class is a simulation of the JUMP sensor. It can be configured equally to the real JUMP sensor. It contains the models of the actual sensors of the JUMP sensor according to the datasheets of the sensors. The JUMP sensor simulation can be used to test the algorithms of the ZurichMove Project.

The JUMP sensor is equipped with the following sensors:

  • MPU9250 9-axis IMU containing :
    • 3-axis accelerometer
    • 3-axis gyroscope
    • 3-axis magnetometer

ADXL375 3-axis accelerometer (high-g)

  • MS5611 barometer and temperature sensor
% example code
% create a JUMP sensor with default settings
jump = JumpSensor();
% generate true data (examples, use the \ref trajectoryGenerationApp.m for more realistic data)
acc_true = zeros(1000,3); % laying still
gyr_true = zeros(1000,3); % not moving
ori_true = quaternion.ones(1000,1); % no rotation
% generate sensor data
data = jump.generate(acc_true, gyr_true, ori_true);
function JumpSensor(in args)
JumpSensor is the constructor of the JUMP sensor.
function generate(in obj, in acc_true, in gyr_true, in ori_true, in options)
generate generates sensor data from true data.
app that helps to generate a trajectory.

see also the more detailed example in jumpSensorExample.m

Examples
derivation1KalmanFilter.m, derivation2KalmanFilter.m, derivation3RtsSmoother.m, derivation4ExtendedKalmanFilter.m, derivation5Ekf6D.m, derivation6Ekf6D.m, derivation7IntialParamEst.m, derivation8Ekf6D_pt1.m, derivation8Ekf6D_pt2.m, jumpSensorExample.m, and waypointsToMeasurementsExample.m.

Definition at line 40 of file JumpSensor.m.

Constructor & Destructor Documentation

◆ JumpSensor()

function JumpSensor ( in args)

JumpSensor is the constructor of the JUMP sensor.

Note
the barometer is implemented directly in the generate function

JumpSensor creates a JUMP sensor with the given settings. The settings are the same as in the JUMPconnect software. The JUMP sensor can be used to generate sensor data from true data.

Parameters
accRange(optional) - the acceleration range of the MPU9250 in g
gyroRange(optional) - the gyroscope range of the MPU9250 in °/s
sampleRate(optional) - the sample rate of the MPU9250 in Hz
sampleRatePressure(optional) - the sample rate of the pressure and temperature sensor in Hz
Return values
obj- the created JUMP sensor

Member Function Documentation

◆ createHig()

function createHig ( in obj)
private

createHig creates the ADXL375 sensor.

createHig creates the ADXL375 sensor with the settings specified in the properties of the JUMP sensor model.

Parameters
obj(JumpSensor) - the JUMP sensor
Return values
none
Note
in here the actual sensor is modeled with noise and bias. See the actual code for the parameters and explanations.

◆ createMpu()

function createMpu ( in obj)
private

createMpu creates the MPU9250 sensor.

createMpu creates the MPU9250 sensor with the settings specified in the properties of the JUMP sensor model.

Parameters
obj(JumpSensor) - the JUMP sensor
Return values
none
Note
in here the actual sensor is modeled with noise and bias. See the actual code for the parameters and explanations.

◆ generate()

function generate ( in obj,
in acc_true,
in gyr_true,
in ori_true,
in options )

generate generates sensor data from true data.

generate generates sensor data from true data with the defined sensor models. The data format is identical to the data format of the parsing function of the function JUMPREADDATA.

Parameters
acc_true(nx3 double) - the true accelerometer data in m/s^2
gyr_true(nx3 double) - the true gyroscope data in deg/s
ori_true(nx1 quaternion) - the true orientation data in quaternions
options.alt_true(nx1 double, optional) - the true altitude in m (default: 500 m)
options.tmp_true(nx1 double, optional) - the true temperature in °C (default: 25°C)
options.t_start(datetime, optional) - the start time of the sensor data (default: now)
options.simulate_mpu(logical, optional) - simulate the MPU9250 sensor (default: true)
options.simulate_hig(logical, optional) - simulate the ADXL375 sensor (default: true)
options.simulate_prs(logical, optional) - simulate the MS5611 sensor (default: true)
options.simulate_tmp(logical, optional) - simulate the temperature sensor (default: true)
Return values
data(struct) - the sensor data in the format of the parsing function of the function JUMPREADDATA
  • data.tt (timetable) - timetable containing the sensor data
  • data.ID (char) - sensor ID
  • data.UID (char) - sensor UID
  • data.name (char) - sensor name (fixed to 'JUMP model')
  • data.sw_version (char) - sensor software version
  • data.hw_version (char) - sensor hardware version
  • data.acc_range (double) - accelerometer range
  • data.gyro_range (double) - gyroscope range
  • data.mpu_cal (double) - mpu calibration
  • data.act_thrs (double) - activity threshold
  • data.inact_dur (double) - inactivity duration
  • data.mpu_rate (double) - mpu rate
  • data.adxl_rate (double) - adxl rate
  • data.pres_rate (double) - pressure rate
  • data.magn_en (double) - magnetometer enabled
  • data.sync (double) - sync mode
  • data.ble_adress (char) - ble adress
Note
for whatever reason the MATLAB imuSensor class negates the accelerometer data. I guess, because they missunderstand how the gravitational force works. According to their algorithm description, they negate the input acceleration and then add the gravity vector. This is not the correct way to do it. The correct way is to negate the gravity vector. Therefore, the input is negated and the gravity vector is added two times before the imuSensor class is called. This is a bug in the MATLAB imuSensor class. In ither words, we have the actual acceleration \( a \). to patch the MATLAB bevavior, we do:

\[ a_{patched} = -a + 2 \cdot [0,0,g], \]

before we call the imuSensor class.then the imuSensor class does

\[ totalAcc = -a_{input} + [0,0, g] = -(-a + 2 \cdot [0,0,g]) + [0,0, +g] = a - [0,0,g], \]

which brings the correct result.
Todo
check the covariances of the sensors
Todo
check the axis misalignment and sensitivity over time.

◆ generateFromTrajectory()

function generateFromTrajectory ( in obj,
in traj )

generates data from a Trajectory object.

generateFromTrajectory generates sensor data from a Trajectory object. The sensor data is generated with the defined sensor models.

Parameters
obj(JumpSensor) - the JUMP sensor
traj(Trajectory) - the trajectory object
Return values
data(struct) - the sensor data in the format defined in generate
Examples
derivation1KalmanFilter.m, derivation2KalmanFilter.m, derivation3RtsSmoother.m, derivation4ExtendedKalmanFilter.m, derivation5Ekf6D.m, derivation6Ekf6D.m, derivation7IntialParamEst.m, derivation8Ekf6D_pt1.m, and derivation8Ekf6D_pt2.m.

◆ generateNoise()

static function generateNoise ( in n,
in N,
in K,
in B,
in fs )
staticprivate

generateNoise generates noise with the given parameters.

generateNoise generates noise with the given parameters. The noise is generated with the following model:

  • white noise with the noise density N
  • random walk with the coefficient K
  • bias instability with the coefficient B The noise is generated with the sample rate fs.
Parameters
n(1x1 double) - the number of samples
N(1x1 double) - the noise density
K(1x1 double) - the random walk coefficient
B(1x1 double) - the bias instability coefficient
fs(1x1 double) - the sample rate
Return values
noise(nx1 double) - the generated noise

◆ getMisalignmentMatrix()

static function getMisalignmentMatrix ( in x,
in y,
in z,
in sensitivity )
staticprivate

getMisalignmentMatrix returns a misalignment matrix for the accelerometer or gyroscope.

getMisalignmentMatrix returns a misalignment matrix for the accelerometer or gyroscope. The misalignment matrix is a 3x3 matrix which is used to rotate the sensor axes to the reference frame. The misalignment matrix is generated randomly.

Parameters
x(1x1 double) - the typical misalignment of the x-axis in percent
y(1x1 double) - the typical misalignment of the y-axis in percent
z(1x1 double) - the typical misalignment of the z-axis in percent
sensitivity(1x1 double) - the overall sensitivity error in percent
Return values
M(3x3 double) - the misalignment matrix in percent
Note
the misalignment matrix is generated with the following steps:
  1. generate the three axis in perfect alignment, but with sensitivity errors
  2. generate the misalignment angles
  3. generate the misalignment rotation
  4. rotate the axes (attention, the rotx function works with degrees!)
  5. create the misalignment matrix

◆ getParams()

function getParams ( in obj)

returns the parameters of the JUMP sensor.

getParams returns the parameters of the JUMP sensor. The parameters are used to generate the erroneous sensor data.

Parameters
obj(JumpSensor) - the JUMP sensor
Return values
params(struct) - the parameters of the JUMP sensor
  • params.mpu.acc (struct) - the parameters of the MPU9250 accelerometer
  • params.mpu.gyr (struct) - the parameters of the MPU9250 gyroscope
  • params.mpu.mag (struct) - the parameters of the MPU9250 magnetometer
  • params.hig.acc (struct) - the parameters of the ADXL375 accelerometer

◆ getPressureFromAltitude()

function getPressureFromAltitude ( in obj,
in alt,
in tmp,
in prs_sealvl )
private

getPressureFromAltitude returns the pressure from the altitude.

getPressureFromAltitude returns the pressure from the altitude. The pressure is modeled with the barometric formula and the actual sensor is modeled with noise and bias.

Parameters
obj(JumpSensor) - the JUMP sensor
alt(nx1 double) - the altitude in m
tmp(nx1 double, optional) - the temperature in °C (default: 25°C)
prs_sealvl(1x1 double, optional) - the pressure at sea level in mbar (default: 1013.25 mbar)
Return values
mbar(nx1 double) - the pressure in mbar
Note
the experiment 240213_pressure_membrane suggested a mean raise time of 0.5s. Since this is approx the free fall duration (=0.49 s), we assume that the pressure sensor is able to measure the pressure with almost no delay. Therefore, we do not need to model the delay of the sensor.
formula from: https://www.omnicalculator.com/physics/air-pressure-at-altitude, last accessed: 2024-02

◆ getSensorTemperature()

function getSensorTemperature ( in obj,
in tmp_true )
private

getSensorTemperature returns the sensor temperature.

getSensorTemperature returns the sensor temperature with the actual sensor noise and bias.

Parameters
obj(JumpSensor) - the JUMP sensor
tmp_true(nx1 double) - the true temperature in °C
Return values
degC(nx1 double) - the sensor temperature in °C

◆ rant()

static function rant ( in lower,
in upper,
in nstd )
staticprivate

rant returns a typical value in the sense of datasheet typical values.

rant(lower) returns a typical random number with a symmetric distribution around zero, where the range is defined by the lower bound. The random number is gaussian distributed with lower been the two standard deviation range.

rant(lower, upper) returns a typical random number with a gaussian distribution with the given range.

rant(lower, upper, nstd) returns a typical random number with a gaussian distribution with nstd standard deviations.

Parameters
lower(1x1 double) - the lower bound of the distribution
upper(1x1 double) - the upper bound of the distribution
nstd(1x1 double) - the number of standard deviations
Return values
number(1x1 double) - the random number

Member Data Documentation

◆ accRange

Property accRange
private

Definition at line 47 of file JumpSensor.m.

◆ gyroRange

Property gyroRange
private

Definition at line 49 of file JumpSensor.m.

◆ hig

Property hig
private

Definition at line 61 of file JumpSensor.m.

◆ mpu

Property mpu
private

Definition at line 59 of file JumpSensor.m.

◆ sampleRate

Property sampleRate
private

Definition at line 51 of file JumpSensor.m.

◆ sampleRateMagnetometer

Property sampleRateMagnetometer
private

Definition at line 55 of file JumpSensor.m.

◆ sampleRatePressure

Property sampleRatePressure
private

Definition at line 53 of file JumpSensor.m.


The documentation for this class was generated from the following file: