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

tutorials/09_use_custom_engine: Add actual build&run instructions #689

Merged
merged 4 commits into from
Sep 16, 2024
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
57 changes: 50 additions & 7 deletions tutorials/09_use_custom_engine.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,56 @@ While we won't go into detail, here is an example to test our new

To get a more comprehensive view of how `EntityManagementFeatures` are constructed in TPE and Dartsim,
feel free to take a look here:
- Dartsim: [EntityManagementFeatures.hh](https://github.com/gazebosim/gz-physics/blob/ign-physics2/dartsim/src/EntityManagementFeatures.hh) and [EntityManagementFeatures.cc](https://github.com/gazebosim/gz-physics/blob/ign-physics2/dartsim/src/EntityManagementFeatures.cc)
- TPE: [EntityManagementFeatures.hh](https://github.com/gazebosim/gz-physics/blob/ign-physics2/tpe/plugin/src/EntityManagementFeatures.hh) and [EntityManagementFeatures.cc](https://github.com/gazebosim/gz-physics/blob/ign-physics2/tpe/plugin/src/EntityManagementFeatures.cc)
- Dartsim: [EntityManagementFeatures.hh](https://github.com/gazebosim/gz-physics/blob/main/dartsim/src/EntityManagementFeatures.hh) and [EntityManagementFeatures.cc](https://github.com/gazebosim/gz-physics/blob/main/dartsim/src/EntityManagementFeatures.cc)
- TPE: [EntityManagementFeatures.hh](https://github.com/gazebosim/gz-physics/blob/main/tpe/plugin/src/EntityManagementFeatures.hh) and [EntityManagementFeatures.cc](https://github.com/gazebosim/gz-physics/blob/main/tpe/plugin/src/EntityManagementFeatures.cc)

## Compile and run the example

Clone the source code, create a build directory and use `cmake` to compile the code:

```bash
git clone https://github.com/gazebosim/gz-physics
cd gz-physics/examples/simple_plugin
mkdir build
cd build
cmake ..
# Linux
cmake --build . --target PluginTest
# Windows
cmake --build . --target PluginTest --config Release
```

Run the test to verify the new physis plugin:

```bash
# Linux
./PluginTest

# Windows
.\Release\PluginTest.exe
```

You'll see:

```bash
$ ./PluginTest
Created empty world!
```

Once you implement more features, you could try passing `SimplePlugin` as the physics engine
to Gazebo Sim following \ref physicsengine "Use different physics engines" tutorial, e.g. setting

# Linux
export GZ_SIM_PHYSICS_ENGINE_PATH=$GZ_SIM_PHYSICS_ENGINE_PATH:$(pwd)/build
# Windows
set GZ_SIM_PHYSICS_ENGINE_PATH=<PATH_TO_THE_EXAMPLE_DIR>\build\Release

And run Gazebo sim with

## Load and test
gz sim -v4 -s --physics-engine SimplePlugin

Please follow the previous tutorial \ref installation "Installation" to build
`gz-physics` from source again for our new feature to be compiled.
However, with the poor one feature we have implemented in this tutorial, you will only see an error,
because Gazebo Sim needs much more features:

Now we can load the new physics plugin named `gz-physics-tpe-plugin`
to test it on Gazebo by following this \ref physicsengine "Use different physics engines" tutorial.
[error] [Physics.cc:854] No physics plugins implementing required interface found in library
[D:\programming\gz9-ws\gz-ws\src\gz-physics\examples\simple_plugin\build\Release\SimplePlugin.dll].