我是靠谱客的博主 优雅枫叶,这篇文章主要介绍MATLAB robotics toolbox机器人工具箱 (Index exceeds the number of array elements报错)解决方案报错信息解决方法运行效果,现在分享给大家,希望可以做个参考。

MATLAB 机器人工具箱 plot/teach可视化程序 数组越界报错/解决方案

  • 报错信息
  • 解决方法
  • 运行效果

报错信息

当在MATLAB 2019及以上版本中使用Robotics工具箱时,运行plot或teach等含可视化功能的命令时出现以下报错信息:

复制代码
1
2
3
4
5
6
7
8
Index exceeds the number of array elements. Index must not exceed 4. 出错 SerialLink/plot>create_robot (第 469 行) d = norm( d(4:6)-d(1:3) ) / 72; 出错 SerialLink/plot (第 252 行) handle = create_robot(robot, opt);

在这里插入图片描述
索引超出数组数目
在MATLAB2018b以前版本中不会出现这个问题

解决方法

一、临时解决方案
每次都在可视化语句前加入以下命令:

复制代码
1
2
view(3);

虽能解决可视化问题,但仍会报错

复制代码
1
2
3
4
5
6
7
8
此类型的变量不支持使用点进行索引。 出错 SerialLink/animate (第 105 行) if h.link(L) ~= 0 出错 SerialLink/plot (第 299 行) robot.animate(qq);

二、一劳永逸方案
1、在命令行窗口中输入

复制代码
1
2
edit SerialLink.plot

此时会打开工具箱中的plot.m文件,如下图:
在这里插入图片描述
2、在程序的开头处加入如下程序

复制代码
1
2
3
4
5
[myModifyForViewErrorA,myModifyForViewErrorB]=view(gca); if isequal([myModifyForViewErrorA,myModifyForViewErrorB],[0,90]) view(3) end

如下图:
在这里插入图片描述
再次执行可视化程序,即可成功运行!

运行效果

1、运行示例程序

复制代码
1
2
3
4
5
6
7
startup_rvc L1 = Link('d', 0, 'a', 1, 'alpha', pi/2) L2 = Link('d', 0, 'a', 1, 'alpha', 0) bot = SerialLink([L1 L2], 'name', 'my robot') bot.fkine([0.1 0.2]) bot.plot([pi/4 pi/3])

2、绘图效果
在这里插入图片描述
参考博客:
解决高版本MATLAB robotics toolbox在plot/teach时报错问题

最后

以上就是优雅枫叶最近收集整理的关于MATLAB robotics toolbox机器人工具箱 (Index exceeds the number of array elements报错)解决方案报错信息解决方法运行效果的全部内容,更多相关MATLAB内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(91)

评论列表共有 0 条评论

立即
投稿
返回
顶部