From 10035a10cec1ad7123e5e5523a333dfc20ec8d14 Mon Sep 17 00:00:00 2001 From: Carlos Mastalli <carlos.mastalli@laas.fr> Date: Mon, 26 Aug 2019 19:29:32 +0200 Subject: [PATCH] [script] Now the loader script works for any installation folder --- CMakeLists.txt | 16 +++++++++++++++- python/robots_loader.py | 5 ++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e4f36c4..d3796cb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,12 +4,26 @@ INCLUDE(cmake/base.cmake) INCLUDE(cmake/test.cmake) INCLUDE(cmake/python.cmake) +# Set up project properties SET(PROJECT_NAMESPACE gepetto) SET(PROJECT_NAME example-robot-data) SET(PROJECT_DESCRIPTION "Set of robot URDFs for benchmarking and developed examples.") - SET(PROJECT_URL https://gepgitlab.laas.fr/${PROJECT_NAMESPACE}/${PROJECT_NAME}) +# Print initial message +MESSAGE("${PROJECT_DESCRIPTION}, version ${PROJECT_VERSION}") +MESSAGE("Copyright (C) 2018-2019 CNRS-LAAS") +MESSAGE("All rights reserved.") +MESSAGE("Released under the BSD 3-Clause License.") + +# Set a default build type to 'Release' if none was specified +IF(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + MESSAGE(STATUS "Setting build type to 'Release' as none was specified.") + SET(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE) + # Set the possible values of build type for cmake-gui + SET_PROPERTY(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") +ENDIF() + SETUP_PROJECT() ADD_REQUIRED_DEPENDENCY("pinocchio >= 2.1.0") diff --git a/python/robots_loader.py b/python/robots_loader.py index da229de..b759161 100644 --- a/python/robots_loader.py +++ b/python/robots_loader.py @@ -1,12 +1,15 @@ from os.path import exists, join +import sys import numpy as np import pinocchio from pinocchio.robot_wrapper import RobotWrapper def getModelPath(subpath): - for path in ['..', '../..', '/opt/openrobots/share/example-robot-data']: + base = '../../../share/example-robot-data' + for p in sys.path: + path = join(p, base.strip('/')) if exists(join(path, subpath.strip('/'))): print("using %s as modelPath" % path) return path -- GitLab