Skip to content

Commit

Permalink
Merge pull request #1316 from gazebosim/merge_13_14_20230830
Browse files Browse the repository at this point in the history
Merge 13 -> 14
  • Loading branch information
iche033 authored Aug 30, 2023
2 parents 017e1f6 + f7b355f commit 1455c69
Show file tree
Hide file tree
Showing 18 changed files with 698 additions and 251 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ if (BUILD_SDF)
gz_configure_project(
NO_PROJECT_PREFIX
REPLACE_INCLUDE_PATH sdf
VERSION_SUFFIX)
VERSION_SUFFIX pre1)

#################################################
# Find tinyxml2.
Expand Down
30 changes: 30 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,36 @@

## libsdformat 13.X

### libsdformat 13.6.0 (2023-08-30)

1. Use relative path in an urdf include to avoid confusion between internal and system headers
* [Pull request #1259](https://github.com/gazebosim/sdformat/pull/1259)

1. parser.cc update calls to use sdf::Errors output
* [Pull request #1294](https://github.com/gazebosim/sdformat/pull/1294)

1. Fix deeply nested merge-include for custom parsed files
* [Pull request #1293](https://github.com/gazebosim/sdformat/pull/1293)

1. Updated findfile() to search localpath first
* [Pull request #1292](https://github.com/gazebosim/sdformat/pull/1292)

1. World requires a scene and atmosphere
* [Pull request #1308](https://github.com/gazebosim/sdformat/pull/1308)

1. Infrastructure
* [Pull request #1307](https://github.com/gazebosim/sdformat/pull/1307)
* [Pull request #1306](https://github.com/gazebosim/sdformat/pull/1306)

1. Remove robot not found error when parsing fails
* [Pull request #1290](https://github.com/gazebosim/sdformat/pull/1290)

1. Make some sdfdbg messages sdfmsgs
* [Pull request #1288](https://github.com/gazebosim/sdformat/pull/1288)

1. Minor clean up of tests
* [Pull request #1289](https://github.com/gazebosim/sdformat/pull/1289)

### libsdformat 13.5.0 (2023-05-18)

1. Added projector Python wrapper
Expand Down
4 changes: 4 additions & 0 deletions include/sdf/Error.hh
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ namespace sdf
/// \return Error message.
public: std::string Message() const;

/// \brief Sets the message associated with this error.
/// \param [in] _message Message that describes this error.
public: void SetMessage(const std::string &_message);

/// \brief Get the file path associated with this error.
/// \return Returns the path of the file that this error is related to,
/// nullopt otherwise.
Expand Down
131 changes: 130 additions & 1 deletion include/sdf/parser.hh
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ namespace sdf
SDFORMAT_VISIBLE
bool init(SDFPtr _sdf, const ParserConfig &_config);

/// \brief Initialize the SDF interface from the embedded root spec file
/// \param[out] _errors Vector of errors.
/// \param[out] _sdf Pointer to an SDF object.
/// \param[in] _config Custom parser configuration
/// \return True if successful.
SDFORMAT_VISIBLE
bool init(sdf::Errors &_errors, SDFPtr _sdf, const ParserConfig &_config);

/// \brief Initialize the SDF interface using a file
/// \param[in] _filename Name of the SDF file
/// \param[out] _sdf Pointer to an SDF object.
Expand All @@ -71,9 +79,20 @@ namespace sdf
bool initFile(
const std::string &_filename, const ParserConfig &_config, SDFPtr _sdf);

/// \brief Initialize the SDF interface using a file
/// \param[in] _filename Name of the SDF file
/// \param[in] _config Custom parser configuration
/// \param[out] _sdf Pointer to an SDF object.
/// \param[out] _errors Vector of errors.
/// \return True if successful.
SDFORMAT_VISIBLE
bool initFile(
const std::string &_filename, const ParserConfig &_config, SDFPtr _sdf,
sdf::Errors &_errors);

/// \brief Initialize an SDF Element interface using a file
/// \param[in] _filename Name of the SDF file
/// \param[in] _sdf Pointer to an SDF Element object.
/// \param[out] _sdf Pointer to an SDF Element object.
/// \return True if successful.
SDFORMAT_VISIBLE
bool initFile(const std::string &_filename, ElementPtr _sdf);
Expand All @@ -87,6 +106,16 @@ namespace sdf
bool initFile(const std::string &_filename, const ParserConfig &_config,
ElementPtr _sdf);

/// \brief Initialize an SDFElement interface using a file
/// \param[in] _filename Name of the SDF file
/// \param[in] _config Custom parser configuration
/// \param[out] _sdf Pointer to an SDF Element object.
/// \param[out] _errors Vector of errors.
/// \return True if successful.
SDFORMAT_VISIBLE
bool initFile(const std::string &_filename, const ParserConfig &_config,
ElementPtr _sdf, sdf::Errors &_errors);

/// \brief Initialize the SDF interface using a string
/// \param[in] _xmlString XML string to be parsed.
/// \param[out] _sdf Pointer to an SDF object.
Expand All @@ -103,6 +132,16 @@ namespace sdf
bool initString(
const std::string &_xmlString, const ParserConfig &_config, SDFPtr _sdf);

/// \brief Initialize the SDF interface using a string
/// \param[in] _xmlString XML string to be parsed.
/// \param[in] _config Custom parser configuration
/// \param[out] _sdf Pointer to an SDF object.
/// \param[out] _errors Vector of errors.
/// \return True if successful.
SDFORMAT_VISIBLE
bool initString(const std::string &_xmlString, const ParserConfig &_config,
SDFPtr _sdf, sdf::Errors &_errors);

/// \brief Populate the SDF values from a file
///
/// This populates a new SDF pointer from a file. If the file is a URDF
Expand Down Expand Up @@ -317,6 +356,16 @@ namespace sdf
SDFORMAT_VISIBLE
std::string getModelFilePath(const std::string &_modelDirPath);

/// \brief Get the file path to the model file
/// \param[out] _errors Vector of errors.
/// \param[in] _modelDirPath directory system path of the model
/// \return string with the full filesystem path to the best version (greater
/// SDF protocol supported by this sdformat version) of the .sdf
/// model files hosted by _modelDirPath.
SDFORMAT_VISIBLE
std::string getModelFilePath(sdf::Errors &_errors,
const std::string &_modelDirPath);

/// \brief Convert an SDF file to a specific SDF version.
/// \param[in] _filename Name of the SDF file to convert.
/// \param[in] _version Version to convert _filename to.
Expand Down Expand Up @@ -387,6 +436,17 @@ namespace sdf
SDFORMAT_VISIBLE
bool checkCanonicalLinkNames(const sdf::Root *_root);

/// \brief Check that for each model, the canonical_link attribute value
/// matches the name of a link in the model if the attribute is set and
/// not empty.
/// This checks recursively and should check the files exhaustively
/// rather than terminating early when the first error is found.
/// \param[out] _errors Vector of errors.
/// \param[in] _root SDF Root object to check recursively.
/// \return True if all models have valid canonical_link attributes.
SDFORMAT_VISIBLE
bool checkCanonicalLinkNames(sdf::Errors &_errors, const sdf::Root *_root);

/// \brief For the world and each model, check that the attached_to graphs
/// build without errors and have no cycles.
/// Confirm that following directed edges from each vertex in the graph
Expand All @@ -398,6 +458,18 @@ namespace sdf
SDFORMAT_VISIBLE
bool checkFrameAttachedToGraph(const sdf::Root *_root);

/// \brief For the world and each model, check that the attached_to graphs
/// build without errors and have no cycles.
/// Confirm that following directed edges from each vertex in the graph
/// leads to a model, link, or world frame.
/// This checks recursively and should check the files exhaustively
/// rather than terminating early when the first error is found.
/// \param[out] _errors Vector of errors.
/// \param[in] _root SDF Root object to check recursively.
/// \return True if all attached_to graphs are valid.
SDFORMAT_VISIBLE
bool checkFrameAttachedToGraph(sdf::Errors &_errors, const sdf::Root *_root);

/// \brief Check that for each frame, the attached_to attribute value
/// does not match its own frame name but does match the name of a
/// link, joint, or other frame in the model if the attribute is set and
Expand All @@ -409,6 +481,18 @@ namespace sdf
SDFORMAT_VISIBLE
bool checkFrameAttachedToNames(const sdf::Root *_root);

/// \brief Check that for each frame, the attached_to attribute value
/// does not match its own frame name but does match the name of a
/// link, joint, or other frame in the model if the attribute is set and
/// not empty.
/// This checks recursively and should check the files exhaustively
/// rather than terminating early when the first error is found.
/// \param[out] _errors Vector of errors.
/// \param[in] _root SDF Root object to check recursively.
/// \return True if all frames have valid attached_to attributes.
SDFORMAT_VISIBLE
bool checkFrameAttachedToNames(sdf::Errors &_errors, const sdf::Root *_root);

/// \brief Check that all joints in contained models specify parent
/// and child link names that match the names of sibling links.
/// This checks recursively and should check the files exhaustively
Expand Down Expand Up @@ -469,6 +553,18 @@ namespace sdf
SDFORMAT_VISIBLE
bool checkPoseRelativeToGraph(const sdf::Root *_root);

/// \brief For the world and each model, check that the attached_to graphs
/// build without errors and have no cycles.
/// Confirm that following directed edges from each vertex in the graph
/// leads to a model, link, or world frame.
/// This checks recursively and should check the files exhaustively
/// rather than terminating early when the first error is found.
/// \param[out] _errors Vector of errors.
/// \param[in] _root SDF Root object to check recursively.
/// \return True if all attached_to graphs are valid.
SDFORMAT_VISIBLE
bool checkPoseRelativeToGraph(sdf::Errors &_errors, const sdf::Root *_root);

/// \brief Check that all sibling elements of the same type have unique names.
/// This checks recursively and should check the files exhaustively
/// rather than terminating early when the first duplicate name is found.
Expand All @@ -478,6 +574,17 @@ namespace sdf
SDFORMAT_VISIBLE
bool recursiveSameTypeUniqueNames(sdf::ElementPtr _elem);

/// \brief Check that all sibling elements of the same type have unique names.
/// This checks recursively and should check the files exhaustively
/// rather than terminating early when the first duplicate name is found.
/// \param[out] _errors Vector of errors.
/// \param[in] _elem SDF Element to check recursively.
/// \return True if all contained elements have do not share a name with
/// sibling elements of the same type.
SDFORMAT_VISIBLE
bool recursiveSameTypeUniqueNames(sdf::Errors &_errors,
sdf::ElementPtr _elem);

/// \brief Check that all sibling elements of the any type have unique names.
/// This checks recursively and should check the files exhaustively
/// rather than terminating early when the first duplicate name is found.
Expand All @@ -487,6 +594,16 @@ namespace sdf
SDFORMAT_VISIBLE
bool recursiveSiblingUniqueNames(sdf::ElementPtr _elem);

/// \brief Check that all sibling elements of the any type have unique names.
/// This checks recursively and should check the files exhaustively
/// rather than terminating early when the first duplicate name is found.
/// \param[out] _errors Vector of errors.
/// \param[in] _elem SDF Element to check recursively.
/// \return True if all contained elements have do not share a name with
/// sibling elements of any type.
SDFORMAT_VISIBLE
bool recursiveSiblingUniqueNames(sdf::Errors &_errors, sdf::ElementPtr _elem);

/// \brief Check that all sibling elements do not contain the delimiter
/// double colons '::' in element names, which is reserved for forming scopes
/// in SDFormat 1.8. This checks recursively and should check the files
Expand All @@ -497,6 +614,18 @@ namespace sdf
SDFORMAT_VISIBLE
bool recursiveSiblingNoDoubleColonInNames(sdf::ElementPtr _elem);

/// \brief Check that all sibling elements do not contain the delimiter
/// double colons '::' in element names, which is reserved for forming scopes
/// in SDFormat 1.8. This checks recursively and should check the files
/// exhaustively rather than terminating early when the first name
/// containing '::' is found.
/// \param[out] _errors Vector of errors.
/// \param[in] _elem SDF Element to check recursively.
/// \return True if all contained element names do not have the delimiter '::'
SDFORMAT_VISIBLE
bool recursiveSiblingNoDoubleColonInNames(sdf::Errors &_errors,
sdf::ElementPtr _elem);

/// \brief Check whether the element should be validated. If this returns
/// false, validators such as the unique name and reserve name checkers should
/// skip this element and its descendants.
Expand Down
6 changes: 6 additions & 0 deletions src/Error.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ std::string Error::Message() const
return this->dataPtr->message;
}

/////////////////////////////////////////////////
void Error::SetMessage(const std::string &_message)
{
this->dataPtr->message = _message;
}

/////////////////////////////////////////////////
std::optional<std::string> Error::FilePath() const
{
Expand Down
2 changes: 1 addition & 1 deletion src/Root.cc
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ Errors Root::Load(const std::string &_filename, const ParserConfig &_config)
if (!sdfParsed)
{
errors.push_back(
{ErrorCode::FILE_READ, "Unable to read file:" + _filename});
{ErrorCode::FILE_READ, "Unable to read file: [" + _filename + "]"});
return errors;
}

Expand Down
Loading

0 comments on commit 1455c69

Please sign in to comment.