Converting sensor frames using Aerospace Toolbox

4 views (last 30 days)
Hello,
I'm having trouble wrapping my head around writing quarternion transforms in Matlab to convert between body frames and navigation frames. Does anyone know of some Matlab tutorials, videos, or example code that might help me? I've already looked at the Matlab Help "About Aerospace Coordinate Systems", "Coordinate Systems", "Orientation, Position, and Coordinate Systems", and other provided by Matlab Help, but they are insuffient for me. Specifically, I'm trying to use the Aerospace blockset and toolbox with the Sensor Fusion and Tracking Toolbox, and convert between body-fixed, inertial frame, and navigation frames of the 6DOF (Quaternion) block and imuSensor. Currently I'm doing the following, which I figured out by trial and error.
function [acc, gyro, mag] = fcn(acc_be, angVel, ori)
% Notes
% the input is from the 6DOF (Quaternion) block
% the output is from the imuSensor Model
accBody = [0 0 0]';
gyroBody = [0 0 0]';
magBody = [0 0 0]';
persistent IMU
if isempty(IMU)
IMU = imuSensor('accel-gyro-mag');
IMU.SampleRate = 200;
end
ori_Q = quaternion(ori');
quatRotator = quaternion([0 ,180,180],'eulerd','ZYX','frame');
[aBody, gBody, mBody] = IMU(acc',angVel',ori_Q);
aBody = rotateframe(quatRotator,aBody);
aBody(3) = -aBody(3);
accBody = aBody';
gyroBody = gBody';
magBody = mBody';
end
Thanks

Answers (1)

James Tursa
James Tursa on 6 Apr 2020
This discussion on MATLAB quaternion convention might help you:

Community Treasure Hunt

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

Start Hunting!