petercorke / robotics-toolbox-matlab

Robotics Toolbox for MATLAB
GNU Lesser General Public License v2.1
1.26k stars 440 forks source link

RTB10.4(MATLAB2020a)-Define a desired end-effector pose is not work?Old version RTB is work very well. #96

Open CJ56 opened 3 years ago

CJ56 commented 3 years ago

%first file:gluon6l3_drawCircle.m clear,clc,close all; %% %用standard建立机械人DH参数,姿态为竖直 L(1) = Link('d',105.03,'a',0,'alpha',pi/2,'standard'); L(2) = Link('d',0,'a',-174.42,'alpha',0,'offset',-pi/2,'standard'); L(3) = Link('d',0,'a',-174.42,'alpha',0,'standard'); L(4) = Link('d',75.66,'a',0,'alpha',pi/2,'offset',-pi/2,'standard');
L(5) = Link('d',80.09,'a',0,'alpha',-pi/2,'standard'); L(6) = Link('d',44.36,'a',0,'alpha',0,'standard'); gluon6l3 = SerialLink(L,'name','gluon_6l3','manufacturer','innfos');

%% %定义圆心,半径及插补次数 mm = 1; n = [0 0 1]; r =80mm; c = [200 200 100]mm; step = 60; P= drawing_circle(n,r,c,step);

%% ikInitGuess=[0 0 0 0 0 0]; for i=1:length(P) T1(:,:,i)= transl(P(i,:))*rpy2tr([0,0,pi],'xyz');%Define a desired end-effector pose config= gluon6l3.ikunc(T1(:,:,i),ikInitGuess); ikInitGuess=config; qrt(i,:)=config; end

%% W = [-800,+800,-800,+800,-800,+800]; gluon6l3.plot(qrt,'tilesize',150,'workspace',W);%显示三维动画

%second_file:drawing_circle.m function T = drawing_circle(n,r,c,step) %%example1 %n=[0 0 1]; %法向量n %r=150; %圆的半径为 %c=[200 400 150]; %圆心的坐标 %step = 2500;%插补的次数

theta=(0:2*pi/step:2*pi)'; %theta角从0到2*pi
a=cross(n,[1 0 0]); %n与i叉乘,求取a向量
if ~any(a) %如果a为零向量,将n与j叉乘
    a=cross(n,[0 1 0]);
end
b=cross(n,a); %求取b向量
a=a/norm(a); %单位化a向量
b=b/norm(b); %单位化b向量

c1=c(1)*ones(size(theta,1),1);
c2=c(2)*ones(size(theta,1),1);
c3=c(3)*ones(size(theta,1),1);

x=c1+r*a(1)*cos(theta)+r*b(1)*sin(theta);%圆上各点的x坐标
y=c2+r*a(2)*cos(theta)+r*b(2)*sin(theta);%圆上各点的y坐标
z=c3+r*a(3)*cos(theta)+r*b(3)*sin(theta);%圆上各点的z坐标

points = [x y z];
T = points;

end