How can I make the trajectory of robot with distance and angle values.

조회 수: 5 (최근 30일)
ABdanyia
ABdanyia 2020년 3월 4일
댓글: ABdanyia 2020년 4월 2일
Hi,
I am confusing like how to make the trajectory of my robot when I have just the distance values and angles values. It means that robot start from let suppose position zero and it travel 10 inches after that it turn 25 degree and then move 4 inches and then turn 25 degree. I have this data and I am struggling in plotting the trajectory. If any one help me in this regards is very kind of him.
Thank you
  댓글 수: 3
ABdanyia
ABdanyia 2020년 3월 4일
Hi,
Thank you for reply, So this is my distance values variable "path".
path=[0 25 45 34 12 22 13 17 48 99];
I roughly made the sketch of how it looks like
ABdanyia
ABdanyia 2020년 4월 1일
As darova helped mw with this code, so the thing i want to solved but i am unable to, the problem is the red mark which
I did is not right, the previous turn is fine because of 26 degree turn, but the other turn which i marked should not be there rather the line should move straight after 26 degree turn Can any one help me with it.
clc,clear
path=[800,50,30];
turn=[1,-1,1].*(1:length(path))
%q=(1:length(path));
angle = 26*turn;
x2 = path.*cosd(angle);
y2 = path.*sind(angle);
x = cumsum(x2);
y = cumsum(y2);
t = cumsum(path);
t1 = linspace(0,t(end),100);
x1 = interp1(t,x,t1);
y1 = interp1(t,y,t1);
plot(x,y,'or')
axis([min(x1) max(x1) min(y1) max(y1)])
hold on
for i = 1:length(x1)-1
plot(x1(i:i+1),y1(i:i+1),'.-b')
pause(0.1)
end
hold off

댓글을 달려면 로그인하십시오.

채택된 답변

darova
darova 2020년 3월 4일
I maded simple example for you
L1 = 5;
L2 = 3;
L3 = 4;
t1 = linspace(30,120,20)';
t2 = linspace(10,90,20)';
t3 = linspace(60,0,20)';
x1 = L1*cosd(t1);
y1 = L1*sind(t1);
x2 = x1 + L2*cosd(t2);
y2 = y1 + L2*sind(t2);
x3 = x2 + L3*cosd(t3);
y3 = y2 + L3*sind(t3);
for i = 1:length(t1)
plot([0 x1(i) x2(i) x3(i)],[0 y1(i) y2(i) y3(i)],'.-b')
axis([-1 1 -1 1]*10)
pause(0.1)
end
  댓글 수: 16
darova
darova 2020년 4월 2일
Please see my new improved script (attached)
ABdanyia
ABdanyia 2020년 4월 2일
Yeah it work, Thank you so much for your time really appriciated. God bless you

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Motion Planning에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by