Commit ccc7b784 authored by Sylvain Calinon's avatar Sylvain Calinon

Update of damping ratio test

parent 2d33bc80
......@@ -30,7 +30,7 @@ model.nbFrames = 2; %Number of candidate frames of reference
model.nbVar = 3; %Dimension of the datapoints in the dataset (here: t,x1,x2)
model.dt = 0.01; %Time step
model.kP = 100; %Stiffness gain
model.kV = (2*model.kP)^.5; %Damping gain
model.kV = (2*model.kP)^.5; %Damping gain (with ideal underdamped damping ratio)
nbRepros = 8; %Number of reproductions with new situations randomly generated
%% Load 3rd order tensor data
......
......@@ -30,7 +30,7 @@ rFactor = 1E-1; %Weighting term for the minimization of control commands in LQR
disp('Reproductions with LQR...');
DataIn = [1:nbData] * model.dt;
a.currTar = ones(1,nbData);
a.currSigma = ones(1,1,nbData)/rFactor; %-> LQR with cost X'X + u'u
a.currSigma = ones(1,1,nbData); %/rFactor; %-> LQR with cost X'X + u'u
for n=1:nbRepros
%r(n) = reproduction_LQR_finiteHorizon(DataIn, model, a, 0, rFactor);
r(n) = reproduction_LQR_infiniteHorizon(DataIn, model, a, 0, rFactor);
......@@ -64,11 +64,12 @@ xlabel('t'); ylabel('kp');
%Plot stiffness/damping ratio (equals to optimal control ratio 1/2^.5)
subplot(1,3,3); hold on;
for n=1:nbRepros
plot(DataIn, r(n).kpDet./r(n).kvDet, 'k-', 'linewidth', 2);
%Ideal damping ratio of 1/2^.5 = 0.7071, corresponding to r(n).kvDet(1) = (2*r(n).kpDet(1))^.5
dampingRatio = r(n).kvDet(:) ./ (2*r(n).kpDet(:).^.5);
plot(DataIn, dampingRatio, 'k-', 'linewidth', 2);
end
xlabel('t'); ylabel('kp/kv');
xlabel('t'); ylabel('kv / 2 kp^{0.5}');
r(n).kpDet(1)/r(n).kvDet(1) %equals to optimal control ratio 1/2^.5 = 0.7071
pause;
close all;
%pause;
%close all;
......@@ -90,7 +90,7 @@ for t=1:nbData
r.Data(:,t) = [DataIn(:,t); x];
r.ddxNorm(t) = norm(ddx);
r.kpDet(t) = det(L(:,1:nbVarOut,t));
r.kvDet(t) = det(L(:,nbVarOut+1:end,t));
r.kvDet(t) = det(L(:,nbVarOut+1:end,t));
end
......
......@@ -78,7 +78,7 @@ for t=1:nbData
r.ddxNorm(t) = norm(ddx);
r.kpDet(t) = det(L(:,1:nbVarOut));
r.kvDet(t) = det(L(:,nbVarOut+1:end));
%Note that if [V,D] = eigs(L(:,1:nbVarOut)), we have L(:,nbVarOut+1:end) = V * (2*D).^.5 * V'
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment