Main Content

Esta página se ha traducido mediante traducción automática. Haga clic aquí para ver la última versión en inglés.

Generar lecturas IMU descentradas

Este ejemplo muestra cómo generar lecturas de unidades de medición inercial (IMU) desde un sensor montado en un vehículo terrestre. Dependiendo de la ubicación del sensor, las aceleraciones de la IMU son diferentes.

Crear trayectoria

Especifique la trayectoria del punto de ruta de un vehículo y calcule las poses del vehículo usando lookupPose.

% Sampling rate.
Fs = 100;

% Waypoints and times of arrival.
waypoints = [1 1 1; 3 1 1; 3 0 0; 0 0 0];
t = [1; 10; 20; 30];

% Create trajectory and compute pose.
traj = waypointTrajectory(waypoints, t, "SampleRate", Fs);
[posVeh, orientVeh, velVeh, accVeh, angvelVeh] = lookupPose(traj, ...
    t(1):1/Fs:t(end));

Crear sensor y definir compensación

Cree dos objetos imuSensor de 9 ejes compuestos por sensores de acelerómetro, giroscopio y magnetómetro. Un objeto imuSensor genera lecturas de una IMU montada en el origen del vehículo y el otro genera lecturas de una IMU montada en el asiento del conductor. A continuación, especifique el desplazamiento entre el origen del vehículo y la IMU montada en el asiento del conductor. Llame a helperPlotIMU para visualizar las ubicaciones de los sensores.

% IMU at vehicle origin.
imu = imuSensor("accel-gyro-mag", "SampleRate", Fs);

% IMU at driver's seat.
mountedIMU = imuSensor("accel-gyro-mag", "SampleRate", Fs);

% Position and orientation offset of the vehicle and the mounted IMU.
posVeh2IMU = [2.4 0.5 0.4];
orientVeh2IMU = quaternion([0 0 90], "eulerd", "ZYX", "frame");

% Visualization.
helperPlotIMU(posVeh(1,:), orientVeh(1,:), posVeh2IMU, orientVeh2IMU);

Figure contains an axes object. The axes object contains 2 objects of type line, patch.

Calcule la trayectoria de la IMU utilizando la trayectoria del vehículo

Calcule la trayectoria ground-truth de la IMU montada en el asiento del conductor utilizando la función transformMotion . Esta función utiliza las compensaciones de posición y orientación y la trayectoria del vehículo para calcular la trayectoria de la IMU.

[posIMU, orientIMU, velIMU, accIMU, angvelIMU] = transformMotion( ...
    posVeh2IMU, orientVeh2IMU, ...
    posVeh, orientVeh, velVeh, accVeh, angvelVeh);

Generar lecturas de sensores

Genere las lecturas de la IMU tanto para la IMU montada en el origen del vehículo como para la IMU montada en el asiento del conductor.

% IMU at vehicle origin.
[accel, gyro, mag] = imu(accVeh, angvelVeh, orientVeh);

% IMU at driver's seat.
[accelMounted, gyroMounted, magMounted] = mountedIMU( ...
    accIMU, angvelIMU, orientIMU);

Comparar lecturas del acelerómetro

Compare las lecturas del acelerómetro de las dos IMU. Observe que la aceleración del eje x es diferente debido a la ubicación descentrada.

figure('Name', 'Accelerometer Comparison')
subplot(3, 1, 1)
plot([accel(:,1), accelMounted(:,1)])
legend('Aligned with Vehicle', 'Off-centered')
title('Accelerometer')
ylabel('x-axis (m/s^2)')
subplot(3, 1, 2)
plot([accel(:,2), accelMounted(:,2)])
ylabel('y-axis (m/s^2)')
subplot(3, 1, 3)
plot([accel(:,3), accelMounted(:,3)])
ylabel('z-axis (m/s^2)')

Figure Accelerometer Comparison contains 3 axes objects. Axes object 1 with title Accelerometer, ylabel x-axis (m/s^2) contains 2 objects of type line. These objects represent Aligned with Vehicle, Off-centered. Axes object 2 with ylabel y-axis (m/s^2) contains 2 objects of type line. Axes object 3 with ylabel z-axis (m/s^2) contains 2 objects of type line.

Comparar lecturas de giroscopio

Compare las lecturas del giroscopio de las dos IMU.

figure('Name', 'Gyroscope Comparison')
subplot(3, 1, 1)
plot([gyro(:,1), gyroMounted(:,1)])
ylim([-0.22 0.1])
legend('Aligned with Vehicle', 'Off-centered')
title('Gyroscope')
ylabel('x-axis (rad/s)')
subplot(3, 1, 2)
plot([gyro(:,2), gyroMounted(:,2)])
ylabel('y-axis (rad/s)')
subplot(3, 1, 3)
plot([gyro(:,3), gyroMounted(:,3)])
ylabel('z-axis (rad/s)')

Figure Gyroscope Comparison contains 3 axes objects. Axes object 1 with title Gyroscope, ylabel x-axis (rad/s) contains 2 objects of type line. These objects represent Aligned with Vehicle, Off-centered. Axes object 2 with ylabel y-axis (rad/s) contains 2 objects of type line. Axes object 3 with ylabel z-axis (rad/s) contains 2 objects of type line.

Comparar lecturas del magnetómetro

Compare las lecturas del magnetómetro de las dos IMU.

figure('Name', 'Magnetometer Comparison')
subplot(3, 1, 1)
plot([mag(:,1), magMounted(:,1)])
legend('Aligned with Vehicle', 'Off-centered')
title('Magnetometer')
ylabel('x-axis (\muT)')
subplot(3, 1, 2)
plot([mag(:,2), magMounted(:,2)])
ylabel('y-axis (\muT)')
subplot(3, 1, 3)
plot([mag(:,3), magMounted(:,3)])
ylabel('z-axis (\muT)')

Figure Magnetometer Comparison contains 3 axes objects. Axes object 1 with title Magnetometer, ylabel x-axis (\muT) contains 2 objects of type line. These objects represent Aligned with Vehicle, Off-centered. Axes object 2 with ylabel y-axis (\muT) contains 2 objects of type line. Axes object 3 with ylabel z-axis (\muT) contains 2 objects of type line.