How can I use plotTransforms in App Designer?
Show older comments
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?
Accepted Answer
More Answers (0)
Categories
Find more on Robotics System Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!