SMACC2
Loading...
Searching...
No Matches
cb_hold_position.cpp
Go to the documentation of this file.
1// Copyright 2025 Robosoft 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
17
18namespace cl_px4_mr
19{
20
21CbHoldPosition::CbHoldPosition(float durationSeconds) : durationSeconds_(durationSeconds) {}
22
24{
26
27 RCLCPP_INFO(getLogger(), "CbHoldPosition: holding position for %.1f seconds", durationSeconds_);
28
30 startTime_ = std::chrono::steady_clock::now();
31}
32
34
36{
37 auto now = std::chrono::steady_clock::now();
38 double elapsed = std::chrono::duration<double>(now - startTime_).count();
39
40 if (elapsed >= durationSeconds_)
41 {
42 RCLCPP_INFO(
43 getLogger(), "CbHoldPosition: duration reached (%.1f s) - posting success", elapsed);
44 this->postSuccessEvent();
45 }
46}
47
48} // namespace cl_px4_mr
CpTrajectorySetpoint * trajectorySetpoint_
CbHoldPosition(float durationSeconds=5.0f)
std::chrono::steady_clock::time_point startTime_
virtual rclcpp::Logger getLogger() const
void requiresComponent(SmaccComponentType *&storage, ComponentRequirement requirementType=ComponentRequirement::SOFT)