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.
2 次查看(过去 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
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
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
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Manipulator Modeling 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!