From 729f7581332fc09fdec499955a88a34e06bd7bdc Mon Sep 17 00:00:00 2001 From: Diego Ferigo Date: Mon, 25 Oct 2021 17:28:00 +0200 Subject: [PATCH 1/6] Bump specifier set of ScenarIO dependency in devel --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 536d22046..acc92355c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -58,7 +58,7 @@ package_dir = =python python_requires = >=3.8 install_requires = - scenario ~= 1.3.1.pre + scenario >= 1.3.2.dev gym >= 0.13.1 numpy scipy From 95a185b3a98e7177de5a73c95c6d1356866054e1 Mon Sep 17 00:00:00 2001 From: Diego Ferigo Date: Sat, 6 Nov 2021 17:29:43 +0100 Subject: [PATCH 2/6] Extend functions that process SDF files to also accept SDF strings --- .../gazebo/include/scenario/gazebo/utils.h | 29 +++++++-------- scenario/src/gazebo/src/utils.cpp | 37 +++++++++++-------- 2 files changed, 36 insertions(+), 30 deletions(-) diff --git a/scenario/src/gazebo/include/scenario/gazebo/utils.h b/scenario/src/gazebo/include/scenario/gazebo/utils.h index 5d8cb0833..ef2cbb3c1 100644 --- a/scenario/src/gazebo/include/scenario/gazebo/utils.h +++ b/scenario/src/gazebo/include/scenario/gazebo/utils.h @@ -111,28 +111,27 @@ namespace scenario::gazebo::utils { std::string getSdfString(const std::string& fileName); /** - * Get the name of a model from a SDF file. + * Get the name of a model from a SDF file or SDF string. * - * @note sdformat supports only one model per SDF file. + * @note sdformat supports only one model per SDF. * - * @param fileName An SDF file. It could be either an absolute path - * to the file or the file name if the parent folder is part - * of the ``IGN_GAZEBO_RESOURCE_PATH`` environment variable. - * @return The name of the model if the file was found and is valid, - * an empty string otherwise. + * @param fileName An SDF file or string. It could be an absolute path to + * the file, the file name if the parent folder is part of the + * ``IGN_GAZEBO_RESOURCE_PATH`` environment variable, or a SDF string. + * @return The name of the model if the SDF is valid, an empty string + * otherwise. */ std::string getModelNameFromSdf(const std::string& fileName); /** - * Get the name of a world from a SDF file. + * Get the name of a world from a SDF file or SDF string. + * + * @param fileName An SDF file or string. It could be an absolute path to + * the file, the file name if the parent folder is part of the + * ``IGN_GAZEBO_RESOURCE_PATH`` environment variable, or a SDF string. + * @return The name of the world if the SDF is valid, an empty string + * otherwise. * - * @param fileName An SDF file. It could be either an absolute path - * to the file or the file name if the parent folder is part - * of the ``IGN_GAZEBO_RESOURCE_PATH`` environment variable. - * @param worldIndex The index of the world in the SDF file. By - * default it finds the first world. - * @return The name of the world if the file was found and is valid, - * an empty string otherwise. */ std::string getWorldNameFromSdf(const std::string& fileName, const size_t worldIndex = 0); diff --git a/scenario/src/gazebo/src/utils.cpp b/scenario/src/gazebo/src/utils.cpp index 2405ed12d..d7d498579 100644 --- a/scenario/src/gazebo/src/utils.cpp +++ b/scenario/src/gazebo/src/utils.cpp @@ -88,19 +88,20 @@ std::string utils::getSdfString(const std::string& fileName) { // NOTE: We could use std::filesystem for the following, but compilers // support is still rough even with C++17 enabled :/ - std::string sdfFileAbsPath; + std::string sdfFileAbsPath = fileName; - if (!ignition::common::isFile(fileName)) { + std::shared_ptr root; + + if (ignition::common::isFile(fileName)) { sdfFileAbsPath = findSdfFile(fileName); + root = getSdfRootFromFile(fileName); } - - if (sdfFileAbsPath.empty()) { - return {}; + else { + root = getSdfRootFromString(sdfFileAbsPath); } - auto root = getSdfRootFromString(sdfFileAbsPath); - if (!root) { + sError << "Failed to get SDF string" << std::endl; return {}; } @@ -109,24 +110,30 @@ std::string utils::getSdfString(const std::string& fileName) std::string utils::getModelNameFromSdf(const std::string& fileName) { - std::string absFileName = findSdfFile(fileName); + // NOTE: We could use std::filesystem for the following, but compilers + // support is still rough even with C++17 enabled :/ + std::string sdfFileAbsPath = fileName; - if (absFileName.empty()) { - sError << "Failed to find file " << fileName << std::endl; - return {}; - } + std::shared_ptr root; - const auto root = utils::getSdfRootFromFile(absFileName); + if (ignition::common::isFile(fileName)) { + sdfFileAbsPath = findSdfFile(fileName); + root = getSdfRootFromFile(fileName); + } + else { + root = getSdfRootFromString(sdfFileAbsPath); + } if (!root) { + sError << "Failed to get model name from SDF" << std::endl; return {}; } - if (const auto model = root->Model()) { + if (const auto& model = root->Model()) { return model->Name(); } - sError << "No model found in file " << fileName << std::endl; + sError << "No model found in SDF" << std::endl; return {}; } From 4c4a37789471d8e72403317717b1fa022f94571f Mon Sep 17 00:00:00 2001 From: Diego Ferigo Date: Sat, 6 Nov 2021 17:33:25 +0100 Subject: [PATCH 3/6] Introduce support for Trivial Physics Engine --- scenario/src/gazebo/include/scenario/gazebo/World.h | 4 ++++ scenario/src/gazebo/src/World.cpp | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/scenario/src/gazebo/include/scenario/gazebo/World.h b/scenario/src/gazebo/include/scenario/gazebo/World.h index 5bec422db..f74b86bc1 100644 --- a/scenario/src/gazebo/include/scenario/gazebo/World.h +++ b/scenario/src/gazebo/include/scenario/gazebo/World.h @@ -50,6 +50,10 @@ namespace scenario::gazebo { /// The physics engine included in the Dynamic Animation and Robotics /// Toolkit. Dart, + + /// The Trivial Physics Engine, a kinematics-only physics engine + /// developed by Open Robotics. + TPE, }; } // namespace scenario::gazebo diff --git a/scenario/src/gazebo/src/World.cpp b/scenario/src/gazebo/src/World.cpp index bbdc63ee4..30ec18e0d 100644 --- a/scenario/src/gazebo/src/World.cpp +++ b/scenario/src/gazebo/src/World.cpp @@ -257,6 +257,10 @@ bool World::setPhysicsEngine(const PhysicsEngine engine) return "ignition-physics" + std::to_string(IGNITION_PHYSICS_MAJOR_VERSION) + "-dartsim-plugin"; + case PhysicsEngine::TPE: + return "ignition-physics" + + std::to_string(IGNITION_PHYSICS_MAJOR_VERSION) + + "-tpe-plugin"; } return ""; }(); From 4a6568cf40cf485f6cde79c4074471c67f4492b8 Mon Sep 17 00:00:00 2001 From: Diego Ferigo Date: Mon, 25 Oct 2021 10:22:01 +0200 Subject: [PATCH 4/6] Update classifiers to mark Python 3.10 support --- scenario/setup.cfg | 1 + setup.cfg | 1 + 2 files changed, 2 insertions(+) diff --git a/scenario/setup.cfg b/scenario/setup.cfg index 83dd3bfc8..3d2f04d52 100644 --- a/scenario/setup.cfg +++ b/scenario/setup.cfg @@ -44,6 +44,7 @@ classifiers = Programming Language :: C++ Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 + Programming Language :: Python :: 3.10 Programming Language :: Python :: 3 :: Only Programming Language :: Python :: Implementation :: CPython License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+) diff --git a/setup.cfg b/setup.cfg index acc92355c..9266f2177 100644 --- a/setup.cfg +++ b/setup.cfg @@ -47,6 +47,7 @@ classifiers = Intended Audience :: Science/Research Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 + Programming Language :: Python :: 3.10 Programming Language :: Python :: 3 :: Only Programming Language :: Python :: Implementation :: CPython License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+) From b245ec7ffaf6e84cf6a1e7e58e68b256633ee87d Mon Sep 17 00:00:00 2001 From: Diego Ferigo Date: Mon, 25 Oct 2021 10:25:21 +0200 Subject: [PATCH 5/6] Enable Python 3.10 in CI --- .github/workflows/cicd.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index ab4e4b95d..adb098945 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -140,6 +140,7 @@ jobs: python: - 3.8 - 3.9 + - "3.10" steps: - name: '🔍 Inspect Environment' From 3d9f58a9f834f33463869a255762016eb93827f3 Mon Sep 17 00:00:00 2001 From: Diego Ferigo Date: Sat, 13 Nov 2021 11:02:39 +0100 Subject: [PATCH 6/6] Fix converting transform from idyntree to numpy --- python/gym_ignition/rbd/idyntree/numpy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/gym_ignition/rbd/idyntree/numpy.py b/python/gym_ignition/rbd/idyntree/numpy.py index 8a7268997..d38c873f1 100644 --- a/python/gym_ignition/rbd/idyntree/numpy.py +++ b/python/gym_ignition/rbd/idyntree/numpy.py @@ -129,7 +129,7 @@ def from_idyntree_transform( return position.toNumPy(), rotation.toNumPy() else: - H = np.zeros(shape=[4, 4]) + H = np.eye(4) H[0:3, 3] = position.toNumPy() H[0:3, 0:3] = rotation.toNumPy()