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

ign -> gz Migrate Ignition Headers : gz-physics #402

Merged
merged 6 commits into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ find_package(ignition-cmake2 2.14.0 REQUIRED)
#============================================================================
# Configure the project
#============================================================================
ign_configure_project(VERSION_SUFFIX)
ign_configure_project(
REPLACE_IGNITION_INCLUDE_PATH gz/physics
VERSION_SUFFIX
)

#============================================================================
# Set project-specific options
Expand Down
2 changes: 2 additions & 0 deletions dartsim/include/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
add_subdirectory(gz)
install(DIRECTORY ignition DESTINATION ${IGN_INCLUDE_INSTALL_DIR_FULL})
62 changes: 62 additions & 0 deletions dartsim/include/gz/physics/dartsim/World.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright (C) 2018 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

#ifndef GZ_PHYSICS_DARTSIM_WORLD_HH_
#define GZ_PHYSICS_DARTSIM_WORLD_HH_

#include <dart/simulation/World.hpp>

#include <gz/physics/FeatureList.hh>

namespace ignition {
namespace physics {
namespace dartsim {

/////////////////////////////////////////////////
class RetrieveWorld : public virtual Feature
{
public: template <typename PolicyT, typename FeaturesT>
class World : public virtual Feature::World<PolicyT, FeaturesT>
{
/// \brief Get the underlying dartsim world for this World object.
public: dart::simulation::WorldPtr GetDartsimWorld();
};

public: template <typename PolicyT>
class Implementation : public virtual Feature::Implementation<PolicyT>
{
public: virtual dart::simulation::WorldPtr GetDartsimWorld(
const Identity &_worldID) = 0;
};
};

/////////////////////////////////////////////////
//! [feature template]
template <typename PolicyT, typename FeaturesT>
dart::simulation::WorldPtr RetrieveWorld::World<PolicyT, FeaturesT>
::GetDartsimWorld()
{
return this->template Interface<RetrieveWorld>()
->GetDartsimWorld(this->identity);
}
//! [feature template]

}
}
}

#endif
19 changes: 19 additions & 0 deletions dartsim/include/ignition/physics/dartsim-plugin/Export.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright (C) 2022 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

#include <gz/physics/dartsim-plugin/Export.hh>
#include <ignition/physics/config.hh>
51 changes: 4 additions & 47 deletions dartsim/include/ignition/physics/dartsim/World.hh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 Open Source Robotics Foundation
* Copyright (C) 2022 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -13,50 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
*/

#ifndef IGNITION_PHYSICS_DARTSIM_WORLD_HH_
#define IGNITION_PHYSICS_DARTSIM_WORLD_HH_

#include <dart/simulation/World.hpp>

#include <ignition/physics/FeatureList.hh>

namespace ignition {
namespace physics {
namespace dartsim {

/////////////////////////////////////////////////
class RetrieveWorld : public virtual Feature
{
public: template <typename PolicyT, typename FeaturesT>
class World : public virtual Feature::World<PolicyT, FeaturesT>
{
/// \brief Get the underlying dartsim world for this World object.
public: dart::simulation::WorldPtr GetDartsimWorld();
};

public: template <typename PolicyT>
class Implementation : public virtual Feature::Implementation<PolicyT>
{
public: virtual dart::simulation::WorldPtr GetDartsimWorld(
const Identity &_worldID) = 0;
};
};

/////////////////////////////////////////////////
//! [feature template]
template <typename PolicyT, typename FeaturesT>
dart::simulation::WorldPtr RetrieveWorld::World<PolicyT, FeaturesT>
::GetDartsimWorld()
{
return this->template Interface<RetrieveWorld>()
->GetDartsimWorld(this->identity);
}
//! [feature template]

}
}
}

#endif
#include <gz/physics/dartsim/World.hh>
#include <ignition/physics/config.hh>
8 changes: 4 additions & 4 deletions dartsim/src/Base.hh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*
*/

#ifndef IGNITION_PHYSICS_DARTSIM_BASE_HH_
#define IGNITION_PHYSICS_DARTSIM_BASE_HH_
#ifndef GZ_PHYSICS_DARTSIM_BASE_HH_
#define GZ_PHYSICS_DARTSIM_BASE_HH_

#include <dart/dynamics/BodyNode.hpp>
#include <dart/dynamics/SimpleFrame.hpp>
Expand All @@ -30,8 +30,8 @@
#include <utility>
#include <vector>

#include <ignition/common/Console.hh>
#include <ignition/physics/Implements.hh>
#include <gz/common/Console.hh>
#include <gz/physics/Implements.hh>

namespace ignition {
namespace physics {
Expand Down
16 changes: 8 additions & 8 deletions dartsim/src/Base_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@

#include <gtest/gtest.h>

#include <ignition/physics/Implements.hh>

#include <ignition/physics/sdf/ConstructCollision.hh>
#include <ignition/physics/sdf/ConstructJoint.hh>
#include <ignition/physics/sdf/ConstructLink.hh>
#include <ignition/physics/sdf/ConstructModel.hh>
#include <ignition/physics/sdf/ConstructVisual.hh>
#include <ignition/physics/sdf/ConstructWorld.hh>
#include <gz/physics/Implements.hh>

#include <gz/physics/sdf/ConstructCollision.hh>
#include <gz/physics/sdf/ConstructJoint.hh>
#include <gz/physics/sdf/ConstructLink.hh>
#include <gz/physics/sdf/ConstructModel.hh>
#include <gz/physics/sdf/ConstructVisual.hh>
#include <gz/physics/sdf/ConstructWorld.hh>

#include "dart/dynamics/BoxShape.hpp"
#include "dart/dynamics/FreeJoint.hpp"
Expand Down
80 changes: 41 additions & 39 deletions dartsim/src/Collisions_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,59 +19,61 @@

#include <test/PhysicsPluginsList.hh>

#include <ignition/physics/FindFeatures.hh>
#include <ignition/physics/RequestEngine.hh>
#include <ignition/plugin/Loader.hh>
#include <gz/physics/FindFeatures.hh>
#include <gz/physics/RequestEngine.hh>
#include <gz/plugin/Loader.hh>

// Features
#include <ignition/physics/ConstructEmpty.hh>
#include <ignition/physics/ForwardStep.hh>
#include <ignition/physics/FrameSemantics.hh>
#include <ignition/physics/FreeJoint.hh>
#include <ignition/physics/GetEntities.hh>
#include <ignition/physics/mesh/MeshShape.hh>
#include <ignition/physics/PlaneShape.hh>
#include <ignition/physics/FixedJoint.hh>

#include <ignition/common/MeshManager.hh>

using TestFeatureList = ignition::physics::FeatureList<
ignition::physics::LinkFrameSemantics,
ignition::physics::ForwardStep,
ignition::physics::GetEntities,
ignition::physics::ConstructEmptyWorldFeature,
ignition::physics::ConstructEmptyModelFeature,
ignition::physics::ConstructEmptyLinkFeature,
ignition::physics::mesh::AttachMeshShapeFeature,
ignition::physics::AttachPlaneShapeFeature,
ignition::physics::SetFreeJointRelativeTransformFeature,
ignition::physics::AttachFixedJointFeature
#include <gz/physics/ConstructEmpty.hh>
#include <gz/physics/ForwardStep.hh>
#include <gz/physics/FrameSemantics.hh>
#include <gz/physics/FreeJoint.hh>
#include <gz/physics/GetEntities.hh>
#include <gz/physics/mesh/MeshShape.hh>
#include <gz/physics/PlaneShape.hh>
#include <gz/physics/FixedJoint.hh>

#include <gz/common/MeshManager.hh>

using namespace ignition;

using TestFeatureList = physics::FeatureList<
physics::LinkFrameSemantics,
physics::ForwardStep,
physics::GetEntities,
physics::ConstructEmptyWorldFeature,
physics::ConstructEmptyModelFeature,
physics::ConstructEmptyLinkFeature,
physics::mesh::AttachMeshShapeFeature,
physics::AttachPlaneShapeFeature,
physics::SetFreeJointRelativeTransformFeature,
physics::AttachFixedJointFeature
>;

using TestWorldPtr = ignition::physics::World3dPtr<TestFeatureList>;
using TestEnginePtr = ignition::physics::Engine3dPtr<TestFeatureList>;
using TestWorldPtr = physics::World3dPtr<TestFeatureList>;
using TestEnginePtr = physics::Engine3dPtr<TestFeatureList>;

using WorldConstructor = std::function<TestWorldPtr(const TestEnginePtr&)>;

std::unordered_set<TestWorldPtr> LoadWorlds(
const std::string &_library,
const WorldConstructor &_constructor)
{
ignition::plugin::Loader loader;
plugin::Loader loader;
loader.LoadLib(_library);

const std::set<std::string> pluginNames =
ignition::physics::FindFeatures3d<TestFeatureList>::From(loader);
physics::FindFeatures3d<TestFeatureList>::From(loader);

std::unordered_set<TestWorldPtr> worlds;
for (const std::string &name : pluginNames)
{
ignition::plugin::PluginPtr plugin = loader.Instantiate(name);
plugin::PluginPtr plugin = loader.Instantiate(name);

std::cout << " -- Plugin name: " << name << std::endl;

auto engine =
ignition::physics::RequestEngine3d<TestFeatureList>::From(plugin);
physics::RequestEngine3d<TestFeatureList>::From(plugin);
EXPECT_NE(nullptr, engine);

worlds.insert(_constructor(engine));
Expand All @@ -86,11 +88,11 @@ class Collisions_TEST
{};

INSTANTIATE_TEST_CASE_P(PhysicsPlugins, Collisions_TEST,
::testing::ValuesIn(ignition::physics::test::g_PhysicsPluginLibraries),); // NOLINT
::testing::ValuesIn(physics::test::g_PhysicsPluginLibraries),); // NOLINT

TestWorldPtr ConstructMeshPlaneWorld(
const ignition::physics::Engine3dPtr<TestFeatureList> &_engine,
const ignition::common::Mesh &_mesh)
const physics::Engine3dPtr<TestFeatureList> &_engine,
const common::Mesh &_mesh)
{
auto world = _engine->ConstructEmptyWorld("world");

Expand All @@ -109,7 +111,7 @@ TestWorldPtr ConstructMeshPlaneWorld(
model = world->ConstructEmptyModel("plane");
link = model->ConstructEmptyLink("link");

link->AttachPlaneShape("plane", ignition::physics::LinearVector3d::UnitZ());
link->AttachPlaneShape("plane", physics::LinearVector3d::UnitZ());
link->AttachFixedJoint(nullptr);

return world;
Expand All @@ -122,7 +124,7 @@ TEST_P(Collisions_TEST, MeshAndPlane)
return;

const std::string meshFilename = IGNITION_PHYSICS_RESOURCE_DIR "/chassis.dae";
auto &meshManager = *ignition::common::MeshManager::Instance();
auto &meshManager = *common::MeshManager::Instance();
auto *mesh = meshManager.Load(meshFilename);

std::cout << "Testing library " << library << std::endl;
Expand All @@ -138,9 +140,9 @@ TEST_P(Collisions_TEST, MeshAndPlane)
EXPECT_NEAR(
0.0, link->FrameDataRelativeToWorld().pose.translation()[2], 1e-6);

ignition::physics::ForwardStep::Output output;
ignition::physics::ForwardStep::State state;
ignition::physics::ForwardStep::Input input;
physics::ForwardStep::Output output;
physics::ForwardStep::State state;
physics::ForwardStep::Input input;
for (std::size_t i = 0; i < 1000; ++i)
{
world->Step(output, state, input);
Expand Down
4 changes: 2 additions & 2 deletions dartsim/src/CustomFeatures.hh
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
#ifndef IGNITION_PHYSICS_SRC_CUSTOMFEATURES_HH
#define IGNITION_PHYSICS_SRC_CUSTOMFEATURES_HH

#include <ignition/physics/Implements.hh>
#include <gz/physics/Implements.hh>

#include <ignition/physics/dartsim/World.hh>
#include <gz/physics/dartsim/World.hh>

#include "Base.hh"

Expand Down
Loading