我试着从某些几何图形中移除接近的作用。但是,我收到的错误是我的植物源id没有注册:
Referenced geometry source 0 is not registered.我已经检查了工厂是否真的注册了,因为呼叫
plant->RegisterAsSourceForSceneGraph(scene_graph);!geometry_source_is_registered()失败。
我还创建了几何图形(通过添加sdf模型),因此source_id应该是有效的。以下是我尝试的方法:
drake::systems::DiagramBuilder<double> builder;
drake::multibody::MultibodyPlant<double>* plant{};
drake::geometry::SceneGraph<double>* scene_graph{};
std::tie(plant, scene_graph) = drake::multibody::AddMultibodyPlantSceneGraph(&builder, timestep);
drake::multibody::Parser parser(plant, scene_graph);
const auto robot_model_index = parser.AddModelFromFile(sdf_filepath, "robot");
plant->Finalize();
const auto& source_id = plant->get_source_id().value();
const auto& inspector = scene_graph->model_inspector();
auto all_geom_ids = inspector.GetAllGeometryIds();
for (auto& geom_id : all_geom_ids) {
const auto frame_id = inspector.GetFrameId(geom_id);
const auto geom_model_index = inspector.GetFrameGroup(frame_id);
// https://stackoverflow.com/questions/68225198/does-a-modelinstance-in-a-multibodyplan-have-a-unique-source-id-for-determining
if (geom_model_index == robot_model_index) {
// This fails: Referenced geometry source 0 is not registered.
scene_graph->RemoveRole(source_id, geom_id, drake::geometry::Role::kProximity);
}
}发布于 2022-09-30 22:25:05
如果要更改与a MultibodyPlant关联的几何,则要使用的source_id是plant.get_source_id()。
https://stackoverflow.com/questions/73912495
复制相似问题