Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plotting quaternion in Matlab using "engine.h" from c++

I have an algorithm in C++ that uses Kalman Filter. Somewhere in the code a predict a Quaternion q' and then I update the Quaternion with Kalman Filter q.

I want to plot two graphics in Matlab with the evolution of the predicted quaternion and the corrected(updated) quaternion so I am using "engine.h" library to send quaternion info to Matlab during processing (actually what I send is a 4x1 matrix).

So my question is: What is the best way to plot a quaternion in Matlab so I can visually extract information? Is it maybe better to plot the angles separately?

like image 974
Jav_Rock Avatar asked Feb 22 '23 21:02

Jav_Rock


1 Answers

I think a good option is sending the quaternion as a vector to MATLAB, using C++ MATLAB engine

[qx qy qz qw]

Then, in MATLAB environment you can use a toolbox for translating to Euler Angles, which is a common visual option.

For adding a path of a toolbox in matlab engine:

addpath(genpath('C:\Program Files (x86)\MATLAB\R2010a\toolbox\SpinCalc'));

With spincalc toolbox, converting would be something like this:

Angles=SpinCalc('QtoEA321',Quaternion,0,0);
like image 72
Carlos Cachalote Avatar answered Mar 03 '23 07:03

Carlos Cachalote