• 【无人机】四轴无人机的轨迹进行可视化和动画处理(Matlab代码实现)


     📋📋📋本文目录如下:⛳️⛳️⛳️

    目录

    1 概述

    2 运行结果

    3 参考文献

    4 Matlab代码实现


    1 概述

    随着传感器检测技术、智能控制技术和材料技术的快速发展,四轴无人机及其配套系统的发展越来越成熟。无人机遥感系统具有成本低、易维护、效率高、时效性强及对环境要求低等特点。

    2 运行结果

     

    部分代码:

    1. function animation = drone_Animation(x,y,z,roll,pitch,yaw)
    2. % This Animation code is for QuadCopter. Written by Jitendra Singh
    3. %% Define design parameters
    4. D2R = pi/180;
    5. R2D = 180/pi;
    6. b = 0.6; % the length of total square cover by whole body of quadcopter in meter
    7. a = b/3; % the legth of small square base of quadcopter(b/4)
    8. H = 0.06; % hight of drone in Z direction (4cm)
    9. H_m = H+H/2; % hight of motor in z direction (5 cm)
    10. r_p = b/4; % radius of propeller
    11. %% Conversions
    12. ro = 45*D2R; % angle by which rotate the base of quadcopter
    13. Ri = [cos(ro) -sin(ro) 0;
    14. sin(ro) cos(ro) 0;
    15. 0 0 1]; % rotation matrix to rotate the coordinates of base
    16. base_co = [-a/2 a/2 a/2 -a/2; % Coordinates of Base
    17. -a/2 -a/2 a/2 a/2;
    18. 0 0 0 0];
    19. base = Ri*base_co; % rotate base Coordinates by 45 degree
    20. to = linspace(0, 2*pi);
    21. xp = r_p*cos(to);
    22. yp = r_p*sin(to);
    23. zp = zeros(1,length(to));
    24. %% Define Figure plot
    25. fig1 = figure('pos', [0 50 800 600]);
    26. hg = gca;
    27. view(68,53);
    28. grid on;
    29. axis equal;
    30. xlim([-1.5 1.5]); ylim([-1.5 1.5]); zlim([0 3.5]);
    31. title('(JITENDRA) Drone Animation')
    32. xlabel('X[m]');
    33. ylabel('Y[m]');
    34. zlabel('Z[m]');
    35. hold(gca, 'on');
    36. %% Design Different parts
    37. % design the base square
    38. drone(1) = patch([base(1,:)],[base(2,:)],[base(3,:)],'r');
    39. drone(2) = patch([base(1,:)],[base(2,:)],[base(3,:)+H],'r');
    40. alpha(drone(1:2),0.7);
    41. % design 2 parpendiculer legs of quadcopter
    42. [xcylinder ycylinder zcylinder] = cylinder([H/2 H/2]);
    43. drone(3) = surface(b*zcylinder-b/2,ycylinder,xcylinder+H/2,'facecolor','b');
    44. drone(4) = surface(ycylinder,b*zcylinder-b/2,xcylinder+H/2,'facecolor','b') ;
    45. alpha(drone(3:4),0.6);
    46. % design 4 cylindrical motors
    47. drone(5) = surface(xcylinder+b/2,ycylinder,H_m*zcylinder+H/2,'facecolor','r');
    48. drone(6) = surface(xcylinder-b/2,ycylinder,H_m*zcylinder+H/2,'facecolor','r');
    49. drone(7) = surface(xcylinder,ycylinder+b/2,H_m*zcylinder+H/2,'facecolor','r');
    50. drone(8) = surface(xcylinder,ycylinder-b/2,H_m*zcylinder+H/2,'facecolor','r');
    51. alpha(drone(5:8),0.7);
    52. % design 4 propellers
    53. drone(9) = patch(xp+b/2,yp,zp+(H_m+H/2),'c','LineWidth',0.5);
    54. drone(10) = patch(xp-b/2,yp,zp+(H_m+H/2),'c','LineWidth',0.5);
    55. drone(11) = patch(xp,yp+b/2,zp+(H_m+H/2),'p','LineWidth',0.5);
    56. drone(12) = patch(xp,yp-b/2,zp+(H_m+H/2),'p','LineWidth',0.5);
    57. alpha(drone(9:12),0.3);
    58. %% create a group object and parent surface
    59. combinedobject = hgtransform('parent',hg );
    60. set(drone,'parent',combinedobject)
    61. % drawnow
    62. for i = 1:length(x)
    63. ba = plot3(x(1:i),y(1:i),z(1:i), 'b:','LineWidth',1.5);
    64. translation = makehgtform('translate',...
    65. [x(i) y(i) z(i)]);
    66. %set(combinedobject, 'matrix',translation);
    67. rotation1 = makehgtform('xrotate',(pi/180)*(roll(i)));
    68. rotation2 = makehgtform('yrotate',(pi/180)*(pitch(i)));
    69. rotation3 = makehgtform('zrotate',yaw(i));
    70. %scaling = makehgtform('scale',1-i/20);
    71. set(combinedobject,'matrix',...
    72. translation*rotation3*rotation2*rotation1);
    73. %movieVector(i) = getframe(fig1);
    74. %delete(b);
    75. drawnow
    76. % pause(0.2);
    77. end

    function animation = drone_Animation(x,y,z,roll,pitch,yaw)
    % This Animation code is for QuadCopter. Written by Jitendra Singh 

    %% Define design parameters
    D2R = pi/180;
    R2D = 180/pi;
    b   = 0.6;   % the length of total square cover by whole body of quadcopter in meter
    a   = b/3;   % the legth of small square base of quadcopter(b/4)
    H   = 0.06;  % hight of drone in Z direction (4cm)
    H_m = H+H/2; % hight of motor in z direction (5 cm)
    r_p = b/4;   % radius of propeller
    %% Conversions
    ro = 45*D2R;                   % angle by which rotate the base of quadcopter
    Ri = [cos(ro) -sin(ro) 0;
          sin(ro) cos(ro)  0;
           0       0       1];     % rotation matrix to rotate the coordinates of base 
    base_co = [-a/2  a/2 a/2 -a/2; % Coordinates of Base 
               -a/2 -a/2 a/2 a/2;
                 0    0   0   0];
    base = Ri*base_co;             % rotate base Coordinates by 45 degree 

    to = linspace(0, 2*pi);
    xp = r_p*cos(to);
    yp = r_p*sin(to);
    zp = zeros(1,length(to));
    %% Define Figure plot
     fig1 = figure('pos', [0 50 800 600]);
     hg   = gca;
     view(68,53);
     grid on;
     axis equal;
     xlim([-1.5 1.5]); ylim([-1.5 1.5]); zlim([0 3.5]);
     title('(JITENDRA) Drone Animation')
     xlabel('X[m]');
     ylabel('Y[m]');
     zlabel('Z[m]');
     hold(gca, 'on');
     
    %% Design Different parts
    % design the base square
     drone(1) = patch([base(1,:)],[base(2,:)],[base(3,:)],'r');
     drone(2) = patch([base(1,:)],[base(2,:)],[base(3,:)+H],'r');
     alpha(drone(1:2),0.7);
    % design 2 parpendiculer legs of quadcopter 
     [xcylinder ycylinder zcylinder] = cylinder([H/2 H/2]);
     drone(3) =  surface(b*zcylinder-b/2,ycylinder,xcylinder+H/2,'facecolor','b');
     drone(4) =  surface(ycylinder,b*zcylinder-b/2,xcylinder+H/2,'facecolor','b') ; 
     alpha(drone(3:4),0.6);
    % design 4 cylindrical motors 
     drone(5) = surface(xcylinder+b/2,ycylinder,H_m*zcylinder+H/2,'facecolor','r');
     drone(6) = surface(xcylinder-b/2,ycylinder,H_m*zcylinder+H/2,'facecolor','r');
     drone(7) = surface(xcylinder,ycylinder+b/2,H_m*zcylinder+H/2,'facecolor','r');
     drone(8) = surface(xcylinder,ycylinder-b/2,H_m*zcylinder+H/2,'facecolor','r');
     alpha(drone(5:8),0.7);
    % design 4 propellers
     drone(9)  = patch(xp+b/2,yp,zp+(H_m+H/2),'c','LineWidth',0.5);
     drone(10) = patch(xp-b/2,yp,zp+(H_m+H/2),'c','LineWidth',0.5);
     drone(11) = patch(xp,yp+b/2,zp+(H_m+H/2),'p','LineWidth',0.5);
     drone(12) = patch(xp,yp-b/2,zp+(H_m+H/2),'p','LineWidth',0.5);
     alpha(drone(9:12),0.3);

    %% create a group object and parent surface
      combinedobject = hgtransform('parent',hg );
      set(drone,'parent',combinedobject)
    %  drawnow
     
     for i = 1:length(x)
      
         ba = plot3(x(1:i),y(1:i),z(1:i), 'b:','LineWidth',1.5);
       
         translation = makehgtform('translate',...
                                   [x(i) y(i) z(i)]);
         %set(combinedobject, 'matrix',translation);
         rotation1 = makehgtform('xrotate',(pi/180)*(roll(i)));
         rotation2 = makehgtform('yrotate',(pi/180)*(pitch(i)));
         rotation3 = makehgtform('zrotate',yaw(i));
         %scaling = makehgtform('scale',1-i/20);
         set(combinedobject,'matrix',...
              translation*rotation3*rotation2*rotation1);
          
          %movieVector(i) =  getframe(fig1);
            %delete(b);
         drawnow
       % pause(0.2);
     end

     
     

     


    🏆博主优势:🌞🌞🌞博客内容尽量做到思维缜密,逻辑清晰,为了方便读者,博主专门做了一个专栏目录,整个专栏只放了一篇文章,做到极度细致,方便大家进行学习!亲民!!!还有我开了一个专栏给女朋友的,很浪漫的喔,代码学累的时候去瞧一瞧,看一看:女朋友的浪漫邂逅。有问题可以私密博主,博主看到会在第一时间回复。
     

                              👨‍🎓博主课外兴趣:中西方哲学,送予读者:

    👨‍💻做科研,涉及到一个深在的思想系统,需要科研者逻辑缜密,踏实认真,但是不能只是努力,很多时候借力比努力更重要,然后还要有仰望星空的创新点和启发点。当哲学课上老师问你什么是科学,什么是电的时候,不要觉得这些问题搞笑,哲学就是追究终极问题,寻找那些不言自明只有小孩子会问的但是你却回答不出来的问题。建议读者按目录次序逐一浏览,免得骤然跌入幽暗的迷宫找不到来时的路,它不足为你揭示全部问题的答案,但若能让人胸中升起一朵朵疑云,也未尝不会酿成晚霞斑斓的别一番景致,万一它居然给你带来了一场精神世界的苦雨,那就借机洗刷一下原来存放在那儿的“真理”上的尘埃吧。

         或许,雨过云收,神驰的天地更清朗.......🔎🔎🔎

    3 参考文献

    部分理论引用网络文献,如有侵权请联系删除。

    [1]李想,李阳.四轴无人机在林业管理中的应用[J].广西林业科学,2020,49(02):296-299.DOI:10.19692/j.cnki.gfs.2020.02.028.

    4 Matlab代码实现

    博客主页:辅导帮

  • 相关阅读:
    【shell】linux通过complete命令完成使用tab键自动补全
    iText7高级教程之构建基础块——5.使用AbstractElement对象(part 2)
    前端入门学习笔记三十四
    【MySQL】MySQL建表与常见类型设计陷阱(MySQL专栏启动)
    LabVIEW使用性能和内存信息
    程序员必读书籍有哪些值得推荐?
    【技术积累】HTML+CSS+JavaScript中的基础知识【三】
    MySQL高阶语句
    NC20566 [SCOI2010]游戏
    计算机网络基础知识
  • 原文地址:https://blog.csdn.net/2201_75454341/article/details/128097432