Skip to content
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

Cherry-pick sdf9 to sdf10 #436

Merged
merged 5 commits into from
Dec 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: macOS latest

on: [push, pull_request]

jobs:
build:

env:
PACKAGE: sdformat10
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master
- run: brew config

- name: Install base dependencies
run: |
brew tap osrf/simulation;
brew install --only-dependencies ${PACKAGE};

- run: mkdir build
- name: cmake
working-directory: build
run: cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/${PACKAGE}/HEAD
- run: make
working-directory: build
- run: make test
working-directory: build
env:
CTEST_OUTPUT_ON_FAILURE: 1
- name: make install
working-directory: build
run: |
make install;
brew link ${PACKAGE};
- name: Compile example code
working-directory: examples
run: |
mkdir build;
cd build;
cmake ..;
make;
./simple ../simple.sdf;
2 changes: 1 addition & 1 deletion .github/workflows/pr-collection-labeler.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: PR Collection Labeler

on: pull_request
on: pull_request_target

jobs:
pr_collection_labeler:
Expand Down
8 changes: 8 additions & 0 deletions Migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,14 @@ but with improved human-readability..
+ required: 0
+ [BitBucket pull request 589](https://osrf-migration.github.io/sdformat-gh-pages/#!/osrf/sdformat/pull-requests/589)

1. **material.sdf** `//material/double_sided` element
+ description: Flag to indicate whether the mesh that this material is applied to
will be rendered as double sided.
+ type: bool
+ default: false
+ required: 0
+ [pull request 418](https://github.com/osrf/sdformat/pull/418)

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
Expand Down
12 changes: 11 additions & 1 deletion src/parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,8 @@ std::string getModelFilePath(const std::string &_modelDirPath)
if (!sdf::filesystem::exists(configFilePath))
{
// We didn't find manifest.xml either, output an error and get out.
sdferr << "Could not find model.config or manifest.xml for the model\n";
sdferr << "Could not find model.config or manifest.xml in ["
<< _modelDirPath << "]\n";
return std::string();
}
else
Expand Down Expand Up @@ -960,6 +961,15 @@ bool readXml(tinyxml2::XMLElement *_xml, ElementPtr _sdf, Errors &_errors)

// Get the config.xml filename
filename = getModelFilePath(modelPath);

if (filename.empty())
{
_errors.push_back({ErrorCode::URI_LOOKUP,
"Unable to resolve uri[" + uri + "] to model path [" +
modelPath + "] since it does not contain a model.config " +
"file."});
continue;
}
}
else
{
Expand Down
37 changes: 37 additions & 0 deletions test/integration/includes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -318,3 +318,40 @@ TEST(IncludesTest, Includes_15_convert)
EXPECT_EQ("1.6", modelElem->OriginalVersion());
EXPECT_EQ("1.6", linkElem->OriginalVersion());
}

//////////////////////////////////////////////////
TEST(IncludesTest, IncludeModelMissingConfig)
{
sdf::setFindCallback(findFileCb);

std::ostringstream stream;
stream
<< "<sdf version='" << SDF_VERSION << "'>"
<< "<include>"
<< " <uri>box_missing_config</uri>"
<< "</include>"
<< "</sdf>";

sdf::SDFPtr sdfParsed(new sdf::SDF());
sdf::init(sdfParsed);
sdf::Errors errors;
ASSERT_TRUE(sdf::readString(stream.str(), sdfParsed, errors));

ASSERT_GE(1u, errors.size());
EXPECT_EQ(1u, errors.size());
std::cout << errors[0] << std::endl;
EXPECT_EQ(errors[0].Code(), sdf::ErrorCode::URI_LOOKUP);
EXPECT_NE(std::string::npos, errors[0].Message().find(
"Unable to resolve uri[box_missing_config] to model path")) << errors[0];
EXPECT_NE(std::string::npos, errors[0].Message().find(
"box_missing_config] since it does not contain a model.config file"))
<< errors[0];

sdf::Root root;
errors = root.Load(sdfParsed);
for (auto e : errors)
std::cout << e.Message() << std::endl;
EXPECT_TRUE(errors.empty());

EXPECT_EQ(0u, root.ModelCount());
}
22 changes: 22 additions & 0 deletions test/integration/model/box_missing_config/model.sdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" ?>
<sdf version="1.5">
<model name="box">
<pose>0 0 0.5 0 0 0</pose>
<link name="link">
<collision name="collision">
<geometry>
<box>
<size>1 1 1</size>
</box>
</geometry>
</collision>
<visual name="visual">
<geometry>
<box>
<size>1 1 1</size>
</box>
</geometry>
</visual>
</link>
</model>
</sdf>