Vector animation to resolve mechanism motion defects.

1 visualizzazione (ultimi 30 giorni)
I am creating a program that is able to find the dimensions of a 6-bar rigid-link mechanism where all joints are revolute joints. (Examples of four-bar revolute joint mechanisms: https://upload.wikimedia.org/wikipedia/commons/thumb/5/5f/Linkage_four_bar_fixed.svg/750px-Linkage_four_bar_fixed.svg.png).
The dimensional analysis section of the code is working, and returns the 6 lengths and angles of the different links in the mechanism as vectors. I am then able to plot those vectors in the prescribed positions to verify its accuracy. However, one ongoing problem I am having is that frequently the motion between certain positions is impossible because a certain link is too long or too short. I am hoping to visualize these types of issues by animating the motion of the vectors relative to each other, but I have not been able to figure out how to preserve the relationships between the links (based on revolute joints, they must go tip of one vector to tail of the next one) while the links are moving. Does anyone have matlab animation tips for this type of situation?
The current plotting code is shown below, where the W, Z and V terms are vectors, and alpha, beta, and gamma are all rotation angles.
text = sprintf('Solution Dyads');
figure('Position', [10 50 800 600], 'Name', text,'NumberTitle', 'off');
hold on;
axis equal;
grid on;
title('4PP Watt One Linkage Solution Colored Links');
h=axis;
scale=(h(2)-h(1))/10;
i=sqrt(-1);
for j = 1: 4
%Triad
%Plot WA
quiver(real(OAT),imag(OAT),real(W1T*(exp(alphaT(j)*1i))), imag(W1T *(exp(alphaT(j)*1i))),1, 'Color', 'r','LineWidth',2);
%Plot V1
quiver(real(OAT+W1T*(exp(alphaT(j)*1i))), imag(OAT+W1T*(exp(alphaT(j)*1i))),real(V1T*(exp(betaT(j)*1i))), imag(V1T*(exp(betaT(j)*1i))),1, 'Color', 'b','LineWidth',2);
%Plot Z1
quiver(real(OAT+W1T*(exp(alphaT(j)*1i))+V1T*(exp(betaT(j)*1i))), imag(OAT+W1T*(exp(alphaT(j)*1i))+V1T*(exp(betaT(j)*1i))),real(Z1T*(exp(gammaT(j)*1i))), imag(Z1T*(exp(gammaT(j)*1i))),1, 'Color', 'c','LineWidth',2);
%Dyad 2
%Plot WA
quiver(real(OAD2),imag(OAD2),real(W1D2*(exp(1i*betaD2(j)))), imag(W1D2 *(exp(1i*betaD2(j)))),1, 'Color', 'r','LineWidth',2);
%Plot ZA
quiver(real(OAD2+W1D2*(exp(betaD2(j)*1i))), imag(OAD2+W1D2*(exp(betaD2(j)*1i))),real(Z1D2*(exp(alphaD2(j)*1i))), imag(Z1D2*(exp(alphaD2(j)*1i))),1, 'Color', 'k','LineWidth',2);
%Dyad 3
%Plot WA
quiver(real(OAD3),imag(OAD3),real(W1D3*(exp(betaD3(j)*1i))), imag(W1D3 *(exp(betaD3(j)*1i))),1, 'Color', 'm','LineWidth',2);
%Plot ZA
quiver(real(OAD3+W1D3*(exp(betaD3(j)*1i))), imag(OAD3+W1D3*(exp(betaD3(j)*1i))),real(Z1D3*(exp(alphaD3(j)*1i))), imag(Z1D3*(exp(alphaD3(j)*1i))),1, 'Color', 'b','LineWidth',2);
%Close Ternary Links
plot([real(OAT+W1T*(exp(alphaT(j)*1i))), real(OAD3+W1D3*(exp(betaD3(j)*1i)))],[imag(OAT+W1T*(exp(alphaT(j)*1i))),imag(OAD3+W1D3*(exp(betaD3(j)*1i)))],'b','LineWidth',2);
plot([real(OAT+W1T*(exp(alphaT(j)*1i))), real(OAD2+W1D2*(exp(betaD2(j)*1i)))],[imag(OAT+W1T*(exp(alphaT(j)*1i))),imag(OAD2+W1D2*(exp(betaD2(j)*1i)))],'r','LineWidth',2);
end
quiver(real(pps(1)),imag(pps(1)),1,0,scale,'ok');
quiver(real(pps(1))+real(delta(2)),imag(pps(1))+imag(delta(2)),real(exp(gamma(2)*1i)),imag(exp(gamma(2)*1i)),scale,'ok');
quiver(real(pps(1))+real(delta(3)),imag(pps(1))+imag(delta(3)),real(exp(gamma(3)*1i)),imag(exp(gamma(3)*1i)),scale,'ok');
quiver(real(pps(1))+real(delta(4)),imag(pps(1))+imag(delta(4)),real(exp(gamma(4)*1i)),imag(exp(gamma(4)*1i)),scale,'ok');
axis equal;
hold off;

Risposta accettata

Ayush
Ayush il 29 Ago 2023
It is my understanding that you would like to animate your 6-bar rigid-link mechanism where all joints are revolute joints. You want your visualisation of the same to animate the vectors resulted by the dimensional analysis.
A possible workaround for this can be to use the “animatedline” function to animate the links with respect to each other.You can refer to the below documentation to know more about the “animatedline” function:
Here are the steps that you can follow:
  • Define the link lengths and rotation angles between these lengths (this would be part of your dimensional analysis).
  • In case of animation parameters, from the code provided you are making a 4-frame animation.
  • After creating the figure and the axis, you would need to first initialise the “animatedline” object for each of the link as shown in the following code snippet.
% Initialize animated lines for each link
links = gobjects(1, 6);
for i = 1:6
links(i) = animatedline('LineWidth', 2);
end
  • In the for loop define the x and y coordinates for each link of your plot using the real“ and “imag” functions respectively for each iteration as you have done earlier. You can refer to the below documentation to know more about the “real” and “imag” function:
  • Replace the quiver function with the for loop which traverses 6-link animatedline objects and animate them using “clearpoints” and “addpoints”. You can refer to the below documentation to know more about the “clearpoints” and “addpoints” function:
  • Add a pause function to visualise your animation
Some assumptions that I have taken:
  • Vectors W, Z and V are the link lengths that would be used to derive the x and y coordinates on the plot along with rotational angles alpha, beta and gamma.
  • You are aiming for a 4-frame animation based on your initial provided for loop length suggesting the vectors are of length 4
  • The x and y coordinates are joint and correlated such as the tip of one vector should go to the tail of the other based on your calculations as seen in the above code where x1 would then join x2 with an added rotational angle.
Hope it helps,
Regards,
Ayush Misra

Più risposte (0)

Categorie

Scopri di più su Animation in Help Center e File Exchange

Prodotti


Release

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by