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中對應對象并設(shè)置屬性】
% 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、結(jié)果【同樣的軌跡,實影的先運動幾個步數(shù),虛影后續(xù)運動】
?文章來源地址http://www.zghlxwxcb.cn/news/detail-581220.html文章來源:http://www.zghlxwxcb.cn/news/detail-581220.html
?
到了這里,關(guān)于matlab中畫有重影的機器人運動過程【給另一個機器人設(shè)置透明度】的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!