From bc5880bfba4fce8e744bbbfb5f2cbe8b0fb07a27 Mon Sep 17 00:00:00 2001 From: Steve Peters Date: Thu, 5 Dec 2019 16:29:05 -0800 Subject: [PATCH 1/4] Allow static models without links, and skip loading FrameAttachedToGraph for static models for now until we can update its implementation --- src/Model.cc | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/src/Model.cc b/src/Model.cc index a5799fe25..aa3a8659a 100644 --- a/src/Model.cc +++ b/src/Model.cc @@ -259,9 +259,10 @@ Errors Model::Load(ElementPtr _sdf) frameNames.insert(link.Name()); } + // If the model is not static: // Require at least one link so the implicit model frame can be attached to // something. - if (this->dataPtr->links.empty()) + if (!this->Static() && this->dataPtr->links.empty()) { errors.push_back({ErrorCode::MODEL_WITHOUT_LINK, "A model must have at least one link."}); @@ -320,21 +321,29 @@ Errors Model::Load(ElementPtr _sdf) } // Build the graphs. - this->dataPtr->frameAttachedToGraph - = std::make_shared(); - Errors frameAttachedToGraphErrors = - buildFrameAttachedToGraph(*this->dataPtr->frameAttachedToGraph, this); - errors.insert(errors.end(), frameAttachedToGraphErrors.begin(), - frameAttachedToGraphErrors.end()); - Errors validateFrameAttachedGraphErrors = - validateFrameAttachedToGraph(*this->dataPtr->frameAttachedToGraph); - errors.insert(errors.end(), validateFrameAttachedGraphErrors.begin(), - validateFrameAttachedGraphErrors.end()); - for (auto &frame : this->dataPtr->frames) - { - frame.SetFrameAttachedToGraph(this->dataPtr->frameAttachedToGraph); + + // Build the FrameAttachedToGraph if the model is not static. + // Re-enable this when the buildFrameAttachedToGraph implementation handles + // static models. + if (!this->Static()) + { + this->dataPtr->frameAttachedToGraph + = std::make_shared(); + Errors frameAttachedToGraphErrors = + buildFrameAttachedToGraph(*this->dataPtr->frameAttachedToGraph, this); + errors.insert(errors.end(), frameAttachedToGraphErrors.begin(), + frameAttachedToGraphErrors.end()); + Errors validateFrameAttachedGraphErrors = + validateFrameAttachedToGraph(*this->dataPtr->frameAttachedToGraph); + errors.insert(errors.end(), validateFrameAttachedGraphErrors.begin(), + validateFrameAttachedGraphErrors.end()); + for (auto &frame : this->dataPtr->frames) + { + frame.SetFrameAttachedToGraph(this->dataPtr->frameAttachedToGraph); + } } + // Build the PoseRelativeToGraph this->dataPtr->poseGraph = std::make_shared(); Errors poseGraphErrors = buildPoseRelativeToGraph(*this->dataPtr->poseGraph, this); From 890ed60e9f241fe17156fa0268792e5952080453 Mon Sep 17 00:00:00 2001 From: Steve Peters Date: Thu, 5 Dec 2019 16:31:39 -0800 Subject: [PATCH 2/4] root_multiple_models.sdf: remove a model's links but make it static --- test/sdf/root_multiple_models.sdf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/sdf/root_multiple_models.sdf b/test/sdf/root_multiple_models.sdf index 7a3da5d19..e6ab334a5 100644 --- a/test/sdf/root_multiple_models.sdf +++ b/test/sdf/root_multiple_models.sdf @@ -7,6 +7,6 @@ - + true From 51c91f4bcb187f3f699996f32c8745744cb52881 Mon Sep 17 00:00:00 2001 From: Steve Peters Date: Thu, 5 Dec 2019 17:18:56 -0800 Subject: [PATCH 3/4] changelog and migration guide --- Changelog.md | 3 +++ Migration.md | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Changelog.md b/Changelog.md index 1eb30e8e6..3b7d7899f 100644 --- a/Changelog.md +++ b/Changelog.md @@ -43,6 +43,9 @@ 1. sdf 1.7: add `//model/@canonical_link` attribute and require models to have at least one link. * [Pull request 601](https://bitbucket.org/osrf/sdformat/pull-requests/601) +1. Static models: allow them to have no links and skip building FrameAttachedToGraph. + * [Pull request 626](https://bitbucket.org/osrf/sdformat/pull-requests/626) + 1. sdf 1.7: add `//frame/attached_to`, only allow frames in model and world, add Frame DOM. * [pull request 603](https://bitbucket.org/osrf/sdformat/pull-requests/603) diff --git a/Migration.md b/Migration.md index 9fe939b1e..8775da64f 100644 --- a/Migration.md +++ b/Migration.md @@ -199,7 +199,8 @@ but with improved human-readability.. 1. **model.sdf** `//model/@canonical_link` attribute + description: The name of the canonical link in this model to which the model's implicit frame is attached. This implies that a model must have - at least one link, which is also stated in the Modifications section. + at least one link (unless it is static), which is also stated in the + Modifications section. + type: string + default: "" + required: 0 @@ -210,9 +211,10 @@ but with improved human-readability.. ### Modifications -1. A model must have at least one link, as specified in the +1. A non-static model must have at least one link, as specified in the [proposal](http://sdformat.org/tutorials?tut=pose_frame_semantics_proposal&cat=pose_semantics_docs-model-frame-and-canonical-link). + [pull request 601](https://bitbucket.org/osrf/sdformat/pull-requests/601) + + [pull request 626](https://bitbucket.org/osrf/sdformat/pull-requests/626) 1. Unique names for all sibling elements: + As described in the [proposal](http://sdformat.org/tutorials?tut=pose_frame_semantics_proposal&cat=pose_semantics_docs-2-unique-names-for-all-sibling-elements), From 678330b6bc229b480bc0c07b97230f5713d561e1 Mon Sep 17 00:00:00 2001 From: Steve Peters Date: Fri, 6 Dec 2019 18:00:14 +0000 Subject: [PATCH 4/4] Close branch allow_static_models_without_links