I have a MultibodyPlant
which has several robots in it, each of which is a ModelInstance
and they are added to the plant using AddModelInstance
. During collision, I would like to determine which of these model instances a colliding object (tagged by a geometry_id) belongs to.
I was trying something like
// register the model instance
const auto robot_model_index {
Parser(robots_plant_, scene_graph_)
.AddModelFromFile(entity->urdf, entity->name)};
/*
lots of code
*/
const auto& query_object {
query_port.Eval<QueryObject<double>>(*plant_context_)};
const auto& inspector {query_object.inspector()};
// determine the source_id of a given model_instance
// does not work
const auto& my_robot_id {robot_model_index.get_source_id().value()};
// query ownership
bool belongs_to_my_robot {inspector.BelongsToSource(signed_distance_pair.id_A, robot_id)};
How can I query ownership of a given geometry_id
to a ModelInstance
within a multibody plant? Am I missing some easy helper function which gives a source_id
for a ModelInstance
? Or another way to query ownership rather than BelongsToSource
?