-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #166 from resibots/utheque
Utheque: URDF-theque (library of URDFs)
- Loading branch information
Showing
347 changed files
with
244 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# - Config file for the utheque package | ||
# example: | ||
# find_package(Utheque REQUIRED) | ||
# add_executable(your_example example.cpp) | ||
# target_link_libraries(your_example Utheque) | ||
|
||
include(CMakeFindDependencyMacro) | ||
include(FindPackageHandleStandardArgs) | ||
|
||
# CMAKE_MODULE_PATH | ||
set(CMAKE_MODULE_PATH "@Utheque_CMAKE_MODULE_PATH@") | ||
|
||
find_package(Boost REQUIRED filesystem) | ||
|
||
set(Utheque_INCLUDE_DIRS "@Utheque_INCLUDE_DIRS@") | ||
|
||
set(Utheque_LIBRARIES "Boost::filesystem") | ||
|
||
add_library(Utheque INTERFACE IMPORTED) | ||
set_target_properties(Utheque PROPERTIES | ||
INTERFACE_LINK_LIBRARIES "${Utheque_LIBRARIES}" | ||
INTERFACE_COMPILE_DEFINITIONS @Utheque_PREFIX@ | ||
INTERFACE_INCLUDE_DIRECTORIES "${Utheque_INCLUDE_DIRS}") | ||
|
||
# Handle the QUIET and REQUIRED arguments | ||
find_package_handle_standard_args( | ||
Utheque #Package name | ||
DEFAULT_MSG | ||
# Variables required to evaluate as TRUE | ||
Utheque_INCLUDE_DIRS) | ||
|
||
mark_as_advanced(Utheque_INCLUDE_DIRS Utheque_FOUND) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
set(PACKAGE_VERSION "@utheque_VERSION@") | ||
|
||
# Check whether the requested PACKAGE_FIND_VERSION is compatible | ||
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}") | ||
set(PACKAGE_VERSION_COMPATIBLE FALSE) | ||
else() | ||
set(PACKAGE_VERSION_COMPATIBLE TRUE) | ||
if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}") | ||
set(PACKAGE_VERSION_EXACT TRUE) | ||
endif() | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
cmake_minimum_required(VERSION 3.10 FATAL_ERROR) | ||
project(utheque_example) | ||
|
||
find_package(Utheque REQUIRED) | ||
|
||
add_executable(utheque_example example_utheque.cpp) | ||
set_target_properties(utheque_example PROPERTIES CXX_STANDARD 11 CXX_STANDARD_REQUIRED YES) | ||
target_link_libraries(utheque_example PUBLIC Utheque) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#include <iostream> | ||
#include <utheque/utheque.hpp> | ||
|
||
int main() | ||
{ | ||
auto p = utheque::path("talos/talos.urdf", true); // verbose mode | ||
std::cout << "Path of the URDF: " << p << std::endl; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#ifndef UTHEQUE_HPP_ | ||
#define UTHEQUE_HPP_ | ||
|
||
#include <boost/algorithm/string.hpp> | ||
#include <boost/filesystem.hpp> // will move to std::filesystem | ||
#include <exception> | ||
#include <string> | ||
|
||
namespace utheque { | ||
#ifndef UTHEQUE_PREFIX | ||
static constexpr char* DEFAULT_PREFIX = const_cast<char*>("/usr/local"); | ||
#else | ||
static constexpr char* DEFAULT_PREFIX = const_cast<char*>(UTHEQUE_PREFIX); | ||
#endif | ||
/// return the directory where to find the urdf (or urdf package) from the utheque (URDF library) | ||
/// if start by /, do nothing | ||
/// otherwise, search (in this order): | ||
/// - in the current directory | ||
/// - in <current_directory>/utheque/ | ||
/// - $UTHEQUE_PATH | ||
/// - in <prefix>/share/utheque | ||
/// The default prefix is got : | ||
/// - from the cmake config (which defines UTHEQUE_PREFIX) | ||
/// - otherwise from -DUTHEQUE_PREFIX="..." | ||
/// - if no UTHEQUE_PREFIX, then use /usr/local | ||
/// @arg urdf or package name (e.g. talos/talos.urdf or talos_description) | ||
/// @arg prefix (default to UTHEQUE_PREFIX) | ||
/// @arg verbose print search paths | ||
/// @return the full (absolute) path where to find the URDF (e.g. /usr/local/share/utheque/) | ||
static std::string directory(const std::string& filename, bool verbose = false, const std::string& prefix = DEFAULT_PREFIX) | ||
{ | ||
namespace fs = boost::filesystem; | ||
fs::path model_file(boost::trim_copy(filename)); | ||
if (verbose) | ||
std::cout << "utheque: searching for [" << model_file.string() << "]" << std::endl; | ||
|
||
if (model_file.string()[0] == '/') | ||
return "/"; | ||
|
||
if (verbose) | ||
std::cout << "utheque: not an absolute path" << std::endl; | ||
|
||
// search current directory | ||
if (fs::exists(model_file)) | ||
return fs::current_path().string(); | ||
|
||
if (verbose) | ||
std::cout << "utheque: not found in current path [" << fs::current_path().string() << "]" << std::endl; | ||
|
||
// search <current_directory>/robots | ||
if (fs::exists(fs::path("utheque") / model_file)) | ||
return (fs::current_path() / fs::path("utheque")).string(); | ||
|
||
if (verbose) | ||
std::cout << "utheque: not found in current path/utheque [" << (fs::current_path() / fs::path("utheque")).string() << "]" << std::endl; | ||
|
||
// search $UTHEQUE_PATH | ||
const char* env = std::getenv("UTHEQUE_PATH"); | ||
if (env != nullptr) { | ||
if (verbose) | ||
std::cout << "Utheque: $UTHEQUE_PATH: [" << env << "]" << std::endl; | ||
fs::path env_path(env); | ||
if (fs::exists(env_path / model_file)) | ||
return env_path.string(); | ||
} | ||
else if (verbose) | ||
std::cout << "Utheque: no $UTHEQUE_PATH" << std::endl; | ||
|
||
if (verbose) | ||
std::cout << "utheque: not found in $UTHEQUE_PATH" << std::endl; | ||
|
||
// search PREFIX/share/utheque | ||
fs::path system_path(prefix + "/share/utheque"); | ||
if (fs::exists(system_path / model_file)) | ||
return system_path.string(); | ||
|
||
if (verbose) | ||
std::cout << "utheque: not found in [" << system_path.string() << "]" << std::endl; | ||
|
||
throw std::runtime_error(std::string("Utheque:: could not find: ") + filename); | ||
|
||
return std::string(); | ||
} | ||
|
||
/// call directory() and put the filename back in the path | ||
/// @arg urdf or package name (e.g. talos/talos.urdf or talos_description) | ||
/// @arg prefix /usr/local/ | ||
/// @return full path of the URDF file: (e.g. /usr/local/share/utheque/talos/talos.urdf) | ||
static std::string path(const std::string& filename, bool verbose = false, const std::string& prefix = DEFAULT_PREFIX) | ||
{ | ||
namespace fs = boost::filesystem; | ||
auto file_dir = fs::path(directory(filename, verbose, prefix)); | ||
auto model_file = file_dir / fs::path(boost::trim_copy(filename)); | ||
return model_file.string(); | ||
} | ||
} // namespace utheque | ||
|
||
#endif |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.