Converting sensor frames using Aerospace Toolbox
4 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Guidance, Navigation, and Control (GNC) 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!