2019-06-19 15:09:19 +07:00
|
|
|
clear -all
|
|
|
|
close all
|
|
|
|
%% conRobot = [2 1 1; 3 2 1; 3 1 1;3 4 1; 2 4 1; 5 3 1; 5 1 1;6 4 1; 6 2 1; 5 6 1];
|
|
|
|
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;];
|
|
|
|
%% conRobot = [2 1 1; 3 2 1; 3 1 1;3 4 1; 2 4 1;];
|
|
|
|
|
|
|
|
%% corRobot = [0; 0; 1; 0; 2; 2; 1; 1; -1; -1; 0; -1; ]; % xy xy xy
|
|
|
|
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
|
|
|
|
%% corRobot = [0; 0; 1; 0; 2; 2; 1; 1;]; % xy xy xy
|
|
|
|
d = 3;
|
|
|
|
%% figure(1)
|
|
|
|
[R,K] = rigidityMatrixFnc(conRobot);
|
|
|
|
vref = [-5; 5];
|
2019-06-20 14:36:48 +07:00
|
|
|
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;
|
|
|
|
];
|
2019-06-19 15:09:19 +07:00
|
|
|
kp = 2;
|
|
|
|
ki = 3;
|
|
|
|
|
|
|
|
sInit = [corRobot; zeros(size(R(corRobot,K),1),1)];
|
2019-06-20 14:36:48 +07:00
|
|
|
%% tspan = linspace(1,0.1,30);
|
|
|
|
tspan = 1:0.01:5;
|
2019-06-19 15:09:19 +07:00
|
|
|
dydt = @(t, y) systm_robot(t, y,d, R,K, kp, ki, B, vref);
|
|
|
|
|
|
|
|
[t,y] = ode45(dydt, tspan, sInit);
|
|
|
|
%% figure(2)
|
|
|
|
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);
|
2019-06-20 14:36:48 +07:00
|
|
|
|
2019-06-19 15:09:19 +07:00
|
|
|
hold on
|
2019-06-20 14:36:48 +07:00
|
|
|
str_tmp = "@(t) plot( [";
|
2019-06-19 15:09:19 +07:00
|
|
|
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("], \"^\");"));
|
2019-06-20 14:36:48 +07:00
|
|
|
plot_rb = eval(str_tmp);
|
2019-06-19 15:09:19 +07:00
|
|
|
|
|
|
|
xrb = 1:2:length(corRobot);
|
|
|
|
yrb = 2:2:length(corRobot);
|
|
|
|
|
2019-06-20 14:36:48 +07:00
|
|
|
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
|
2019-06-19 15:09:19 +07:00
|
|
|
|
2019-06-20 14:36:48 +07:00
|
|
|
plot_con(plot_rb, y', conRobot, xrb, yrb, 1);
|
|
|
|
plot_con(plot_rb, y', conRobot, xrb, yrb, length(tspan));
|
2019-06-19 15:09:19 +07:00
|
|
|
|
|
|
|
%% plot_rb(20);
|
|
|
|
%% plot_rb(40);
|
|
|
|
%% plot_rb(60);
|
|
|
|
%% plot_rb(80);
|
|
|
|
%% plot_rb(100);
|
|
|
|
|
|
|
|
|