Skip to content

Commit

Permalink
Add workaround for "ODE INTERNAL ERROR 1: assertion "!colliders_initi…
Browse files Browse the repository at this point in the history
…alized" failed in dInitColliders() [collision_kernel.cpp:168]" crash
  • Loading branch information
traversaro committed Aug 23, 2024
1 parent 1f5b43d commit 62498e5
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 18 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/apt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 15 additions & 7 deletions tests/commons/ConcurrentInstancesTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
23 changes: 16 additions & 7 deletions tests/controlboard/ControlBoardOnMultipleGazeboInstancesTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<const sdf::Element>& /*_sdf*/,
Expand Down Expand Up @@ -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<const sdf::Element>& /*_sdf*/,
Expand Down Expand Up @@ -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())
{
Expand Down

0 comments on commit 62498e5

Please sign in to comment.