This is a follow-up after reading this:
Adding New Geometries Post-Finalize
I was wondering about the way to change the geometry of meshes, for perception and illustration roles. It was mentioned that it is possible to get deeper into the SceneGraph
object and manipulate the objects.
However, I was not able to find the appropriate API calls to retrieve and set the geometry.
In the example that I am working on, I would like to update a mesh of a link as part of a multi-body plant.
To be more specific, I have a fixed link with a mesh that represents a rough terrain.I would like to visualize some sort of arbitrary change to each vertice on the mesh and move them. (somewhat similar to a deformable body, but explicitly moving the points rather than involving forces)
Side note for context: These are my early steps to integrate a soil simulator for terra-mechanics simulation.
I am a novice Drake user and I appreciate the help and support.
I loaded up an SDF model with a .dae
mesh file and I was successful in creating the right plan and scene. Yet, I did not know how to change a mesh during simulation run time.
So, the only recourse you have is redefining the shape associated with the geometry. We currently don't have any mechanism by which you can perturb particular vertex locations. The workflow would look something like this:
Mesh
shape to SceneGraph
with illustration or perception properties. You need its GeometryId
and (currently) the SourceId
that was used. Most likely, if you parsed it from an sdf/urdf file, it was registered with the MultibodyPlant
's source id (MultibodyPlant::get_source_id()
).ground1.obj
.SceneGraph::ChangeShape()
pass where you provide a Mesh
which references ground1.obj
.
ChangeShape()
whose first parameter is your current Context
.That's it. It's cumbersome (having to go to disk), but, currently, that's the only mechanism we have for changing the geometry. Fortunately, MultibodyPlant
is not sensitive to the visual (illustration/perception) representations of the bodies, so it doesn't interfere with these actions.