MATLAB: How to use plotTransforms in App Designer

app designerNavigation Toolbox

I have the following code that draws a robot on a binary occupancy map.
load exampleMaps.mat
map = binaryOccupancyMap(simpleMap,1);
fig = figure('Name','SimpleMap');
show(map);
poses = [5;5;1.57];
plotTrvec = [poses(1:2, 1); 0];
plotRot = axang2quat([0 0 1 poses(3, 1)]);
plotTransforms(plotTrvec', plotRot, 'MeshFilePath', 'groundvehicle.stl', 'View', '2D', 'Parent', fig.CurrentAxes);
I would like to create an app in App Designer that displays this result. I have added one Axes(app.UIAxes) and Button(app.Button) object each to my app and added the following callback functions.
% Callbacks that handle component events
methods (Access = private)
% Code that executes after component creation
function startupFcn(app)
load exampleMaps.mat
map = binaryOccupancyMap(simpleMap,1);
show(map, 'Parent', app.UIAxes);
end
% Button pushed function: Button
function ButtonPushed(app, event)
poses = [5;5;1.57];
plotTrvec = [poses(1:2, 1); 0];
plotRot = axang2quat([0 0 1 poses(3, 1)]);
plotTransforms(plotTrvec', plotRot, 'MeshFilePath', 'groundvehicle.stl', 'View', '2D', 'Parent', app.UIAxes);
end
end
The map is displayed correctly in the map. However, when I push the Button I get the following error,
Error using plotTransforms (line 97)
The value of 'Parent' is invalid. Expected Parent to be one of these types:
matlab.graphics.axis.Axes
Instead its type was matlab.ui.control.UIAxes.
I am not sure why I am getting this error, as the documentation of plotTransforms says the value of the 'Parent' property can be either an Axes or UIAxes object.
Is there another way to show the results of plotTransforms in App Designer that I may be missing?

Best Answer

I will confirm that the R2020a documentation states that the parent for plottransforms can be an axes of a uiaxes. When I tested in R2020b, it did work. However, when I tested in R2020a and R2020a Update 6, I got the same error message.
I also tested in MATLAB (not app designer) using the following simple script, and it also resulted in the same error message.
ax=uiaxes;
tr = [1 1 1; 2 2 2];
ro = [1 1 1 0; 1 3 5 0];
plotTransforms(tr,ro,'Parent',ax)
It appears to be a situation where the documentation got ahead of the product. I do not believe there is a workaround to get it to work in 20a. If you can, my suggestion is to update to 20b.
Related Question