2024-12-16 14:09:04 +00:00
|
|
|
gearRatio = [100,100,120,100,100,80,50,100,1/(0.012/(2*pi))];
|
|
|
|
|
motorConstant = [0.21*2.5,0.21*2.5,0.128,0.119,0.094,0.094,0.094,0.099,0.031];
|
|
|
|
|
sensorDir = [-1,1,-1,-1,-1,1,-1,1,1];
|
2024-12-17 13:44:56 +00:00
|
|
|
% load("D:\1833128421\123同步文件夹\R1000-GC-Data\lab12.mat");
|
2024-12-16 14:09:04 +00:00
|
|
|
posDir = [1,1,1,1,1,1,1,-1,1];
|
|
|
|
|
|
|
|
|
|
% J9 traj
|
2024-12-17 13:44:56 +00:00
|
|
|
for i=6
|
2024-12-16 14:09:04 +00:00
|
|
|
fileData=eval(strcat('fileData', num2str(i)));
|
|
|
|
|
data = fileData.data;
|
|
|
|
|
dataLength = length(data);
|
|
|
|
|
figure(i)
|
|
|
|
|
d1Length = floor(length(data) / 2);
|
|
|
|
|
% Hack: change J8 dir
|
|
|
|
|
%data(:,8+1+11) = -data(:,8+1+11);
|
2024-12-17 13:44:56 +00:00
|
|
|
if i==2
|
|
|
|
|
plot3(data(1:d1Length,i+1+11),data(1:d1Length,6+1+11),data(1:d1Length,i+1+11*2)*gearRatio(i)*motorConstant(i),'r'); hold on;
|
|
|
|
|
plot3(data(d1Length:end,i+1+11),data(d1Length:end,6+1+11),data(d1Length:end,i+1+11*2)*gearRatio(i)*motorConstant(i),'b'); hold on;
|
|
|
|
|
plot3(data(:,i+1+11),data(:,6+1+11),data(:,(6*(i+1))+11*3)*sensorDir(i),'m'); hold on;
|
|
|
|
|
else
|
|
|
|
|
plot3(data(1:d1Length,i+1+11),data(1:d1Length,i+11),data(1:d1Length,i+1+11*2)*gearRatio(i)*motorConstant(i),'r'); hold on;
|
|
|
|
|
plot3(data(d1Length:end,i+1+11),data(d1Length:end,i+11),data(d1Length:end,i+1+11*2)*gearRatio(i)*motorConstant(i),'b'); hold on;
|
|
|
|
|
plot3(data(:,i+1+11),data(:,i+11),data(:,(6*(i+1))+11*3)*sensorDir(i),'m'); hold on;
|
|
|
|
|
end
|
2024-12-16 14:09:04 +00:00
|
|
|
hold off;
|
2024-12-17 13:44:56 +00:00
|
|
|
title(['J' num2str(i) ' Gravity Model']);
|
|
|
|
|
xlabel('X Pos/rad');ylabel('Y Pos/rad');zlabel('Torque /Nm')
|
2024-12-16 14:09:04 +00:00
|
|
|
end
|
|
|
|
|
%%
|
|
|
|
|
% should run identifcation program firstly
|
|
|
|
|
resolution = 20;
|
|
|
|
|
tau_estimate=[];
|
2024-12-17 13:44:56 +00:00
|
|
|
for k=6
|
|
|
|
|
if k ==2
|
|
|
|
|
qx = idntfcnTrjctry(k).q(k,:);
|
|
|
|
|
qy = idntfcnTrjctry(k).q(6,:);
|
|
|
|
|
else
|
|
|
|
|
qx = idntfcnTrjctry(k).q(k,:);
|
|
|
|
|
qy = idntfcnTrjctry(k).q(k-1,:);
|
|
|
|
|
end
|
2024-12-16 14:09:04 +00:00
|
|
|
[X, Y] = meshgrid(linspace(min(qx), max(qx), resolution), linspace(min(qy), max(qy), resolution));
|
|
|
|
|
q = mean(idntfcnTrjctry(k).q,2);qd=zeros(9,1);qdd=zeros(9,1);
|
|
|
|
|
for i = 1 : length(X)
|
|
|
|
|
for j = 1 : length(Y)
|
|
|
|
|
q(k) = X(i,j);q(k-1) = Y(i,j);
|
|
|
|
|
base_regressor_func = sprintf('base_regressor_%s',opt.robotName);
|
|
|
|
|
Yb = feval(base_regressor_func,q,qd,qdd,robot.baseQR);
|
|
|
|
|
torque=Yb*robot.sol.pib_MLS;
|
|
|
|
|
tau_estimate(i,j)=torque(k);
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
hold on;
|
|
|
|
|
mesh(X,Y,tau_estimate,tau_estimate, 'FaceAlpha', 0.0)
|
|
|
|
|
|