机器人关节图的绘图位置不起作用

机器人关节图的绘图位置不起作用

本文介绍了机器人关节图的绘图位置不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一个命令来显示机器人位置方程及其图形。这是我的命令,但它没有显示图表:

I want to write a command to display equation of robot position and its graph. This is my command, but it did not display the graph:

clear;
clc;

% initial position
theta1s=-150;
theta2s=-80;
theta3s=-50;
theta4s=-100;
theta5s=-180;

% final position
theta1f=20;
theta2f=100;
theta3f=80;
theta4f=50;
theta5f=180;

% time taken for movement
tf=input('time=')

% acceleration for every link
acc1=(4.*(20-(-150)))./(tf^2)
acc2=(4.*(100-(-80)))./(tf^2)
acc3=(4.*(80-(-50)))./(tf^2)
acc4=(4.*(50-(-100)))./(tf^2)
acc5=(4.*(180-(-180)))./(tf^2)

% blending time for every link
tb1=((0.5.*(tf))-(0.5.*(sqrt((((tf^2).*acc1)-(4.*(20-(-150))))./acc1))))
t = 0;
for x = 0:tf;
    t = t + 0.1;
    if 0<t<=tb1;
        y = theta1s+((0.5.*acc1).*(t^2));
    elseif tb1<t<=tf-tb1;
        y = (theta1s-((0.5.*acc1).*(tb1^2)))+(acc1.*tb1.*t);
    else tf-tb1<t<=tf;
        y = theta1s-((0.5.*acc1).*(tf.*t)^2);
    end

    plot(x,y,'r')
    title('Position Versus Time');
    xlabel('time in s');
    ylabel('position in m');
    grid on;
    drawnow;
end

disp(y);


推荐答案

您可以将plot(x,y,'r ')通过绘图(x,y,'r *')。所以,你将能够看到sepparate点。
您还需要在绘图函数之后添加hold on以便能够覆盖所有迭代的图。

You can replace plot(x,y,'r') by plot(x,y,'r*'). So, you will be able to see sepparate points.Also you will need to add "hold on" after plot function to be able to overlay plots for all iterations.

如果要绘制线但不能sepparate points,你应该更好地将可视化移出循环。这里是修改过的代码:

If you want to draw line but not sepparate points, you should better move the visualization out of the loop. Here is the modified code:

clear;
clc;

% initial position
theta1s=-150;
theta2s=-80;
theta3s=-50;
theta4s=-100;
theta5s=-180;

% final position
theta1f=20;
theta2f=100;
theta3f=80;
theta4f=50;
theta5f=180;

% time taken for movement
tf=input('time=')

% acceleration for every link
acc1=(4.*(20-(-150)))./(tf^2)
acc2=(4.*(100-(-80)))./(tf^2)
acc3=(4.*(80-(-50)))./(tf^2)
acc4=(4.*(50-(-100)))./(tf^2)
acc5=(4.*(180-(-180)))./(tf^2)

% blending time for every link
tb1=((0.5.*(tf))-(0.5.*(sqrt((((tf^2).*acc1)-(4.*(20-(-150))))./acc1))))
t = 0;

% allocate memory for array
y = zeros(1, tf+1);

for x = 0:tf;
    t = t + 0.1;
    if 0<t<=tb1;
        y(x+1) = theta1s+((0.5.*acc1).*(t^2));
    elseif tb1<t<=tf-tb1;
        y(x+1) = (theta1s-((0.5.*acc1).*(tb1^2)))+(acc1.*tb1.*t);
    else tf-tb1<t<=tf;
        y(x+1) = theta1s-((0.5.*acc1).*(tf.*t)^2);
    end
end

plot(0:tf,y,'r')
title('Position Versus Time');
xlabel('time in s');
ylabel('position in m');
grid on;
drawnow;

disp(y);

这篇关于机器人关节图的绘图位置不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 01:49