Albert_Lsk 2020-10-21 15:47
浏览 107

Matlab 画出机器人工作空间,但有部分索引超出维度。

Matlab 这部分索引超出维度,请问是为什么?

     for cout=1:1:num
         figure_x(cout,1)=T_cell{cout}(1,4);
         figure_y(cout,1)=T_cell{cout}(2,4);
         figure_z(cout,1)=T_cell{cout}(3,4);
     end

以下是完整的代码片段

clc;
clear;

%% 准备
    %保留精度
    format short;

    %角度转换
    du=pi/180;  %度
    radian=180/pi; %弧度

    %模型导入
    mdl_puma560

%% 参数
    %关节角限位
    q1_s=-180; q1_end=180;
    q2_s=0;    q2_end=90;
    q3_s=-90;  q3_end=90;
    q4_s=-180; q4_end=180;
    q5_s=-90;  q5_end=90;
    q6_s=0;    q6_end=360;

    %计算点数
    num=1000;

%% 求取工作空间
    %设置轴关节随机分布,轴6不对工作范围产生影响,设置为0
    q1_rand = q1_s + rand(num,1)*(q1_end - q1_s);%rand产生num行1列,在0~1之间的随机数
    q2_rand = q2_s + rand(num,1)*(q2_end - q2_s);
    q3_rand = q3_s + rand(num,1)*(q3_end - q3_s);
    q4_rand = q4_s + rand(num,1)*(q4_end - q4_s);
    q5_rand = q5_s + rand(num,1)*(q5_end - q5_s);
    q6_rand = rand(num,1)*0;
    q = [q1_rand q2_rand q3_rand q4_rand q5_rand q6_rand]*du;

    %正运动学计算工作空间
    tic;
    T_cell = cell(num,1);
    for i=1:1:num
        [T_cell{i}]=p560.fkine(q(i,:));%正向运动学仿真函数
    end
%     [T_cell{:,1}]=p560.fkine(q);%正向运动学仿真函数
    disp(['运行时间:',num2str(toc)]);

 %% 分析结果
    %绘制工作空间
    t1=clock;
    figure('name','机械臂工作空间')
    hold on
    plotopt = {'noraise', 'nowrist', 'nojaxes', 'delay',0};
    p560.plot([0 30*du 0 0 40*du 0], plotopt{:});
     figure_x=zeros(num,1);
     figure_y=zeros(num,1);
     figure_z=zeros(num,1);
     for cout=1:1:num
         figure_x(cout,1)=T_cell{cout}(1,4);
         figure_y(cout,1)=T_cell{cout}(2,4);
         figure_z(cout,1)=T_cell{cout}(3,4);
     end
     plot3(figure_x,figure_y,figure_z,'r.','MarkerSize',3);
     hold off
     disp(['绘制工作空间运行时间:',num2str(etime(clock,t1))]);  

     %获取X,Y,Z空间坐标范围
     Point_range=[min(figure_x) max(figure_x) min(figure_y) max(figure_y) min(figure_z) max(figure_z)];
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥50 永磁型步进电机PID算法
    • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
    • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
    • ¥15 如何处理复杂数据表格的除法运算
    • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
    • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
    • ¥200 uniapp长期运行卡死问题解决
    • ¥15 latex怎么处理论文引理引用参考文献
    • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
    • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?