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

Prepare multiple physics engines support #338

Merged
merged 1 commit into from
Apr 28, 2021
Merged
Changes from all 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
30 changes: 22 additions & 8 deletions cpp/scenario/gazebo/src/World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include <ignition/gazebo/components/Name.hh>
#include <ignition/gazebo/components/ParentEntity.hh>
#include <ignition/gazebo/components/Physics.hh>
#include <ignition/gazebo/components/PhysicsEnginePlugin.hh>
#include <ignition/gazebo/components/Pose.hh>
#include <ignition/math/Pose3.hh>
#include <ignition/math/Vector3.hh>
Expand Down Expand Up @@ -271,16 +272,29 @@ bool World::insertWorldPlugin(const std::string& libName,

bool World::setPhysicsEngine(const PhysicsEngine engine)
{
std::string libName;
std::string className;

switch (engine) {
case PhysicsEngine::Dart:
libName = "PhysicsSystem";
className = "scenario::plugins::gazebo::Physics";
break;
// Get the name of the physics plugin
const std::string pluginLib = [&engine]() -> std::string {
switch (engine) {
case PhysicsEngine::Dart:
return "ignition-physics-dartsim-plugin";
}
return "";
}();

if (pluginLib.empty()) {
sError << "Failed to retrieve the name of physics plugin library";
return false;
}

// This component is read by the Physics system during its configuration
utils::setComponentData<ignition::gazebo::components::PhysicsEnginePlugin>(
m_ecm, m_entity, pluginLib);

// Vendored Physics system
const std::string libName = "PhysicsSystem";
const std::string className = "scenario::plugins::gazebo::Physics";

// Load the Physics system
if (!this->insertWorldPlugin(libName, className)) {
sError << "Failed to insert the physics plugin" << std::endl;
return false;
Expand Down