赞
踩
机器人的参数:
Th_1 = str2double(handles.Theta_1.String)*pi/180; Th_2 = str2double(handles.Theta_2.String)*pi/180; Th_3 = str2double(handles.Theta_3.String)*pi/180;%取得输入的值 %%DH法创建机器人 L_1 = 20; L_2 = 50; L_3 = 40; L(1) = Link([0 L_1 0 pi/2]); L(2) = Link([0 0 L_2 0]); L(3) = Link([0 0 L_3 0]); Robot = SerialLink(L); Robot.name = 'S725'; Robot.plot([Th_1 Th_2 Th_3]); T = Robot.fkine([Th_1 Th_2 Th_3]);%建立矩阵 disp(T); Pos_x = T.t(1); Pos_y = T.t(2); Pos_z = T.t(3); disp(Pos_x); disp(Pos_y); disp(Pos_z); handles.X.String = num2str(floor(Pos_x)); handles.Y.String = num2str(floor(Pos_y)); handles.Z.String = num2str(floor(Pos_z));
运行结果:正运动学输入值得出空间位置坐标值:
逆运动学的回调
Pos_x = str2double(handles.X.String); Pos_y = str2double(handles.Y.String); Pos_z = str2double(handles.Z.String); %%机器人的逆运动学 L_1 = 20; L_2 = 50; L_3 = 40; L(1) = Link([0 L_1 0 pi/2]); L(2) = Link([0 0 L_2 0]); L(3) = Link([0 0 L_3 0]); robot=SerialLink([L(1) L(2) L(3)],'name','S725'); p = [1 0 0 Pos_x; 0 1 0 Pos_y; 0 0 1 Pos_z; 0 0 0 1]; mask = [1 1 1 0 0 0]; q=ikine(robot,p,'mask',mask); %ikine逆解函数,根据末端位姿p,求解出关节角q robot.plot(q);%输出机器人模型,后面的三个角为输出时的theta姿态 q_1 = q(1)*180/pi; q_2 = q(2)*180/pi; q_3 = q(3)*180/pi; % J = Robot.ikine(T,[0 0 0],[1 1 1 0 0 0])*180/pi; handles.Theta_1.String = num2str(floor(q_1)); handles.Theta_2.String = num2str(floor(q_2)); handles.Theta_3.String = num2str(floor(q_3));%回传值
逆运动学结果(逆解的结果不止一种):
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。