目录
基于matlab机器人工具箱的四足机器人DH建模
模型展示
代码
参考博客
基于matlab机器人工具箱的四足机器人DH建模
模型展示
代码
%/10/28四足机器人DH建模%碎弧的星星clc; clear;close all;%机器人结构参数L1 = 10; L2 = 20; L3 = 30;L = 50; W = 30; H = 5;%关闭注释,如手腕轴、地面阴影、关节轴、无平滑着色。plotopt = {'noraise', 'nobase', 'noshadow', 'nowrist', 'nojaxes', 'delay', 0};%单腿DH建模s = 'Rx(q1).Tz(L1).Ry(q2).Tx(L2).Ry(q3).Tx(L3)';dh = DHFactor(s);%生成一个工具箱命令字符串,用以创建一个 serialLink对象:mand('leg') ;%将serialLink对象转换成Matlab可执行语句leg = eval( mand('leg') );%设置初始关节角leg.offset=[0;pi-pi/6;+pi/3];%设置四条腿的的基座位置legs(1) = SerialLink(leg, 'name', 'leg1', 'base', transl( L/2, W/2, 0)*trotx(pi)*troty(pi/2)); legs(2) = SerialLink(leg, 'name', 'leg2', 'base', transl(-L/2, W/2, 0)*trotx(pi)*troty(pi/2));legs(3) = SerialLink(leg, 'name', 'leg3', 'base', transl( L/2, -W/2, 0)*trotx(pi)*troty(pi/2));legs(4) = SerialLink(leg, 'name', 'leg4', 'base', transl(-L/2, -W/2, 0)*trotx(pi)*troty(pi/2));%应用patch函数构建机器人身躯v = [ L/2 W/2 0; -L/2 W/2 0; -L/2 -W/2 0; L/2 -W/2 0;L/2 W/2 H; -L/2 W/2 H; -L/2 -W/2 H; L/2 -W/2 H;L/2 W/2 0; -L/2 W/2 0; -L/2 W/2 H; L/2 W/2 H;L/2 -W/2 0; -L/2 -W/2 0; -L/2 -W/2 H; L/2 -W/2 H;L/2 W/2 0; L/2 -W/2 0; L/2 -W/2 H; L/2 W/2 H;-L/2 W/2 0; -L/2 -W/2 0; -L/2 -W/2 H; -L/2 W/2 H ];f = [ 1 2 3 4 ; 5 6 7 8 ; 9 10 11 12;13 14 15 16 ; 17 18 19 20 ; 21 22 23 24 ];patch('Faces',f,'Vertices',v,'FaceColor','cyan');hold on%将所有腿显示出来%初始位置legs(1).plot([0,0,0], plotopt{:});legs(2).plot([0,0,0], plotopt{:});legs(3).plot([0,0,0], plotopt{:});legs(4).plot([0,0,0], plotopt{:});
参考博客
参考博客:四足机器人|机器狗|仿生机器人|多足机器人|MATLAB动画仿真|Simulink动画仿真_Ezekiel_Mok的博客-CSDN博客/Ezekiel_Mok/article/details/114686907