Having difficulty plotting a robot in a patch plot, robot plot is correctly plotted but when added after hold on statement in patch plot, it is not plotted correctly.

조회 수: 6 (최근 30일)
%Set up robot
KSetUp;
% KPfadgenerator;
minJerkPath = [];
for i = 1:length(X(indexOfPoints))
test = dataKartesisch(indexOfPoints(i), 2:end);
minJerkPath(end+1,:) = dataKartesisch(indexOfPoints(i), 2:end);
end
% laufbahn(robot,minJerkPath,1,true)
% show(robot,-minJerkPath(1,:),"Visuals","off", "Position",[5,5,5,0])
% show(robot,-minJerkPath(2,:),"Visuals","off", "Position",[8,8,8,0])
% show(robot,-minJerkPath(3,:),"Visuals","off", "Position",[9,9,9,0])
%Configure Figure and plot
fig = figure(1);
subplot(2,2,1)
patch(splineX,splineY,splineZ,splineZ,'FaceColor','none','EdgeColor','interp')
colormap(gca,customColormap(64:192,:));
caxis([min(splineZ) max(splineZ)])
hold on
scatter3(X(indexOfPoints),Y(indexOfPoints),Z(indexOfPoints),50);
for i = 1:length(X(indexOfPoints))
stringNum = num2str(i) + ".";
text(X(indexOfPoints(i)),Y(indexOfPoints(i)), Z(indexOfPoints(i)),stringNum,'FontSize', 15)
end
show(robot,-minJerkPath(1,:), "Position",[X(indexOfPoints(1)),Y(indexOfPoints(1)), Z(indexOfPoints(1)),0],'PreservePlot',true)
hold off
% laufbahn(robot,minJerkPath,1,true)
daspect([1, 1, 1])
xlabel('X-Profil [mm]')
ylabel('Y-Profil [mm]')
zlabel('Z-Profil [mm]')
% xlim(XAxisLimit)
% ylim(YAxisLimit)
% zlim(ZAxisLimit)
title('Bewegungsprofil im globalen Arbeitsraum-KOS')
set(gca, 'XMinorGrid','on', 'YMinorGrid','on')
a = colorbar;
ylabel(a,'Z-Profil [mm]','FontSize',12,'Rotation',270);
a.Label.Position(1) = 5;
view(view3D)
%Set LineWidth for all patch objects
patch_handles = findobj(gcf,'Type','patch'); % find all patch objects in the current figure
for k = 1:length(patch_handles)
set(patch_handles(k),'LineWidth',lineSize); %set the linewidth to 2 for all patch objects
end
end
I am trying to plot a robot in a 3D patch plot in Matlab, but the robot is not appearing correctly. When I click on the patch plot, the graph disappears. I have set up the robot using the rigidBodyTree class and have plotted it using the 'show' function after creating the patch plot. I am unsure what is causing the issue and would like assistance troubleshooting the problem.
  댓글 수: 2
Githin John
Githin John 2023년 1월 26일
Hello,
Can you provide a script that can be reproduced? Also can you share an image of the issue in the plot?
Thanks.
Githin John
Githin John 2023년 3월 9일
Hello,
I tried a simple reproduction using the basic steps you have here. Created a plot with a patch, scatter plot and a rigidBodyTree. I haven't seen any issues yet when interacting with the meshes.
Please provide a working script so I can try to recreate the issue.
Thanks.

댓글을 달려면 로그인하십시오.

답변 (1개)

Supraja
Supraja 2023년 5월 5일
After you
hold on
you can do
ax = gca;
set(ax, 'XLimMode', 'auto', 'YLimMode', 'auto')
before you draw the new items.
Note: if you set XLimMode or YLimMode to auto after you have added the new data, then MATLAB will typically not rescan the data to determine what it should use.

카테고리

Help CenterFile Exchange에서 Plot Customization에 대해 자세히 알아보기

태그

제품


릴리스

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by