robotology / gz-sim-yarp-plugins

YARP plugins for Modern Gazebo (gz-sim).
BSD 3-Clause "New" or "Revised" License
8 stars 0 forks source link

Run two parallel simulations of a gz-sim-yarp-plugins-enabled robot #153

Closed xela-95 closed 2 months ago

xela-95 commented 2 months ago

Closes #147

xela-95 commented 2 months ago

In https://github.com/robotology/gz-sim-yarp-plugins/pull/153/commits/b460db8597023f5573ad90c78a11f28540919827, two simualtions of the same world are instantiated and launched together, using TestFixture class provided by gz-sim.

Notes:

xela-95 commented 2 months ago

With https://github.com/robotology/gz-sim-yarp-plugins/pull/153/commits/bb537e51d2a76e4c74cf7db4f02e7ab2dbb09fc6 the unit test ControlBoardOnMultipleGazeboInstances uses a coupled pendulum model with a controlboard plugin.

Now the unit test fails, since there is an error when trying to set two devices in DeviceRegister with the same key.

It is then time to make a modification to the way the keys are generated.

@traversaro if I recall well you suggested prefixing the current device key with the memory address stored into the pointer in the call to:

DeviceRegistry::setDevice(std::string deviceDatabaseKey, yarp::dev::PolyDriver* device2add)

Moreover, I think that all the plugin singletons key should be updated in the same way, since for example, we should be able to store the data for the same controlboard device belonging to the same model used in two parallel simulations.

Do you foresee any troubles in progressing on this path?

xela-95 commented 2 months ago

In the last 5 commits I've restructured the data management mechanisms of the plugins that previously made use of the singletons (see https://github.com/robotology/gz-sim-yarp-plugins/issues/147#issuecomment-2049366584). Now the only singleton in the codebase is constituted by the DeviceRegistry class.

xela-95 commented 2 months ago

With https://github.com/robotology/gz-sim-yarp-plugins/pull/153/commits/c345e4cf30d89a92a37a45c3802db81fa877803a I updated the unit test to use a double pendulum, such that the reading of the second joint would present numerical differences pretty quickly.

Here's a video of the simulation of such model:

https://github.com/robotology/gz-sim-yarp-plugins/assets/57228872/7e1bb59d-a7eb-494b-9908-24f3e222299b

Now to make the unit test pass I used the uglier way possible, but also the only one that seems to work at the moment, i.e. using the ECM memory address in the device id (along the scoped name of the device and the yarpDeviceName property).

I'm restructuring the code and the unit test in order to make them pass with the new modifications introduced, thing that is taking a bit of time.

xela-95 commented 2 months ago

There are still three tests failing:

xela-95 commented 2 months ago

What was causing the strange errors (really difficult to debug) the unit test https://github.com/robotology/gz-sim-yarp-plugins/actions/runs/8718567060/job/23916088302#step:12:217 was the use of the TestHelpers method https://github.com/robotology/gz-sim-yarp-plugins/blob/9dc1044dc307742d4c5e7ed45d31392931f2440a/tests/test-helpers/TestHelpers.hh#L14-L32

I created this to help retrieve only a vector of devices already casted to the interface needed in the test. For example, if the model under test has different gz-sim-yarp-plugins defined, I want to perform tests only on ControlBoardDriver devices, but the way in which I implemented it does not work and make the tests crash in unexpected ways.

Before it was easy to reconstruct manually the deviceId since it was only the composition of the device scoped name and the yarpDeviceName (even if this is a code smell since it was relying on the internal implementation of the key string). So maybe now we should find an easy way to query the DeviceRegistry filtering the device to return based on some properties it has (type of Device, model to which it belongs, etc).

xela-95 commented 2 months ago

Since leaving a pendulum freely swing was not giving clear evidence of having two different simulations running concurrently, to assess this in a clear way I updated the test as suggested by @S-Dafarra: now two simulations of a single pendulum (from the same model) in which the joint is position controlled, receive two different reference positions. in this way we can check if the two joints are able to reach their setpoint.

Luckily this was the case! So I can finally conclude that we are able to simulate concurrently the same model on gazebo! 🥳

xela-95 commented 2 months ago

This is the outcome of the unit test in which in one simulation the reference position is 10 degrees, and in the other is 5 degrees:

Start 10: ControlBoardOnMultipleGazeboInstancesTest

10: Test command: /home/acroci/repos/gz-sim-yarp-plugins/build/bin/ControlBoardOnMultipleGazeboInstancesTest
10: Working Directory: /home/acroci/repos/gz-sim-yarp-plugins/build/tests/controlboard
10: Environment variables: 
10:  GZ_SIM_SYSTEM_PLUGIN_PATH=/home/acroci/repos/gz-sim-yarp-plugins/build/lib
10: Test timeout computed to be: 1500
10: Running main() from /home/acroci/repos/gz-sim-yarp-plugins/build/_deps/googletest-src/googletest/src/gtest_main.cc
10: [==========] Running 1 test from 1 test suite.
10: [----------] Global test environment set-up.
10: [----------] 1 test from ControlBoardOnMultipleGazeboInstances
10: [ RUN      ] ControlBoardOnMultipleGazeboInstances.StartConcurrentGazeboInstances
10: [WARNING] File specified with a relative path:  ../../../tests/controlboard/conf/gazebo_controlboard_multiple_instances.ini , resolved to:  /home/acroci/repos/gz-sim-yarp-plugins/build/tests/controlboard/../../../tests/controlboard/conf/gazebo_controlboard_multiple_instances.ini . It is recommended to use a URI.
10: [INFO] Yarp configuration file loaded:  /home/acroci/repos/gz-sim-yarp-plugins/build/tests/controlboard/../../../tests/controlboard/conf/gazebo_controlboard_multiple_instances.ini
10: [INFO] gz-sim-yarp-controlboard-system: configuration of device  controlboard_plugin_device2  loaded
10: [DEBUG] gz-sim-yarp-controlboard-system : robot scoped name:  model/triple_pendulum
10: ==================== ecm address for generated id: 0x58490cc5e5e8
10: [DEBUG] gz-sim-yarp-controlboard-system : deviceId:  0x58490cc5e5e8/model/triple_pendulum/controlboard_plugin_device2
10: [DEBUG] gz-sim-yarp-controlboard-system: initialConfiguration:  0.0
10: [DEBUG] |yarp.dev.PolyDriver|gazebo_controlboard| Parameters are (LIMITS (jntPosMax (10000.0)) (jntPosMin (-10000.0))) (POSITION_CONTROL (controlUnits metric_units) (controlLaw joint_pid_gazebo_v1) (kp (3000.0)) (kd (2.0)) (ki (0.100000000000000005551)) (maxInt (99999)) (maxOutput (99999)) (shift (0.0)) (ko (0.0)) (stictionUp (0.0)) (stictionDwn (0.0))) (VELOCITY_CONTROL (controlUnits metric_units) (controlLaw joint_pid_gazebo_v1) (velocityControlImplementationType integrator_and_position_pid) (kp (500.0)) (kd (2.0)) (ki (0.100000000000000005551)) (maxInt (9999)) (maxOutput (9999)) (shift (0.0)) (ko (0.0)) (stictionUp (0.0)) (stictionDwn (0.0))) (controlBoardId "0x58490cc5e5e8/model/triple_pendulum/controlboard_plugin_device2") (device gazebo_controlboard) (initialConfiguration "0.0") (jointNames (joint1)) (yarpDeviceName controlboard_plugin_device2)
10: [INFO] |yarp.dev.PolyDriver|gazebo_controlboard| Created device <gazebo_controlboard>. See C++ class ControlBoardDriver for documentation.
10: [INFO] Found 1 joints from the plugin configuration.
10: [INFO] Found 2 joints from the model description.
10: [INFO] Joint  joint1  added to the control board data.
10: [WARNING] Group TRAJECTORY_GENERATION not found in plugin configuration. Defaults to minimum jerk trajectory.
10: [WARNING] Group TRAJECTORY_GENERATION not found in plugin configuration. Defaults trajectory generation reference speed and accelerations will be applied
10: [DEBUG] Joint  joint1  trajectory generation reference speed:  10  [deg/s]
10: [DEBUG] Joint  joint1  trajectory generation reference acceleration:  10  [deg/s^2]
10: [INFO] Initial configuration found, initializing trajectory generator with it
10: [INFO] Registered YARP device with instance name: 0x58490cc5e5e8/model/triple_pendulum/controlboard_plugin_device2
10: [WARNING] File specified with a relative path:  ../../../tests/controlboard/conf/gazebo_controlboard_multiple_instances.ini , resolved to:  /home/acroci/repos/gz-sim-yarp-plugins/build/tests/controlboard/../../../tests/controlboard/conf/gazebo_controlboard_multiple_instances.ini . It is recommended to use a URI.
10: [INFO] Yarp configuration file loaded:  /home/acroci/repos/gz-sim-yarp-plugins/build/tests/controlboard/../../../tests/controlboard/conf/gazebo_controlboard_multiple_instances.ini
10: [INFO] gz-sim-yarp-controlboard-system: configuration of device  controlboard_plugin_device2  loaded
10: [DEBUG] gz-sim-yarp-controlboard-system : robot scoped name:  model/triple_pendulum
10: ==================== ecm address for generated id: 0x58490e649a88
10: [DEBUG] gz-sim-yarp-controlboard-system : deviceId:  0x58490e649a88/model/triple_pendulum/controlboard_plugin_device2
10: [DEBUG] gz-sim-yarp-controlboard-system: initialConfiguration:  0.0
10: [DEBUG] |yarp.dev.PolyDriver|gazebo_controlboard| Parameters are (LIMITS (jntPosMax (10000.0)) (jntPosMin (-10000.0))) (POSITION_CONTROL (controlUnits metric_units) (controlLaw joint_pid_gazebo_v1) (kp (3000.0)) (kd (2.0)) (ki (0.100000000000000005551)) (maxInt (99999)) (maxOutput (99999)) (shift (0.0)) (ko (0.0)) (stictionUp (0.0)) (stictionDwn (0.0))) (VELOCITY_CONTROL (controlUnits metric_units) (controlLaw joint_pid_gazebo_v1) (velocityControlImplementationType integrator_and_position_pid) (kp (500.0)) (kd (2.0)) (ki (0.100000000000000005551)) (maxInt (9999)) (maxOutput (9999)) (shift (0.0)) (ko (0.0)) (stictionUp (0.0)) (stictionDwn (0.0))) (controlBoardId "0x58490e649a88/model/triple_pendulum/controlboard_plugin_device2") (device gazebo_controlboard) (initialConfiguration "0.0") (jointNames (joint1)) (yarpDeviceName controlboard_plugin_device2)
10: [INFO] |yarp.dev.PolyDriver|gazebo_controlboard| Created device <gazebo_controlboard>. See C++ class ControlBoardDriver for documentation.
10: [INFO] Found 1 joints from the plugin configuration.
10: [INFO] Found 2 joints from the model description.
10: [INFO] Joint  joint1  added to the control board data.
10: [WARNING] Group TRAJECTORY_GENERATION not found in plugin configuration. Defaults to minimum jerk trajectory.
10: [WARNING] Group TRAJECTORY_GENERATION not found in plugin configuration. Defaults trajectory generation reference speed and accelerations will be applied
10: [DEBUG] Joint  joint1  trajectory generation reference speed:  10  [deg/s]
10: [DEBUG] Joint  joint1  trajectory generation reference acceleration:  10  [deg/s^2]
10: [INFO] Initial configuration found, initializing trajectory generator with it
10: [INFO] Registered YARP device with instance name: 0x58490e649a88/model/triple_pendulum/controlboard_plugin_device2
10: Waiting for Gazebo simulation to finish...
10: Waiting for Gazebo simulation to finish...
10: [Msg] Found no publishers on /stats, adding root stats topic
10: [Msg] Found no publishers on /stats, adding root stats topic
10: [Msg] Found no publishers on /clock, adding root clock topic
10: [Msg] Found no publishers on /clock, adding root clock topic
10: [Dbg] [SimulationRunner.cc:545] Creating PostUpdate worker threads: 4
10: Creating PostUpdate worker threads: [Dbg] [SimulationRunner.cc:545] Creating PostUpdate worker threads: 4
10: [Dbg] [SimulationRunner.cc:556] Creating postupdate worker thread (0)
10: Creating postupdate worker thread (0)
10: [Dbg] [SimulationRunner.cc:556] Creating postupdate worker thread (1)
10: Creating postupdate worker thread (1)
10: [Dbg] [SimulationRunner.cc:556] Creating postupdate worker thread (2)
10: [Dbg] [SimulationRunner.cc:556] Creating postupdate worker thread (2)
10: [Msg] Serving scene information on [/world/tutorial_controlboard/scene/info]
10: [Msg] Serving scene information on [/world/tutorial_controlboard/scene/info]
10: [Msg] Serving graph information on [/world/tutorial_controlboard/scene/graph]
10: [Msg] Serving graph information on [/world/tutorial_controlboard/scene/graph]
10: [Msg] Serving full state on [/world/tutorial_controlboard/state]
10: [Msg] Serving full state on [/world/tutorial_controlboard/state]
10: [Msg] Serving full state (async) on [/world/tutorial_controlboard/state_async]
10: [Msg] Serving full state (async) on [/world/tutorial_controlboard/state_async]
10: [Msg] Publishing scene information on [/world/tutorial_controlboard/scene/info]
10: [Msg] Publishing scene information on [/world/tutorial_controlboard/scene/info]
10: [Msg] Publishing entity deletions on [/world/tutorial_controlboard/scene/deletion]
10: [Msg] Publishing entity deletions on [/world/tutorial_controlboard/scene/deletion]
10: [Msg] Publishing state changes on [/world/tutorial_controlboard/state]
10: [Msg] Publishing state changes on [/world/tutorial_controlboard/state]
10: [Msg] Publishing pose messages on [/world/tutorial_controlboard/pose/info]
10: [Msg] Publishing pose messages on [/world/tutorial_controlboard/pose/info]
10: [Msg] Publishing dynamic pose messages on [/world/tutorial_controlboard/dynamic_pose/info]
10: [Msg] Publishing dynamic pose messages on [/world/tutorial_controlboard/dynamic_pose/info]
10: Waiting for Gazebo simulation to finish...
10: Waiting for Gazebo simulation to finish...
10: Waiting for Gazebo simulation to finish...
10: Waiting for Gazebo simulation to finish...
10: Waiting for Gazebo simulation to finish...
10: Waiting for Gazebo simulation to finish...
10: Waiting for Gazebo simulation to finish...
10: Waiting for Gazebo simulation to finish...
10: Waiting for Gazebo simulation to finish...
10: Waiting for Gazebo simulation to finish...
10: Motion done simulation 1 in 1000 iterations
10: Motion done simulation 2 in 500 iterations
10: Final joint position simulation 1: 9.9983920082
10: Final joint position simulation 2: 4.9983734197
10: [Dbg] [SimulationRunner.cc:572] [Dbg] [SimulationRunner.cc:572] Exiting postupdate worker thread (1)
10: Exiting postupdate worker thread ([Dbg] [SimulationRunner.cc:572] Exiting postupdate worker thread (2)Exiting postupdate worker thread (0
10: )[Dbg] [SimulationRunner.cc:572] Exiting postupdate worker thread (0[Dbg] [SimulationRunner.cc:572] 0))[Dbg] [SimulationRunner.cc:572] Exiting postupdate worker thread (2)
10: 
10: 1)
10: [       OK ] ControlBoardOnMultipleGazeboInstances.StartConcurrentGazeboInstances (12327 ms)
10: [----------] 1 test from ControlBoardOnMultipleGazeboInstances (12327 ms total)
10: 
10: [----------] Global test environment tear-down
10: [==========] 1 test from 1 test suite ran. (12327 ms total)
10: [  PASSED  ] 1 test.
1/1 Test #10: ControlBoardOnMultipleGazeboInstancesTest ...   Passed   12.39 sec
xela-95 commented 2 months ago

I want to iterate a bit on the DeviceRegistry data structure, I will put again this PR into a draft.

xela-95 commented 2 months ago

In https://github.com/robotology/gz-sim-yarp-plugins/pull/153/commits/cd0cd2fb80cb727913a55f7dab560bfb04eec78b I have done substantial restrucuring of the DeviceRegistry interface and of its internal data structure. I adapted all the plugins to use the new interface and finally also the unit tests.

I'm getting a strange behavior on the following unit test, in which is loaded a model containing all plugins we have developed, each one with its yarpConfigurationFile. The strange thing is that if I enable the lines related to the check of the ControlBoard (now commented out), the entire tests is messed up, with Gazebo logging errors in which it cannot find the plugins libraries and the DeviceRegistry holding only the driver related to the controlboard.

https://github.com/robotology/gz-sim-yarp-plugins/blob/cd0cd2fb80cb727913a55f7dab560bfb04eec78b/tests/commons/ConfigurationParsingFromFileTest.cc#L41-L48

The error log I got on my machine is the following:

   Start 11: ConfigurationParsingFromFileTest

11: Test command: /home/acroci/repos/gz-sim-yarp-plugins/build/bin/ConfigurationParsingFromFileTest
11: Working Directory: /home/acroci/repos/gz-sim-yarp-plugins/build/tests/commons
11: Environment variables: 
11:  LIBGL_ALWAYS_SOFTWARE=1
11:  GZ_SIM_SYSTEM_PLUGIN_PATH=/home/acroci/repos/gz-sim-yarp-plugins/build/lib
11:  GZ_SIM_RESOURCE_PATH=:/home/acroci/repos/gz-sim-yarp-plugins/tests/commons/..
11: Test timeout computed to be: 1500
11: Running main() from /home/acroci/repos/gz-sim-yarp-plugins/build/_deps/googletest-src/googletest/src/gtest_main.cc
11: [==========] Running 1 test from 1 test suite.
11: [----------] Global test environment set-up.
11: [----------] 1 test from ConfigurationParsingTest
11: [ RUN      ] ConfigurationParsingTest.LoadPluginsWithYarpConfigurationFile
11: [Err] [SystemLoader.cc:107] Failed to load system plugin: (Reason: No plugins detected in library)
11: - Requested plugin name: [gz::sim::systems::Physics]
11: - Requested library name: [gz-sim-physics-system]
11: - Resolved library path: [/home/acroci/mambaforge/envs/walking/lib/gz-sim-8/plugins/libgz-sim-physics-system.so]
11: [Err] [SystemLoader.cc:107] Failed to load system plugin: (Reason: No plugins detected in library)
11: - Requested plugin name: [gz::sim::systems::UserCommands]
11: - Requested library name: [gz-sim-user-commands-system]
11: - Resolved library path: [/home/acroci/mambaforge/envs/walking/lib/gz-sim-8/plugins/libgz-sim-user-commands-system.so]
11: [Err] [SystemLoader.cc:107] Failed to load system plugin: (Reason: No plugins detected in library)
11: - Requested plugin name: [gz::sim::systems::Sensors]
11: - Requested library name: [gz-sim-sensors-system]
11: - Resolved library path: [/home/acroci/mambaforge/envs/walking/lib/gz-sim-8/plugins/libgz-sim-sensors-system.so]
11: [Err] [SystemLoader.cc:107] Failed to load system plugin: (Reason: No plugins detected in library)
11: - Requested plugin name: [gz::sim::systems::SceneBroadcaster]
11: - Requested library name: [gz-sim-scene-broadcaster-system]
11: - Resolved library path: [/home/acroci/mambaforge/envs/walking/lib/gz-sim-8/plugins/libgz-sim-scene-broadcaster-system.so]
11: [Err] [SystemLoader.cc:107] Failed to load system plugin: (Reason: No plugins detected in library)
11: - Requested plugin name: [gzyarp::Camera]
11: - Requested library name: [gz-sim-yarp-camera-system]
11: - Resolved library path: [/home/acroci/repos/gz-sim-yarp-plugins/build/lib/libgz-sim-yarp-camera-system.so]
11: [Err] [SystemLoader.cc:107] Failed to load system plugin: (Reason: No plugins detected in library)
11: - Requested plugin name: [gzyarp::Laser]
11: - Requested library name: [gz-sim-yarp-laser-system]
11: - Resolved library path: [/home/acroci/repos/gz-sim-yarp-plugins/build/lib/libgz-sim-yarp-laser-system.so]
11: [Err] [SystemLoader.cc:107] Failed to load system plugin: (Reason: No plugins detected in library)
11: - Requested plugin name: [gzyarp::Imu]
11: - Requested library name: [gz-sim-yarp-imu-system]
11: - Resolved library path: [/home/acroci/repos/gz-sim-yarp-plugins/build/lib/libgz-sim-yarp-imu-system.so]
11: [Err] [SystemLoader.cc:107] Failed to load system plugin: (Reason: No plugins detected in library)
11: - Requested plugin name: [gzyarp::BaseState]
11: - Requested library name: [gz-sim-yarp-basestate-system]
11: - Resolved library path: [/home/acroci/repos/gz-sim-yarp-plugins/build/lib/libgz-sim-yarp-basestate-system.so]
11: [Err] [SystemLoader.cc:107] Failed to load system plugin: (Reason: No plugins detected in library)
11: - Requested plugin name: [gzyarp::ForceTorque]
11: - Requested library name: [gz-sim-yarp-forcetorque-system]
11: - Resolved library path: [/home/acroci/repos/gz-sim-yarp-plugins/build/lib/libgz-sim-yarp-forcetorque-system.so]
11: [Msg] Loading SDF world file[/home/acroci/repos/gz-sim-yarp-plugins/tests/commons/model_configuration_file.sdf].
11: [Msg] Serving entity system service on [/entity/system/add]
11: [INFO] File is a URI:  model://commons/conf/controlboard.ini
11: [INFO] Yarp configuration file loaded:  /home/acroci/repos/gz-sim-yarp-plugins/tests/commons/../commons/conf/controlboard.ini
11: [INFO] gz-sim-yarp-controlboard-system: configuration of device  controlboard_plugin_device  loaded
11: [DEBUG] gz-sim-yarp-controlboard-system : robot scoped name:  model/model_with_plugins
11: [DEBUG] gz-sim-yarp-controlboard-system : yarpDeviceName:  controlboard_plugin_device
11: [DEBUG] |yarp.dev.PolyDriver|gazebo_controlboard| Parameters are (LIMITS (jntPosMax (200.0)) (jntPosMin (-200.0))) (POSITION_CONTROL (controlUnits metric_units) (controlLaw joint_pid_gazebo_v1) (kp (3000.0)) (kd (2.0)) (ki (0.100000000000000005551)) (maxInt (99999)) (maxOutput (99999)) (shift (0.0)) (ko (0.0)) (stictionUp (0.0)) (stictionDwn (0.0))) (VELOCITY_CONTROL (controlUnits metric_units) (controlLaw joint_pid_gazebo_v1) (velocityControlImplementationType integrator_and_position_pid) (kp (500.0)) (kd (2.0)) (ki (0.100000000000000005551)) (maxInt (9999)) (maxOutput (9999)) (shift (0.0)) (ko (0.0)) (stictionUp (0.0)) (stictionDwn (0.0))) (controlBoardId "model/model_with_plugins") (device gazebo_controlboard) (jointNames (joint_12)) (yarpDeviceName controlboard_plugin_device)
11: [INFO] |yarp.dev.PolyDriver|gazebo_controlboard| Created device <gazebo_controlboard>. See C++ class ControlBoardDriver for documentation.
11: ======== setDevice called for controlboard_plugin_device
11: ========== controlboard driver set in device registry
11: [INFO] Found 1 joints from the plugin configuration.
11: [INFO] Found 1 joints from the model description.
11: [INFO] Joint  joint_12  added to the control board data.
11: [WARNING] Group TRAJECTORY_GENERATION not found in plugin configuration. Defaults to minimum jerk trajectory.
11: [WARNING] Group TRAJECTORY_GENERATION not found in plugin configuration. Defaults trajectory generation reference speed and accelerations will be applied
11: [DEBUG] Joint  joint_12  trajectory generation reference speed:  10  [deg/s]
11: [DEBUG] Joint  joint_12  trajectory generation reference acceleration:  10  [deg/s^2]
11: [WARNING] No initial configuration found, initializing trajectory generator with current values
11: [INFO] Registered YARP device with instance name: model/model_with_plugins/controlboard_plugin_device
11: [Err] [SystemLoader.cc:107] Failed to load system plugin: (Reason: No plugins detected in library)
11: - Requested plugin name: [gz::sim::systems::Physics]
11: - Requested library name: [gz-sim-physics-system]
11: - Resolved library path: [/home/acroci/mambaforge/envs/walking/lib/gz-sim-8/plugins/libgz-sim-physics-system.so]
11: [Err] [SystemLoader.cc:107] Failed to load system plugin: (Reason: No plugins detected in library)
11: - Requested plugin name: [gz::sim::systems::UserCommands]
11: - Requested library name: [gz-sim-user-commands-system]
11: - Resolved library path: [/home/acroci/mambaforge/envs/walking/lib/gz-sim-8/plugins/libgz-sim-user-commands-system.so]
11: [Err] [SystemLoader.cc:107] Failed to load system plugin: (Reason: No plugins detected in library)
11: - Requested plugin name: [gz::sim::systems::SceneBroadcaster]
11: - Requested library name: [gz-sim-scene-broadcaster-system]
11: - Resolved library path: [/home/acroci/mambaforge/envs/walking/lib/gz-sim-8/plugins/libgz-sim-scene-broadcaster-system.so]
11: [Dbg] [SystemManager.cc:74] Loaded system [gzyarp::ControlBoard] for entity [8]
11: [Msg] Loaded level [3]
11: [Msg] No systems loaded from SDF, loading defaults
11: [Dbg] [ServerConfig.cc:1016] Loaded (3) plugins from file [/home/acroci/.gz/sim/8/server.config]
11: [Msg] Serving world controls on [/world/commons_test/control], [/world/commons_test/control/state] and [/world/commons_test/playback/control]
11: [Msg] Serving GUI information on [/world/commons_test/gui/info]
11: [Msg] World [commons_test] initialized with [1ms] physics profile.
11: [Msg] Serving world SDF generation service on [/world/commons_test/generate_world_sdf]
11: [Msg] Serving world names on [/gazebo/worlds]
11: [Msg] Resource path add service on [/gazebo/resource_paths/add].
11: [Msg] Resource path get service on [/gazebo/resource_paths/get].
11: [Msg] Resource path resolve service on [/gazebo/resource_paths/resolve].
11: [Msg] Resource paths published on [/gazebo/resource_paths].
11: [Msg] Server control service on [/server_control].
11: Testing ControlBoard configuration
11: ======== getDevice called for model/model_with_plugins/controlboard_plugin_device
11: Total devices registered: 1, of which of selected type: 1
11: Testing Camera configuration
11: ======== getDevice called for model/model_with_plugins/controlboard_plugin_device
11: Total devices registered: 1, of which of selected type: 0
11: /home/acroci/repos/gz-sim-yarp-plugins/tests/commons/ConfigurationParsingFromFileTest.cc:78: Failure
11: Expected equality of these values:
11:   cameraDrivers.size()
11:     Which is: 0
11:   1
1/1 Test #11: ConfigurationParsingFromFileTest ...***Exception: SegFault  0.45 sec
xela-95 commented 2 months ago

I was able to resolve the error I was getting in https://github.com/robotology/gz-sim-yarp-plugins/pull/153#issuecomment-2064986146, by not including the Driver classes (also, some of them have only .cpp files and no headers) but by calling the view() method on the PolyDriver asking for the interfaces implemented by each driver. In this case no error occurred.

I'm not sure of the reason behind this strange behavior but it could be due to the include of Drivers cpp files that were messing up some library (like the DeviceRegistry singleton).

traversaro commented 2 months ago

The problem was probably some kind of consequences of us breaking the one definition rule (that is the reason why you always include .h header files with declarations or inline definitions and never .cpp with non-inline definitions). Anyhow, if this now works that is great, is this ready for review?

xela-95 commented 2 months ago

The problem was probably some kind of consequences of us breaking the one definition rule (that is the reason why you always include .h header files with declarations or inline definitions and never .cpp with non-inline definitions). Anyhow, if this now works that is great, is this ready for review?

Yep, I agree with you, I had an unpleasant meeting with "undefined behavior" in C++ 🤣

Yep it's ready for review!

traversaro commented 2 months ago

I guess at some point we need to understand how to get the ecm pointer given the server, but for sure this is out of scope for this PR.

xela-95 commented 2 months ago

I guess at some point we need to understand how to get the ecm pointer given the server, but for sure this is out of scope for this PR.

Yes, exactly; for now, this is the elephant in the room.

xela-95 commented 2 months ago

The unit test failing on the CI is quite scary:

ODE INTERNAL ERROR 1: assertion "!colliders_initialized" failed in dInitColliders() [collision_kernel.cpp:168]

gz-sim related issue: https://github.com/gazebosim/gz-sim/issues/18

The unit test failing is launching two parallel Gazebo instances of different models (one sphere and one box bouncing on the ground). This error seems related to the ODE collision detector having issues due to some global variable. However it seems to happen only on the apt CI workflow on Ubuntu@Debug.

traversaro commented 2 months ago

Ah, that is an old foe. For parallel workflows we should either use another collision detection algorithm when using dart (dart supports several of them if I recall correctly), or using another physics engine. cc @diegoferigo as probably we experienced something similar when working on gym-ignition.

xela-95 commented 2 months ago

Now the models used by concurrent tests use dart both as physics engine and collision detector. All the tests are passing.

Merging 🚀

traversaro commented 2 months ago

That is nice for the tests, but it also means that users will start getting the problem if they start using our APIs for parallel computation. We should at least document this once we will document the possibility of running multiserver. See also the discussion in https://github.com/gazebosim/gz-sim/issues/18#issuecomment-2067252636 .