2007年4月23日 星期一

第七次作業

本人4/19有上課

這次作業有用到 function dyad_draw() 而其中有用到function dyad()

function [vec, dyadata] = dyad(rho,theta,td,tdd)
%
% function [vec, th, dyadata] = dyad(rho,theta,td,tdd)
% Analyzes a dyad linkage composing a crank and a dyad.
% Inputs: rho:length of links
% theta:incling angles, deg.
% td:angular velocity, rad/s
% tdd:angular acceleration, rad/s^2
% Outputs: vec:absoute length of links
% th:angles of links, velocities & acc, deg
% dyadata:original data, in complex forms
% Example:[vec,th,dyadata] = dyad([5 10],[30 50],[2 4])
theta=theta(:); rho=rho(:);
n=length(rho);
if nargin<4, tdd="zeros(size(rho));" nargin="=" td="ones(size(rho));" td="ones(size(rho))*td;" tdd="ones(size(rho))*tdd;" td="td(:);" tdd="tdd(:);" d2g="pi/180;" tt="exp(i*theta*d2g);" pp="rho.*tt;" vv="i*td.*pp;" aa="-pp.*td.^2+i*pp.*tdd;" dyadata="[pp" vec="[abs(sum(dyadata));angle(sum(dyadata))/d2g];" x="[0;cumsum(real(data(:,1)))];" y="[0;cumsum(imag(data(:,1)))];" i="1:length(x)-1" k="1:length(rho)" x0="x(k+1);" y0="y(k+1);" vx="x0+real(data(k,2));" vy="y0+imag(data(k,2));" ax="x0+real(data(k,3));" ay="y0+imag(data(k,3));" sdata="sum(data);" ss="[real(sdata(1))" vv="[real(sdata(2))" aa="[real(sdata(3))" nargin="=" dd="1;" d="abs(dd);" ab="(B(1)+j*B(2))-(A(1)+j*A(2));" d="abs(AB);" th="angle(AB);" t="linspace(pi/2,2.5*pi,20);" cout="max(d/2,0.2)*exp(j*t');" cin="Cout/2;">0,
P=[0;Cin;Cout(1:10);D+Cout(11:20);D+Cin;D+Cout(20);Cout(1)];
else P=[Cin;0;D;D+Cin];
end
xx=real(P);
yy=imag(P);
x=xx*cos(th)-yy*sin(th)+A(1);
y=xx*sin(th)+yy*cos(th)+A(2);
line(x,y)
axis equal

p.7-1-1 

在0-5秒內 端桿之對應方位

第零秒

第一秒
第二秒
第三秒
第四秒


第五秒

p.7-1-2
第一桿之速度

第一桿之加速度
第二桿之速度


第二桿之加速度


第三桿之速度


第三桿之加速度



p.7-1-3
將過程繪製成影片
axis equal;
AXIS([-180 180 -180 160]);
dyad_draw([58,63,53],[0,0,0],[0.2,0.5,0.3],[0,0.1,0.2]);pause(5)
clf
for n=1:5
axis equal;
AXIS([-180 180 -180 160]);
dyad_draw([58,63,53],[0.2,0.5+n*0.1,0.3+n*0.2],[0.2,0.5+n*0.1,0.3+n*0.2],[0,0.1,0.2]);
pause(1)
clf
end;




第六次作業

b94611048 張志鵬
本次作業有用到課本裡的function gruebler 及 function grashof
function [df]=gruebler(nlink,jointype)
%% [df]=gruebler(nlink,jointype)
% nlink:no. of total links
% jointype:row matrix for number of joints for each type,
% the order of elements is:
% 1 R-joint 2 slider 3 compound joint(sliding & rolling)
% 4 ball 5 cylinder 6 planar 7 cylinder rolling
% 8 cam 9 helix 10 ball & 11 point contact
% Example: df=gruebler(4,[4])
% Author:D.S.Fon Bime,NTU. Date:Jan. 30, 2007
code=[1 1 2 3 2 3 1 2 1 3 5];
n=length(jointype);
dim=3;
if n>3, dim=6;
end;
ff=0;
njoint=0;
for i=1:n, njoint=njoint+jointype(i);
ff=ff+jointype(i)*code(i);
end;
df=dim*(nlink-njoint-1)+ff;

function ans=grashof(ground_no,linkage)
% Function to test the Grashof linkage
% Inputs:
% ground_no:the ground link number in the order
% linkage: row matrix for lengths of the 4 links
% in original assigned order.
% Example:ans=grashof(4,[4 4.2 2.6 2])
% Revised: March 4, 2006
ground=linkage(ground_no);
link=sort(linkage);% sorting the links
ig=find(linkage==link(1));
if link(1)+link(4)>link(3)+link(2),
ans='Non-Grashof Linkage';
elseif
link(1)+link(4)==link(3)+link(2)
ans='Neutral Linkage';
elseif link(1)==ground,
ans='Double-Crank Linkage';
else
switch ig
case 1 im=3;
case 2 im=4;
case 3 im=1;
case 4 im=2;
end

if ground==linkage(im)
ans='Double-Rocker Linkage';
else
ans='Crank-Rocker Linkage';
end
end

p.6-1-1 

機構共有十二隻桿及十五個結






p.6-1-2 
M=3*(N-J-1)+F N=12 J=15  
十二個旋轉結
一個滑動結
兩個滑槽結 
所以 F=12*1+1*1+2*2=17 M=-12+17=5 
自由度為5

p.6-1-3 

函式輸入 
gruebler(12,[12 1 2]) 
自由度為5

p.6-1-4
滑塊因與地面間的滑動特性,使系統多了一個滑動結滑槽是因其可提供滑動與轉動的自由,自由度+2

p.6-2-1 
J2,J3,J5 為球結, 自由度為3 
J1,J6 為旋轉結,自由度為1 
J5 為圓柱結,自由度為2





p.6-2-2
F=3*3+2*1+1*2 
M=6(N-J-1)+F=6(6-6-1)+13 
M=7 自由度為7

p.6-2-3 
函式輸入 
gruebler(6,[2 0 0 3 1]) 
自由度為7

p.6-2-4 
此機構是有惰性自由度,5號桿與6號桿是可以自轉的,所以機構的惰性自由度為2,
總自由度為7-2=5 
惰性自由度使系統的總自由度減少,
因為可自轉軸的自轉角度並不會影響系統之外型

p.6-3-1
葛拉索型: 
在四連桿組中,最短桿與最長桿之和小於其他兩桿之和時,則至少有一桿為可旋轉桿。
非葛拉索型: 
最短桿與最長桿之和大於其他兩桿之和時,所有的活動連桿必為搖桿

p.6-3-2 
第一組,7+4=6+5
中立連桿組
grashof(1,[7 4 6 5]) ans = Neutral Linkage

第二組中,8+3.6>5.1+4.1
非葛拉索連桿 
grashof(1,[8 3.6 5.1 4.1])
ans = Non-Grashof Linkage

第三組中,
6.6+3.1<5.4+4.7
葛拉索型 
grashof(1,[5.4 3.1 6.6 4.7])
ans = Crank-Rocker Linkage

p.6-3-3
第二組四連桿為非葛拉索型,
要將他改成葛拉索型機構的話,
可將最長桿火最短桿減短,
或是將第二和第三連桿長度增加,
達到葛拉索機構的要求。 

2007年4月11日 星期三

機動學第五次作業

p.5.1.1
%L1是上手臂的長度
%L1是下手臂的長度
%L1是手腕的長度
L1=35;
L2=30;
L3=10;
r1=L1/6;
r2=L1/12;
r3=L3/2;
r4=L2/11;
%以下是我設計的外型
arm1x=[0 r1*cosd(150)+r1 r1*cosd(120)+r1 r1 11*r2 r2*cosd(60)+11*r2 r2*cosd(30)+11*r2 r2*cosd(0)+11*r2 r2*cosd(-30)+11*r2 r2*cosd(-60)+11*r2 11*r2 r1 r1*cosd(240)+r1 r1*cosd(210)+r1 0 L1];

arm1y=[0 r1*sind(150) r1*sind(120) r1 r2 r2*sind(60) r2*sind(30) r2*sind(0) r2*sind(-30)r2*sind(-60) -r2 -r1 r1*sind(240) r1*sind(210) 0 0];

arm2x=[L1 r4*cosd(30)+L1-L2+10*L2/11 r4*cosd(60)+L1-L2+10*L2/11 L1-L2+10*L2/11 L1-L2+L2/11 r4*cosd(120)+L1-L2+L2/11 r4*cosd(150)+L1-L2+L2/11 r4*cosd(180)+L1-L2+L2/11 r4*cosd(210)+L1-L2+L2/11 r4*cosd(240)+L1-L2+L2/11 L1-L2+L2/11 L1-L2+10*L2/11 r4*cosd(-60)+L1-L2+10*L2/11 r4*cosd(-30)+L1-L2+10*L2/11 r4*cosd(0)+L1-L2+10*L2/11 L1-L2];

arm2y=[0 r4*sind(30) r4*sind(60) r4 r4 r4*sind(120) r4*sind(150) r4*sind(180) r4*sind(210) r4*sind(240) -r4 -r4 r4*sind(-60) r4*sind(-30) r4*sind(0) 0];

palmx=[L1-L2 L1-L2 L1-L2+L3 L1-L2 L1-L2 L1-L2+L3];

palmy=[0 r4 0 -r4 0 0];

axis equal
line(arm1x,arm1y);
line(arm2x,arm2y);
line(palmx,palmy);

以是是我在零度時的圖


p.5-1-2

%function body 的設計

function body(L1,L2,L3,theta1,theta2,theta3)
r1=L1/6;
r2=L1/12;
r3=L3/2;
r4=L2/11;


arm1x=[0 r1*cosd(150)+r1 r1*cosd(120)+r1 r1 11*r2 r2*cosd(60)+11*r2 r2*cosd(30)+11*r2 r2*cosd(0)+11*r2 r2*cosd(-30)+11*r2 r2*cosd(-60)+11*r2 11*r2 r1 r1*cosd(240)+r1 r1*cosd(210)+r1 0 L1];

arm1y=[0 r1*sind(150) r1*sind(120) r1 r2 r2*sind(60) r2*sind(30) r2*sind(0) r2*sind(-30) r2*sind(-60) -r2 -r1 r1*sind(240) r1*sind(210) 0 0];

arm2x=[L1 r4*cosd(30)+L1-L2+10*L2/11 r4*cosd(60)+L1-L2+10*L2/11 L1-L2+10*L2/11 L1-L2+L2/11 r4*cosd(120)+L1-L2+L2/11 r4*cosd(150)+L1-L2+L2/11 r4*cosd(180)+L1-L2+L2/11 r4*cosd(210)+L1-L2+L2/11 r4*cosd(240)+L1-L2+L2/11 L1-L2+L2/11 L1-L2+10*L2/11 r4*cosd(-60)+L1-L2+10*L2/11 r4*cosd(-30)+L1-L2+10*L2/11 r4*cosd(0)+L1-L2+10*L2/11 L1-L2];

arm2y=[0 r4*sind(30) r4*sind(60) r4 r4 r4*sind(120) r4*sind(150) r4*sind(180) r4*sind(210) r4*sind(240) -r4 -r4 r4*sind(-60) r4*sind(-30) r4*sind(0) 0];

palmx=[L1-L2 L1-L2 L1-L2+L3 L1-L2 L1-L2 L1-L2+L3];

palmy=[0 r4 0 -r4 0 0];

axis equal
line(arm1x,arm1y);
line(arm2x,arm2y);
line(palmx,palmy);
clf


%這個for loop 在這裡沒用 在第四小題才有用
for n=1:1;
axis equal
AXIS([-80 80 -70 70]);
x1=arm1x*cosd(-theta1(n))-arm1y*sind(-theta1(n));
y1=arm1x*sind(-theta1(n))+arm1y*cosd(-theta1(n));
line(x1,y1)
theta2(n)=180+theta1(n)-theta2(n);
x2=arm2x*cosd(-theta2(n))-arm2y*sind(-theta2(n))+x1(16)-(L1-L2)*cosd(-theta2(n));
y2=arm2x*sind(-theta2(n))+arm2y*cosd(-theta2(n))+y1(16)-(L1-L2)*sind(-theta2(n));
line(x2,y2)
theta3(n)=180+theta2(n)-theta3(n);
x3=palmx*cosd(-theta3(n))-palmy*sind(-theta3(n))+x2(15)-(L1-L2)*cosd(-theta3(n));
y3=palmx*sind(-theta3(n))+palmy*cosd(-theta3(n))+y2(15)-(L1-L2)*sind(-theta3(n));
line(x3,y3)
end;

p.5-1-3

將數值輸入body(35,30,10,90,-45,-30)

下面是我theta1=90 theta2=-45 theta3=-30 時的圖





p.5-1-4

L1=35;
L2=30;
L3=10;
r1=L1/6;
r2=L1/12;
r3=L3/2;
r4=L2/11;

arm1x=[0 r1*cosd(150)+r1 r1*cosd(120)+r1 r1 11*r2 r2*cosd(60)+11*r2 r2*cosd(30)+11*r2 r2*cosd(0)+11*r2 r2*cosd(-30)+11*r2 r2*cosd(-60)+11*r2 11*r2 r1 r1*cosd(240)+r1 r1*cosd(210)+r1 0 L1];
arm1y=[0 r1*sind(150) r1*sind(120) r1 r2 r2*sind(60) r2*sind(30) r2*sind(0) r2*sind(-30) r2*sind(-60) -r2 -r1 r1*sind(240) r1*sind(210) 0 0];
arm2x=[L1 r4*cosd(30)+L1-L2+10*L2/11 r4*cosd(60)+L1-L2+10*L2/11 L1-L2+10*L2/11 L1-L2+L2/11 r4*cosd(120)+L1-L2+L2/11 r4*cosd(150)+L1-L2+L2/11 r4*cosd(180)+L1-L2+L2/11 r4*cosd(210)+L1-L2+L2/11 r4*cosd(240)+L1-L2+L2/11 L1-L2+L2/11 L1-L2+10*L2/11 r4*cosd(-60)+L1-L2+10*L2/11 r4*cosd(-30)+L1-L2+10*L2/11 r4*cosd(0)+L1-L2+10*L2/11 L1-L2];
arm2y=[0 r4*sind(30) r4*sind(60) r4 r4 r4*sind(120) r4*sind(150) r4*sind(180) r4*sind(210) r4*sind(240) -r4 -r4 r4*sind(-60) r4*sind(-30) r4*sind(0) 0];
palmx=[L1-L2 L1-L2 L1-L2+L3 L1-L2 L1-L2 L1-L2+L3];
palmy=[0 r4 0 -r4 0 0];
axis equal
line(arm1x,arm1y);
line(arm2x,arm2y);
line(palmx,palmy);
clf

%將每個角度分成十份
theta1=linspace(-90,-75,10)
theta2=linspace(-45,-35,10)
theta3=linspace(-30,-10,10)
for n=1:10;
axis equal
AXIS([-70 70 -70 40]);
x1=arm1x*cosd(-theta1(n))-arm1y*sind(-theta1(n));
y1=arm1x*sind(-theta1(n))+arm1y*cosd(-theta1(n));
line(x1,y1)
theta2(n)=180+theta1(n)-theta2(n);
x2=arm2x*cosd(-theta2(n))-arm2y*sind(-theta2(n))+x1(16)-(L1-L2)*cosd(-theta2(n));
y2=arm2x*sind(-theta2(n))+arm2y*cosd(-theta2(n))+y1(16)-(L1-L2)*sind(-theta2(n));
line(x2,y2)
theta3(n)=180+theta2(n)-theta3(n);
x3=palmx*cosd(-theta3(n))-palmy*sind(-theta3(n))+x2(15)-(L1-L2)*cosd(-theta3(n));
y3=palmx*sind(-theta3(n))+palmy*cosd(-theta3(n))+y2(15)-(L1-L2)*sind(-theta3(n));
line(x3,y3)
pause(0.5)
clf
end;
這網站是我做出來的動畫
http://www.youtube.com/watch?v=ZEM30bnEnPY

p.5.2.1
手指可分為三節每一節只能旋轉90度若手腕為一桿,一端為定點,加上手指的連結點,就是有三個接點在平的角度來看,自由度總和為1+1+1=3;
p.5.2.2
%下面是手指的function 內部有用到linkshape
function finger1(P,theta1,theta2,theta3)
L3=P*(2.5/17);
L2=P*(2/17);
L1=P*(2.5/17);
f1x=[0 L1]
f1y=[0 0]
f2x=[L1 L1-L2]
f2y=[0 0]
f3x=[L1-L2 L1-L2+L3]
f3y=[0 0]
axis equal
AXIS([-10 10 -10 10])
linkshape([f1x(1) f1y(1)],[f1x(2) f1y(2)], 1)
linkshape([f2x(1) f2y(1)],[f2x(2) f2y(2)], 1)l
inkshape([f3x(1) f3y(1)],[f3x(2) f3y(2)], 1)
clfaxis equalAXIS([-8 8 -8 8])
x1=f1x*cosd(-theta1)-f1y*sind(-theta1);
y1=f1x*sind(-theta1)+f1y*cosd(-theta1);
linkshape([x1(1) y1(1)],[x1(2) y1(2)], 1)
theta2=180+theta1-theta2;
x2=f2x*cosd(-theta2)-f2y*sind(-theta2)+x1(2)-(L1-L2)*cosd(-theta2);
y2=f2x*sind(-theta2)+f2y*cosd(-theta2)+y1(2)-(L1-L2)*sind(-theta2);
linkshape([x2(1) y2(1)],[x2(2) y2(2)], 1)
theta3=180+theta2-theta3;
x3=f3x*cosd(-theta3)-f3y*sind(-theta3)+x2(1)-(L1-L2)*cosd(-theta3);
y3=f3x*sind(-theta3)+f3y*cosd(-theta3)+y2(1)-(L1-L2)*sind(-theta3);
linkshape([x3(1) y3(1)],[x3(2) y3(2)], 1)
每一根手指的極限位置
theta1=linspace(0,90,10)
theta2=linspace(150,90,10)
theta3=linspace(150,90,10)
for n=1:10
finger1(17,theta1(n),theta2(n),theta3(n))
pause(0.05)end;for n=1:10 f
inger2(17,theta1(n),theta2(n),theta3(n))
pause(0.05)
end;
for n=1:10
finger3(17,theta1(n),theta2(n),theta3(n))
pause(0.05)end;
for n=1:10
finger4(17,theta1(n),theta2(n),theta3(n))
pause(0.05)
end;





p.5-2-3
假設球的速度為A那在球離開手的那一刻
手的速度也該為A
w=vr r為手半徑 w為angular velocity
a=br a為手當時的加速度 b是angular accelerationand
v=at t是從手開始動到球離開的時間
所以 w,b 都可以求出來