SMACC2
Loading...
Searching...
No Matches
smacc2_client_library
cl_px4_mr
include
cl_px4_mr
client_behaviors
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
17
#include <
cl_px4_mr/client_behaviors/cb_px4_client_behavior_base.hpp
>
18
19
#include <atomic>
20
#include <chrono>
21
#include <cmath>
22
#include <limits>
23
#include <
smacc2/smacc.hpp
>
24
25
namespace
cl_px4_mr
26
{
27
28
class
CpTrajectorySetpoint;
29
class
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.
37
struct
YawScanParams
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
44
class
CbYawScan
:
public
CbPx4ClientBehaviorBase
45
{
46
public
:
47
explicit
CbYawScan
(
const
YawScanParams
& params = {});
48
49
void
onEntry
()
override
;
50
void
onExit
()
override
;
51
void
update
()
override
;
52
53
private
:
54
float
amplitude_
;
55
float
period_
;
56
float
baseHeading_
;
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
cb_px4_client_behavior_base.hpp
cl_px4_mr::CbPx4ClientBehaviorBase
Definition
cb_px4_client_behavior_base.hpp:62
cl_px4_mr::CbYawScan
Definition
cb_yaw_scan.hpp:45
cl_px4_mr::CbYawScan::CbYawScan
CbYawScan(const YawScanParams ¶ms={})
Definition
cb_yaw_scan.cpp:25
cl_px4_mr::CbYawScan::lastUpdateTime_
std::chrono::steady_clock::time_point lastUpdateTime_
Definition
cb_yaw_scan.hpp:63
cl_px4_mr::CbYawScan::holdZ_
float holdZ_
Definition
cb_yaw_scan.hpp:60
cl_px4_mr::CbYawScan::baseHeading_
float baseHeading_
Definition
cb_yaw_scan.hpp:56
cl_px4_mr::CbYawScan::onEntry
void onEntry() override
Definition
cb_yaw_scan.cpp:32
cl_px4_mr::CbYawScan::holdX_
float holdX_
Definition
cb_yaw_scan.hpp:58
cl_px4_mr::CbYawScan::update
void update() override
Definition
cb_yaw_scan.cpp:87
cl_px4_mr::CbYawScan::elapsed_
float elapsed_
Definition
cb_yaw_scan.hpp:61
cl_px4_mr::CbYawScan::onExit
void onExit() override
Definition
cb_yaw_scan.cpp:76
cl_px4_mr::CbYawScan::holdY_
float holdY_
Definition
cb_yaw_scan.hpp:59
cl_px4_mr::CbYawScan::amplitude_
float amplitude_
Definition
cb_yaw_scan.hpp:54
cl_px4_mr::CbYawScan::period_
float period_
Definition
cb_yaw_scan.hpp:55
cl_px4_mr::CbYawScan::active_
std::atomic< bool > active_
Definition
cb_yaw_scan.hpp:62
cl_px4_mr
Definition
cl_px4_mr.hpp:31
smacc.hpp
cl_px4_mr::YawScanParams
Definition
cb_yaw_scan.hpp:38
cl_px4_mr::YawScanParams::amplitude
float amplitude
Definition
cb_yaw_scan.hpp:39
cl_px4_mr::YawScanParams::baseHeading
float baseHeading
Definition
cb_yaw_scan.hpp:41
cl_px4_mr::YawScanParams::period
float period
Definition
cb_yaw_scan.hpp:40
Generated by
1.12.0