平面机械臂运动学分析
- [一 整体概述](#一 整体概述)
- [二 正向](#二 正向)
- [三 逆向](#三 逆向)
一 整体概述
研究步骤:
1 正向:根据所读取的关节处角度
,立刻计算出末端坐标,可随时计算得出当前末端坐标值,方便用于计算。
2 逆向:根据末端坐标
,计算出各
关节角度
的值,已知终点坐标,计算出各关节角度写入,以到达指定位置。
3 规划路径曲线点,设置曲线路径,使各关节移动丝滑,稳定、快速的到达指定位置。
4 误差补偿,通过PID等算法,补偿摩擦力重力等环境因素带来的影响,优化精度。
二 正向
1 简介:根据已知角度
与杆长
,计算得出机械臂末端位置的位置
变化,角度可由传感器采集。
2 效果:输入各个关节的角度值,可以计算出机械臂末端执行器的位置和姿态。
3 几何分析 :
4 计算方法
5 matlab 模拟测试

matlab测试代码:
matlab
function forward_direction
%----------------------1 初始参数设置---------------------------
l1=50; l2=50; l3=50; %已知信息:臂长
degree1 = deg2rad(0);%各关节角度
degree2 = deg2rad(0);
degree3 = deg2rad(0);
%求出4个点坐标
bx = l1*sin(degree1); % B点坐标,A为(0,0)
by = l1*cos(degree1);
cx = bx+l2*sin(degree1+degree2);% C点坐标
cy = by+l2*cos(degree1+degree2);
dx = cx+l3*sin(degree1+degree2+degree3);% D点坐标
dy = cy+l3*cos(degree1+degree2+degree3);
%-----------------------2初始图像设置---------------------------
x = linspace(0, 150, 1500); % X轴范围包含所有分段
y = zeros(size(x)); % 初始化Y数组
figure('Position', [0 0 600 600]);
axe = axes('Position', [0.1 0.3 0.8 0.6]);
sport_plot = plot(x,y,'.', 'LineWidth', 2);
update();%计算初始参数点,设置分段函数
set(sport_plot, 'YData', y);
axis('equal',[0 200 -150 150]); % 设置坐标轴范围 [x1,x2],[y1,y2]
title('正向运动学分析'); % 标题
xlabel('X坐标'); % x轴标签
ylabel('Y坐标'); % y轴标签
grid on; % 显示网格
%-------------------------3 更新参数点,设置分段函数----------------
function [] =update()
bx = l1*sin(degree1); % B点坐标,A为(0,0)
by = l1*cos(degree1);
cx = bx+l2*sin(degree1+degree2);% C点坐标
cy = by+l2*cos(degree1+degree2);
dx = cx+l3*sin(degree1+degree2+degree3);% D点坐标
dy = cy+l3*cos(degree1+degree2+degree3);
y = zeros(size(x));
%x = linspace(0, dx, 1500);
idx1 = (x >= 0 ) & (x <= bx);
idx2 = (x >= bx) & (x <=cx);
idx3 = (x >= cx) & (x <=dx);
idx4 = x >dx;
y(idx1) = tan(pi/2-degree1)*x(idx1); % 注意使用 .^
y(idx2) = tan(pi/2-degree1-degree2)*(x(idx2)-bx)+by; % 线性计算
y(idx3) = tan(pi/2-degree1-degree2-degree3)*(x(idx3)-cx)+cy;
y(idx4) = 999;
title(axe, ['末端坐标(x,y)=(', num2str(dx), ',', num2str(dy), ')']);
end
%--------------------------4 滑块-----------------------------------------
% 添加degree1滑块
uicontrol('Style', 'slider', ...
'Position', [190 110 200 20], ...
'Min', 0, 'Max', 180, 'Value', degree1, ...
'Callback', @updatedegree1);
uicontrol('Style', 'text', ...
'Position', [140 110 42 15], ...
'String', 'degree1');
% 回调函数1
function updatedegree1(hObj, ~)
tem = hObj.Value;
degree1=deg2rad(hObj.Value);%更新角度
update();
set(sport_plot, 'YData', y);
uicontrol('Style','text','String',num2str(tem),'Position',[400 110 40 15]);
end
% 添加degree2滑块
uicontrol('Style', 'slider', ...
'Position', [190 60 200 20], ...
'Min', 0, 'Max', 180, 'Value', degree2, ...
'Callback', @updatedegree2);
uicontrol('Style', 'text', ...
'Position', [140 60 42 15], ...
'String', 'degree2');
% 回调函数1
function updatedegree2(hObj, ~)
tem = hObj.Value;
degree2=deg2rad(hObj.Value);%更新角度
update();
set(sport_plot, 'YData', y);
uicontrol('Style','text','String',num2str(tem),'Position',[400 60 40 15]);
end
% 添加degree3滑块
uicontrol('Style', 'slider', ...
'Position', [190 13 200 20], ...
'Min', 0, 'Max', 180, 'Value', degree3, ...
'Callback', @updatedegree3);
uicontrol('Style', 'text', ...
'Position', [140 13 42 15], ...
'String', 'degree3');
% 回调函数1
function updatedegree3(hObj, ~)
tem = hObj.Value;
degree3=deg2rad(hObj.Value);%更新角度
update();
set(sport_plot, 'YData', y);
uicontrol('Style','text','String',num2str(tem),'Position',[400 13 40 15]);
end
%------------------------------5 文本框输入------------------------------
uicontrol('Style', 'text', ...
'Position', [450 430 100 20], ...
'String', 'set 1:');
uicontrol('Style', 'edit', ...
'Position', [450 400 100 30], ...
'String', '0', ...
'Callback', @setdegree1);
% 定义回调函数
function setdegree1(src, ~)
% 获取输入值
input_str = get(src, 'String');
input_num = str2double(input_str);
% 验证输入
if isnan(input_num)
errordlg('请输入有效数字!', '输入错误');
return;
end
% 更新全局变量
degree1 = deg2rad(input_num);
update();
set(sport_plot, 'YData', y);
end
uicontrol('Style', 'text', ...
'Position', [450 370 100 20], ...
'String', 'set 2:');
uicontrol('Style', 'edit', ...
'Position', [450 340 100 30], ...
'String', '0', ...
'Callback', @setdegree2);
% 定义回调函数
function setdegree2(src, ~)
% 获取输入值
input_str = get(src, 'String');
input_num = str2double(input_str);
% 验证输入
if isnan(input_num)
errordlg('请输入有效数字!', '输入错误');
return;
end
% 更新全局变量
degree2 = deg2rad(input_num);
update();
set(sport_plot, 'YData', y);
end
uicontrol('Style', 'text', ...
'Position', [450 310 100 20], ...
'String', 'set 3:');
uicontrol('Style', 'edit', ...
'Position', [450 280 100 30], ...
'String', '0', ...
'Callback', @setdegree3);
% 定义回调函数
function setdegree3(src, ~)
% 获取输入值
input_str = get(src, 'String');
input_num = str2double(input_str);
% 验证输入
if isnan(input_num)
errordlg('请输入有效数字!', '输入错误');
return;
end
% 更新全局变量
degree3 = deg2rad(input_num);
update();
set(sport_plot, 'YData', y);
end
end
几何法正向分析比较简单,且此处仅以二维为例
三 逆向
(待补充)