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

Improving URI to be compatible with Windows #517

Merged
merged 36 commits into from
Oct 14, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
d3648fb
Remove old documents: dart-tutorial, programmingGuide
jslee02 Oct 8, 2015
6bf01b5
Merge pull request #515 from dartsim/docs
jslee02 Oct 9, 2015
28015cc
Fix bug in UriHelpers::getUri_InputIsPath_AppendsFileSchema test
jslee02 Oct 9, 2015
caabef0
Change Uri::fromStringOrPath(~) to convert a path to a file URI
jslee02 Oct 10, 2015
8da05d1
Fix bug in Uri::toString() and update Uri tests for Windows
jslee02 Oct 10, 2015
f59420d
Make ResourceRetriever to take Uri instead of std::string
jslee02 Oct 10, 2015
24e4b0e
Make SkelParser to use Uri instead of raw file path
jslee02 Oct 10, 2015
d509dbe
Make urdf parser to use Uri instead of raw file path
jslee02 Oct 10, 2015
2616b75
Change behavior of Uri(string) to parse not only URI but also local path
jslee02 Oct 10, 2015
c731e99
Update resource retriever tests for Windows paths
jslee02 Oct 10, 2015
e1dc055
Update tests to use Uri instead of raw path
jslee02 Oct 10, 2015
875de88
Use path part instead of full file URI to open a file in urdf_world_p…
jslee02 Oct 11, 2015
363d430
Make sdf parser to use Uri instead of raw file path
jslee02 Oct 11, 2015
bd79ad3
Add Uri::fromPath(~) and deprecate Uri::fromStringOrPath(~)
jslee02 Oct 11, 2015
968615e
Use Uri::createFromPath(filename) to pass file URI
jslee02 Oct 11, 2015
29dbdfc
More work on sdf parser to use Uri instead of raw file path
jslee02 Oct 11, 2015
fccd529
Merge remote-tracking branch 'origin/master' into portable_uri
jslee02 Oct 11, 2015
a1cc97b
Generate test file to avoid issue of inconsistency of newline over OSs
jslee02 Oct 11, 2015
12c79ec
More work on sdf parser to use Uri instead of raw file path
jslee02 Oct 11, 2015
d0a2a04
Revert previous commit and use \r\n to represent newline on Windows
jslee02 Oct 11, 2015
a220ee1
Lower verbosity of AppVeyor tests and enable parallel testing
jslee02 Oct 11, 2015
5c835af
Make new functions take Uri to be backward compatible by allowing imp…
jslee02 Oct 11, 2015
2361358
Remove old ResourceRetriever functions takes string instead of Uri
jslee02 Oct 11, 2015
d20b6b9
Add comment on Uri class based on @mkoval's comment on #517
jslee02 Oct 11, 2015
9f3a6f9
Revert path component to be RFC standard and provide getFilesystemPat…
jslee02 Oct 11, 2015
d2a164f
Change Uri from class to struct to follow our convention
jslee02 Oct 12, 2015
0388250
Fix typo: filUri --> fileUri
jslee02 Oct 12, 2015
78051d0
Minor changes based on the discussion on #517
jslee02 Oct 12, 2015
3390cac
Use Uri::getFilesystemPath() to get file path in urdf_world_parser.cpp
jslee02 Oct 12, 2015
7352b35
Clear Uri components when the URI object fails to parse URI
jslee02 Oct 12, 2015
3c44d64
Remove newline from the test text (hello_world.txt)
jslee02 Oct 12, 2015
252012d
Explicitly set /INCREMENTAL:NO for release build on Visual Studio
jslee02 Oct 12, 2015
42515bd
Fix typo
jslee02 Oct 13, 2015
ed369f5
Use Uri::createFromString() when we know the argument is an URI
jslee02 Oct 13, 2015
c9b21ce
Add Uri test to check fromStringOrPath can distinguish path and uri -…
jslee02 Oct 13, 2015
78557fd
Fix fromStringOrPath to correctly distinguish (absolute) path and URI
jslee02 Oct 13, 2015
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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ if(MSVC)
endif()
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${DART_RUNTIME_LIBRARY}d /Zi /Gy /W1 /EHsc")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${DART_RUNTIME_LIBRARY} /Zi /GL /Gy /W1 /EHsc /arch:SSE2")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/LTCG")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/LTCG /INCREMENTAL:NO")
elseif(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "-Wall -msse2 -fPIC")
execute_process(
Expand Down
3 changes: 1 addition & 2 deletions apps/addDeleteSkels/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@
int main(int argc, char* argv[]) {
// create and initialize the world
dart::simulation::WorldPtr myWorld
= dart::utils::SkelParser::readWorld(
DART_DATA_PATH"/skel/ground.skel");
= dart::utils::SkelParser::readWorld(DART_DATA_PATH"/skel/ground.skel");
assert(myWorld != nullptr);
Eigen::Vector3d gravity(0.0, -9.81, 0.0);
myWorld->setGravity(gravity);
Expand Down
6 changes: 3 additions & 3 deletions apps/atlasSimbicon/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@

using namespace std;
using namespace Eigen;
using namespace dart::common;
using namespace dart::dynamics;
using namespace dart::simulation;
using namespace dart::utils;
Expand All @@ -59,9 +60,8 @@ int main(int argc, char* argv[])
DART_DATA_PATH"sdf/atlas/ground.urdf");
// SkeletonPtr atlas = SoftSdfParser::readSkeleton(
// DART_DATA_PATH"sdf/atlas/atlas_v3_no_head.sdf");
SkeletonPtr atlas
= SoftSdfParser::readSkeleton(
DART_DATA_PATH"sdf/atlas/atlas_v3_no_head_soft_feet.sdf");
SkeletonPtr atlas = SoftSdfParser::readSkeleton(
DART_DATA_PATH"sdf/atlas/atlas_v3_no_head_soft_feet.sdf");
myWorld->addSkeleton(atlas);
myWorld->addSkeleton(ground);

Expand Down
3 changes: 1 addition & 2 deletions apps/bipedStand/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@
int main(int argc, char* argv[]) {
// create and initialize the world
dart::simulation::WorldPtr myWorld
= dart::utils::SkelParser::readWorld(
DART_DATA_PATH"skel/fullbody1.skel");
= dart::utils::SkelParser::readWorld(DART_DATA_PATH"skel/fullbody1.skel");
assert(myWorld != nullptr);

Eigen::Vector3d gravity(0.0, -9.81, 0.0);
Expand Down
2 changes: 1 addition & 1 deletion apps/hybridDynamics/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ int main(int argc, char* argv[])
// create and initialize the world
dart::simulation::WorldPtr myWorld
= dart::utils::SkelParser::readWorld(
DART_DATA_PATH"/skel/fullbody1.skel");
DART_DATA_PATH"/skel/fullbody1.skel");
assert(myWorld != nullptr);
Eigen::Vector3d gravity(0.0, -9.81, 0.0);
myWorld->setGravity(gravity);
Expand Down
4 changes: 2 additions & 2 deletions apps/operationalSpaceControl/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ int main(int argc, char* argv[])
// load skeletons
dart::utils::DartLoader dl;
dart::dynamics::SkeletonPtr ground
= dl.parseSkeleton(DART_DATA_PATH"urdf/KR5/ground.urdf");
= dl.parseSkeleton(DART_DATA_PATH"urdf/KR5/ground.urdf");
dart::dynamics::SkeletonPtr robot
= dl.parseSkeleton(DART_DATA_PATH"urdf/KR5/KR5 sixx R650.urdf");
= dl.parseSkeleton(DART_DATA_PATH"urdf/KR5/KR5 sixx R650.urdf");
world->addSkeleton(ground);
world->addSkeleton(robot);

Expand Down
3 changes: 1 addition & 2 deletions apps/rigidCubes/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@
int main(int argc, char* argv[]) {
// create and initialize the world
dart::simulation::WorldPtr myWorld
= dart::utils::SkelParser::readWorld(
DART_DATA_PATH"/skel/cubes.skel");
= dart::utils::SkelParser::readWorld(DART_DATA_PATH"/skel/cubes.skel");
assert(myWorld != nullptr);
Eigen::Vector3d gravity(0.0, -9.81, 0.0);
myWorld->setGravity(gravity);
Expand Down
2 changes: 1 addition & 1 deletion apps/softBodies/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ int main(int argc, char* argv[])
// create and initialize the world
dart::simulation::WorldPtr myWorld
= dart::utils::SkelParser::readWorld(
DART_DATA_PATH"skel/softBodies.skel");
DART_DATA_PATH"skel/softBodies.skel");
assert(myWorld != nullptr);

for(size_t i=0; i<myWorld->getNumSkeletons(); ++i)
Expand Down
2 changes: 0 additions & 2 deletions apps/speedTest/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,7 @@ std::vector<dart::simulation::WorldPtr> getWorlds()
std::vector<std::string> sceneFiles = getSceneFiles();
std::vector<dart::simulation::WorldPtr> worlds;
for(size_t i=0; i<sceneFiles.size(); ++i)
{
worlds.push_back(dart::utils::SkelParser::readWorld(sceneFiles[i]));
}

return worlds;
}
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ build:
verbosity: quiet # MSBuild verbosity level (quiet|minimal|normal|detailed)

test_script:
- cmd: ctest --build-config %configuration% --extra-verbose --output-on-failure
- cmd: ctest --build-config %configuration% --parallel 4 --output-on-failure
34 changes: 10 additions & 24 deletions dart/common/LocalResourceRetriever.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,43 +45,29 @@ namespace dart {
namespace common {

//==============================================================================
bool LocalResourceRetriever::exists(const std::string& _uri)
bool LocalResourceRetriever::exists(const Uri& _uri) const
{
common::Uri uri;
if(!uri.fromString(_uri))
{
dtwarn << "[LocalResourceRetriever::exists] Failed parsing URI '"
<< _uri << "'.\n";
return false;
}

// Open and close the file to check if it exists. It would be more efficient
// to stat() it, but that is not portable.
if(uri.mScheme.get_value_or("file") != "file")
if(_uri.mScheme.get_value_or("file") != "file")
return false;
else if (!uri.mPath)
else if (!_uri.mPath)
return false;

return std::ifstream(*uri.mPath, std::ios::binary).good();
return std::ifstream(_uri.getFilesystemPath(), std::ios::binary).good();
}

//==============================================================================
common::ResourcePtr LocalResourceRetriever::retrieve(const std::string& _uri)
common::ResourcePtr LocalResourceRetriever::retrieve(const Uri& _uri) const
{
common::Uri uri;
if(!uri.fromString(_uri))
{
dtwarn << "[LocalResourceRetriever::retrieve] Failed parsing URI '"
<< _uri << "'.\n";
if(_uri.mScheme.get_value_or("file") != "file")
return nullptr;
}

if(uri.mScheme.get_value_or("file") != "file")
return nullptr;
else if (!uri.mPath)
else if (!_uri.mPath)
return nullptr;

const auto resource = std::make_shared<LocalResource>(*uri.mPath);
const auto resource
= std::make_shared<LocalResource>(_uri.getFilesystemPath());

if(resource->isGood())
return resource;
else
Expand Down
4 changes: 2 additions & 2 deletions dart/common/LocalResourceRetriever.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ class LocalResourceRetriever : public virtual ResourceRetriever
virtual ~LocalResourceRetriever() = default;

// Documentation inherited.
bool exists(const std::string& _uri) override;
bool exists(const Uri& _uri) const override;

// Documentation inherited.
ResourcePtr retrieve(const std::string& _uri) override;
ResourcePtr retrieve(const Uri& _uri) const override;
};

using LocalResourceRetrieverPtr = std::shared_ptr<LocalResourceRetriever>;
Expand Down
8 changes: 5 additions & 3 deletions dart/common/ResourceRetriever.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@

#include <memory>
#include <string>
#include "Resource.h"
#include "dart/common/Deprecated.h"
#include "dart/common/Resource.h"
#include "dart/common/Uri.h"

namespace dart {
namespace common {
Expand All @@ -52,10 +54,10 @@ class ResourceRetriever
virtual ~ResourceRetriever() = default;

/// \brief Return whether the resource specified by a URI exists.
virtual bool exists(const std::string& _uri) = 0;
virtual bool exists(const Uri& _uri) const = 0;

/// \brief Return the resource specified by a URI or nullptr on failure.
virtual ResourcePtr retrieve(const std::string& _uri) = 0;
virtual ResourcePtr retrieve(const Uri& _uri) const = 0;
};

using ResourceRetrieverPtr = std::shared_ptr<ResourceRetriever>;
Expand Down
Loading