Skip to content

Commit

Permalink
Merge branch 'sdf14' into relocbin
Browse files Browse the repository at this point in the history
  • Loading branch information
iche033 authored Aug 13, 2024
2 parents b8035a5 + 86db7db commit c01e865
Show file tree
Hide file tree
Showing 11 changed files with 165 additions and 46 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if(COMMAND CMAKE_POLICY)
CMAKE_POLICY(SET CMP0004 NEW)
endif(COMMAND CMAKE_POLICY)

project (sdformat14 VERSION 14.4.0)
project (sdformat14 VERSION 14.5.0)

# The protocol version has nothing to do with the package version.
# It represents the current version of SDFormat implemented by the software
Expand Down
20 changes: 20 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
## libsdformat 14.X

### libsdformat 14.5.0 (2024-08-05)

1. Adding Errors structure to XmlUtils
* [Pull request #1296](https://github.com/gazebosim/sdformat/pull/1296)

1. Disable latex and class hierarchy generation
* [Pull request #1447](https://github.com/gazebosim/sdformat/pull/1447)

1. Added SetHeightMap and Heighmap to Geometry Python binding
* [Pull request #1440](https://github.com/gazebosim/sdformat/pull/1440)

1. workflows/ci.yml fix push branch regex
* [Pull request #1445](https://github.com/gazebosim/sdformat/pull/1445)

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

1. Added World::ActorByName
* [Pull request #1436](https://github.com/gazebosim/sdformat/pull/1436)

### libsdformat 14.4.0 (2024-06-20)

1. Add Cone as a primitive parametric shape.
Expand Down
3 changes: 3 additions & 0 deletions include/sdf/Error.hh
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ namespace sdf
/// \brief The joint axis mimic does not refer to a valid joint in the
/// current scope.
JOINT_AXIS_MIMIC_INVALID,

/// \brief Error at the XML level.
XML_ERROR,
};

class SDFORMAT_VISIBLE Error
Expand Down
2 changes: 1 addition & 1 deletion package.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<package format="2">
<name>sdformat14</name>
<version>14.4.0</version>
<version>14.5.0</version>
<description>SDFormat is an XML file format that describes environments, objects, and robots
in a manner suitable for robotic applications</description>

Expand Down
10 changes: 6 additions & 4 deletions src/Converter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -264,15 +264,15 @@ void Converter::ConvertImpl(tinyxml2::XMLElement *_elem,
}
else if (name == "copy")
{
Move(_elem, childElem, true);
Move(_elem, childElem, true, _errors);
}
else if (name == "map")
{
Map(_elem, childElem, _errors);
}
else if (name == "move")
{
Move(_elem, childElem, false);
Move(_elem, childElem, false, _errors);
}
else if (name == "add")
{
Expand Down Expand Up @@ -923,7 +923,8 @@ void Converter::Map(tinyxml2::XMLElement *_elem,
/////////////////////////////////////////////////
void Converter::Move(tinyxml2::XMLElement *_elem,
tinyxml2::XMLElement *_moveElem,
const bool _copy)
const bool _copy,
sdf::Errors &_errors)
{
SDF_ASSERT(_elem != NULL, "SDF element is NULL");
SDF_ASSERT(_moveElem != NULL, "Move element is NULL");
Expand Down Expand Up @@ -1024,7 +1025,8 @@ void Converter::Move(tinyxml2::XMLElement *_elem,

if (toElemStr && !toAttrStr)
{
tinyxml2::XMLNode *cloned = DeepClone(moveFrom->GetDocument(), moveFrom);
tinyxml2::XMLNode *cloned = DeepClone(_errors, moveFrom->GetDocument(),
moveFrom);
tinyxml2::XMLElement *moveTo = static_cast<tinyxml2::XMLElement*>(cloned);

moveTo->SetValue(toName);
Expand Down
4 changes: 3 additions & 1 deletion src/Converter.hh
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,11 @@ namespace sdf
/// \param[in] _moveElem A 'convert' element that describes the move
/// operation.
/// \param[in] _copy True to copy the element
/// \param[out] _errors Vector of errors.
private: static void Move(tinyxml2::XMLElement *_elem,
tinyxml2::XMLElement *_moveElem,
const bool _copy);
const bool _copy,
sdf::Errors &_errors);

/// \brief Add an element or attribute to an element.
/// \param[in] _elem The element to receive the value.
Expand Down
21 changes: 15 additions & 6 deletions src/Converter_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3370,7 +3370,8 @@ TEST(Converter, World_17_to_18)
ASSERT_TRUE(errors.empty());

// Compare converted xml with expected
std::string convertedXmlStr = ElementToString(xmlDoc.RootElement());
std::string convertedXmlStr = ElementToString(errors, xmlDoc.RootElement());
ASSERT_TRUE(errors.empty());
ASSERT_FALSE(convertedXmlStr.empty());

std::string expectedXmlStr = R"(
Expand All @@ -3393,7 +3394,9 @@ TEST(Converter, World_17_to_18)
tinyxml2::XMLDocument expectedXmlDoc;
expectedXmlDoc.Parse(expectedXmlStr.c_str());

EXPECT_EQ(ElementToString(expectedXmlDoc.RootElement()), convertedXmlStr);
EXPECT_EQ(ElementToString(errors, expectedXmlDoc.RootElement()),
convertedXmlStr);
ASSERT_TRUE(errors.empty());

// Check some basic elements
tinyxml2::XMLElement *convertedElem = xmlDoc.FirstChildElement();
Expand Down Expand Up @@ -3509,7 +3512,8 @@ TEST(Converter, World_17_to_18)
ASSERT_TRUE(errors.empty());

// Compare converted xml with expected
convertedXmlStr = ElementToString(xmlDoc.RootElement());
convertedXmlStr = ElementToString(errors, xmlDoc.RootElement());
ASSERT_TRUE(errors.empty());
ASSERT_FALSE(convertedXmlStr.empty());

expectedXmlStr = R"(
Expand Down Expand Up @@ -3577,7 +3581,9 @@ TEST(Converter, World_17_to_18)
expectedXmlDoc.Clear();
expectedXmlDoc.Parse(expectedXmlStr.c_str());

EXPECT_EQ(ElementToString(expectedXmlDoc.RootElement()), convertedXmlStr);
EXPECT_EQ(ElementToString(errors, expectedXmlDoc.RootElement()),
convertedXmlStr);
ASSERT_TRUE(errors.empty());


// ------- Another flattened world in 1.7 format
Expand Down Expand Up @@ -3616,7 +3622,8 @@ TEST(Converter, World_17_to_18)
EXPECT_TRUE(buffer.str().empty()) << buffer.str();

// Compare converted xml with expected
convertedXmlStr = ElementToString(xmlDoc.RootElement());
convertedXmlStr = ElementToString(errors, xmlDoc.RootElement());
ASSERT_TRUE(errors.empty());
ASSERT_FALSE(convertedXmlStr.empty());

expectedXmlStr = R"(
Expand Down Expand Up @@ -3655,7 +3662,9 @@ TEST(Converter, World_17_to_18)
expectedXmlDoc.Clear();
expectedXmlDoc.Parse(expectedXmlStr.c_str());

EXPECT_EQ(ElementToString(expectedXmlDoc.RootElement()), convertedXmlStr);
EXPECT_EQ(ElementToString(errors, expectedXmlDoc.RootElement()),
convertedXmlStr);
ASSERT_TRUE(errors.empty());

// Check some basic elements
convertedElem = xmlDoc.FirstChildElement();
Expand Down
52 changes: 27 additions & 25 deletions src/ParamPassing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void updateParams(const ParserConfig &_config,
_errors.push_back({ErrorCode::ATTRIBUTE_MISSING,
"Element identifier requires an element_id attribute, but the "
"element_id is not set. Skipping element alteration:\n"
+ ElementToString(childElemXml)
+ ElementToString(_errors, childElemXml)
});
continue;
}
Expand All @@ -67,7 +67,7 @@ void updateParams(const ParserConfig &_config,
_errors.push_back({ErrorCode::ATTRIBUTE_INVALID,
"Missing name after double colons in element identifier. "
"Skipping element alteration:\n"
+ ElementToString(childElemXml)
+ ElementToString(_errors, childElemXml)
});
continue;
}
Expand All @@ -83,7 +83,7 @@ void updateParams(const ParserConfig &_config,
{
_errors.push_back({ErrorCode::ATTRIBUTE_INVALID,
"Action [" + actionStr + "] is not a valid action. Skipping "
"element alteration:\n" + ElementToString(childElemXml)
"element alteration:\n" + ElementToString(_errors, childElemXml)
});
continue;
}
Expand All @@ -102,7 +102,7 @@ void updateParams(const ParserConfig &_config,
_errors.push_back({ErrorCode::ATTRIBUTE_MISSING,
"Element to be added is missing a 'name' attribute. "
"Skipping element addition:\n"
+ ElementToString(childElemXml)
+ ElementToString(_errors, childElemXml)
});
continue;
}
Expand All @@ -112,7 +112,7 @@ void updateParams(const ParserConfig &_config,
{
_errors.push_back({ErrorCode::ATTRIBUTE_INVALID,
"The 'name' attribute can not be empty. Skipping element addition:\n"
+ ElementToString(childElemXml)
+ ElementToString(_errors, childElemXml)
});
continue;
}
Expand All @@ -129,7 +129,7 @@ void updateParams(const ParserConfig &_config,
+ " element_id='" + childElemXml->Attribute("element_id")
+ "'> because element already exists in included model. "
+ "Skipping element addition:\n"
+ ElementToString(childElemXml)
+ ElementToString(_errors, childElemXml)
});
continue;
}
Expand Down Expand Up @@ -157,7 +157,8 @@ void updateParams(const ParserConfig &_config,
_errors.push_back({ErrorCode::ELEMENT_MISSING,
"Could not find element <" + std::string(childElemXml->Name())
+ " element_id='" + childElemXml->Attribute("element_id") + "'>. " +
"Skipping element modification:\n" + ElementToString(childElemXml)
"Skipping element modification:\n" +
ElementToString(_errors, childElemXml)
});
continue;
}
Expand Down Expand Up @@ -194,7 +195,7 @@ void updateParams(const ParserConfig &_config,
{
_errors.push_back({ErrorCode::ELEMENT_INVALID,
"Unable to convert XML to SDF. Skipping element replacement:\n"
+ ElementToString(childElemXml)
+ ElementToString(_errors, childElemXml)
});
continue;
}
Expand Down Expand Up @@ -355,7 +356,7 @@ ElementPtr initElementDescription(const tinyxml2::XMLElement *_xml,
_errors.push_back({ErrorCode::ELEMENT_INVALID,
"Element [" + std::string(_xml->Name()) + "] is not a defined "
"SDF element. Skipping element alteration\n: "
+ ElementToString(_xml)
+ ElementToString(_errors, _xml)
});
return nullptr;
}
Expand Down Expand Up @@ -384,7 +385,7 @@ void handleIndividualChildActions(const ParserConfig &_config,
"Missing an action attribute. Skipping child element modification "
"with parent <" + std::string(_childrenXml->Name()) + " element_id='"
+ std::string(_childrenXml->Attribute("element_id")) + "'>:\n"
+ ElementToString(xmlChild)
+ ElementToString(_errors, xmlChild)
});
continue;
}
Expand All @@ -397,7 +398,7 @@ void handleIndividualChildActions(const ParserConfig &_config,
"child element modification with parent <"
+ std::string(_childrenXml->Name()) + " element_id='"
+ std::string(_childrenXml->Attribute("element_id")) + "'>:\n"
+ ElementToString(xmlChild)
+ ElementToString(_errors, xmlChild)
});
continue;
}
Expand All @@ -411,7 +412,7 @@ void handleIndividualChildActions(const ParserConfig &_config,
"Could not find element. Skipping child element removal "
"with parent <" + std::string(_childrenXml->Name()) + " element_id='"
+ std::string(_childrenXml->Attribute("element_id")) + "'>:\n"
+ ElementToString(xmlChild)
+ ElementToString(_errors, xmlChild)
});
}
else
Expand All @@ -430,7 +431,7 @@ void handleIndividualChildActions(const ParserConfig &_config,
"Could not find element. Skipping child element modification "
"with parent <" + std::string(_childrenXml->Name()) + " element_id='"
+ std::string(_childrenXml->Attribute("element_id")) + "'>:\n"
+ ElementToString(xmlChild)
+ ElementToString(_errors, xmlChild)
});
}
else
Expand All @@ -455,7 +456,7 @@ void handleIndividualChildActions(const ParserConfig &_config,
"child element modification with parent <"
+ std::string(_childrenXml->Name()) + " element_id='"
+ std::string(_childrenXml->Attribute("element_id")) + "'>:\n"
+ ElementToString(xmlChild)
+ ElementToString(_errors, xmlChild)
});
continue;
}
Expand All @@ -468,7 +469,7 @@ void handleIndividualChildActions(const ParserConfig &_config,
"Unable to convert XML to SDF. Skipping child element alteration "
"with parent <" + std::string(_childrenXml->Name()) + " element_id='"
+ std::string(_childrenXml->Attribute("element_id")) + "'>:\n"
+ ElementToString(xmlChild)
+ ElementToString(_errors, xmlChild)
});
continue;
}
Expand All @@ -486,7 +487,7 @@ void handleIndividualChildActions(const ParserConfig &_config,
"Could not find element. Skipping child element replacement "
"with parent <" + std::string(_childrenXml->Name()) + " element_id='"
+ std::string(_childrenXml->Attribute("element_id")) + "'>:\n"
+ ElementToString(xmlChild)
+ ElementToString(_errors, xmlChild)
});
continue;
}
Expand All @@ -498,7 +499,7 @@ void handleIndividualChildActions(const ParserConfig &_config,
"Replacement element is missing a 'name' attribute. "
"Skipping element replacement <" + std::string(_childrenXml->Name())
+ " element_id='" + std::string(_childrenXml->Attribute("element_id"))
+ "'>:\n" + ElementToString(xmlChild)
+ "'>:\n" + ElementToString(_errors, xmlChild)
});
continue;
}
Expand All @@ -525,7 +526,7 @@ void add(const ParserConfig &_config, const std::string &_source,
{
_errors.push_back({ErrorCode::ELEMENT_INVALID,
"Unable to convert XML to SDF. Skipping element addition:\n"
+ ElementToString(_childXml)
+ ElementToString(_errors, _childXml)
});
}
}
Expand Down Expand Up @@ -557,7 +558,8 @@ void modifyAttributes(tinyxml2::XMLElement *_xml,
{
_errors.push_back({ErrorCode::ATTRIBUTE_INVALID,
"Attribute [" + attrName + "] is invalid. "
"Skipping attribute modification in:\n" + ElementToString(_xml)
"Skipping attribute modification in:\n" +
ElementToString(_errors, _xml)
});
continue;
}
Expand All @@ -582,7 +584,7 @@ void modifyChildren(tinyxml2::XMLElement *_xml,
{
_errors.push_back({ErrorCode::ELEMENT_MISSING,
"Could not find element [" + elemName + "]. "
"Skipping modification for:\n" + ElementToString(_xml)
"Skipping modification for:\n" + ElementToString(_errors, _xml)
});
continue;
}
Expand All @@ -599,7 +601,7 @@ void modifyChildren(tinyxml2::XMLElement *_xml,
_errors.push_back({ErrorCode::ELEMENT_INVALID,
"Value [" + std::string(xmlChild->GetText()) + "] for element ["
+ elemName + "] is invalid. Skipping modification for:\n"
+ ElementToString(_xml)
+ ElementToString(_errors, _xml)
});
continue;
}
Expand All @@ -620,9 +622,9 @@ void modifyChildren(tinyxml2::XMLElement *_xml,
// sdf has child elements but no children were specified in xml
std::stringstream ss;
ss << "No modifications for element "
<< ElementToString(xmlChild)
<< ElementToString(_errors, xmlChild)
<< " provided, skipping modification for:\n"
<< ElementToString(_xml);
<< ElementToString(_errors, _xml);
Error err(ErrorCode::WARNING, ss.str());
enforceConfigurablePolicyCondition(
_config.WarningsPolicy(), err, _errors);
Expand Down Expand Up @@ -650,7 +652,7 @@ void modify(tinyxml2::XMLElement *_xml, const sdf::ParserConfig &_config,
_errors.push_back({ErrorCode::ELEMENT_INVALID,
"Value [" + std::string(_xml->GetText()) + "] for element [" +
std::string(_xml->Name()) + "] is invalid. Skipping modification for:\n"
+ ElementToString(_xml)
+ ElementToString(_errors, _xml)
});
}
}
Expand Down Expand Up @@ -688,7 +690,7 @@ void remove(const tinyxml2::XMLElement *_xml, const sdf::ParserConfig &_config,
+ std::string(xmlParent->Name()) + " element_id='"
+ std::string(xmlParent->Attribute("element_id")) + "'> with parent <"
+ std::string(_xml->Name()) + ">:\n"
+ ElementToString(xmlChild)
+ ElementToString(_errors, xmlChild)
});
continue;
}
Expand Down
Loading

0 comments on commit c01e865

Please sign in to comment.