matlab手眼标定
這里只羅列出可以用于手眼標(biāo)定(相機(jī)坐標(biāo)系和機(jī)械臂基坐標(biāo)系之間的變換矩陣,3X4的。我的項(xiàng)目是eye to hand,所以得到的結(jié)果對(duì)于eye in hand怎么用還不太清楚)
原文鏈接:http://math.loyola.edu/~mili/Calibration/index.html
分為三種情況:
第一種:
你只想用幾對(duì)同源點(diǎn)的空間三維位置坐標(biāo)作為輸入數(shù)據(jù),得到變換矩陣。
方法1:論文:K.S. Arun, T.S. Huang, S.D. Blostein, Least-squares fitting of two 3-d point sets, IEEE Trans. Pattern Anal. Mach. Intell. 9 (5) (1987) 698-700
matlab代碼:
function [R,t] = arun(A,B) % Registers two sets of 3DoF data % Assumes A and B are d,n sets of data % where d is the dimension of the system % typically d = 2,3 % and n is the number of points % typically n>3 % % Mili Shah % July 2014[d,n]=size(A);%Mean Center Data Ac = mean(A')'; Bc = mean(B')'; A = A-repmat(Ac,1,n); B = B-repmat(Bc,1,n);%Calculate Optimal Rotation [u,s,v]=svd(A*B'); R = v*u'; if det(R)<0, disp('Warning: R is a reflection'); end%Calculate Optimal Translation t = Bc - R*Ac;方法2:論文:B.K.P. Horn, H.M. Hilden, S. Negahdaripour, Closed-form solution of absolute orientation using orthonormal matrices, J. Opt. Soc. Am. A 5 (1988) 1127-1135
代碼:
function [R,t] = horn(A,B) % Registers two sets of 3DoF data % Assumes A and B are d,n sets of data % where d is the dimension of the system % typically d = 2,3 % and n is the number of points % typically n>3 % % Mili Shah % July 2014[d,n]=size(A);%Mean Center Data Ac = mean(A')'; Bc = mean(B')'; A = A-repmat(Ac,1,n); B = B-repmat(Bc,1,n);%Calculate Optimal Rotation M = B*A'; R = M*(M'*M)^(-1/2); if det(R)<0, disp('Warning: R is a reflection'); end%Calculate Optimal Translation t = Bc - R*Ac; end方法3:
- B.K.P. Horn, Closed-form solution of absolute orientation using unit quaternions, J. Opt. Soc. Am. A 4 (1987) 629-642.
方法4:M.W. Walker, L. Shao, R.A. Volz, Estimating 3-d location parameters using dual number quaternions, CVGIP: Image Underst. 54 (3) (1991) 358-367.
function [R,t] = walker(A,B) % Registers two sets of 3DoF data % Assumes A and B are 3,n sets of data % and n is the number of points % typically n>3 % % Mili Shah % July 2014[d,n]=size(A);C1 = zeros(4,4); C2 = n*eye(4); C3 = zeros(4,4); for i = 1:nC1 = C1 + -2*Q([1/2*B(:,i);0])'*W([1/2*A(:,i);0]);C3 = C3 + 2*(W([1/2*A(:,i);0])-Q([1/2*B(:,i);0])); end A = 1/2*(C3'*inv(C2+C2')*C3-C1-C1'); [u,v]=eig(A); [m,ind]=max(diag(v)); r = u(:,ind); s = -inv(C2+C2')*C3*r; R = (r(4)^2-r(1:3)'*r(1:3))*eye(3) + 2*r(1:3)*r(1:3)'+2*r(4)*[0 -r(3) r(2);r(3) 0 -r(1);-r(2) r(1) 0]; t = W(r)'*s*2; t = t(1:3); endfunction Q = Q(r) K = [0 -r(3) r(2);r(3) 0 -r(1);-r(2) r(1) 0]; Q = [r(4)*eye(3)+K r(1:3);-r(1:3)' r(4)]; end function W = W(r) K = [0 -r(3) r(2);r(3) 0 -r(1);-r(2) r(1) 0]; W = [r(4)*eye(3)-K r(1:3);-r(1:3)' r(4)]; end方法5:S. Umeyama, Least-squares estimation of transformation parameters between two point patterns, IEEE Trans. Pattern Anal. Mach. Intell. 13 (4) (1991) 376- 380.
?
function [R,t] = umeyama(A,B) % Registers two sets of 3DoF data % Assumes A and B are d,n sets of data % where d is the dimension of the system % typically d = 2,3 % and n is the number of points % typically n>3 % % Mili Shah % July 2014[d,n]=size(A);%Mean Center Data Ac = mean(A')'; Bc = mean(B')'; A = A-repmat(Ac,1,n); B = B-repmat(Bc,1,n);%Calculate Optimal Rotation [u,s,v]=svd(A*B'); R = v*diag([1 1 det(v*u')])*u';%Calculate Optimal Translation t = Bc - R*Ac;第二種情況:輸入的數(shù)據(jù)為位置和姿態(tài),解方程AX=XB
方法1:
- Y. Shiu, S. Ahmad Calibration of Wrist-Mounted Robotic Sensors by Solving Homogeneous Transform Equations of the Form AX = XB. In IEEE Transactions on Robotics and Automation, 5(1):16-29, 1989.
方法2:
- R. Tsai, R. Lenz A New Technique for Fully Autonomous and Efficient 3D Robotics Hand/Eye Calibration. In IEEE Transactions on Robotics and Automation, 5(3):345-358, 1989.
?
function X = tsai(A,B) % Calculates the least squares solution of % AX = XB % % A New Technique for Fully Autonomous % and Efficient 3D Robotics Hand/Eye Calibration % Lenz Tsai % % Mili Shah % July 2014[m,n] = size(A); n = n/4; S = zeros(3*n,3); v = zeros(3*n,1); %Calculate best rotation R for i = 1:nA1 = logm(A(1:3,4*i-3:4*i-1)); B1 = logm(B(1:3,4*i-3:4*i-1));a = [A1(3,2) A1(1,3) A1(2,1)]'; a = a/norm(a);b = [B1(3,2) B1(1,3) B1(2,1)]'; b = b/norm(b);S(3*i-2:3*i,:) = skew(a+b);v(3*i-2:3*i,:) = a-b; end x = S\v; theta = 2*atan(norm(x)); x = x/norm(x); R = (eye(3)*cos(theta) + sin(theta)*skew(x) + (1-cos(theta))*x*x')'; %Calculate best translation t C = zeros(3*n,3); d = zeros(3*n,1); I = eye(3); for i = 1:nC(3*i-2:3*i,:) = I - A(1:3,4*i-3:4*i-1);d(3*i-2:3*i,:) = A(1:3,4*i)-R*B(1:3,4*i); end t = C\d; %Put everything together to form X X = [R t;0 0 0 1];方法3:
- C. Wang Extrinsic Calibration of a Vision Sensor Mounted on a Robot. In IEEE Transactions on Robotics and Automation, 8(2): 161-175, 1992.
方法4:
- R. Liang, J. Mao Hand-Eye Calibration with a New Linear Decomposition Algorithm. In Journal of Zhejiang University, 9(10):1363-1368, 2008.
?
function [X]=liang(AA,BB) % Solves the problem AX=XB % using the formulation of % % Hand-Eye Calibration with a % New Linear Decomposition Algorithm % R. Liang, J. Mao % % Mili Shah % July 2014[m,n]=size(AA); n = n/4;A = zeros(9*n,9); b = zeros(9*n,1); for i = 1:nRa = AA(1:3,4*i-3:4*i-1);Rb = BB(1:3,4*i-3:4*i-1);A(9*i-8:9*i,:) = [kron(Ra,eye(3))+kron(-eye(3),Rb')]; end [u,s,v]=svd(A); x = v(:,end); R=reshape(x(1:9),3,3)'; R = sign(det(R))/abs(det(R))^(1/3)*R; [u,s,v]=svd(R); R = u*v'; if det(R)<0, R = u*diag([1 1 -1])*v'; end C = zeros(3*n,3); d = zeros(3*n,1); I = eye(3); for i = 1:nC(3*i-2:3*i,:) = I - AA(1:3,4*i-3:4*i-1);d(3*i-2:3*i,:) = AA(1:3,4*i)-R*BB(1:3,4*i); end t = C\d; %Put everything together to form X X = [R t;0 0 0 1];?第三種情況:輸入數(shù)據(jù)為位置和姿態(tài),求解方程AX=YB
方法1:
- A. Li, L. Wang, D. Wu Simultaneous robot-world and hand-eye calibration using dual-quaternions and kronecker product. InInternational Journal of the Physical Sciences, 5(10): 1530-1536, 1995.
?
function [X,Y]=li(AA,BB) % Solves the problem AX=YB % using the formulation of % % Simultaneous robot-world and hand-eye calibration % using dual-quaternions and Kronecker product % % Aiguo Li, Lin Wang and Defeng Wu % % Mili Shah % July 2014[m,n]=size(AA); n = n/4;A = zeros(12*n,24); b = zeros(12*n,1); for i = 1:nRa = AA(1:3,4*i-3:4*i-1);Rb = BB(1:3,4*i-3:4*i-1);ta = AA(1:3,4*i);tb = BB(1:3,4*i);A(12*i-11:12*i-3,1:18) = [kron(Ra,eye(3)) kron(-eye(3),Rb')];A(12*i-2:12*i,10:24) = [kron(eye(3),tb') -Ra eye(3)];b(12*i-2:12*i) = ta; end x = A\b;X=reshape(x(1:9),3,3)'; [u,s,v]=svd(X); X = u*v'; if det(X)<0, X = u*diag([1 1 -1])*v'; end X = [X x(19:21);[0 0 0 1]]; Y=reshape(x(10:18),3,3)'; [u,s,v]=svd(Y); Y = u*v'; if det(Y)<0, Y = u*diag([1 1 -1])*v'; end Y = [Y x(22:24);[0 0 0 1]];方法2:
- M. Shah, Solving the Robot-World/Hand-Eye Calibration Problem Using the Kronecker Product, ASME Journal of Mechanisms and Robotics, Volume 5, Issue 3 (2013).
?
總結(jié)
以上是生活随笔為你收集整理的matlab手眼标定的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: matpower在matlab里面吗,m
- 下一篇: 用于微信小程序的图文编辑器