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

4 visualizzazioni (ultimi 30 giorni)
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 Commenti
ABdanyia
ABdanyia il 4 Mar 2020
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 il 1 Apr 2020
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

Accedi per commentare.

Risposta accettata

darova
darova il 4 Mar 2020
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 Commenti
ABdanyia
ABdanyia il 2 Apr 2020
Yeah it work, Thank you so much for your time really appriciated. God bless you

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by