Skip to content

Commit cc4914a

Browse files
authored
Fix ModelPhotoShootTest test failures (#2294)
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 <[email protected]>
1 parent c6aaaf2 commit cc4914a

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

examples/worlds/model_photo_shoot.sdf

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
filename="gz-sim-sensors-system"
1818
name="gz::sim::systems::Sensors">
1919
<render_engine>ogre2</render_engine>
20-
<background_color>1, 1, 1</background_color>
20+
<background_color>1.0 1.0 1.0</background_color>
2121
</plugin>
2222
<include>
2323
<uri>https://fuel.gazebosim.org/1.0/OpenRobotics/models/Robonaut</uri>

test/integration/ModelPhotoShootTest.hh

+8-4
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,6 @@ class ModelPhotoShootTest : public InternalFixture<::testing::Test>
230230
// First run of the server generating images through the plugin.
231231
TestFixture fixture(common::joinPaths(std::string(PROJECT_SOURCE_PATH),
232232
_sdfWorld));
233-
fixture.Server()->SetUpdatePeriod(1ns);
234233

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

246-
fixture.Server()->Run(true, 50, false);
245+
fixture.Server()->SetUpdatePeriod(1ns);
246+
247+
for (int i = 0; i < 50; ++i)
248+
{
249+
fixture.Server()->RunOnce(true);
250+
}
247251
this->LoadPoseValues();
248252

249253
fixture.OnPreUpdate([&](const sim::UpdateInfo &,
@@ -285,15 +289,15 @@ class ModelPhotoShootTest : public InternalFixture<::testing::Test>
285289
}
286290
this->checkRandomJoints = false;
287291
}
288-
}).Finalize();
292+
});
289293

290294
this->takeTestPics = true;
291295

292296
const auto end_time = std::chrono::steady_clock::now() +
293297
std::chrono::milliseconds(3000);
294298
while (takeTestPics && end_time > std::chrono::steady_clock::now())
295299
{
296-
fixture.Server()->Run(true, 1, false);
300+
fixture.Server()->RunOnce(true);
297301
std::this_thread::sleep_for(std::chrono::milliseconds(1));
298302
}
299303
testImages("1.png", "1_test.png");

test/worlds/model_photo_shoot_random_joints.sdf

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
filename="gz-sim-sensors-system"
1818
name="gz::sim::systems::Sensors">
1919
<render_engine>ogre2</render_engine>
20-
<background_color>1, 1, 1</background_color>
20+
<background_color>1.0 1.0 1.0</background_color>
2121
</plugin>
2222
<include>
2323
<uri>https://fuel.gazebosim.org/1.0/OpenRobotics/models/Robonaut</uri>

0 commit comments

Comments
 (0)