Skip to content

Commit db1d5e0

Browse files
shameekgangulyahcordeiche033
authored
Update physics_plugins tutorial (#687)
Signed-off-by: Shameek Ganguly <shameekarcanesphinx@gmail.com> Co-authored-by: Alejandro Hernández Cordero <ahcorde@gmail.com> Co-authored-by: Ian Chen <ichen@openrobotics.org>
1 parent 8e28e94 commit db1d5e0

File tree

1 file changed

+39
-89
lines changed

1 file changed

+39
-89
lines changed

tutorials/03_physics_plugins.md

+39-89
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
\page physicsplugin Understanding the Physics Plugin
22

3-
This is an introduction to different physics engines and how they are integrated into the Gazebo Physics library.
4-
5-
## Gazebo Physics
6-
7-
The \ref gz::physics "Gazebo Physics" library integrates external physics engines into the Gazebo Simulation eco-system.
8-
It allows users to select from multiple supported physics engines based on their simulation needs.
9-
Its plugin interface loads physics engines with requested features at runtime.
3+
The \ref gz::physics "Gazebo Physics" library integrates physics engines into the Gazebo Simulation eco-system.
4+
Each physics engine is wrapped into a Gazebo Physics Plugin that can be loaded in a Gazebo simulation.
5+
The Physics Plugin interface loads physics engines with the requested features at runtime.
106
It is also possible to integrate your own selected physics engine by writing a compatible plugin interface.
117

128
To get a more in-depth understanding of how the physics plugin works in Gazebo, we will start with some high level concepts and definitions.
139

1410
<!-- TODO: add tutorial on how to write your own physics plugin -->
1511

16-
### High Level Concept
12+
## High Level Concept
1713

1814
Conceptually, the physics plugin can be viewed from two sides of its interface: user vs. implementation.
1915

@@ -22,7 +18,7 @@ The interface is made possible through the \ref gz::plugin "Gazebo Plugin" libra
2218
This "user side interface" makes the Gazebo Physics library "callable" from other Gazebo libraries.
2319

2420
The implementation side interface handles specific implementations of each `Feature`.
25-
Depending on what external physics engine we are using (DART, TPE etc.), the interface might be different.
21+
Depending on what physics engine we are using in the plugin (DART, TPE etc.), the interface might be different.
2622
This interface is more internal facing, i.e. used mostly inside the Gazebo Physics library.
2723

2824
The implementation of the physics plugin revolves around four key elements.
@@ -38,7 +34,7 @@ The implementation of the physics plugin revolves around four key elements.
3834
FeaturePolicy is a "policy class" used to provide metadata to features about what kind of simulation engine they are going to be used in.
3935
Many physics simulations software libraries model 3-dimensional systems, though some (like Box2d) only consider 2-dimensional systems.
4036
A FeaturePolicy is used to customize Gazebo Physics' APIs by the number of dimensions (2 or 3) and also the floating point scalar type (float or double).
41-
Dartsim and TPE reference implementations both use FeaturePolicy3d (3 dimensions, double).
37+
(All of the currently supported physics engines use FeaturePolicy3d i.e. 3 dimensions and double.)
4238

4339
3. \ref gz::physics::Feature "Feature"
4440

@@ -52,10 +48,10 @@ The implementation of the physics plugin revolves around four key elements.
5248
FeatureLists can be constructed in hierarchies, e.g. a `FeatureList` can be passed into another `FeatureList`, and the set of all features in the new list will be the sum.
5349

5450

55-
### FeatureList Definitions
51+
## FeatureList Organization
5652

57-
This list of `FeatureLists` is specific to the implementation of `Dartsim` and `TPE-plugin`.
58-
Users do not need to organize their own plugin implementations this way.
53+
For example, here are the `FeatureLists` used in the implementation of the `Dartsim` physics engine.
54+
Plugin implementations for other engines may choose to organize features into `FeatureLists` differently.
5955

6056
| Name | Definition |
6157
|---|---|
@@ -71,92 +67,46 @@ Users do not need to organize their own plugin implementations this way.
7167
| SimulationFeatures | updates `World` and everything within by defined stepsize |
7268
| WorldFeatures | sets options like solver and collision detector |
7369

74-
### Dart vs. TPE
75-
76-
<!-- TODO: add Bullet once it's supported -->
77-
<!-- ### Bullet -->
70+
## Available Physics Plugins
7871

7972
Dart ([Dynamic Animation and Robotics Toolkit](https://dartsim.github.io/)) is an open source library that provides data structures and algorithms for kinematic and dynamic applications in robotics and computer animation.
8073
It is the default physics engine used in Gazebo Simulation.
8174
The source code for Dartsim plugin can be found in [Gazebo Physics repository](https://github.com/gazebosim/gz-physics/tree/main) under `dartsim` directory.
8275

8376
TPE ([Trivial Physics Engine](https://github.com/gazebosim/gz-physics/tree/main/tpe)) is an open source library created by Open Robotics that enables fast, inexpensive kinematics simulation for entities at large scale.
8477
It supports higher-order fleet dynamics without real physics (eg. gravity, force, constraint etc.) and multi-machine synchronization.
85-
Gazebo support for TPE targets [Citadel](https://gazebosim.org/docs/citadel) and onward releases.
8678
The source code for TPE plugin can be found in [Gazebo Physics repository](https://github.com/gazebosim/gz-physics/tree/main) under the `tpe/plugin` directory.
8779

88-
The following is a list of features supported by each physics engine to help users select one that fits their needs.
80+
Bullet ([Bullet3 Physics Engine](https://github.com/bulletphysics/bullet3)) is an open source library that supports real-time collision detection and multi-physics simulation for robotics and other application domains.
81+
Since Bullet supports two different APIs - a rigid-body API and a multibody API - with different physics implementations, there are two available plugin implementations:
82+
- The `bullet` plugin implements the rigid-body API, and the source code can be found in [Gazebo Physics repository](https://github.com/gazebosim/gz-physics/tree/main) under the `bullet` directory.
83+
- The `bullet-featherstone` plugin implements the multibody API (based on Featherstone's algorithms), and the source code can be found in [Gazebo Physics repository](https://github.com/gazebosim/gz-physics/tree/main) under the `bullet-featherstone` directory.
8984

90-
#### Entity Comparison
85+
### Entity Comparison
9186

92-
The following is a table of `Entity` names used in Gazebo Physics plugin interface, Dart and TPE.
87+
The following is a table of `Entity` names used in the Gazebo Physics plugin interface, mapped to corresponding types in each supported physics engine.
9388
Entities are arranged in top-down hierarchical order.
9489

95-
| Physics Plugin | Dart | TPE |
96-
|:-:|:-:|:-:|
97-
| Engine | Engine | Engine |
98-
| World | World | World |
99-
| Frame | Frame | N/A |
100-
| Model | Skeleton | Model |
101-
| Joint | Joint | N/A |
102-
| Link | BodyNode | Link |
103-
| Shape | Shape | Collision |
104-
| Box/Sphere/Cylinder etc. | Box/Sphere/Cylinder etc. | Box/Sphere/Cylinder/Mesh etc. |
105-
106-
#### Feature Comparison
107-
108-
The following is a table of implemented `Features` of Dartsim and TPE-Plugin.
109-
110-
| Features | Dartsim | TPE-Plugin |
111-
|:-:|:-:|:-:|
112-
| GetEntities || ✓ (no joint in TPE) |
113-
| RemoveEntities |||
114-
| ConstructEmptyWorldFeature |||
115-
| ConstructEmptyModelFeature |||
116-
| ConstructEmptyLinkFeature |||
117-
| CollisionFilterMaskFeature |||
118-
| FindFreeGroupFeature |||
119-
| SetFreeGroupWorldPose |||
120-
| SetFreeGroupWorldVelocity |||
121-
| GetBasicJointState |||
122-
| SetBasicJointState |||
123-
| GetBasicJointProperties |||
124-
| SetJointTransformFromParentFeature |||
125-
| SetJointTransformToChildFeature |||
126-
| DetachJointFeature |||
127-
| SetFreeJointRelativeTransformFeature |||
128-
| AttachFixedJointFeature |||
129-
| SetRevoluteJointProperties |||
130-
| GetRevoluteJointProperties |||
131-
| AttachRevoluteJointFeature |||
132-
| SetPrismaticJointProperties |||
133-
| GetPrismaticJointProperties |||
134-
| AttachPrismaticJointFeature |||
135-
| SetJointVelocityCommandFeature |||
136-
| LinkFrameSemantics |||
137-
| ShapeFrameSemantics |||
138-
| FreeGroupFrameSemantics |||
139-
| AddLinkExternalForceTorque |||
140-
| sdf::ConstructSdfWorld |||
141-
| sdf::ConstructSdfModel |||
142-
| sdf::ConstructSdfLink |||
143-
| sdf::ConstructSdfJoint |||
144-
| sdf::ConstructSdfCollision |||
145-
| sdf::ConstructSdfVisual |||
146-
| GetShapeKinematicProperties |||
147-
| SetShapeKinematicProperties |||
148-
| GetShapeBoundingBox |||
149-
| GetBoxShapeProperties |||
150-
| AttachBoxShapeFeature |||
151-
| GetCylinderShapeProperties |||
152-
| AttachCylinderShapeFeature |||
153-
| GetSphereShapeProperties |||
154-
| AttachSphereShapeFeature |||
155-
| mesh::GetMeshShapeProperties |||
156-
| mesh::AttachMeshShapeFeature |||
157-
| ForwardStep |||
158-
| GetContactsFromLastStepFeature |||
159-
| CollisionDetector ||
160-
| Solver ||
161-
| heightmap::GetHeightmapShapeProperties || |
162-
| heightmap::AttachHeightmapShapeFeature || |
90+
| Physics Plugin | Dart | TPE | Bullet | Bullet Featherstone |
91+
|:-:|:-:|:-:|:-:|:-:|
92+
| Engine | Engine | Engine | Engine | Engine |
93+
| World | World | World | btDiscreteDynamicsWorld | btMultiBodyDynamicsWorld |
94+
| Frame | Frame | N/A | N/A<sup>1</sup> | N/A<sup>1</sup> |
95+
| Model | Skeleton | Model | N/A<sup>2</sup> | btMultiBody |
96+
| Joint | Joint | N/A | btTypedConstraint | btMultiBodyJoint<sup>3</sup> |
97+
| Link | BodyNode | Link | btRigidBody | btMultiBodyLink |
98+
| Shape | Shape | Collision | btCollisionShape | btCollisionShape |
99+
| Box/Sphere/Cylinder etc. | Box/Sphere/Cylinder etc. | Box/Sphere/Cylinder etc. | Box/Sphere/Cylinder etc. | Box/Sphere/Cylinder etc. |
100+
101+
<sup>1</sup> Frames are implicitly attached to joints, links, collisions or models in the Bullet physics engine.
102+
103+
<sup>2</sup> The Bullet rigid-body API does not have a concept of a Model, but the plugin maintains a collection of Links and Joints in the engine associated with a Model.
104+
105+
<sup>3</sup> There are multiple types in the Bullet Featherstone API to interact with joints, such as btMultiBodyJointLimitConstraint, btMultiBodyJointMotor and btMultiBodyJointFeedback.
106+
107+
### Feature Comparison
108+
109+
For a list of all available `Features` in the Gazebo Physics library, check the classes inherited from `Feature` in the [Gazebo Physics API](https://gazebosim.org/api/physics/8/hierarchy.html).
110+
To check if a physics plugin implements a particular `Feature`, check the `FeatureLists` supported by that plugin as specified in the plugin.cc file, for example, [dartsim/src/plugin.cc](https://github.com/gazebosim/gz-physics/blob/main/dartsim/src/plugin.cc).
111+
112+
Next, check out the tutorial on \ref pluginloading "Loading physics plugins" on how to load a plugin and access a specific `Feature` interface of the plugin programmatically.

0 commit comments

Comments
 (0)