FormationControlSimulation/SOURCE/rigidityMatrixFnc.m

29 lines
1.2 KiB
Matlab
Raw Normal View History

2019-07-10 13:34:08 +07:00
function [R,K, d] = rigidityMatrixFnc (edgeL)
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
2019-12-18 14:23:12 +07:00
tmp = getNodes(gInc,'adjacency');
2019-06-17 14:31:50 +07:00
K = kron(adj2inc(edgeL2adj(edgeL))',eye(2));
edgeVector = @(x,k) k*x;
% hasil turunan dari fungsi edge
str = "errBlockDiagonal = @(errVec) (blkdiag(";
for i = 1:2:(length(tmp)*2)-2
str = strcat(str,sprintf("errVec(%i:%i)', ",i,i+1));
endfor
str = strcat(str,sprintf("errVec(%i:%i)' ));",i+2,i+3));
% 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