How to change Physics Engine behaviour in Ignition or Classic?
Hi everyone,
I would like to know how to modify in a certain way the Physics Engine (PE) in Ignition/Classic Gazebo. I'm particularly interested in collision computation, e.g. changing the object representation, collision detection, forces rendering, etc.
As far as I know, there are three possible ways to do this:
- Writing a physics plugin for Classic or Ignition. My question here is, can you actually modify the behaviour of the PE or is the API just meant for getting info from the PE and maybe set some "superficial" parameters, say the gravity vector or the friction coefficient for a given material/object?
Modifying the PE itself. I guess that should be the optimal option because I'd have total freedom. Here, the question is if the following workflow is correct:
git clone
both Gazebo and the PE.- Modify the PE as desired.
- Somehow linking Gazebo
CMakeLists.txt
to my cloned PE repo? - Compile Gazebo
As stated in an upcoming ign-physics tutorial, you can create new
Features
for each PE. The question is the same as no. 1.
If you can also provide a MWE, that would be awesome <3
Cheers,
mcres
Asked by mcres on 2020-11-05 08:48:25 UTC
Answers
Hi, glad you looked at the tutorials. Here's the complete list for context https://github.com/ignitionrobotics/ign-physics/tree/main/tutorials
- To answer your first question, the physics plugin is only an interface to physics engine and cannot modify physics engine behavior. To do that, you will need to modify the particular physics engine source code.
- To see how to link custom physics engine to ignition, you can follow the tutorial here https://github.com/ignitionrobotics/ign-physics/blob/main/tutorials/09-set-up-physics-engine-tpe.md. Basically you will need to implement a physics engine API, and set it up following the example of TPE https://github.com/ignitionrobotics/ign-physics/tree/main/tpe, then write physics plugin feature for the physics engine.
- In the tutorial linked above, there is a minimum example focusing on EntityManagement feature in physics plugin and implementation in TPE.
Hope this helps
Asked by claireyywang on 2020-12-18 15:02:21 UTC
Comments
This is a big question! If you're willing to build the underlying physics engines from source, I think you can change just about anything. Here's a list of approaches you can take for osrf/gazebo (I will leave discussion of ignition for a follow-up post):
To add functionality using the
gazebo::physics
APIs that are agnostic of physics engine, you can write aModelPlugin
orWorldPlugin
. See the HarnessPlugin for example.You can also write plugins that are specific to certain physics engines if the
gazebo::physics
API is not enough. For example, the WheelSlipPlugin uses ODE slip parameters that aren't broadly exposed by thegazebo::physics
API.To change the way Gazebo interfaces its
gazebo::physics
APIs with a physics engine, modify the files in the sub-folders like gazebo/physics/dart or gazebo/physics/bullet. For example, see some changes to support of kinematic loops in DART in bitbucket pull request 3086 merged in osrf/gazebo@bee69082.To modify the way a physics engine works, you can build it from source. The easiest example of this is by modifying our fork of Open Dynamics Engine in the deps/opende folder. For example see a modification of the Gearbox joint in our ODE fork in bitbucket pull request 3073 merged in osrf/gazebo@e11215a7. There are some old instructions for building the other physics engines from source using a catkin workspace, though I would now recommend using a colcon workspace.
Adding or modifying the
gazebo::physics
API that is agnostic of physics engine is a bigger endeavor since it may require modifying the interfaces to all the supported physics engines.
Asked by scpeters on 2020-12-18 15:44:05 UTC
Comments