Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/BoundingBoxCameraSensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -427,10 +427,13 @@ bool BoundingBoxCameraSensor::Update(
}

// render only if necessary
if (this->dataPtr->isTriggeredCamera &&
!this->dataPtr->isTriggered)
{
return true;
std::lock_guard<std::mutex> lock(this->dataPtr->mutex);
if (this->dataPtr->isTriggeredCamera &&
!this->dataPtr->isTriggered)
{
return true;
}
}

// don't render if there are no subscribers nor saving
Expand Down
7 changes: 4 additions & 3 deletions test/integration/triggered_boundingbox_camera.cc
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,13 @@ void TriggeredBoundingBoxCameraTest::BoxesWithBuiltinSDF(
gz::msgs::Boolean msg;
msg.set_data(true);
pub.Publish(msg);
// sleep to wait for trigger msg to be received before calling mgr.RunOnce
std::this_thread::sleep_for(2s);

// we should receive images and boxes after trigger
{
std::string imageTopic =
"/test/integration/TriggeredBBCameraPlugin_imagesWithBuiltinSDF_image";
WaitForMessageTestHelper<gz::msgs::Image> helper(imageTopic);
WaitForMessageTestHelper<gz::msgs::AnnotatedAxisAligned2DBox_V>
helper(boxTopic);
mgr.RunOnce(std::chrono::steady_clock::duration::zero(), true);
EXPECT_TRUE(helper.WaitForMessage(10s)) << helper;
g_mutex.lock();
Expand Down