%% Introduction to Simulating IMU Measurements
% This example shows how to simulate inertial measurement unit (IMU)
% measurements using the |imuSensor| System object. An IMU can include a combination of
% individual sensors, including a gyroscope, an accelerometer, and a
% magnetometer. You can specify properties of the individual sensors using
% |gyroparams|, |accelparams|, and |magparams|, respectively.
%
% In the following plots, unless otherwise noted, only the x-axis
% measurements are shown.
% Copyright 2018-2019 The MathWorks, Inc.
%% Default Parameters
% The default parameters for the gyroscope model simulate an ideal signal.
% Given a sinusoidal input, the gyroscope output should match exactly.
params = gyroparams
% Generate N samples at a sampling rate of Fs with a sinusoidal frequency
% of Fc.
N = 1000;
Fs = 100;
Fc = 0.25;
t = (0:(1/Fs):((N-1)/Fs)).';
acc = zeros(N, 3);
angvel = zeros(N, 3);
angvel(:,1) = sin(2*pi*Fc*t);
imu = imuSensor('SampleRate', Fs, 'Gyroscope', params);
[~, gyroData] = imu(acc, angvel);
figure
plot(t, angvel(:,1), '--', t, gyroData(:,1))
xlabel('Time (s)')
ylabel('Angular Velocity (rad/s)')
title('Ideal Gyroscope Data')
legend('x (ground truth)', 'x (gyroscope)')
%% Hardware Parameter Tuning
% The following parameters model hardware limitations or defects. Some can
% be corrected through calibration.
%%
% |MeasurementRange| determines the maximum absolute value reported by the
% gyroscope. Larger absolute values are saturated. The effect is shown by
% setting the measurement range to a value smaller than the amplitude of
% the sinusoidal ground-truth angular velocity.
imu = imuSensor('SampleRate', Fs, 'Gyroscope', params);
imu.Gyroscope.MeasurementRange = 0.5; % rad/s
[~, gyroData] = imu(acc, angvel);
figure
plot(t, angvel(:,1), '--', t, gyroData(:,1))
xlabel('Time (s)')
ylabel('Angular Velocity (rad/s)')
title('Saturated Gyroscope Data')
legend('x (ground truth)', 'x (gyroscope)')
%%
% |Resolution| affects the step size of the digital measurements. Use this
% parameter to model the quantization effects from the analog-to-digital
% converter (ADC). The effect is shown by increasing the parameter to a
% much larger value than is typical.
imu = imuSensor('SampleRate', Fs, 'Gyroscope', params);
imu.Gyroscope.Resolution = 0.5; % (rad/s)/LSB
[~, gyroData] = imu(acc, angvel);
figure
plot(t, angvel(:,1), '--', t, gyroData(:,1))
xlabel('Time (s)')
ylabel('Angular Velocity (rad/s)')
title('Quantized Gyroscope Data')
legend('x (ground truth)', 'x (gyroscope)')
%%
% |AxesMisalignment| is the amount of skew in the sensor axes. This skew
% normally occurs when the sensor is mounted to the PCB and can be
% corrected through calibration. The effect is shown by skewing the x-axis
% slightly and plotting both the x-axis and y-axis.
imu = imuSensor('SampleRate', Fs, 'Gyroscope', params);
imu.Gyroscope.AxesMisalignment = [2 0 0]; % percent
[~, gyroData] = imu(acc, angvel);
figure
plot(t, angvel(:,1:2), '--', t, gyroData(:,1:2))
xlabel('Time (s)')
ylabel('Angular Velocity (rad/s)')
title('Misaligned Gyroscope Data')
legend('x (ground truth)', 'y (ground truth)', ...
'x (gyroscope)', 'y (gyroscope)')
%%
% |ConstantBias| occurs in sensor measurements due to hardware defects.
% Since this bias is not caused by environmental factors, such as
% temperature, it can be corrected through calibration.
imu = imuSensor('SampleRate', Fs, 'Gyroscope', params);
imu.Gyroscope.ConstantBias = [0.4 0 0]; % rad/s
[~, gyroData] = imu(acc, angvel);
figure
plot(t, angvel(:,1), '--', t, gyroData(:,1))
xlabel('Time (s)')
ylabel('Angular Velocity (rad/s)')
title('Biased Gyroscope Data')
legend('x (ground truth)', 'x (gyroscope)')
%% Random Noise Parameter Tuning
% The following parameters model random noise in sensor measurements. More
% information on these parameters can be found in the
% <docid:fusion_ug#mw_aa75f9c3-b6d6-45af-b219-65102598c2be
% Inertial Sensor Noise Analysis Using Allan Variance> example.
%%
% |NoiseDensity| is the amount of white noise in the sensor measurement. It
% is sometimes called angle random walk for gyroscopes or velocity random
% walk for accelerometers.
%
rng('default')
imu = imuSensor('SampleRate', Fs, 'Gyroscope', params);
imu.Gyroscope.NoiseDensity = 1.25e-2; % (rad/s)/sqrt(Hz)
[~, gyroData] = imu(acc, angvel);
figure
plot(t, angvel(:,1), '--', t, gyroData(:,1))
xlabel('Time (s)')
ylabel('Angular Velocity (rad/s)')
title('White Noise Gyroscope Data')
legend('x (ground truth)', 'x (gyroscope)')
%%
% |BiasInstability| is the amount of pink or flicker noise in the sensor
% measurement.
%
imu = imuSensor('SampleRate', Fs, 'Gyroscope', params);
imu.Gyroscope.BiasInstability = 2.0e-2; % rad/s
[~, gyroData] = imu(acc, angvel);
figure
plot(t, angvel(:,1), '--', t, gyroData(:,1))
xlabel('Time (s)')
ylabel('Angular Velocity (rad/s)')
title('Bias Instability Gyroscope Data')
legend('x (ground truth)', 'x (gyroscope)')
%%
% |RandomWalk| is the amount of Brownian noise in the sensor measurement.
% It is sometimes called rate random walk for gyroscopes or acceleration
% random walk for accelerometers.
%
imu = imuSensor('SampleRate', Fs, 'Gyroscope', params);
imu.Gyroscope.RandomWalk = 9.1e-2; % (rad/s)*sqrt(Hz)
[~, gyroData] = imu(acc, angvel);
figure
plot(t, angvel(:,1), '--', t, gyroData(:,1))
xlabel('Time (s)')
ylabel('Angular Velocity (rad/s)')
title('Random Walk Gyroscope Data')
legend('x (ground truth)', 'x (gyroscope)')
%% Environmental Parameter Tuning
% The following parameters model noise that arises from changes to the
% environment of the sensor.
%%
% |TemperatureBias| is the bias added to sensor measurements due to
% temperature difference from the default operating temperature. Most
% sensor datasheets list the default operating temperature as 25 degrees
% Celsius. This bias is shown by setting the parameter to a non-zero value
% and setting the operating temperature to a value above 25 degrees
% Celsius.
imu = imuSensor('SampleRate', Fs, 'Gyroscope', params);
imu.Gyroscope.TemperatureBias = 0.06; % (rad/s)/(degrees C)
imu.Temperature = 35;
[~, gyroData] = imu(acc, angvel);
figure
plot(t, angvel(:,1), '--', t, gyroData(:,1))
xlabel('Time (s)')
ylabel('Angular Velocity (rad/s)')
title('Temperature-Biased Gyroscope Data')
legend('x (ground truth)', 'x (gyroscope)')
%%
% |TemperatureScaleFactor| is the error in the sensor scale factor due to
% changes in the operating temperature. This causes errors in the scaling
% of the measurement; in other words smaller ideal values have less error
% than larger values. This error is shown by linearly increasing the
% temperature.
imu = imuSensor('SampleRate', Fs, 'Gyroscope', params);
imu.Gyroscope.TemperatureScaleFactor = 3.2; % %/(degrees C)
standardTemperature = 25; % degrees C
temperatureSlope = 2; % (degrees C)/s
temperature = temperatureSlope*t + standardTemperature;
gyroData = zeros(N, 3);
for i = 1:N
imu.Temperature = temperature(i);
[~, gyroData(i,:)] = imu(acc(i,:), angvel(i,:));
end
figure
plot(t, angvel(:,1), '--', t, gyroData(:,1))
xlabel('Time (s)')
ylabel('Angular Velocity (rad/s)')
title('Temperature-Scaled Gyroscope Data')
legend('x (ground truth)', 'x (gyroscope)')
%%
% |AccelerationBias| is the bias added to the gyroscope measurement due to
% linear accelerations. This parameter is specific to the gyroscope. This
% bias is shown by setting the parameter to a non-zero value and using a
% non-zero input acceleration.
imu = imuSensor('SampleRate', Fs, 'Gyroscope', params);
imu.Gyroscope.AccelerationBias = 0.3; % (rad/s)/(m/s^2)
acc(:,1) = 1;
[~, gyroData] = imu(acc, angvel);
figure
plot(t, angvel(:,1), '--', t, gyroData(:,1))
xlabel('Time (s)')
ylabel('Angular Velocity (rad/s)')
title('Acceleration-Biased Gyroscope Data')
legend('x (ground truth)', 'x (gyroscope)')
没有合适的资源?快使用搜索试试~ 我知道了~
(matlab程序)使用 System 对象模拟惯性测量单元测量仿真.rar
共1个文件
m:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 2 下载量 15 浏览量
2023-02-08
20:00:47
上传
评论 2
收藏 2KB RAR 举报
温馨提示
此示例演示如何使用 System 对象模拟惯性测量单元 (IMU) 测量。IMU 可以包括单个传感器的组合,包括陀螺仪、加速度计和磁力计。在下面的图中,除非另有说明,否则仅显示 x 轴测量值。 陀螺仪模型的默认参数模拟理想信号。给定正弦输入,陀螺仪输出应完全匹配。 以下参数对硬件限制或缺陷进行建模。有些可以通过校准进行校正。 MeasurementRange确定陀螺仪报告的最大绝对值。较大的绝对值将饱和。通过将测量范围设置为小于正弦真实角速度振幅的值来显示效果。
资源推荐
资源详情
资源评论
收起资源包目录
使用 System 对象模拟惯性测量单元测量仿真.rar (1个子文件)
使用 System 对象模拟惯性测量单元测量仿真
IMUSimulationExample.m 8KB
共 1 条
- 1
资源评论
- 蒋小馨2023-12-08资源很实用,内容详细,值得借鉴的内容很多,感谢分享。
- MrKINGDOMF2023-10-21资源很实用,对我启发很大,有很好的参考价值,内容详细。
珞瑜·
- 粉丝: 10w+
- 资源: 500
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功