How to transform coordinates of accelerometer data?

조회 수: 24 (최근 30일)
Reina
Reina 2022년 10월 28일
답변: Vinayak 2023년 8월 29일
Hello, I am an undergraduate student and I am new to MATLAB, so please be understanding and kindly correct me if I use improper terms.
I have an accelerometer data which I collected by walking with the device (phone) in my pocket. I want to transform this data such that they are all referenced to the axis of when a phone is lying horizontally on a surface.
From my very basic understanding of the concept of transformation, I need a direction cosine matrix. This would also vary with time since the orientation of the local axes vary wrt global axes when walking. I then have the following questions:
  • How to create a DCM? What information do I need to create a DCM for each sample? Do I need data about the angular velocity, orientation, and/or magnetic field?
  • How do I consider factors like noise?
  • Also, how can I apply the DCM to the accelerometer data?
Thank you very much in advance.

답변 (1개)

Vinayak
Vinayak 2023년 8월 29일
Hi,
A direction cosine matrix can be created by making use of the "angle2dcm" function in MATLAB in the following way.
We could use this function to derive the DCM either from the angles or from rotation angle and sequence.
A sample code snippet of this implementation is as follows:-
% Define Euler angles (roll, pitch, yaw) in radians
roll = 0.1; % Example roll angle
pitch = 0.2; % Example pitch angle
yaw = 0.3; % Example yaw angle
% Compute the DCM using Euler angles
dcm = angle2dcm(roll,pitch,yaw);
To consider factors like noise, you can add random perturbations to the Euler angles or quaternion representation before calculating the DCM. This can simulate the effect of noise or measurement errors in the orientation data.
To apply the DCM to accelerometer data, you can use the following steps:
  1. Obtain accelerometer measurements in a specific coordinate frame (e.g., body-fixed frame).
  2. Multiply the accelerometer measurements with the DCM to transform them into a desired coordinate frame (e.g., Earth-fixed frame).
% Assume accelerometer measurements in the body-fixed frame
accel_body = [0.1; 0.2; 9.8]; % Example accelerometer measurements
% Apply DCM to transform accelerometer measurements to Earth-fixed frame
accel_earth = dcm * accel_body;
More information about this function can be inferred from here,
Thanks,
Vinayak

Community Treasure Hunt

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

Start Hunting!

Translated by