function obj = formationControl2ndBuilder(param) addpath("./networks-toolbox"); edgeL = param.edgeL; model = param.model.origin; kp1 = param.kp1; kp2 = param.kp2; ki1 = param.ki1; ki2 = param.ki2; dScale = param.dScale; nNodeVref = param.nNodeVref; obj = struct(); robStateLen = size(model.syscl.A,1) [obj.R, obj.K, obj.d] = rigidityMatrixFnc(edgeL,robStateLen); obj.m = length(obj.d); obj.n = numNodes(edgeL); obj.nodeStateLength = robStateLen*obj.n; obj.stateLength = 3 * obj.nodeStateLength + obj.m; % build matrix sistem obj.A1 = @(st) [zeros(obj.nodeStateLength), eye(obj.nodeStateLength), zeros(obj.nodeStateLength), zeros(obj.nodeStateLength,obj.m)]; obj.A2 = @(st) [-kp2*obj.R(st(1:(obj.nodeStateLength)),obj.K)'*obj.R(st(1:(obj.nodeStateLength)),obj.K), -kp1*eye(obj.nodeStateLength), -eye(obj.nodeStateLength), -obj.R(st(1:(obj.nodeStateLength)),obj.K)']; obj.A3 = @(st) [zeros(obj.nodeStateLength), ki1*eye(obj.nodeStateLength), zeros(obj.nodeStateLength), zeros(obj.nodeStateLength,obj.m)]; obj.A4 = @(st) [ki2*obj.R(st(1:(obj.nodeStateLength)),obj.K), zeros(obj.m,obj.nodeStateLength), zeros(obj.m,obj.nodeStateLength), zeros(obj.m)]; obj.A = @(st) [obj.A1(st); obj.A2(st); obj.A3(st); obj.A4(st)]; obj.sizeA = size(obj.A(ones(obj.stateLength,1))); % build matrix input obj.B = @(st) [zeros(obj.nodeStateLength,obj.m); kp2*obj.R(st(1:(obj.nodeStateLength)),obj.K)'; zeros(obj.nodeStateLength,obj.m); -ki2*eye(obj.m,obj.m)] obj.sizeB = size(obj.B(ones(obj.stateLength,1))); %build state space obj.Kb = zeros(obj.n*3,1); obj.Kb(obj.n+nNodeVref) = 1; obj.Kb = [kron(obj.Kb,eye(robStateLen)); zeros(obj.m,robStateLen)]; obj.d = obj.d*dScale; obj.dss = @(st,h,vRef) (eye(obj.sizeA) + (obj.A(st)*h))*st + (obj.B(st)*h)*obj.d + (obj.Kb*h)*vRef; obj.ss = @(st,vRef) obj.A(st)*st + obj.B(st)*obj.d + obj.Kb*vRef; printf("============== Formation Control ============ \n"); printf(" state model : %i \n", obj.nodeStateLength); printf(" Node : %i \n", obj.n); printf(" Edge : %i \n", obj.m); printf("Dimention State : %i \n", obj.stateLength); printf(" Dimention A : %i x %i \n", obj.sizeA); printf(" Dimention B : %i x %i \n", obj.sizeB); printf("============================================= \n"); endfunction