Pages

Wednesday, April 21, 2010

Theo Jansen Mechanism Matlab Code


As promised, here is some of the Matlab code for the Theo Jansen Mechanism we posted a video of a little while back. We begin every Matlab program with the clear all command. Next are the lengths for all of the linkages.

clear all

%Link Lengths

L1=286;

L2=120;

L3=400;

L4=275;

L5=400;

L6=290;

L7=275;

L8=275;

L9=400;

L10=290;

L11=400;

L12=275;

L13=170;


 

%To get the video output:

a=1;

mov=avifile('TheoJansen.avi','COMPRESSION','None');

for theta=0:pi/20:8*pi


 

%Relating all values to theta2 of 4-bar mechanism O2ABO1

theta2=pi-theta;

ssquared=(L2)^2+(L1)^2-(2*L1*L2*cos(theta2));

s=sqrt(ssquared);

beta=asin((L2*sin(theta2))/s);

psi=acos(((L3^2)+(s^2)-(L4^2))/(2*L3*s));

lambda=acos((L4^2+s^2-L3^2)/(2*L4*s));

theta3=pi-psi+beta;

theta4=pi+beta+lambda;

theta5=lambda+beta;


 

%Finding the points relative to the motion of theta2

O1=[0,0];

O2=[-L1,0];

A=[L2*cos(theta) L2*sin(theta)];

B=[A(1)-L3*cos(psi-beta) A(2)+L3*sin(psi-beta)];


 


%Plotting the 4-bar mechanism


plot ([O1(1),A(1)],[O1(2),A(2)],'r','linewidth',3)

hold on

plot ([O2(1),O1(1)],[O2(2),O1(2)],'black','linewidth',3)

plot ([A(1),B(1)],[A(2),B(2)],'g','linewidth',3)

plot ([O2(1),B(1)],[O2(2),B(2)],'r','linewidth',3)

%Bottom triangle DEF

F=[E(1)-L12*cos(lambda+beta) E(2)-L12*sin(lambda+beta)];


 

plot([D(1),F(1)],[D(2),F(2)],'linewidth',3)

plot([E(1),F(1)],[E(2),F(2)],'linewidth',3)


 


%Link FG


G=[F(1)-L13*cos(lambda+beta) F(2)-L13*sin(lambda+beta)];


 


%Trajectory of point G


plot([F(1),G(1)],[F(2),G(2)],'linewidth',3)

Gx(a)=G(1);

Gy(a)=G(2);

plot(Gx,Gy)


 

axis([-800 400 -800 400])

hold off

a=a+1;

pause(.1)

M=getframe;

mov=addframe(mov,M);

end

mov=close(mov);


 

I left out a portion in the middle so you'll just have to figure that out by yourself!


 




Bookmark and Share

Thursday, April 8, 2010

Looking for Guest Bloggers

Are you interested in guest blogging? Do you have CAD experience or an interesting project to share? Want to get recognition and build links to your own blog or website? Leave your name and email in the comment field and I will contact you about writing an article for this blog!

Monday, March 22, 2010

CATSettings Pointers for CATIA Users


I'm starting to realize deleting the CATSettings fixes a whole bunch of strange issue in CATIA.
 
Recently had this problem in CATIA NC workbench:  cannot pick the start/stop points in Multi-Axis Curve Machining.  This only happens with his log-in on his computer; using his log-in on another computer works fine.  The points, in the machining operation window (where you pick other driving geometry) are shown as solid black dots.  Is this a Tools -> Options issue?  Un/Re-installing CATIA doesn't fix this either. V5R18SP7.  Everything else (as far as we can see) works fine.  Any ideas?

CATSetttings is probably the biggest quirk in CATIA V5. I made a screenshot of all my Tools/Options and anytime we go to another revision I recreate my CATSettings. Like many other people, I learned the hard way. Anytime something is acting strangely it usually ends up being the CATSettings.


A few other CATSettings pointers on this. Do not use the same settings folder for multiple versions (R18/R19), keep a back up copy of a clean start - they will get corrupt from time to time. When unpredictable things happen - example your picking issue, replace your settings with clean set. Re-installing Catia does not clean up your setttings directory. You can find your directory in C:\Documents and Settings\USER NAME\Application Data\DassaultSystemes.
In there I would create CATSettingsR18 and CATSettingsR19, to do this you need to modify in the Environment Editor the path in variable CATUserSettingsPath.

Wednesday, March 10, 2010

Theo Jansen Mechanism drawn in Matlab

For one on my classes this quarter we had to draw the Theo Jansen 12 bar mechanism in Matlab. To do this we had to calculate each angle based on the input angle which in the video is the red link connected to the black base link. This took over 100 lines of code in Matlab which took forever to figure out but in the end it was worth it. There will be more projects to come in the future. Feel free to comment if you have any questions or want to see my .m file for this!

Monday, March 8, 2010

Update on CATIA Train Model

I promise to do a complete "How to" later on, seeing as how this is the CAD Systems Help blog and I don't think I've done much to help other than show off my own work. Here is my progress after about 8 hours of work on the Locomotive 020T Decauville CATIA model, which I uploaded to my 3D Via page. What do you think?