I have the following code that draws a robot on a binary occupancy map.
load exampleMaps.matmap = 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); endend
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.AxesInstead 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