Is it possible to toggle the visibility of 'some' frames when using rigidBodyTree?

14 visualizaciones (últimos 30 días)
Since a rigidBodyTree has several kinds of joints, when using show(robot) it shows the frames for fixed joints as well.
Is it possible to hide some frames programmatically?
I am aware that 'Frames','off' arrtibute can be used to hide all frames.
To be specific I just want to hide the fixed frames but still want the revolute ones to be visible.
Thanks in advance

Respuesta aceptada

Hannes Daepp
Hannes Daepp el 30 de Jul. de 2021
Hi Kartikeya,
The frames are patch objects, so as long as you can get the handles to these objects, you can enable and disable their visibility (what the "Frames" name-value argument is doing in bulk).
For example, suppose we show one of the built-in RigidBodyTree objects. For convenience, assume the visuals are already not shown, though this doesn't matter:
robot = loadrobot("abbIrb120");
show(robot,"Visuals","off");
You can find all the patch objects in the figure by using the findall command.
>> allPatches = findall(gcf, "Type", "Patch")
allPatches =
16×1 Patch array:
Patch (DO_NOT_EDIT_UwdU6)
Patch (DO_NOT_EDIT_UwdU6)
Patch (DO_NOT_EDIT_UwdU6)
Patch (DO_NOT_EDIT_UwdU6)
Patch (DO_NOT_EDIT_UwdU6)
Patch (DO_NOT_EDIT_UwdU6)
Patch (DO_NOT_EDIT_UwdU6)
Patch (DO_NOT_EDIT_UwdU6)
Patch (DO_NOT_EDIT_UwdU6)
Patch (DO_NOT_EDIT_UwdU6)
Patch (DO_NOT_EDIT_UwdU6)
Patch (DO_NOT_EDIT_UwdU6)
Patch (DO_NOT_EDIT_UwdU6)
Patch (DO_NOT_EDIT_UwdU6)
Patch (DO_NOT_EDIT_UwdU6)
Patch (DO_NOT_EDIT_UwdU6)
You'll note that in the above example, all the patches are associated with a tag. This tag is unique to each rigidBodyTree.show command and specifies that these patch objects are affiliated with the rigid body tree object. If your figure contains more patches than those affiliated with the tree, you can limit selections by specifying that tag as part of the findall command:
allPatches = findall(gcf, "Type", "Patch", "Tag", "DO_NOT_EDIT_UwdU6")
Now all you need to do is figure out which of these patches is associated with the frame you'd like to disable, and turn it off. You can iterate over the list of patches and check if setting visibility off removes the patch from the corresponding figure. For example, the following call clearly removes the frame associated with link_4 located at the 90 degree angle:
Before removal, robot has a frame at link_4 (highlighted)
allPatches(11).Visible='off'
Visual after frame removal call
If your rigid body tree object is the only item in the figure and the visuals are already off, an easy way to get this list is to reduce the scope of patches to those with visibility off.
visiblePatches =
9×1 Patch array:
Patch (DO_NOT_EDIT_UwdU6)
Patch (DO_NOT_EDIT_UwdU6)
Patch (DO_NOT_EDIT_UwdU6)
Patch (DO_NOT_EDIT_UwdU6)
Patch (DO_NOT_EDIT_UwdU6)
Patch (DO_NOT_EDIT_UwdU6)
Patch (DO_NOT_EDIT_UwdU6)
Patch (DO_NOT_EDIT_UwdU6)
Patch (DO_NOT_EDIT_UwdU6)
The list above corresponds to the list of frame patches.
  1 comentario
Kartikeya Walia
Kartikeya Walia el 2 de Ag. de 2021
Editada: Kartikeya Walia el 2 de Ag. de 2021
Thankyou for the amazing response. I really appreciate.
Are the patches generated in random order? Or is there any property for patches to relate to for identifying it correctly and programmatically?

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by