FormationControlSimulation/SOURCE/rigidityMatrixFnc.m

30 lines
1.3 KiB
Matlab
Raw Permalink Normal View History

2020-07-29 11:31:38 +07:00
function [R,K, d] = rigidityMatrixFnc (edgeL,stateLen)
2019-06-17 14:31:50 +07:00
%% Fungsi ini digunakan untuk menggenerasi fungsi rigidity R.
%% diaman fungsi tersebut adalah hasil turunan dari fungsi edge
addpath("./networks-toolbox");
pkg load symbolic
% generasi koneksi bentuk incidence
tmp = edgeL2adj(edgeL);
2019-07-10 13:34:08 +07:00
d = ones(numEdges(tmp),1);
2019-12-18 14:23:12 +07:00
printf("Jumlah Edge : %i \n", length(d));
2019-06-17 14:31:50 +07:00
gInc = adj2inc(tmp);
2019-12-18 14:23:12 +07:00
tmp = numNodes(adj2adjL(tmp));
printf("Jumlah Robot : %i \n", tmp);
2019-06-17 14:31:50 +07:00
% generasi vector error menggunakan matrix
% koneksi
% tmp = getNodes(gInc,'adjacency');
2020-07-29 11:31:38 +07:00
K = kron(adj2inc(edgeL2adj(edgeL))',eye(stateLen));
tmp = 1:(size(K,1)/stateLen);
2019-06-17 14:31:50 +07:00
edgeVector = @(x,k) k*x;
% hasil turunan dari fungsi edge
str = "errBlockDiagonal = @(errVec) (blkdiag(";
2020-07-29 11:31:38 +07:00
for i = 1:stateLen:(length(tmp)*stateLen)-stateLen
str = strcat(str,sprintf("errVec(%i:%i)', ",i,i+(stateLen-1)));
2019-06-17 14:31:50 +07:00
endfor
2020-07-29 11:31:38 +07:00
str = strcat(str,sprintf("errVec(%i:%i)' ));",i+stateLen,i+(stateLen*2 -1)));
2019-06-17 14:31:50 +07:00
% return sebagai fungsi R
eval(str); %% replicate from https://www.mathworks.com/help/matlab/ref/blkdiag.html
2019-06-17 14:31:50 +07:00
R = @(x,k) errBlockDiagonal(edgeVector(x,k))*k;
2019-07-10 13:34:08 +07:00
2019-06-17 14:31:50 +07:00
endfunction