Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[devel]→[master] Preparation of v1.3.2 #419

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ jobs:
python:
- 3.8
- 3.9
- "3.10"
steps:

- name: '🔍 Inspect Environment'
Expand Down
1 change: 1 addition & 0 deletions scenario/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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+)
Expand Down
4 changes: 4 additions & 0 deletions scenario/src/gazebo/include/scenario/gazebo/World.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
29 changes: 14 additions & 15 deletions scenario/src/gazebo/include/scenario/gazebo/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions scenario/src/gazebo/src/World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 "";
}();
Expand Down
37 changes: 22 additions & 15 deletions scenario/src/gazebo/src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<sdf::Root> 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 {};
}

Expand All @@ -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<sdf::Root> 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 {};
}

Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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+)
Expand Down