129 lines
2.7 KiB
Matlab
129 lines
2.7 KiB
Matlab
clear -all
|
|
close all
|
|
conRobot = [1 2 1;
|
|
1 4 1;
|
|
1 5 1;
|
|
1 6 1;
|
|
2 3 1;
|
|
2 4 1;
|
|
3 4 1;
|
|
4 5 1;
|
|
5 6 1;
|
|
5 2 1;
|
|
%% 6 3 1;
|
|
%% 6 4 1;
|
|
%% 6 2 1;
|
|
%% 3 1 1;
|
|
%% 3 5 1;
|
|
];
|
|
dRobot = [ 1;
|
|
1;
|
|
1;
|
|
1;
|
|
1;
|
|
1;
|
|
1;
|
|
1;
|
|
1;
|
|
1;
|
|
%% 1;
|
|
%% 2;
|
|
%% 2;
|
|
%% 2;
|
|
%% 2;
|
|
%% 2;
|
|
];
|
|
corRobot = [2; 2.5;
|
|
2.7; 2.6;
|
|
3; 2.3;
|
|
2.5; 1.5;
|
|
1.8; 1.5;
|
|
1.5; 2;
|
|
]; % xy xy xy
|
|
%% figure(1)
|
|
[R,K,d] = rigidityMatrixFnc(conRobot);
|
|
vref = [-5; 5];
|
|
B = [
|
|
1 0; 0 1;
|
|
0 0; 0 0;
|
|
0 0; 0 0;
|
|
0 0; 0 0;
|
|
0 0; 0 0;
|
|
0 0; 0 0;
|
|
];
|
|
kp = 10;
|
|
ki = 3;
|
|
_zero = zeros(size(R(corRobot,K),1),1);
|
|
sInit = [corRobot; _zero;];
|
|
sAnsInit =[_zero; _zero;];
|
|
%% tspan = linspace(1,0.1,30);
|
|
tspan = 1:0.01:10;
|
|
dydt = @(t, y) systm_robot(t, y,(dRobot*6), R,K, kp, ki, B, vref);
|
|
[t,y] = ode45(dydt, tspan, sInit);
|
|
|
|
cntr = 1;
|
|
bypassCntr = @(c) cntr;
|
|
plusPlusCntr = @(c) cntr++;
|
|
|
|
dyansdt = @(t, yin) systm_anlys_robot(t, yin, y(:,1:(2*numNodes(edgeL2adj(conRobot)))) ,bypassCntr, plusPlusCntr ,(dRobot*6), R, K, kp, ki, B, vref);
|
|
[t,yans] = ode45(dyansdt, tspan, sAnsInit);
|
|
|
|
ddYans = zeros(size(yans,1),1);
|
|
for i = 1:size(yans,1)
|
|
ddYans(i) = norm(yans(i,1:(size(yans,2)/2)));
|
|
endfor
|
|
|
|
figure(1)
|
|
|
|
str_tmp = "plot(";
|
|
for i = 1:length(corRobot)-1
|
|
str_tmp = strcat(str_tmp,sprintf("y'(%i,:),",i));
|
|
endfor
|
|
str_tmp = strcat(str_tmp,sprintf("y'(%i,:));",i+1));
|
|
eval(str_tmp);
|
|
|
|
hold on
|
|
str_tmp = "@(t) plot( [";
|
|
for i = 1:2:length(corRobot)
|
|
str_tmp = strcat( str_tmp, sprintf("y'(%i,t), ",i));
|
|
endfor
|
|
str_tmp = strcat( str_tmp, sprintf("], ["));
|
|
for i = 2:2:length(corRobot)
|
|
str_tmp = strcat( str_tmp, sprintf("y'(%i,t), ",i));
|
|
endfor
|
|
str_tmp = strcat( str_tmp, sprintf("], \"^\");"));
|
|
plot_rb = eval(str_tmp);
|
|
|
|
xrb = 1:2:length(corRobot);
|
|
yrb = 2:2:length(corRobot);
|
|
|
|
function plot_con (pltRb, yOut, conIn,xm,ym, time)
|
|
pltRb(time);
|
|
for i = 1:length(conIn)
|
|
plot([yOut(xm(conIn(i, 1)),time), yOut(xm(conIn(i, 2)),time)],
|
|
[yOut(ym(conIn(i,1)),time), yOut(ym(conIn(i,2)),time)], "r" )
|
|
endfor
|
|
endfunction
|
|
|
|
plot_con(plot_rb, y', conRobot, xrb, yrb, 1);
|
|
plot_con(plot_rb, y', conRobot, xrb, yrb, length(tspan));
|
|
|
|
|
|
str_tmp = "legend(";
|
|
for i = 1:numNodes(edgeL2adjL(conRobot))-1;
|
|
str_tmp =strcat(str_tmp,sprintf("\"Robot %i \", ",i));
|
|
endfor
|
|
str_tmp =strcat(str_tmp,sprintf("\"Robot %i \" )",++i));
|
|
eval(str_tmp)
|
|
|
|
figure(2)
|
|
plot([1:length(ddYans)],ddYans )
|
|
|
|
%% plot_rb(20);
|
|
%% plot_rb(40);
|
|
%% plot_rb(60);
|
|
%% plot_rb(80);
|
|
%% plot_rb(100);
|
|
|
|
|