六轴可视化机械臂仿真(三维模型导入matlab)
代码如下
clear,clc,close all
L(1) = Link( 'd', 0.122, 'a' , 0 , 'alpha', pi/2,'offset',0);
L(2) = Link( 'd', 0.019 , 'a' ,0.408 , 'alpha', 0,'offset',pi/2);
L(3) = Link( 'd', 0 , 'a' , 0.3759 , 'alpha',0,'offset',0);
L(4) = Link( 'd', 0.1023, 'a' , 0 , 'alpha', -pi/2 ,'offset',pi/2);
L(5) = Link( 'd', -0.1023 , 'a' , 0 , 'alpha',pi/2,'offset',pi);
L(6) = Link( 'd', -0.25281 , 'a' , 0 , 'alpha',0,'offset',0);
robot = SerialLink(L,'name','六轴机械臂'); %建立连杆机器
robot.display;
%定义圆弧轨迹
x=-0.75;y=-0.25;z=0;%中心点
r=0.28;%
q1=-50*(pi/180);q2=60*(pi/180);
i=q1:(q2-q1)/50:q2;
y1=x+r*sin(i);
x1=ones(1,51)*y;
z1=z+r*cos(i);
hold on
plot3(x1,y1,z1)
for i=1:length(x1)
T(:,:,i)=transl([x1(i),y1(i),z1(i)])*trotx(-(50-i)*(pi/300));
end
q=robot.ikunc(T);
plot3(x1,y1,z1)
% robot.plot(q)
%% 绘制末端位置与运动仿真
% w=[-1000,+700,-700,+700,0,+1000]*0.001;'workspace',w,
plot3(x1,y1,z1)
hold on
% view(120,20)
robot.plot3d(q,'tilesize',0.1,'view',[120,20],'path',...
'E:\Project tasks_unfinished2\机械臂stl文件\','nowrist')
hold on
plot3(x1,y1,z1)
axis equal
完整代码+stl模型见付费链接、或者仿真源代码下载可联系扣扣2386317960