Skip to content

Commit

Permalink
Fix ModelPhotoShootTest test failures
Browse files Browse the repository at this point in the history
The failures are caused by a change in the DART physics engine
(dartsim/dart#1774) which causes joints to
recover after reaching or exceeding their position limits. It seems like
the model used in this plugin starts off with joint limits violated and
recovers after a few iterations. This causes a small movement of the
robot. Since the test works by comparing images taken of the robot at
the start of simulation and after a few iterations, the small movement
causes a discrepancy in the images. The solution here is to run the
whole test while simulation is paused.

This also cleans up some TestFixture warnings.

Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
  • Loading branch information
azeey committed Jan 19, 2024
1 parent c6aaaf2 commit 65c7be6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion examples/worlds/model_photo_shoot.sdf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
filename="gz-sim-sensors-system"
name="gz::sim::systems::Sensors">
<render_engine>ogre2</render_engine>
<background_color>1, 1, 1</background_color>
<background_color>1.0 1.0 1.0</background_color>
</plugin>
<include>
<uri>https://fuel.gazebosim.org/1.0/OpenRobotics/models/Robonaut</uri>
Expand Down
12 changes: 8 additions & 4 deletions test/integration/ModelPhotoShootTest.hh
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ class ModelPhotoShootTest : public InternalFixture<::testing::Test>
// First run of the server generating images through the plugin.
TestFixture fixture(common::joinPaths(std::string(PROJECT_SOURCE_PATH),
_sdfWorld));
fixture.Server()->SetUpdatePeriod(1ns);

common::ConnectionPtr postRenderConn;
fixture.OnConfigure([&](
Expand All @@ -243,7 +242,12 @@ class ModelPhotoShootTest : public InternalFixture<::testing::Test>
std::bind(&ModelPhotoShootTest::OnPostRender, this));
}).Finalize();

fixture.Server()->Run(true, 50, false);
fixture.Server()->SetUpdatePeriod(1ns);

for (int i = 0; i < 50; ++i)
{
fixture.Server()->RunOnce(true);
}
this->LoadPoseValues();

fixture.OnPreUpdate([&](const sim::UpdateInfo &,
Expand Down Expand Up @@ -285,15 +289,15 @@ class ModelPhotoShootTest : public InternalFixture<::testing::Test>
}
this->checkRandomJoints = false;
}
}).Finalize();
});

this->takeTestPics = true;

const auto end_time = std::chrono::steady_clock::now() +
std::chrono::milliseconds(3000);
while (takeTestPics && end_time > std::chrono::steady_clock::now())
{
fixture.Server()->Run(true, 1, false);
fixture.Server()->RunOnce(true);
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
testImages("1.png", "1_test.png");
Expand Down
2 changes: 1 addition & 1 deletion test/worlds/model_photo_shoot_random_joints.sdf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
filename="gz-sim-sensors-system"
name="gz::sim::systems::Sensors">
<render_engine>ogre2</render_engine>
<background_color>1, 1, 1</background_color>
<background_color>1.0 1.0 1.0</background_color>
</plugin>
<include>
<uri>https://fuel.gazebosim.org/1.0/OpenRobotics/models/Robonaut</uri>
Expand Down

0 comments on commit 65c7be6

Please sign in to comment.