cyberbotics / webots

Webots Robot Simulator
https://cyberbotics.com
Apache License 2.0
3.2k stars 1.68k forks source link

Physics plugin execution scheme documentation does not match code #5783

Open brettle opened 1 year ago

brettle commented 1 year ago

The execution scheme document says that dSpaceCollide is called before webots_physics_step():

https://github.com/cyberbotics/webots/blob/edf2c18bd759de470c3aa546cabf4b5b8c8ad39a/docs/reference/execution-scheme.md?plain=1#L12-L13

However in the code, it looks like webots_physics_step() is called before collisions. See:

https://github.com/cyberbotics/webots/blob/edf2c18bd759de470c3aa546cabf4b5b8c8ad39a/src/webots/engine/WbSimulationWorld.cpp#L241-L249

webots_physics_step() is called as a result of line 242 and collisions are done during the execution of line 249 (in particular, mCluster->step() calls dWorldStepAndSpaceCollide().

I've marked this as a documentation bug for now, but it's not clear if the current order in the code is intentional/desirable. In particular, the current order precludes a physics plugin from influencing the physics after all of the contact joints have been created.

omichel commented 1 year ago

I agree there is a mismatch here and we should probably fix the documentation in a first step.

Then, it should be investigated, probably in a PR, whether it is possible and desirable to change this order. The PR should demonstrate that changing this order doesn't break anything that can't be repaired and should argue the benefits of such a change.