得出并将逆运动学应用于两连锁机器人臂
该示例通过使用MATLAB®和Symbolic Math Toolbox™来推导并将逆运动学应用于两连锁机器人组。
该示例象征性地定义了关节参数和最终效应器位置,计算和可视化运动和逆运动溶液,并找到系统jacobian,这对于模拟机器人组的运动很有用。金宝搏官方网站
步骤1:定义几何参数
将机器人的链路长度,关节角度和最终效应器位置定义为符号变量。
符号L_1L_2theta_1theta_2XE是的
指定机器人链路长度的值。
L1 = 1;L2 = 0.5;
步骤2:定义末端效应器的X和Y坐标
定义最终效应器的X和Y坐标作为关节角度的函数
。
XE_RHS = l_1*cos(theta_1) + l_2*cos(theta_1 + theta_2)
XE_RHS =
ye_rhs = l_1*sin(theta_1) + l_2*sin(theta_1 + theta_2)
ye_rhs =
将符号表达式转换为MATLAB函数。
xe_mlf = matlabFunction(xe_rhs,'vars',[l_1 l_2 theta_1 theta_2]);ye_mlf = matlabfunction(ye_rhs,'vars',[l_1 l_2 theta_1 theta_2]);
步骤3:计算和可视化向前运动学
向前运动学将关节角度转化为最终效应的位置:
。给定特定的联合角度值,请使用正向运动学来计算最终效应器位置。
将关节角的输入值指定为
和
。
t1_degs_row = linspace(0,90,100);t2_degs_row = linspace(-180,180,100);[tt1_degs,tt2_degs] = meshgrid(t1_degs_row,t2_degs_row);
将角度单元从学位转换为弧度。
tt1_rads = deg2rad(tt1_degs);tt2_rads = deg2rad(tt2_degs);
使用MATLAB函数计算X和Y坐标XE_MLF和ye_mlf, 分别。
X_MAT = XE_MLF(L1,L2,TT1_RADS,TT2_RADS);y_mat = ye_mlf(l1,l2,tt1_rads,tt2_rads);
使用辅助功能可视化X和Y坐标plot_xy_given_theta_2dof。
plot_xy_given_theta_2dof(tt1_degs,tt2_degs,x_mat,y_mat,(l1+l2))
第4步:查找逆运动学
逆运动学将终端效应的位置转化为关节角度:
。从正向运动学方程式找到逆运动学。
定义前向运动学方程。
Xe_eq = Xe == Xe_rhs;ye_eq = ye == ye_rhs;
解决
和
。
s = solve([xe_eq ye_eq],[theta_1 theta_2])
s =带有字段的结构:theta_1:[2x1 sym] theta_2:[2x1 sym]
结构s代表多个解决方案金宝搏官方网站
和
。显示一对解决方案金宝搏官方网站
。
简化(s.theta_1)
ans =
显示一对解决方案金宝搏官方网站
。
简化(s.theta_2)
ans =
该示例通过使用MATLAB®和Symbolic Math Toolbox™来推导并将逆运动学应用于两连锁机器人组。 该示例象征性地定义了关节参数和最终效应器位置,计算和可视化运动和逆运动溶液,并找到系统jacobian,这对于模拟机器人组的运动很有用。金宝搏官方网站
将机器人的链路长度,关节角度和最终效应器位置定义为符号变量。 指定机器人链路长度的值。 定义最终效应器的X和Y坐标作为关节角度的函数 将符号表达式转换为MATLAB函数。 向前运动学将关节角度转化为最终效应的位置: 将关节角的输入值指定为 将角度单元从学位转换为弧度。 使用MATLAB函数计算X和Y坐标 使用辅助功能可视化X和Y坐标 逆运动学将终端效应的位置转化为关节角度: 定义前向运动学方程。 解决 结构
显示一对解决方案金宝搏官方网站
步骤1:定义几何参数
符号
L1 = 1;L2 = 0.5;
步骤2:定义末端效应器的X和Y坐标
XE_RHS = l_1*cos(theta_1) + l_2*cos(theta_1 + theta_2)
XE_RHS =
ye_rhs = l_1*sin(theta_1) + l_2*sin(theta_1 + theta_2)
ye_rhs =
xe_mlf = matlabFunction(xe_rhs,
步骤3:计算和可视化向前运动学
t1_degs_row = linspace(0,90,100);t2_degs_row = linspace(-180,180,100);[tt1_degs,tt2_degs] = meshgrid(t1_degs_row,t2_degs_row);
tt1_rads = deg2rad(tt1_degs);tt2_rads = deg2rad(tt2_degs);
X_MAT = XE_MLF(L1,L2,TT1_RADS,TT2_RADS);y_mat = ye_mlf(l1,l2,tt1_rads,tt2_rads);
plot_xy_given_theta_2dof(tt1_degs,tt2_degs,x_mat,y_mat,(l1+l2))
第4步:
Xe_eq = Xe == Xe_rhs;ye_eq = ye == ye_rhs;
s = solve([xe_eq ye_eq],[theta_1 theta_2])
s =
简化(s.theta_1)
ans =
简化(s.theta_2)
ans =
将解决方案转换为MATL金宝搏官方网站AB功能,您可以在以后使用。功能 使用逆运动学计算 定义X和Y坐标的网格点。 计算角度 将角度单元从弧度转换为度。 某些输入坐标,例如(x,y)=(1.5,1.5),超出了最终效应器的可触及工作空间。逆运动溶液可以生成一些需要校正的假想theta金宝搏官方网站值。更正假想的theta值。 可视化角度 系统的定义雅各比式是:
th1_mlf {1} = matlabFunction(s.theta_1(1),
步骤5:计算和可视化逆运动学
[XMAT,YMAT] = MESHGRID(0:0.01:1.5,0:0.01:1.5);
tmp_th1_mat = th1_mlf {1}(l1,l2,xmat,ymat);tmp_th2_mat = th2_mlf {1}(l1,l2,xmat,ymat);
tmp_th1_mat = rad2deg(tmp_th1_mat);tmp_th2_mat = rad2deg(tmp_th2_mat);
th1_mat = nan(size(tmp_th1_mat));th2_mat = nan(size(tmp_th2_mat));tf_mat = imag(tmp_th1_mat)== 0;th1_mat(tf_mat)= real(tmp_th1_mat(tf_mat));tf_mat = imag(tmp_th2_mat)== 0;th2_mat(tf_mat)= real(tmp_th2_mat(tf_mat));
plot_theta_given_xy_2dof(xmat,ymat,th1_mat,th2_mat)
步骤6:计算系统Jacobian
the_j = jacobian([xe_rhs ye_rhs],[theta_1 theta_2])
the_j =