SMACC2
Loading...
Searching...
No Matches
cb_wait_for_frame.cpp
Go to the documentation of this file.
1// Copyright 2026 RobosoftAI Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
16
17namespace cl_rgb
18{
19
21: CbRgbClientBehaviorBase(params.camera), params_(params)
22{
23}
24
26{
27 if (camera_ == nullptr)
28 {
29 return;
30 }
31 const FramePtr latest = camera_->latestFrame();
32 startSequence_ = latest ? latest->sequence : 0;
35}
36
38{
39 if (camera_ == nullptr)
40 {
41 RCLCPP_ERROR(getLogger(), "CbWaitForFrame: no camera named '%s'", params_.camera.c_str());
42 this->postRgbFailure();
43 return;
44 }
45 RCLCPP_INFO(
46 getLogger(), "CbWaitForFrame: waiting for %u new image(s) of '%s'", params_.frames,
47 params_.camera.c_str());
48}
49
51{
52 if (frame->sequence >= startSequence_.load() + params_.frames)
53 {
54 this->postRgbSuccess();
55 }
56}
57
58} // namespace cl_rgb
std::atomic< uint64_t > startSequence_
void wireCompletionSignals() override
CbWaitForFrame(const WaitForFrameParams &params=WaitForFrameParams())
void onFrame(const FramePtr &frame)
WaitForFrameParams params_
FramePtr latestFrame() const
Definition cp_camera.cpp:87
smacc2::SmaccSignal< void(const FramePtr &)> onFrame_
Definition cp_camera.hpp:62
virtual rclcpp::Logger getLogger() const
smacc2::SmaccSignalConnection createSignalConnection(TSmaccSignal &signal, TMemberFunctionPrototype callback, TSmaccObjectType *object)
std::shared_ptr< const Frame > FramePtr
Definition types.hpp:39