Advertisement
urbmal

TSR3

Oct 28th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. clear all;
  2. clc;
  3. close all;
  4.  
  5. kp=3; ka=8; kb=-1.5;
  6. %xfinal=1;
  7. %yfinal=14;
  8. %x=5;y=5;
  9. theta=pi/15;
  10. T=0.03;
  11. figure
  12. %plot(x,y,'o'); hold on,grid on
  13. % dx=yfinal-y;
  14. %dy=xfinal-x;
  15. %
  16. % p=sqrt(dx^2+dy^2);
  17. % a=-theta+atan2(dy,dx);
  18. % b=-theta-a;
  19. %
  20. % %legea de control
  21. % v=kp*p;
  22. % w=ka*a+kb*b;
  23. %coordonate
  24. % purm = -kp*p*cos(a);
  25. % aurm = kp*sin(a)-ka*a-kb*b;
  26. % burm = -kp*sin(a);
  27. % xf=0;
  28. % yf=0;
  29. % zf=0;
  30. % xsimi = R*cos(theta) + x;
  31. % ysimi = R*cos(theta) + y;
  32. %i=0;
  33. h = findobj(gca,'Type','line')
  34. %xxx=getpos
  35. %yyy=getpos
  36. xlim([-15 15])
  37. ylim([-15 15])
  38. [xi,yi] = getpts
  39. xi';
  40. yi';
  41.  
  42. for i=1:7
  43. x= xi(i);
  44. y= yi(i);
  45. xfinal=xi(i+1);yfinal=yi(i+1);
  46. dy=yfinal-y;
  47. dx=xfinal-x;
  48.  
  49. theta=pi/15;
  50.  
  51. while abs(dx)>0.1 && abs(dx)>0.1
  52. % plot(aurm,burm,'o'); hold on
  53. dy=yfinal-y;
  54. dx=xfinal-x;
  55. p=sqrt(dx^2+dy^2)
  56. a=-theta+atan2(dy,dx)
  57. b=-theta-a
  58.  
  59. %
  60. v=kp*p
  61. w=ka*a+kb*b
  62. %
  63. x=x+T*v*cos(theta)
  64. y=y+T*v*sin(theta)
  65. theta=theta+T*w
  66.  
  67.  
  68.  
  69. %Afisare
  70. xlim([-15 15])
  71. ylim([-15 15])
  72. plot(x,y,'or'); hold on
  73. line([x x+cos(theta)],[y y+sin(theta)])
  74. pause(0.05)
  75.  
  76. end
  77.  
  78. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement