
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
How can I make the trajectory of robot with distance and angle values.
조회 수: 5 (최근 30일)
이전 댓글 표시
ABdanyia
2020년 3월 4일
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
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
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
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
ABdanyia
2020년 3월 4일
why this code gives error in my matlab 2015a.
Error using are (line 21)
Nonsquare A matrix
ABdanyia
2020년 3월 4일
Here is this are function.
function X = are(A,B,C)
%ARE Algebraic Riccati Equation solution.
%
% X = ARE(A, B, C) returns the stablizing solution (if it
% exists) to the continuous-time Riccati equation:
%
% A'*X + X*A - X*B*X + C = 0
%
% assuming B is symmetric and nonnegative definite and C is
% symmetric.
%
% See also RIC, CARE, DARE.
% M. Wette, ECE Dept., Univ. of California 5-11-87
% Revised 6-16-87 MW
% 3-16-88 MW
% Copyright 1986-2002 The MathWorks, Inc.
% -- check for correct input problem --
[nr,nc] = size(A); n = nr;
if (nr ~= nc), error('Nonsquare A matrix'); end;
[nr,nc] = size(B);
if (nr~=n | nc~=n), error('Incorrectly dimensioned B matrix'); end;
[nr,nc] = size(C);
if (nr~=n | nc~=n), error('Incorrectly dimensioned C matrix'); end;
% Following is much faster than before
[q,t] = schur([A -B; -C -A']);
[q,t] = rsf2csf(q,t);
tol = 10.0*eps*max(abs(diag(t))); % ad hoc tolerance
ns = 0;
%
% Prepare an array called index to send message to ordering routine
% giving location of eigenvalues with respect to the imaginary axis.
% -1 denotes open left-half-plane
% 1 denotes open right-half-plane
% 0 denotes within tol of imaginary axis
%
index = [];
for i = 1:2*n,
if (real(t(i,i)) < -tol),
index = [ index -1 ];
ns = ns + 1;
elseif (real(t(i,i)) > tol),
index = [ index 1 ];
else,
index = [ index 0 ];
end;
end;
if (ns ~= n), error('No solution: (A,B) may be uncontrollable or no solution exists'); end;
[q,t] = schord(q,t,index);
X = real(q(n+1:n+n,1:n)/q(1:n,1:n));
ABdanyia
2020년 3월 4일
Well I dont know about this are function. Now instead of are , it work when putting sind function.
ABdanyia
2020년 3월 4일
HI,
I try something with that. I am thinking to make the triangle with the distance and angle and find the points with that, so in this way plotting the hypotenuse, I find the triangular sides and then connect these points. Thats what I am trying to do in this code but could not able to plot successfully. :-(
path=[0 25 45 34 12 22 13 17 48 99];
angle=25;
x=zeros(1,length(path));
y=zeros(1,length(path));
for i=2:length(path)
x(i)=(path(i)*sind(angle))+path(i-1);
y(i)= path(i);
end
figure
for i=1:length(k);
plot([x(i),y(i)],'-o')
pause(1)
hold on
drawnow
end
darova
2020년 3월 5일
Can you explain what do these lines mean?
path=[0 25 45 34 12 22 13 17 48 99];
angle=25;
ABdanyia
2020년 3월 5일
This path is the distances, So let me explain this , path array contains the number of distance robot move before rotate with an angle of 25. Angle 25 is fixed. SO the robot start from initial point having distance zero at first, the robot move 25 mili meter distance after that robot rotate at an angle of 25, then the sensor started again for distance then robot move 45 mili meter of distance and then rotate 25 degree. So path is just a sample array this array of path may contain upto 100 values. My robot is an obstacle avoidence robot and it contain distance sensor it gives value untill the object come or the robot rotate at an angle of 25.
darova
2020년 3월 5일
Ok. I understand
clc,clear
path=[0 25 45 34 12 22 13 17 48 99];
angle = 25*(1:length(path));
x = path.*cosd(angle);
y = path.*sind(angle);
x = cumsum(x);
y = cumsum(y);
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
ABdanyia
2020년 4월 1일
Hi,
Sorry to disturb you again, Now I am runing this code according to my scenerio, now i have a problem is that sometimes is gave 25 degree but sometimes not also i have to move robot in both direction means that for left the angle is 25 degree and for right it should be -25 degree, so now i am facing this problem, i am also done by multiplying some values with negative but it does not show right graph. i f anyone help me in this regard, i will be grateful.
Thank you
darova
2020년 4월 1일
Add this line
angle = 25*(1:length(path));
angle([1 3 5]) = -25; % indices of array you want to be negative (-25)
ABdanyia
2020년 4월 1일
Hi,
Thank you for your reply, i done the changes and run it, the problem is now the black highlighted part not
giving the 25 degree.

clc,clear
path=[80,50,30,35];
angle = 25*(1:length(path));
angle([1 3]) = -25;
%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)])
%axis([-100 1000 -100 1000])
hold on
for i = 1:length(x1)-1
plot(x1(i:i+1),y1(i:i+1),'.-b')
pause(0.1)
end
hold off
ABdanyia
2020년 4월 2일
Yeah it work, Thank you so much for your time really appriciated. God bless you
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Motion Planning에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)

