LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Rotate 3D pictures with IMU

I am reading Quaternions, Rotation matrix, Euler angles and Raw Acc, gyro, mag data from IMU.But I want to use this data in 3D orientation view.

-I cannot use Euler angles directly. Because if the IMU reaches 90 degrees in the Pitch direction, there is a change in the ''roll'' degree.In other words, even if the pitch(X) angle changes to 90 degrees, the Roll(Y) angle must be maintained.

 

Actually, what I want to tell is to create something like here.

I have a VI that rotates a 3D image like the one below, but I was unable to visualize the rotation according to the IMU movements

 

 

 

-I did some research. It looks like Madgwick filter is being used but I'm not sure.

There is no example that applies the Madgwick filter in labVIEW anyway.

 

What path should I follow?
Anyone have an idea about this?.

 

Any opinion given is worthy of respect

Download All
0 Kudos
Message 1 of 16
(1,763 Views)

Hi constructionworker,

 

From what I can recall, there is an ambiguity in the orientation when using the Euler angles. There is not only one way to handle the ambiguity. You have to handle the ambiguity the way that is specific to your case. If you use quaternion (4 parameters), there is no orientation ambiguity. So, for full spherical orientation, using quaternions is preferable.

 

There is a Euler angles to quaternion function in the Haro3D library. I would suggest that you simply start using quaternions everywhere in your code. Take your inputs from the IMU and transform right away into quaternions. Within your code, this is where you would handle the ambiguity associated the Euler angles.

Marc Dubois
0 Kudos
Message 2 of 16
(1,718 Views)

Thank you for your answer  MarcDub

I think the toolkit you suggested is to calculate Euler angles to quaternion. However, I'm already reading the Quaternion information directly from the IMU with serial communication right now.

constructionworker_1-1677275922165.png

 

 

But I could not understand how to rotate a 3D object with this Quaternions information.

I think I would understand better if there was an example to give some idea about this.

 

 

0 Kudos
Message 3 of 16
(1,706 Views)
 

I think that for a full spherical representation, quaternions are much easier to use than Euler angles, once you understand them.

 
A quaternion contains 4-element cluster: (w, x, y, z). A quaternion represents a rotation of a given angle around a given axis. The sum of the square of its components must be equal to 1.
 
As an absolute orientation, a quaternion represents the rotation from the default orientation to the current orientation.
 
A quaternion is defined as w+ x + y + z
 
where
 
w = cos(a/2)
x = sin(a/2)* xR
y = sin(a/2)* yR
z = sin(a/2)* zR
 
where (xR,yR,zR) is the normalized direction of the rotation axis and a is the rotation angle. Therefore, (w = 1, x = 0, y = 0, z = 0) represents no rotation (a = 0°).
Use quaternions and convert into angles only when necessary. There are rules to use quaternions. For example, to apply a rotation to a previous rotation, you just multiply the 2 quaternions. However, quaternions multiplication is not trivial. That is why I created tools within Haro3D library to use quaternions. Quaternions are pretty common in 3D software development.
Have a look at this Wikipedia page.
Marc Dubois
0 Kudos
Message 4 of 16
(1,636 Views)

Thanks for your answer,  MarcDub

I've done a lot of research and I'm still trying to figure it out.

 

Based on what you said,

I created something like the following, but according to the quaternion information you provided, the movements are in the opposite direction. Yaw, pitch, roll movements rotate in a mixed way.

 

What is the solution to this?

0 Kudos
Message 5 of 16
(1,605 Views)

I don't understand your problem. There is no defined direction between Yaw, Pitch, Roll and quaternions. For the quaternions, it also depends on the orientation of your rotation axis.

 

If you want an unambiguous method of dealing with rotation in 3D space, quaternions are the way to go. They are less intuitive but if you pass the initial hurdles, they are quite straightforward.

Marc Dubois
0 Kudos
Message 6 of 16
(1,593 Views)

thanks for your answer.  MarcDub

Let me explain the problem a little more.

In the example below, it actually works exactly the way I want it to work, except for one thing, it happens to deviations when the pitch 90 approaches.
But I couldn't figure out how to apply Quaternion here. 

 

constructionworker_0-1677680419069.png

 

I checked your previous post here and tried to integrate it into my own application. But I couldn't get the yaw axis rotation here.

 

if I try to implement ''Rotation matrix'' and use ''rotate object.vi'' should I use a new ''rotate object.vi'' for each axis?

 

0 Kudos
Message 7 of 16
(1,571 Views)

I do not understand your problem. You are only saying that the Euler angles do not work when nearing 90 degrees, and that you do not get the Yaw to work. You don't say what does not work with the Yaw.

 

Euler angles have a problem when values near 90 or 180 degrees. They work well when your problem is limited to a half sphere.

 

When you talk about Yaw, Pitch, and roll, it sounds to me that they refer to relative angles (roll is along the fuselage of the airplane for example, just an opinion...). So that would mean that to correctly apply those angles, you need to rotate the coordinate system of the airplane. Just guessing here, since I do not know what your problem is.

 

So, make sure that you know what you are looking for. Relative or absolute angles (or a combination)? I think that is your actual problem. And then you can decide if you want to use Euler angles or quaternions.

Marc Dubois
0 Kudos
Message 8 of 16
(1,565 Views)

It's really my fault I can't explain the problem well.

 

I want to start over and over.

I read Euler angle, rotation matrix, and quaternion information directly with serial communication.

With this read data, I want the 3D picture to move according to the axis and degree of the IMU.

The ones I tested.
-Example VI in the picture I sent in the previous message. Here he is trying to move the 3D picture with euler angles. But I don't want to use it because of the Gimbal lock problem.

You said you need to use quaternions to bypass the gimbal lock. But I couldn't figure out how to connect quaternions to ''Rotate object.vi'' input. Because ''Rotate object.vi'' has axis(cluster) and Angle(numeric) inputs.

If I need to convert quaternions to "Rotation matrix" and connect X,Y,Z information to "axis" input of "Rotate object.vi", what information should I give to "angle"?

 

If I use the rotation matrix. The rotation matrix has 3x3=9 elements.
If I convert it to a 2D array and Then convert it to a 1D array. I get 3 pieces of X information, 3 pieces of Y information, 3 pieces of Z information. What reading X value or Y value or Z value should I give to the 'Axis' input. and what data should I bind to the 'Angle' input.

 

I hope I was able to explain in detail.

 

I appreciate your trying to help.

0 Kudos
Message 9 of 16
(1,560 Views)

Unfortunately, I will not be able to fix your specific problem. I can only try to answer specific questions.

 

I think that you need to understand what is the information provided by your IMU (absolute or relative angles?,  and/or coordinate systems?)

 

Then going through the angles or quaternions should be trivial. Rotation matrices would work as well but they do not contain more information than the quaternions.

 

Try things and try to understand the concepts. Once again, if you have a specific question, ask again, and try to back it up with code. Long winded questions without code are time-consuming to answer.

Marc Dubois
0 Kudos
Message 10 of 16
(1,543 Views)