From 62498e558f02f79561c133fb05b4d7a8486e8135 Mon Sep 17 00:00:00 2001 From: Silvio Traversaro Date: Fri, 23 Aug 2024 16:07:32 +0200 Subject: [PATCH] Add workaround for "ODE INTERNAL ERROR 1: assertion "!colliders_initialized" failed in dInitColliders() [collision_kernel.cpp:168]" crash --- .github/workflows/apt.yml | 8 +++---- tests/commons/ConcurrentInstancesTest.cc | 22 ++++++++++++------ ...ntrolBoardOnMultipleGazeboInstancesTest.cc | 23 +++++++++++++------ 3 files changed, 35 insertions(+), 18 deletions(-) diff --git a/.github/workflows/apt.yml b/.github/workflows/apt.yml index 471bdf6..2876cb9 100644 --- a/.github/workflows/apt.yml +++ b/.github/workflows/apt.yml @@ -101,18 +101,18 @@ jobs: run: | cd build # Deterministic tests - ctest -E "^ConcurrentInstancesTest|^ControlBoardOnMultipleGazeboInstancesTest|^CameraTest" --output-on-failure -C ${{ matrix.build_type }} . + ctest -E "^CameraTest" --output-on-failure -C ${{ matrix.build_type }} . # Non-deterministic tests - ctest -R "^ConcurrentInstancesTest|^ControlBoardOnMultipleGazeboInstancesTest|^CameraTest" --repeat until-pass:10 --output-on-failure -C ${{ matrix.build_type }} . + ctest -R "^CameraTest" --repeat until-pass:10 --output-on-failure -C ${{ matrix.build_type }} . - name: Test (Debug) if: contains(matrix.build_type, 'Debug') run: | cd build # Deterministic tests - ctest -E "^ConcurrentInstancesTest|^ControlBoardOnMultipleGazeboInstancesTest|^CameraTest" -T Test -T Coverage --output-on-failure -C ${{ matrix.build_type }} . + ctest -E "^CameraTest" -T Test -T Coverage --output-on-failure -C ${{ matrix.build_type }} . # Non-deterministic tests - ctest -R "^ConcurrentInstancesTest|^ControlBoardOnMultipleGazeboInstancesTest|^CameraTest" -T Test -T Coverage --repeat until-pass:10 --output-on-failure -C ${{ matrix.build_type }} . + ctest -R "^CameraTest" -T Test -T Coverage --repeat until-pass:10 --output-on-failure -C ${{ matrix.build_type }} . - name: Install diff --git a/tests/commons/ConcurrentInstancesTest.cc b/tests/commons/ConcurrentInstancesTest.cc index 849a166..78f5c00 100644 --- a/tests/commons/ConcurrentInstancesTest.cc +++ b/tests/commons/ConcurrentInstancesTest.cc @@ -13,22 +13,30 @@ TEST(ConcurrentInstancesTest, StartConcurrentGazeboInstancesOfDifferentModels) { auto plannedIterations = 1'000; + gz::common::Console::SetVerbosity(4); + + gz::sim::TestFixture fixture1( (std::filesystem::path(CMAKE_CURRENT_SOURCE_DIR) / "dummy_sphere.sdf").string()); + fixture1.Finalize(); + + // Workaround for https://github.com/robotology/gz-sim-yarp-plugins/issues/201 + gz::sim::TestFixture fixture2( (std::filesystem::path(CMAKE_CURRENT_SOURCE_DIR) / "dummy_box.sdf").string()); - gz::common::Console::SetVerbosity(4); - - fixture1.Finalize(); fixture2.Finalize(); - ASSERT_TRUE(fixture1.Server()->Run(false, plannedIterations, false)); - ASSERT_TRUE(fixture2.Server()->Run(false, plannedIterations, false)); + // First do a step blocked to workaround https://github.com/robotology/gz-sim-yarp-plugins/issues/20 + // Remove if and once https://github.com/gazebosim/gz-physics/pull/675 is merged + ASSERT_TRUE(fixture1.Server()->Run(/*blocking=*/true, 1, /*paused=*/false)); + ASSERT_TRUE(fixture2.Server()->Run(/*blocking=*/true, 1, /*paused=*/false)); + + ASSERT_TRUE(fixture1.Server()->Run(/*paused=*/false, plannedIterations-1, /*paused=*/false)); + ASSERT_TRUE(fixture2.Server()->Run(/*paused=*/false, plannedIterations-1, /*paused=*/false)); while (fixture1.Server()->Running() || fixture2.Server()->Running()) { - std::this_thread::sleep_for(std::chrono::milliseconds(1000)); - std::cerr << "Waiting for Gazebo simulation to finish..." << std::endl; + std::this_thread::sleep_for(std::chrono::milliseconds(100)); } ASSERT_EQ(fixture1.Server()->IterationCount(), plannedIterations); diff --git a/tests/controlboard/ControlBoardOnMultipleGazeboInstancesTest.cc b/tests/controlboard/ControlBoardOnMultipleGazeboInstancesTest.cc index 9294043..8dcd5aa 100644 --- a/tests/controlboard/ControlBoardOnMultipleGazeboInstancesTest.cc +++ b/tests/controlboard/ControlBoardOnMultipleGazeboInstancesTest.cc @@ -60,14 +60,11 @@ TEST(ControlBoardOnMultipleGazeboInstances, StartConcurrentGazeboInstances) unsigned int iterationsToCompleteMotion1 = 0; unsigned int iterationsToCompleteMotion2 = 0; + gz::common::Console::SetVerbosity(4); + gz::sim::TestFixture fixture1( (std::filesystem::path(CMAKE_CURRENT_SOURCE_DIR) / "pendulum_multiple_gz_instances.sdf") .string()); - gz::sim::TestFixture fixture2( - (std::filesystem::path(CMAKE_CURRENT_SOURCE_DIR) / "pendulum_multiple_gz_instances.sdf") - .string()); - gz::common::Console::SetVerbosity(4); - fixture1 .OnConfigure([&](const gz::sim::Entity& _worldEntity, const std::shared_ptr& /*_sdf*/, @@ -98,6 +95,13 @@ TEST(ControlBoardOnMultipleGazeboInstances, StartConcurrentGazeboInstances) }) .Finalize(); + // Workaround for https://github.com/robotology/gz-sim-yarp-plugins/issues/201 + // Remove if and once https://github.com/gazebosim/gz-physics/pull/675 is merged + std::this_thread::sleep_for(std::chrono::milliseconds(10)); + + gz::sim::TestFixture fixture2( + (std::filesystem::path(CMAKE_CURRENT_SOURCE_DIR) / "pendulum_multiple_gz_instances.sdf") + .string()); fixture2 .OnConfigure([&](const gz::sim::Entity& _worldEntity, const std::shared_ptr& /*_sdf*/, @@ -132,8 +136,13 @@ TEST(ControlBoardOnMultipleGazeboInstances, StartConcurrentGazeboInstances) iPositionControl1->positionMove(0, refPosition1); iPositionControl2->positionMove(0, refPosition2); - ASSERT_TRUE(fixture1.Server()->Run(false, plannedIterations, false)); - ASSERT_TRUE(fixture2.Server()->Run(false, plannedIterations, false)); + // First do a step blocked to workaround https://github.com/robotology/gz-sim-yarp-plugins/issues/20 + // Remove if and once https://github.com/gazebosim/gz-physics/pull/675 is merged + ASSERT_TRUE(fixture1.Server()->Run(/*blocking=*/true, 1, /*paused=*/false)); + ASSERT_TRUE(fixture2.Server()->Run(/*blocking=*/true, 1, /*paused=*/false)); + + ASSERT_TRUE(fixture1.Server()->Run(/*blocking=*/false, plannedIterations-1, /*paused=*/false)); + ASSERT_TRUE(fixture2.Server()->Run(/*blocking=*/false, plannedIterations-1, /*paused=*/false)); while (fixture1.Server()->Running() || fixture2.Server()->Running()) {