Main Content

Generate Off-Centered IMU Readings

This example shows how to generate inertial measurement unit (IMU) readings from a sensor that is mounted on a ground vehicle. Depending on the location of the sensor, the IMU accelerations are different.

创建轨迹

Specify the waypoint trajectory of a vehicle and compute the vehicle poses using求婚

% 采样率。FS = 100;%航路点和到达时间。Waypoints = [1 1 1;3 1 1;3 0 0;0 0 0];t = [1;10;20;30];%创建轨迹和计算姿势。traj = WaypointTrajectory(Waypoints,t,“采样率”,fs);[posveh,orientveh,velveh,accveh,angvelveh] = lookuppose(traj,...t(1):1/fs:t(end));

创建传感器并定义偏移

Create two 9-axisimusensor由加速度计,陀螺仪和磁力计传感器组成的对象。一imusensor物体生成安装在车辆起源的IMU的读数,另一个物体会产生安装在驾驶员座椅上的IMU的读数。接下来,指定车辆原点与安装在驾驶员座椅上的IMU之间的偏移。称呼Helpplotimu可视化传感器的位置。

%IMU在车辆起源。imu = imusensor("accel-gyro-mag",,,,“采样率”,fs);%imu在驾驶员座位上。MONTEDIMU = iMusensor("accel-gyro-mag",,,,“采样率”,fs);百分比的位置和方向抵消了车辆和安装的IMU。posveh2imu = [2.4 0.5 0.4];entientveh2imu = quaternion([0 0 90],,"eulerd",,,,“ zyx”,,,,"frame");% Visualization.Helpplotimu(posveh(1,:),orientveh(1,:),posveh2imu,orientveh2imu);

图包含一个轴。轴包含2个类型线的对象,补丁。

使用车辆轨迹计算IMU轨迹

计算地面真理轨迹IMU的谅解备忘录nted at the driver's seat using thetransformMotion功能。此功能使用位置和方向偏移和车辆轨迹来计算IMU轨迹。

[posIMU, orientIMU, velIMU, accIMU, angvelIMU] = transformMotion(...posveh2imu,orientveh2imu,...posveh,orientveh,velveh,accveh,angvelveh);

Generate Sensor Readings

为安装在车辆起源的IMU和安装在驾驶员座椅上的IMU生成IMU读数。

%IMU在车辆起源。[ACCEL,GYRO,MAG] = IMU(Accveh,Angvelveh,orientveh);%imu在驾驶员座位上。[加速,旋转,岩浆] = mountedimu(...Accimu,Angvelimu,Orientimu);

比较加速度计读数

比较两个IMU的加速度计读数。注意X-axis acceleration is different because of the off-center location.

数字('姓名',,,,'Accelerometer Comparison')子图(3,1,1)图([Accel(:1),AccelMounted(::,1)])ligend(“与车辆对齐”,,,,'Off-centered') 标题('Accelerometer')ylabel('X轴(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轴(m/s^2)'

图加速度计的比较包含3个轴。带标题加速度计的轴1包含2个类型线的对象。这些物体表示与车辆对齐,不为中心。轴2包含2个类型线的对象。轴3包含2个类型线的对象。

比较陀螺仪读数

比较两个IMU的陀螺仪读数。

数字('姓名',,,,'Gyroscope Comparison')子图(3,1,1)图([gyro(:1),gyromounted(::,1)])ylim([ -  0.22 0.1])传奇([ -  0.22 0.1])“与车辆对齐”,,,,'Off-centered') 标题(“陀螺仪”)ylabel('x-axis (rad/s)')子图(3,1,2)图([gyro(:,2),gyromounted(::,2)])ylabel('y-axis (rad/s)')subplot(3, 1, 3) plot([gyro(:,3), gyroMounted(:,3)]) ylabel('z-axis (rad/s)'

图陀螺仪比较包含3个轴。带标题陀螺仪的轴1包含2个类型线的对象。这些物体表示与车辆对齐,不为中心。轴2包含2个类型线的对象。轴3包含2个类型线的对象。

比较磁力计读数

比较两个IMU的磁力计读数。

数字('姓名',,,,“磁力计比较”)子图(3,1,1)图([mag(::,1),magmounted(::,1)])传说(“与车辆对齐”,,,,'Off-centered') 标题('Magnetometer')ylabel('x-axis (\muT)')子图(3,1,2)图([mag(::,2),magmounted(::,2)])ylabel('y轴(\ mut)')子图(3,1,3)图([mag(::,3),magmounted(::,3)])ylabel('z轴(\ mut)'

Figure Magnetometer Comparison contains 3 axes. Axes 1 with title Magnetometer contains 2 objects of type line. These objects represent Aligned with Vehicle, Off-centered. Axes 2 contains 2 objects of type line. Axes 3 contains 2 objects of type line.