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' 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() 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/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/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/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 ""; }(); 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 {}; } 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+)