Skip to content

Commit

Permalink
Use URI in tests if applicable
Browse files Browse the repository at this point in the history
  • Loading branch information
jslee02 committed Jan 31, 2017
1 parent 4363ec8 commit 162b7a8
Show file tree
Hide file tree
Showing 29 changed files with 286 additions and 271 deletions.
24 changes: 14 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,9 @@ set(INCLUDE_INSTALL_DIR "include")
set(LIBRARY_INSTALL_DIR "lib")
set(CONFIG_INSTALL_DIR "share/${PROJECT_NAME}/cmake")

if(WIN32)
set()
else()
endif()

set(DART_DATA_INSTALL_REL_PATH "share/doc/${PROJECT_NAME}")
# Set relative location to install additional documentation (sample data,
# examples, and tutorials)
set(DART_ADDITIONAL_DOCUMENTATION_INSTALL_PATH "share/doc/${PROJECT_NAME}")

set(CMAKE_DEBUG_POSTFIX "d")
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
Expand All @@ -52,8 +49,6 @@ if(WIN32)
set(CMAKE_INSTALL_PREFIX "C:/Golems" CACHE PATH "Install prefix" FORCE)
endif()

message(STATUS "CMAKE_INSTALL_DOCDIR: ${CMAKE_INSTALL_DOCDIR}")

#===============================================================================
# Project settings
#===============================================================================
Expand Down Expand Up @@ -388,11 +383,20 @@ install(FILES ${PC_CONFIG_OUT} DESTINATION lib/pkgconfig)
install(FILES package.xml DESTINATION share/${PROJECT_NAME})

#===============================================================================
# Install Misc.
# Install sample data, examples, and tutorials
#===============================================================================

# Sample data
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/data"
DESTINATION ${DART_DATA_INSTALL_REL_PATH})
DESTINATION ${DART_ADDITIONAL_DOCUMENTATION_INSTALL_PATH})

# Examples source
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/examples"
DESTINATION ${DART_ADDITIONAL_DOCUMENTATION_INSTALL_PATH})

# Tutorials source
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/tutorials"
DESTINATION ${DART_ADDITIONAL_DOCUMENTATION_INSTALL_PATH})

#===============================================================================
# Uninstall
Expand Down
2 changes: 1 addition & 1 deletion dart/config.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
#define DART_DATA_PATH "@CMAKE_SOURCE_DIR@/data/"

#define DART_DATA_LOCAL_PATH "@CMAKE_SOURCE_DIR@/data/"
#define DART_DATA_GLOBAL_PATH "@CMAKE_INSTALL_PREFIX@/@DART_DATA_INSTALL_REL_PATH@/data/"
#define DART_DATA_GLOBAL_PATH "@CMAKE_INSTALL_PREFIX@/@DART_ADDITIONAL_DOCUMENTATION_INSTALL_PATH@/data/"

// See #451
#cmakedefine01 ASSIMP_AISCENE_CTOR_DTOR_DEFINED
Expand Down
2 changes: 1 addition & 1 deletion dart/utils/urdf/DartLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ simulation::WorldPtr DartLoader::parseWorldString(
}

std::shared_ptr<urdf_parsing::World> worldInterface =
urdf_parsing::parseWorldURDF(_urdfString, _baseUri);
urdf_parsing::parseWorldURDF(_urdfString, _baseUri, resourceRetriever);

if(!worldInterface)
{
Expand Down
33 changes: 18 additions & 15 deletions dart/utils/urdf/urdf_world_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ Entity::Entity(const urdf::Entity& urdfEntity)
*/
std::shared_ptr<World> parseWorldURDF(
const std::string& _xml_string,
const dart::common::Uri& _baseUri)
const dart::common::Uri& _baseUri,
const common::ResourceRetrieverPtr& retriever)
{
TiXmlDocument xml_doc;
xml_doc.Parse( _xml_string.c_str() );
Expand Down Expand Up @@ -145,32 +146,34 @@ std::shared_ptr<World> parseWorldURDF(
return nullptr;
}

const std::string fileFullName = absoluteUri.getFilesystemPath();
entity.uri = absoluteUri;
// Parse model
std::string xml_model_string;
std::fstream xml_file( fileFullName.c_str(), std::fstream::in );

if(!xml_file.is_open())
// Parse model
const common::ResourcePtr resource = retriever->retrieve(absoluteUri);
if(!resource)
{
dtwarn << "[parseWorldURDF] Could not open the file [" << fileFullName
<< "]. Returning a nullptr.\n";
return nullptr;
dtwarn << "[openXMLFile] Failed opening URI '"
<< absoluteUri.toString() << "'.\n";
throw std::runtime_error("Failed opening URI.");
}

while( xml_file.good() )
// C++11 guarantees that std::string has contiguous storage.
const std::size_t size = resource->getSize();
std::string xml_model_string;
xml_model_string.resize(size);
if(resource->read(&xml_model_string.front(), size, 1) != 1)
{
std::string line;
std::getline( xml_file, line );
xml_model_string += (line + "\n");
dtwarn << "[openXMLFile] Failed reading from URI '"
<< absoluteUri.toString() << "'.\n";
throw std::runtime_error("Failed reading from URI.");
}
xml_file.close();

entity.model = urdf::parseURDF( xml_model_string );

if( !entity.model )
{
dtwarn << "[parseWorldURDF] Could not find a model named ["
<< xml_model_string << "] in file [" << fileFullName
<< xml_model_string << "] from [" << absoluteUri.toString()
<< "]. We will return a nullptr.\n";
return nullptr;
}
Expand Down
2 changes: 1 addition & 1 deletion dart/utils/urdf/urdf_world_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class World
};

std::shared_ptr<World> parseWorldURDF(const std::string &xml_string,
const dart::common::Uri& _baseUri);
const dart::common::Uri& _baseUri, const common::ResourceRetrieverPtr& retriever);

} // namespace urdf_parsing
} // namespace utils
Expand Down
2 changes: 1 addition & 1 deletion examples/atlasSimbicon/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ int main(int argc, char* argv[])
SkeletonPtr ground = urdfLoader.parseSkeleton(
"file://sample/sdf/atlas/ground.urdf");
SkeletonPtr atlas = SdfParser::readSkeleton(
DART_DATA_PATH"sdf/atlas/atlas_v3_no_head_soft_feet.sdf");
"file://sample/sdf/atlas/atlas_v3_no_head_soft_feet.sdf");
myWorld->addSkeleton(atlas);
myWorld->addSkeleton(ground);

Expand Down
2 changes: 1 addition & 1 deletion examples/bipedStand/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,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("file://sample/skel/fullbody1.skel");
assert(myWorld != nullptr);

Eigen::Vector3d gravity(0.0, -9.81, 0.0);
Expand Down
2 changes: 1 addition & 1 deletion examples/jointConstraints/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ int main(int argc, char* argv[])
// load a skeleton file
// create and initialize the world
dart::simulation::WorldPtr myWorld
= utils::SkelParser::readWorld(DART_DATA_PATH"skel/fullbody1.skel");
= utils::SkelParser::readWorld("file://sample/skel/fullbody1.skel");
assert(myWorld != nullptr);

Eigen::Vector3d gravity(0.0, -9.81, 0.0);
Expand Down
2 changes: 1 addition & 1 deletion examples/mixedChain/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ int main(int argc, char* argv[])
// create and initialize the world
dart::simulation::WorldPtr myWorld
= dart::utils::SkelParser::readWorld(
DART_DATA_PATH"skel/test/test_articulated_bodies_10bodies.skel");
"file://sample/skel/test/test_articulated_bodies_10bodies.skel");
assert(myWorld != nullptr);

int dof = myWorld->getSkeleton(1)->getNumDofs();
Expand Down
4 changes: 2 additions & 2 deletions examples/operationalSpaceControl/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,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("file://sample/urdf/KR5/ground.urdf");
dart::dynamics::SkeletonPtr robot
= dl.parseSkeleton(DART_DATA_PATH"urdf/KR5/KR5 sixx R650.urdf");
= dl.parseSkeleton("file://sample/urdf/KR5/KR5 sixx R650.urdf");
world->addSkeleton(ground);
world->addSkeleton(robot);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ int main()

// Load the robot
dart::dynamics::SkeletonPtr robot =
loader.parseSkeleton(DART_DATA_PATH"urdf/KR5/KR5 sixx R650.urdf");
loader.parseSkeleton("file://sample/urdf/KR5/KR5 sixx R650.urdf");
world->addSkeleton(robot);

// Set the colors of the models to obey the shape's color specification
Expand All @@ -275,7 +275,7 @@ int main()

// Load the ground
dart::dynamics::SkeletonPtr ground =
loader.parseSkeleton(DART_DATA_PATH"urdf/KR5/ground.urdf");
loader.parseSkeleton("file://sample/urdf/KR5/ground.urdf");
world->addSkeleton(ground);

// Rotate and move the ground so that z is upwards
Expand Down
2 changes: 1 addition & 1 deletion examples/osgExamples/osgSoftBodies/osgSoftBodies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ int main()
using namespace dart::dynamics;

dart::simulation::WorldPtr world =
dart::utils::SkelParser::readWorld(DART_DATA_PATH"skel/softBodies.skel");
dart::utils::SkelParser::readWorld("file://sample/skel/softBodies.skel");

osg::ref_ptr<RecordingWorld> node = new RecordingWorld(world);

Expand Down
2 changes: 1 addition & 1 deletion examples/rigidShapes/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ int main(int argc, char* argv[])
// load a skeleton file
// create and initialize the world
dart::simulation::WorldPtr myWorld
= dart::utils::SkelParser::readWorld(DART_DATA_PATH"skel/shapes.skel");
= dart::utils::SkelParser::readWorld("file://sample/skel/shapes.skel");
assert(myWorld != NULL);

// create a window and link it to the world
Expand Down
2 changes: 1 addition & 1 deletion examples/softBodies/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,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");
"file://sample/skel/softBodies.skel");
assert(myWorld != nullptr);

for(std::size_t i=0; i<myWorld->getNumSkeletons(); ++i)
Expand Down
38 changes: 19 additions & 19 deletions examples/speedTest/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,25 +164,25 @@ void print_results(const std::vector<double>& result)
std::vector<std::string> getSceneFiles()
{
std::vector<std::string> scenes;
scenes.push_back(DART_DATA_PATH"skel/test/chainwhipa.skel");
scenes.push_back(DART_DATA_PATH"skel/test/single_pendulum.skel");
scenes.push_back(DART_DATA_PATH"skel/test/single_pendulum_euler_joint.skel");
scenes.push_back(DART_DATA_PATH"skel/test/single_pendulum_ball_joint.skel");
scenes.push_back(DART_DATA_PATH"skel/test/double_pendulum.skel");
scenes.push_back(DART_DATA_PATH"skel/test/double_pendulum_euler_joint.skel");
scenes.push_back(DART_DATA_PATH"skel/test/double_pendulum_ball_joint.skel");
scenes.push_back(DART_DATA_PATH"skel/test/serial_chain_revolute_joint.skel");
scenes.push_back(DART_DATA_PATH"skel/test/serial_chain_eulerxyz_joint.skel");
scenes.push_back(DART_DATA_PATH"skel/test/serial_chain_ball_joint.skel");
scenes.push_back(DART_DATA_PATH"skel/test/serial_chain_ball_joint_20.skel");
scenes.push_back(DART_DATA_PATH"skel/test/serial_chain_ball_joint_40.skel");
scenes.push_back(DART_DATA_PATH"skel/test/simple_tree_structure.skel");
scenes.push_back(DART_DATA_PATH"skel/test/simple_tree_structure_euler_joint.skel");
scenes.push_back(DART_DATA_PATH"skel/test/simple_tree_structure_ball_joint.skel");
scenes.push_back(DART_DATA_PATH"skel/test/tree_structure.skel");
scenes.push_back(DART_DATA_PATH"skel/test/tree_structure_euler_joint.skel");
scenes.push_back(DART_DATA_PATH"skel/test/tree_structure_ball_joint.skel");
scenes.push_back(DART_DATA_PATH"skel/fullbody1.skel");
scenes.push_back("file://sample/skel/test/chainwhipa.skel");
scenes.push_back("file://sample/skel/test/single_pendulum.skel");
scenes.push_back("file://sample/skel/test/single_pendulum_euler_joint.skel");
scenes.push_back("file://sample/skel/test/single_pendulum_ball_joint.skel");
scenes.push_back("file://sample/skel/test/double_pendulum.skel");
scenes.push_back("file://sample/skel/test/double_pendulum_euler_joint.skel");
scenes.push_back("file://sample/skel/test/double_pendulum_ball_joint.skel");
scenes.push_back("file://sample/skel/test/serial_chain_revolute_joint.skel");
scenes.push_back("file://sample/skel/test/serial_chain_eulerxyz_joint.skel");
scenes.push_back("file://sample/skel/test/serial_chain_ball_joint.skel");
scenes.push_back("file://sample/skel/test/serial_chain_ball_joint_20.skel");
scenes.push_back("file://sample/skel/test/serial_chain_ball_joint_40.skel");
scenes.push_back("file://sample/skel/test/simple_tree_structure.skel");
scenes.push_back("file://sample/skel/test/simple_tree_structure_euler_joint.skel");
scenes.push_back("file://sample/skel/test/simple_tree_structure_ball_joint.skel");
scenes.push_back("file://sample/skel/test/tree_structure.skel");
scenes.push_back("file://sample/skel/test/tree_structure_euler_joint.skel");
scenes.push_back("file://sample/skel/test/tree_structure_ball_joint.skel");
scenes.push_back("file://sample/skel/fullbody1.skel");

return scenes;
}
Expand Down
4 changes: 2 additions & 2 deletions tutorials/tutorialBiped-Finished/tutorialBiped-Finished.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ class MyWindow : public SimWindow
SkeletonPtr loadBiped()
{
// Create the world with a skeleton
WorldPtr world = SkelParser::readWorld(DART_DATA_PATH"skel/biped.skel");
WorldPtr world = SkelParser::readWorld("file://sample/skel/biped.skel");
assert(world != nullptr);

SkeletonPtr biped = world->getSkeleton("biped");
Expand Down Expand Up @@ -337,7 +337,7 @@ void setInitialPose(SkeletonPtr biped)
void modifyBipedWithSkateboard(SkeletonPtr biped)
{
// Load the Skeleton from a file
WorldPtr world = SkelParser::readWorld(DART_DATA_PATH"skel/skateboard.skel");
WorldPtr world = SkelParser::readWorld("file://sample/skel/skateboard.skel");

SkeletonPtr skateboard = world->getSkeleton(0);

Expand Down
2 changes: 1 addition & 1 deletion tutorials/tutorialBiped/tutorialBiped.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ SkeletonPtr loadBiped()
// Lesson 1

// Create the world with a skeleton
WorldPtr world = SkelParser::readWorld(DART_DATA_PATH"skel/biped.skel");
WorldPtr world = SkelParser::readWorld("file://sample/skel/biped.skel");
assert(world != nullptr);

SkeletonPtr biped = world->getSkeleton("biped");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ SkeletonPtr createManipulator()
// Load the Skeleton from a file
dart::utils::DartLoader loader;
SkeletonPtr manipulator =
loader.parseSkeleton(DART_DATA_PATH"urdf/KR5/KR5 sixx R650.urdf");
loader.parseSkeleton("file://sample/urdf/KR5/KR5 sixx R650.urdf");
manipulator->setName("manipulator");

// Position its base in a reasonable way
Expand Down
38 changes: 19 additions & 19 deletions unittests/comprehensive/test_Constraint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,25 +66,25 @@ class ConstraintTest : public ::testing::Test
//==============================================================================
void ConstraintTest::SetUp()
{
list.push_back(DART_DATA_PATH"skel/test/chainwhipa.skel");
list.push_back(DART_DATA_PATH"skel/test/single_pendulum.skel");
list.push_back(DART_DATA_PATH"skel/test/single_pendulum_euler_joint.skel");
list.push_back(DART_DATA_PATH"skel/test/single_pendulum_ball_joint.skel");
list.push_back(DART_DATA_PATH"skel/test/double_pendulum.skel");
list.push_back(DART_DATA_PATH"skel/test/double_pendulum_euler_joint.skel");
list.push_back(DART_DATA_PATH"skel/test/double_pendulum_ball_joint.skel");
list.push_back(DART_DATA_PATH"skel/test/serial_chain_revolute_joint.skel");
list.push_back(DART_DATA_PATH"skel/test/serial_chain_eulerxyz_joint.skel");
list.push_back(DART_DATA_PATH"skel/test/serial_chain_ball_joint.skel");
list.push_back(DART_DATA_PATH"skel/test/serial_chain_ball_joint_20.skel");
list.push_back(DART_DATA_PATH"skel/test/serial_chain_ball_joint_40.skel");
list.push_back(DART_DATA_PATH"skel/test/simple_tree_structure.skel");
list.push_back(DART_DATA_PATH"skel/test/simple_tree_structure_euler_joint.skel");
list.push_back(DART_DATA_PATH"skel/test/simple_tree_structure_ball_joint.skel");
list.push_back(DART_DATA_PATH"skel/test/tree_structure.skel");
list.push_back(DART_DATA_PATH"skel/test/tree_structure_euler_joint.skel");
list.push_back(DART_DATA_PATH"skel/test/tree_structure_ball_joint.skel");
list.push_back(DART_DATA_PATH"skel/fullbody1.skel");
list.push_back("file://sample/skel/test/chainwhipa.skel");
list.push_back("file://sample/skel/test/single_pendulum.skel");
list.push_back("file://sample/skel/test/single_pendulum_euler_joint.skel");
list.push_back("file://sample/skel/test/single_pendulum_ball_joint.skel");
list.push_back("file://sample/skel/test/double_pendulum.skel");
list.push_back("file://sample/skel/test/double_pendulum_euler_joint.skel");
list.push_back("file://sample/skel/test/double_pendulum_ball_joint.skel");
list.push_back("file://sample/skel/test/serial_chain_revolute_joint.skel");
list.push_back("file://sample/skel/test/serial_chain_eulerxyz_joint.skel");
list.push_back("file://sample/skel/test/serial_chain_ball_joint.skel");
list.push_back("file://sample/skel/test/serial_chain_ball_joint_20.skel");
list.push_back("file://sample/skel/test/serial_chain_ball_joint_40.skel");
list.push_back("file://sample/skel/test/simple_tree_structure.skel");
list.push_back("file://sample/skel/test/simple_tree_structure_euler_joint.skel");
list.push_back("file://sample/skel/test/simple_tree_structure_ball_joint.skel");
list.push_back("file://sample/skel/test/tree_structure.skel");
list.push_back("file://sample/skel/test/tree_structure_euler_joint.skel");
list.push_back("file://sample/skel/test/tree_structure_ball_joint.skel");
list.push_back("file://sample/skel/fullbody1.skel");
}

//==============================================================================
Expand Down
Loading

0 comments on commit 162b7a8

Please sign in to comment.