1、前言如题
2、参考连接如下
How to plot two moving robot in the same figure and change one of them transparency? - MATLAB Answers - MATLAB Central (mathworks.cn)3、代码:【找到figure中对应对象并设置属性】
% Create two instances of a rigid body tree since we want two visuals
rbt=loadrobot("kinovagen3",DataFormat="row");
copyrbt=copy(rbt);
% Some random configurations
q0=homeConfiguration(rbt);
q1=randomConfiguration(rbt);
q2=randomConfiguration(rbt);
% Generate a trajectory to the random configurations
tpts=[0,1];
tquery=tpts(1):0.01:tpts(end);
traj1=quinticpolytraj([q0',q1'],tpts,tquery)';
traj2=quinticpolytraj([q0',q2'],tpts,tquery)';
% Find the patches which have a display name of '_mesh', and set their
% alpha values.
ax=show(rbt,traj1(1,:),PreservePlot=false,FastUpdate=true);
rbtpatches=findobj(ax.Children,'Type','patch','-regexp','DisplayName','_mesh');
set(rbtpatches,'FaceAlpha',0.2);
% Now visualize another instance of the same robot
hold on;
show(copyrbt,traj2(1,:),PreservePlot=false,FastUpdate=true,Parent=ax);
% This call will also find the previous patches. Hence we need to remove
% previously found patches from this query.
patchesnew=findobj(ax.Children,'Type','patch','-regexp','DisplayName','_mesh');
copyrbtpatches=patchesnew(~ismember(patchesnew,rbtpatches));
% You can also change the color aside from alpha
set(copyrbtpatches,'FaceAlpha',0.7);
set(copyrbtpatches,'FaceColor',[1,0,0]);
%% Visualize
rc=rateControl(50);
for i=1:size(tquery,2)
show(rbt,traj1(i,:),PreservePlot=false,FastUpdate=true);
show(copyrbt,traj2(i,:),PreservePlot=false,FastUpdate=true,Parent=ax);
waitfor(rc);
end
hold off;
4、结果【同样的轨迹,实影的先运动几个步数,虚影后续运动】
文章来源地址https://www.toymoban.com/news/detail-581220.html文章来源:https://www.toymoban.com/news/detail-581220.html
到了这里,关于matlab中画有重影的机器人运动过程【给另一个机器人设置透明度】的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!