基于Simulink的机械臂逆运动学轨迹追踪

仿真平台

该机械手运动学轨迹仿真基于以下平台:

    MATLAB®2020 Simulink® Robotics System Toolbox™

路径规划

基于Simulink®平台使用刚体连杆结构建立机械手的逆运动学模型,设定机械臂运动轨迹导入仿真平台,求解机械臂各关节运动角度仿真显示。

  1. 导入机械臂刚体模型
robot = importrobot(iiwa14.urdf);
robot.DataFormat = column;
ax = show(robot);
  1. 路径规划
x = 0.5*zeros(1,4)+0.25;
y = 0.25*[-1 -1 1 1];
z = 0.25*[-1 1 -1 1] + 0.75;
hold on
plot3(x,y,z,--r,LineWidth,2,Parent,ax)
hold off
close
  1. 求解计算
open_system(sm_ik_trajectory_model.slx)
sim(sm_ik_trajectory_model.slx)
  1. 机械臂运动图像显示
figure(Visible,on);
tformIndex = 1;
for i = 1:10:numel(configs.Data)/7
currConfig = configs.Data(:,1,i);
show(robot,currConfig);
drawnow
xyz(tformIndex,:) = tform2trvec(getTransform(robot,currConfig,iiwa_link_ee));
tformIndex = tformIndex + 1;
end
  1. 运动轨迹图像显示
figure(Visible,on)
show(robot,configs.Data(:,1,end));
hold on
plot3(xyz(:,1),xyz(:,2),xyz(:,3),-k,LineWidth,3);
>> plot3(x,y,z,--r,LineWidth,3)
hold off
经验分享 程序员 微信小程序 职场和发展