137 views (last 30 days)

Hello to everyone,

I have calculated orientation and traslation data with an inertial sensor. The fact is that I want to create a 3d trayectory, plotting the gathered orientation (roll, pitch, yaw) and traslation of each iteration.

I have saved all the orientation data in a matrix of "m" x 3 size, where "m" is the number of the samples of the measurement over the time:

m = length(time);

So, my "Orientation" matrix will be something like:

orientation = zeros(length(time), 3);

for i=1:length(time)

orientation(i,:) = [EulerAngles_Roll(i) EulerAngles_Pitch(i) EulerAngles_Yaw(i)];

end

where EulerAngles_Roll, EulerAngles_Pitch and EulerAngles_Yaw contain all the angles of roll, pitch and yaw of each iteration. Then, after some functions and some calculations, I have calculated all the points in XYZ coordinates and the vector or the line that goes from the previous point to the current point. Hence, all the points are saved in a matrix of the same size as "orientation" matrix. This matrix is called "points". It happens the same with the matrix that contains all the distances or vectors from the previous point to the current one. In order to do that, I have calculated the directional unitary vector (called "vector_direc") from the orientation and then, I have multiplied thar directonal vector (3x1 vector) by the magnitude of the distance (scalar value called "ProbeAdvance_Iter") of each iteration, obtaining "step" . So:

Starting_Eul_Orient = [EulerAngles_Roll(1) EulerAngles_Pitch(1) EulerAngles_Yaw(1)];

Starting_point = [0 0 0];

orientation(1,:) = Starting_Eul_Orient;

point(1,:) = [0 0 0];

Starting_Vector_Direc = Calc_Vector_Directional(Starting_Eul_Orient(1), Starting_Eul_Orient(2), Starting_Eul_Orient(3));%calcular vector direccional

vector_direc(1,:) = Starting_Vector_Direc;

for i=2:length(time)

orientation(i,:) = [EulerAngles_Roll(i) EulerAngles_Pitch(i) EulerAngles_Yaw(i)];

vector_direc(i,:)= Calc_Vector_Directional(orientation(i,1), orientation(i,2), orientation(i,3));

step(i-1,:) = vector_direc(i-1,:)*ProbeAdvance_Iter(i-1);

point(i,:) = point(i-1,:) + step(i-1,:);

end

I know that this is a way to represent the points in 3d:

figure(9)

plot3(point(:,1),point(:,2),point(:,3),'+');

But I would like to represent not only the point, but also the orientation and at least, the lines from one point to the next one.

I would appreciate any idea. Thanks.

Thomas Satterly
on 30 Oct 2019

Sign in to comment.

Aitor Burdaspar
on 31 Oct 2019

Thomas Satterly
on 31 Oct 2019

Your orientation should be Cartesian, not Euler angles. And yes, plotting a line (either directly with “line” as you discovered, or “plot3” as a more general approach) represents the trajectory. Try subsampling the data for quiver plots so you don’t have so much going on, that should clear it up a bit.

Alternatively, if you want to visualize the true orientation a bit better (such as roll angle, which is difficult to communicate with a vector), you can create multiple patch objects at moments in time and the rotate command to orient them.

Sign in to comment.

Sign in to answer this question.

Opportunities for recent engineering grads.

Apply Today
## 0 Comments

Sign in to comment.