Creation of Imu geometric model in Matlab In order to generate Synthetic data(Accelerometer and Gyroscope) 6DOF

12 visualizzazioni (ultimi 30 giorni)
I am looking to create a geometric model(using the simulink blocks) of an IMU sensor that is available in Mathworks 'Sensor Fusion Toolbox'. I have to generate synthetic data of the 3-axis accelerometer,3-axis gyroscope(6DOF) in order to calculate the quaternions(to calculate the orientation) using an sensor fusion algorithm(Madgwick Filter or any similar one). I want to do this in Simulink without using real hardware sensors.I am stuck at this point how to go forward.
Looking for any suggestions or references of similar models.
Thanks in advance.

Risposte (2)

cui,xingxing
cui,xingxing il 10 Ott 2024
@Revanth Kumar Adireddy Hi, I have given here the synthetic simulation data generated by imuSensor and then recovered the attitude data through the filter and simulated it.
%% 定义滤波器
SampleRate = 100;
fuse1 = imufilter(ReferenceFrame='NED',SampleRate=SampleRate,GyroscopeNoise=1e-4, GyroscopeDriftNoise=1e-6);
% fuse2 = ahrsfilter('SampleRate', SampleRate); % thiS filter must need magnetometer
fuse3 = complementaryFilter(ReferenceFrame='NED',HasMagnetometer=false,AccelerometerGain=0.01);
%% 定义人工生成的groundTruth
% 分别在2秒内绕x,y,z轴旋转360度,得到真值仿真数据
fs = SampleRate;
eachLoopNumSamples = fs*2;
totalNumSamples = 3*eachLoopNumSamples;
traj = kinematicTrajectory('SampleRate',fs);
accBody = zeros(totalNumSamples,3);
angVelBody = zeros(totalNumSamples,3);
angVelBody(1:eachLoopNumSamples,1) = (2*pi)/2;
angVelBody(eachLoopNumSamples+1:2*eachLoopNumSamples,2) = (2*pi)/2;
angVelBody(2*eachLoopNumSamples:end,3) = (2*pi)/2;
[~,orientationNED,~,accNED,angVelNED] = traj(accBody,angVelBody);
IMU = imuSensor('accel-gyro','SampleRate',fs);
% % 加点噪音模拟真实的IMU
% IMU.Accelerometer = accelparams(...
% MeasurementRange=20,...
% Resolution=0.00239,...
% TemperatureScaleFactor=0.008,...
% ConstantBias=0.1962,...
% TemperatureBias=0.0015,...
% NoiseDensity=0.1);
[accelReadings,gyroReadings] = IMU(accNED,angVelNED,orientationNED);
t = (0:(totalNumSamples-1))/SampleRate;
plot(t,accelReadings)
legend('X-axis','Y-axis','Z-axis')
ylabel('Acceleration (m/s^2)')
title('Accelerometer Readings')
%% 展示姿态解算恢复结果
fig = figure;
ax = axes(Parent=fig);
pp = poseplot(ax,"NED");
xlabel("North-x (m)")
ylabel("East-y (m)")
zlabel("Down-z (m)");
for idx = 1:size(accelReadings,1)
% Get the latest acceleration and angular velocity data
acc = accelReadings(idx,:);
gyr = gyroReadings(idx,:);
if ~isempty(acc) && ~isempty(gyr)
% acc = -[acc(2),acc(1),-acc(3)]; % if data from matlab mobile™ APP
% gyr = [gyr(2),gyr(1),gyr(3)];
% Use the imufilter to estimate orientation (quaternion)
orientation = fuse3(acc, gyr);
% Convert quaternion to rotation matrix
rotm = quat2rotm(orientation);
set(pp, "Orientation", orientation);
end
% Refresh the plot
% drawnow ;
pause(1/SampleRate);
end

Brian Fanous
Brian Fanous il 25 Ago 2022
You can use waypointTrajectory and imuSensor to accomplish this in MATLAB. There is an equivalent Simulink block for imuSensor but you'd have to put the waypointTrajectory code in a MATLAB Function block to handle the trajectory generation portion:
% Simulink IMU data during a trajectory between two random orientations
wp = waypointTrajectory('Waypoints', zeros(2,3), 'Orientation', randrot(2,1), 'TimeOfArrival', [0 1].');
sampleRate = 10;
[~, orient, ~, acceleration, angvel] = lookupPose(wp, 0:(1/sampleRate):1);
imu = imuSensor('SampleRate', sampleRate);
[acc, gyro] = imu(acceleration, angvel, orient);
  1 Commento
Revanth Kumar Adireddy
Revanth Kumar Adireddy il 19 Set 2022
Modificato: Revanth Kumar Adireddy il 20 Set 2022
Hi,
Dear Brian,
I wanted to generate artificial imu data using kinematic trajectory generation.
Trajectory : 0° to 90° and back from 90° to 0°.
Any ideas or piece of code would be helpful.
Thanks!

Accedi per commentare.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by