-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement SDFormat 1.8 Interface API #475
Merged
Merged
Changes from 75 commits
Commits
Show all changes
76 commits
Select commit
Hold shift + click to select a range
c4e2ba4
Remove outdated error message
azeey 89dc847
Add ParserConfig class to encapsulate file path settings
azeey 7badb17
Use semi-colon as path separator in windows
azeey b4f1da3
Add header to CMakeLists
azeey e3e05f3
Merge remote-tracking branch 'upstream/master' into parser_config
azeey f9e3ef2
Address reviewer feedback
azeey deda523
Rename DefaultConfig to GlobalConfig
azeey b9bb22b
Fix style
azeey 66d2967
Remove outdated error message
azeey d06e21d
Add ParserConfig class to encapsulate file path settings
azeey ad2f9a3
Use semi-colon as path separator in windows
azeey db1de1d
Add header to CMakeLists
azeey 81d7998
Address reviewer feedback
azeey a00553d
Rename DefaultConfig to GlobalConfig
azeey e8e7237
Fix style
azeey 84f80f4
Allow files paths for include URIs
azeey b84443b
WIP
azeey 61eec3f
Update test expectations after merge
azeey b8a8f6b
WIP: TOML parser with array of tables
azeey 2f498cc
WIP: Map of Maps TOML data structure
azeey b9a4be2
Add ign-utils dependency
azeey a8bfcf4
WIP: Add NestedIncludeData test
azeey 46a4d68
Add InterfaceFrame
azeey ddafb64
Merge remote-tracking branch 'upstream/master' into parser_config
azeey e358786
Add InterfaceJoint
azeey 74eacf0
Merge remote-tracking branch 'upstream/master' into parser_config
azeey f088be8
Fix test expectations after merge
azeey 5084a6d
Merge remote-tracking branch 'upstream/master' into parser_config
azeey 4099c44
Merge remote-tracking branch 'upstream/master' into interface_api
azeey 52d57c1
Build pose relative-to and frame attached-to graphs for interface ele…
azeey 5dfe1a0
Merge branch 'master' into parser_config
scpeters 1cf635a
Merge branch 'master' into parser_config
scpeters e42bbda
sdf -> SDF
azeey 6388959
Use ImplPtr for ParserConfig
azeey fde3b1b
Implement initString overload
azeey 6f53a9f
List the search order in sdf::findFile
azeey 8977cd1
Add test checking that URI paths have precedence over findFile callbacks
azeey 5972b53
Codecheck
azeey 1d321e0
Add reference to `sdf::findFile` in the docs of ParserConfig
azeey 8a9e4e8
Expand documentation for ParserConfig::SetFindCallback
azeey 53af3c7
Merge branch 'master' into parser_config
azeey ed20a74
Add test expecations with sdf::findFile
azeey b9b0b26
Handle interface models included by a model, start Reposture
azeey 7a0c858
Merge remote-tracking branch 'origin/parser_config' into interface_api
azeey 6eec877
Add ability to resolve to world for reposture
azeey 2747f02
Revert error message changes
azeey e43b7ba
Codecheck
azeey 8d3353f
Merge remote-tracking branch 'upstream/master' into interface_api
azeey 44ca401
Fix codecheck
azeey 1c0fa20
Add missing includes
azeey 78ca98c
Add include files to CMakeLists, fix windows warning
azeey a699ba3
Merge remote-tracking branch 'upstream/master' into interface_api
azeey 55a3379
Handle placement frames for Interface models
azeey cc995e0
Remove relative_to from InterfaceModel since its in NestedInclude
azeey 37e1b62
Renamed loadInterfaceElements and moved it to Utils.cc
azeey 75d839c
Fix order in which custom parsers are called
azeey 0ab0a06
Address remaining todos, add duplicate name test
azeey 11e48a1
Remove the possibility that an interface model can be a root model
azeey 7fa3c16
Merge remote-tracking branch 'upstream/master' into interface_api
azeey d40348b
Update docs
azeey cbbc0e6
Update docs, simplify InterfaceModelPoseGraph
azeey d5d02e5
Merge remote-tracking branch 'upstream/master' into interface_api
azeey bbb8ef6
Change localModelName to std::optional
azeey 0522877
Merge remote-tracking branch 'upstream/master' into interface_api
azeey 80d3e86
Add InterfaceModelPoseGraph::ResolveNestedFramePose
azeey d9e6a58
Refactor reposture callback invocation, invoke recursively
azeey 9a77c1d
Merge remote-tracking branch 'upstream/master' into interface_api
azeey 62e6078
Add the "test" directory as an include in cppcheck
azeey d773f70
Minor fixes based on reviewer feedback
azeey a6a975f
Address reviewer feedback for interface_api test (part 1)
azeey 154b845
Address reviewer feedback
azeey d832ed3
Move the toml parser into its own file
azeey 90cafa2
Test a condition where multiple custom parsers can successfully parse…
azeey c0af826
Pass the entire `//include` element to custom parsers
azeey 93f5977
Fix typos
azeey 1676e5d
Ignore C4251 for NestedInclude
azeey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
/* | ||
* Copyright 2021 Open Source Robotics Foundation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
#ifndef SDF_INTERFACE_ELEMENTS_HH_ | ||
#define SDF_INTERFACE_ELEMENTS_HH_ | ||
|
||
#include <string> | ||
#include <memory> | ||
|
||
#include <ignition/math/Pose3.hh> | ||
|
||
#include "sdf/Element.hh" | ||
#include "sdf/InterfaceModel.hh" | ||
#include "sdf/Types.hh" | ||
|
||
#include "sdf/sdf_config.h" | ||
#include "sdf/system_util.hh" | ||
|
||
namespace sdf | ||
{ | ||
inline namespace SDF_VERSION_NAMESPACE | ||
{ | ||
/// \brief Contains the necessary information about an included model file | ||
/// for custom model parsers to be able to find the file and parse it. | ||
struct SDFORMAT_VISIBLE NestedInclude | ||
{ | ||
/// \brief Provides the URI as specified in `//include/uri`. This may or may | ||
/// not end with a file extension (it will not end with an extension if it | ||
/// refers to a model package). | ||
std::string uri; | ||
|
||
/// \brief Provides the *resolved* absolute file path from the URI. | ||
/// It is recommended to use this in `CustomModelParser` when checking | ||
/// predicates on filenames -- however, the predicates should generally only | ||
/// check the file extension. | ||
std::string resolvedFileName; | ||
|
||
/// \brief Name of the parent entity in absolute hierarchy. | ||
/// Example: if the interface model's name is | ||
/// `top_model::middle_model::my_new_model`, the absoluteParentName would be | ||
/// `top_model::middle_model`. If the parent entity is the world, this would | ||
/// be an empty string. | ||
std::string absoluteParentName; | ||
|
||
/// \brief Name relative to immediate parent as specified in | ||
/// `//include/name`. This is nullopt if `//include/name` is not set. Then the | ||
/// name of the model must be determined by the custom model parser from the | ||
/// included model file. | ||
/// Example: `my_new_model` | ||
std::optional<std::string> localModelName; | ||
|
||
/// \brief Whether the model is static as defined by `//include/static`. This | ||
/// is nullopt if `//include/static` is not set. | ||
std::optional<bool> isStatic; | ||
|
||
/// \brief The raw pose as specified in //include/pose. This is nullopt if | ||
/// `//include/pose` is not set. | ||
std::optional<ignition::math::Pose3d> includeRawPose; | ||
|
||
/// \brief The relative-to frame of the pose as specified in | ||
/// `//include/pose/@relative_to`. This is nullopt if | ||
/// `//include/pose/@relative_to` is not set. | ||
std::optional<std::string> includePoseRelativeTo; | ||
|
||
/// \brief The placement frame as specified in `//include/placement_frame`. | ||
/// This is nullopt if `//include/placement_frame` is is not set. | ||
std::optional<std::string> placementFrame; | ||
|
||
/// This is the `//include` element. This can be used to pass custom elements | ||
/// and attributes to the custom model parser. | ||
sdf::ElementPtr includeElement; | ||
}; | ||
|
||
/// Defines a custom model parser. | ||
/// | ||
/// Every custom model parser should define it's own way of (quickly) | ||
/// determining if it should parse a model. This should generally be done by | ||
/// looking at the file extension of `include.resolvedFileName`, and | ||
/// returning nullptr if it doesn't match a given criteria. | ||
/// | ||
/// Custom model parsers are visited in the *reverse* of how they are defined. | ||
/// The latest parser gains precedence. | ||
/// | ||
/// Custom model parsers are *never* checked if resolved file extension ends | ||
/// with `*.sdf` or `*.world`. | ||
/// If libsdformat encounters a `*.urdf` file, it will first check custom | ||
/// parser. If no custom parser is found, it will then convert the URDF XML to | ||
/// SDFormat XML, and parse it as an SDFormat file. | ||
/// | ||
/// \param[in] include The parsed //include information from which this model | ||
/// should be parsed. | ||
/// \param[out] errors Errors encountered during custom parsing. | ||
/// If any errors are reported, this must return nullptr. | ||
/// \return An optional ModelInterface. | ||
/// * If not nullptr, the returned model interface is incorporated into the | ||
/// existing model and its frames are exposed through the frame graph. | ||
/// * If nullptr and no errors are reported, then libsdformat should | ||
/// continue testing out other custom parsers registered under the same | ||
/// extension (e.g. a parser for `.yaml`, which may cover many different | ||
/// schemas). | ||
/// | ||
/// If an exception is raised by this callback, libsdformat will *not* try to | ||
/// intercept the exception. | ||
/// | ||
/// To see an example implementation, please refer to | ||
/// test/integration/interface_api.cc | ||
using CustomModelParser = | ||
std::function<sdf::InterfaceModelPtr(const sdf::NestedInclude &, Errors &)>; | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright 2021 Open Source Robotics Foundation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
#ifndef SDF_INTERFACE_FRAME_HH_ | ||
#define SDF_INTERFACE_FRAME_HH_ | ||
|
||
#include <string> | ||
|
||
#include <ignition/math/Pose3.hh> | ||
#include <ignition/utils/ImplPtr.hh> | ||
|
||
#include "sdf/sdf_config.h" | ||
#include "sdf/system_util.hh" | ||
|
||
namespace sdf | ||
{ | ||
inline namespace SDF_VERSION_NAMESPACE | ||
{ | ||
/// \brief Interface element representing an explicit frame | ||
class SDFORMAT_VISIBLE InterfaceFrame | ||
{ | ||
/// \brief Constructor | ||
/// \param[in] _name The *local* name. | ||
/// \param[in] _attachedTo Name of the attached-to frame. This cannot be an | ||
/// empty string. If the frame is attached to the model frame, this must be | ||
/// "__model__" . The (implicit or explicit) frame must exist in the scope of | ||
/// this frame. | ||
/// \param[in] _pose The pose of the frame relative to the attached-to frame. | ||
public: InterfaceFrame(const std::string &_name, | ||
const std::string &_attachedTo, const ignition::math::Pose3d &_pose); | ||
|
||
/// \brief Get the name of the frame. | ||
/// \return Local name of the frame. | ||
public: const std::string &Name() const; | ||
|
||
/// \brief Get the name of the coordinate frame to which this frame is | ||
/// attached. | ||
/// \return The name of the attached-to frame. | ||
public: const std::string &AttachedTo() const; | ||
|
||
/// \brief Get the pose of this frame relative to the attached-to frame. | ||
/// \return The pose of this frame in the attached-to frame. | ||
public: const ignition::math::Pose3d &PoseInAttachedToFrame() const; | ||
|
||
/// \brief Private data pointer. | ||
IGN_UTILS_IMPL_PTR(dataPtr) | ||
}; | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright 2021 Open Source Robotics Foundation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
#ifndef SDF_INTERFACE_JOINT_HH_ | ||
#define SDF_INTERFACE_JOINT_HH_ | ||
|
||
#include <string> | ||
|
||
#include <ignition/math/Pose3.hh> | ||
#include <ignition/utils/ImplPtr.hh> | ||
|
||
#include "sdf/sdf_config.h" | ||
#include "sdf/system_util.hh" | ||
|
||
namespace sdf | ||
{ | ||
inline namespace SDF_VERSION_NAMESPACE | ||
{ | ||
/// \brief Interface element representing a Joint | ||
class SDFORMAT_VISIBLE InterfaceJoint | ||
{ | ||
/// \brief Constructor | ||
/// \param[in] name The *local* name. | ||
/// \param[in] _childName Name of the child link or frame. | ||
/// \param[in] _pose The pose of the joint relative to the child frame. | ||
public: InterfaceJoint(const std::string &_name, | ||
const std::string &_childName, const ignition::math::Pose3d &_pose); | ||
|
||
/// \brief Get the name of the joint. | ||
/// \return Local name of the joint. | ||
public: const std::string &Name() const; | ||
|
||
/// \brief Get the name of the joint's child. | ||
/// \return The name of the joint's child link or frame. | ||
public: const std::string &ChildName() const; | ||
|
||
/// \brief Get the pose of this joint in the child frame. | ||
/// \return The pose of this joint in the child frame. | ||
public: const ignition::math::Pose3d &PoseInChildFrame() const; | ||
|
||
/// \brief Private data pointer. | ||
IGN_UTILS_IMPL_PTR(dataPtr) | ||
}; | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright 2021 Open Source Robotics Foundation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
#ifndef SDF_INTERFACE_LINK_HH_ | ||
#define SDF_INTERFACE_LINK_HH_ | ||
|
||
#include <string> | ||
|
||
#include <ignition/math/Pose3.hh> | ||
#include <ignition/utils/ImplPtr.hh> | ||
|
||
#include "sdf/sdf_config.h" | ||
#include "sdf/system_util.hh" | ||
|
||
namespace sdf | ||
{ | ||
inline namespace SDF_VERSION_NAMESPACE | ||
{ | ||
/// \brief Interface element representing a Link | ||
class SDFORMAT_VISIBLE InterfaceLink | ||
{ | ||
/// \brief Constructor | ||
/// \param[in] name The *local* name. | ||
/// \param[in] _pose The pose of the link relative to model frame. | ||
public: InterfaceLink( | ||
const std::string &_name, const ignition::math::Pose3d &_pose); | ||
|
||
/// \brief Get the name of the link. | ||
/// \return Local name of the link. | ||
public: const std::string &Name() const; | ||
|
||
/// \brief Get the pose of this link in the parent model frame. | ||
/// \return The pose of this link in the parent model frame. | ||
public: const ignition::math::Pose3d &PoseInModelFrame() const; | ||
|
||
/// \brief Private data pointer. | ||
IGN_UTILS_IMPL_PTR(dataPtr) | ||
}; | ||
} | ||
} | ||
|
||
#endif |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to include
_parentName
as a parameter and associated getter?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a comment in https://reviewable.io/reviews/osrf/sdformat/475#-MUP_KA_Ml7w3E1kCP9n-r7-40