From 1528f0cf05fcae55be6941694f7d935d0fa378b0 Mon Sep 17 00:00:00 2001 From: David Lechner Date: Thu, 17 Feb 2022 14:37:49 -0600 Subject: [PATCH] camera_server: improve in_progress state --- examples/camera_server/camera_server.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/examples/camera_server/camera_server.cpp b/examples/camera_server/camera_server.cpp index 19ba845b2c..bed24d1e0e 100644 --- a/examples/camera_server/camera_server.cpp +++ b/examples/camera_server/camera_server.cpp @@ -45,8 +45,10 @@ int main(int argc, char** argv) // First add all subscriptions. This defines the camera capabilities. camera_server->subscribe_take_photo( - [camera_server, &all_camera_servers](CameraServer::Result result, int32_t index) { - camera_server->set_in_progress(true); + [&all_camera_servers](CameraServer::Result result, int32_t index) { + for (auto&& [key, value] : all_camera_servers) { + value->set_in_progress(true); + } std::cout << "taking a picture (" << +index << ")..." << std::endl; @@ -62,9 +64,10 @@ int main(int argc, char** argv) duration_cast(system_clock::now().time_since_epoch()).count(); auto success = true; - camera_server->set_in_progress(false); + for (auto&& [key, value] : all_camera_servers) { + value->set_in_progress(false); + } - // hack to simulate broadcast and keep total count in sync for (auto&& [key, value] : all_camera_servers) { value->respond_take_photo({ .position = position, @@ -79,6 +82,8 @@ int main(int argc, char** argv) // Then set the initial state of everything. + // TODO: this state is not guaranteed, e.g. a new system appears + // while a capture is in progress camera_server->set_in_progress(false); // Finally call set_information() to "activate" the camera plugin.