forked from gazebosim/gz-physics
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Citadel] Update tutorials (gazebosim#204)
Signed-off-by: claireyywang <22240514+claireyywang@users.noreply.github.com> Signed-off-by: anindex <an.thai.le97@gmail.com> Co-authored-by: anindex <an.thai.le97@gmail.com> Co-authored-by: Louise Poubel <louise@openrobotics.org> Co-authored-by: Claire Wang <22240514+claireyywang@users.noreply.github.com> Co-authored-by: Steve Peters <scpeters@openrobotics.org>
- Loading branch information
1 parent
671ee8c
commit 966b7ec
Showing
27 changed files
with
592 additions
and
413 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
cmake_minimum_required(VERSION 3.5 FATAL_ERROR) | ||
|
||
set(IGN_PLUGIN_VER 1) | ||
find_package(ignition-plugin${IGN_PLUGIN_VER} 1.1 REQUIRED COMPONENTS all) | ||
|
||
set(IGN_PHYSICS_VER 2) | ||
find_package(ignition-physics${IGN_PHYSICS_VER} REQUIRED) | ||
|
||
add_library(SimplePlugin SHARED plugin.cc EntityManagementFeatures.cc) | ||
target_link_libraries(SimplePlugin | ||
PRIVATE | ||
ignition-physics${IGN_PHYSICS_VER}::ignition-physics${IGN_PHYSICS_VER}) | ||
|
||
add_executable(PluginTest EntityManagementFeatures_TEST.cc) | ||
target_link_libraries(PluginTest | ||
ignition-plugin${IGN_PLUGIN_VER}::loader | ||
ignition-physics${IGN_PHYSICS_VER}::ignition-physics${IGN_PHYSICS_VER}) | ||
|
||
target_compile_definitions(PluginTest PRIVATE | ||
"simple_plugin_LIB=\"$<TARGET_FILE:SimplePlugin>\"") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (C) 2021 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 <string> | ||
#include "EntityManagementFeatures.hh" | ||
|
||
using namespace ignition; | ||
using namespace physics; | ||
using namespace simpleplugin; | ||
|
||
///////////////////////////////////////////////// | ||
Identity EntityManagementFeatures::ConstructEmptyWorld( | ||
const Identity &, const std::string &_name) | ||
{ | ||
// Generate dummy identity | ||
return this->GenerateIdentity(0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright (C) 2021 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. | ||
* | ||
*/ | ||
|
||
//! [basic include] | ||
#include <string> | ||
#include <ignition/physics/Implements.hh> | ||
//! [basic include] | ||
|
||
//! [include feature] | ||
#include <ignition/physics/ConstructEmpty.hh> | ||
|
||
namespace ignition { | ||
namespace physics { | ||
namespace simpleplugin { | ||
|
||
struct EntityManagementFeatureList : FeatureList< | ||
ConstructEmptyWorldFeature | ||
> { }; | ||
|
||
//! [include feature] | ||
|
||
//! [override feature] | ||
class EntityManagementFeatures : | ||
public virtual Implements3d<EntityManagementFeatureList> | ||
{ | ||
/// \brief Construct an empty dummy world. | ||
/// \param[in] _engineID Identity for the engine. | ||
/// \param[in] _name Name of the world. | ||
public: Identity ConstructEmptyWorld( | ||
const Identity &_engineID, const std::string &_name) override; | ||
}; | ||
|
||
} | ||
} | ||
} | ||
//! [override feature] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright (C) 2021 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 <iostream> | ||
|
||
#include <ignition/plugin/Loader.hh> | ||
#include <ignition/physics/RequestEngine.hh> | ||
#include "EntityManagementFeatures.hh" | ||
|
||
// Simple executable that loads the simple plugin and constructs a world. | ||
|
||
struct TestFeatureList : ignition::physics::FeatureList< | ||
ignition::physics::simpleplugin::EntityManagementFeatureList | ||
> { }; | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
// Load the custom plugin | ||
ignition::plugin::Loader loader; | ||
loader.LoadLib(simple_plugin_LIB); | ||
|
||
auto simplePlugin = | ||
loader.Instantiate("ignition::physics::simpleplugin::Plugin"); | ||
|
||
// Get the engine pointer | ||
auto engine = | ||
ignition::physics::RequestEngine3d<TestFeatureList>::From(simplePlugin); | ||
|
||
if (nullptr == engine) | ||
{ | ||
std::cerr << "Something went wrong, the engine is null" << std::endl; | ||
return -1; | ||
} | ||
|
||
auto world = engine->ConstructEmptyWorld("empty world"); | ||
|
||
if (nullptr == world) | ||
{ | ||
std::cerr << "Failed to create empty world" << std::endl; | ||
return -1; | ||
} | ||
|
||
std::cout << "Created empty world!" << std::endl; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright (C) 2021 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 <ignition/physics/FeatureList.hh> | ||
#include <ignition/physics/FeaturePolicy.hh> | ||
#include <ignition/physics/Register.hh> | ||
|
||
#include "EntityManagementFeatures.hh" | ||
|
||
namespace ignition { | ||
namespace physics { | ||
namespace simpleplugin { | ||
|
||
struct SimplePluginFeatures : FeatureList< | ||
EntityManagementFeatureList | ||
> { }; | ||
|
||
class Plugin : | ||
public virtual EntityManagementFeatures, | ||
public virtual Implements3d<SimplePluginFeatures> | ||
{ | ||
using Identity = ignition::physics::Identity; | ||
public: Identity InitiateEngine(std::size_t /*_engineID*/) override | ||
{ | ||
return this->GenerateIdentity(0); | ||
} | ||
}; | ||
|
||
IGN_PHYSICS_ADD_PLUGIN(Plugin, FeaturePolicy3d, SimplePluginFeatures) | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.