cyberbotics / webots

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

Reset from GUI still not working on certain cases #3051

Closed ad-daniel closed 3 years ago

ad-daniel commented 3 years ago

Describe the Bug As it surfaced here #3036, some issues persist on the master branch regarding the reset.

How to reproduce:

  1. Load the tests/protos/worlds/nested_parameter_transform_node.wbt world.
  2. Run it and notice the PROTO node move.
  3. Reset. The node doesn't return to the initial position.

It's unclear what about it makes it fail, the specific case is a heavily nested PROTO with multiple instances.

ShuffleWire commented 3 years ago

I have another case, when using SolidReference :

  1. Open the following world :

    world file
    #VRML_SIM R2021a utf8
    WorldInfo {
    coordinateSystem "NUE"
    }
    Viewpoint {
    orientation -0.9351235864913506 -0.31827338836034974 -0.1557110408711453 0.9640363489590187
    position -1.87889558080866 7.2834176780814746 6.396411931107234
    }
    TexturedBackground {
    }
    TexturedBackgroundLight {
    }
    Robot {
    children [
    Solid {
      translation 2 0 0
      children [
        Shape {
          geometry Cylinder {
          }
        }
      ]
    }
    Solid {
      children [
        Shape {
          geometry Box {
          }
        }
        SliderJoint {
          device [
            LinearMotor {
            }
          ]
          endPoint SolidReference {
            solidName "solid"
          }
        }
      ]
      name "solid(1)"
    }
    ]
    controller "my_controller"
    }
    
  2. Create a controller named my_controller and use the following code :

    controller file
    #include <webots/robot.h>
    #include <webots/motor.h>
    

define TIME_STEP 64

int main(int argc, char **argv) { wb_robot_init(); WbDeviceTag motor = wb_robot_get_device("linear motor"); while (wb_robot_step(TIME_STEP) != -1) { wb_motor_set_position(motor, 2); }; wb_robot_cleanup(); return 0; }

Run simulation, cylindre should move. Pause the simulation. Restart the simulation. Cylinder don't go back to the original position. BUT Hit a few time the "Execute one simulation step" button, and the cylinder will eventually go back to position. Note that when it come back, it doesn't go at the position 0, but a bit more, like if the simulation have been actually running during those few step, and the cylinder "catch up" to the correct position only at this moment.