SMACC2
Loading...
Searching...
No Matches
cb_yaw_scan.hpp
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
15#pragma once
16
18
19#include <atomic>
20#include <chrono>
21#include <cmath>
22#include <limits>
23#include <smacc2/smacc.hpp>
24
25namespace cl_px4_mr
26{
27
28class CpTrajectorySetpoint;
29class CpVehicleLocalPosition;
30
31// Continuous behavior: hold the entry position while the heading sweeps
32// sinusoidally around a base heading. Never posts success - the state machine
33// must provide the exit event (timer orthogonal, mission event, keyboard).
34// On exit, one final setpoint restores the base heading, so the vehicle always
35// returns to it regardless of where in the sweep the state change lands.
36// Posts failure only if local position is invalid at entry.
38{
39 float amplitude = 0.6f; // rad each side of the base heading
40 float period = 6.0f; // s per sweep cycle
41 float baseHeading = std::numeric_limits<float>::quiet_NaN(); // NED yaw, rad; NaN = entry heading
42};
43
45{
46public:
47 explicit CbYawScan(const YawScanParams & params = {});
48
49 void onEntry() override;
50 void onExit() override;
51 void update() override;
52
53private:
55 float period_;
57
58 float holdX_ = 0.0f;
59 float holdY_ = 0.0f;
60 float holdZ_ = 0.0f;
61 float elapsed_ = 0.0f;
62 std::atomic<bool> active_{false};
63 std::chrono::steady_clock::time_point lastUpdateTime_;
64};
65
66} // namespace cl_px4_mr
CbYawScan(const YawScanParams &params={})
std::chrono::steady_clock::time_point lastUpdateTime_
void onEntry() override
void update() override
void onExit() override
std::atomic< bool > active_