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 <smacc2/smacc.hpp>
23
24namespace cl_px4_mr
25{
26
27class CpTrajectorySetpoint;
28class CpVehicleLocalPosition;
29
30// Continuous behavior: hold the entry position while the heading sweeps
31// sinusoidally around a base heading. Never posts success - the state machine
32// must provide the exit event (timer orthogonal, mission event, keyboard).
33// On exit, one final setpoint restores the base heading, so the vehicle always
34// returns to it regardless of where in the sweep the state change lands.
35// Posts failure only if local position is invalid at entry.
37{
38public:
40 float amplitude = 0.6f, float period = 6.0f,
41 float baseHeading = std::numeric_limits<float>::quiet_NaN());
42
43 void onEntry() override;
44 void onExit() override;
45 void update() override;
46
47private:
49 float period_;
51
52 float holdX_ = 0.0f;
53 float holdY_ = 0.0f;
54 float holdZ_ = 0.0f;
55 float elapsed_ = 0.0f;
56 std::atomic<bool> active_{false};
57 std::chrono::steady_clock::time_point lastUpdateTime_;
58};
59
60} // namespace cl_px4_mr
std::chrono::steady_clock::time_point lastUpdateTime_
void onEntry() override
void update() override
void onExit() override
CbYawScan(float amplitude=0.6f, float period=6.0f, float baseHeading=std::numeric_limits< float >::quiet_NaN())
std::atomic< bool > active_