SMACC2
Loading...
Searching...
No Matches
smacc2_client_library
cl_px4_mr
include
cl_px4_mr
client_behaviors
cb_wait_for_heading_stable.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
#include <rclcpp/rclcpp.hpp>
19
#include <
smacc2/smacc.hpp
>
20
21
#include <cmath>
22
#include <limits>
23
24
namespace
cl_px4_mr
25
{
26
27
// Preflight gate on the EKF heading. A vehicle sitting still on the ground must
28
// report a constant heading; if the estimate is drifting, the yaw gyro bias
29
// has not converged (or the magnetometer has been rejected) and a takeoff in
30
// that state is unstable: with a large heading error the position loop pushes
31
// the wrong way and the vehicle flips over (sm_cl_px4_mr_test_5 run 19: 186
32
// degrees of drift in 30 s, crash 4 s after liftoff).
33
//
34
// Success when the heading moved less than maxDriftRadS * windowS over the
35
// last windowS seconds (and, if expectedHeadingRad is finite, is also within
36
// headingTolRad of it). Failure on timeout, with the drift rate in the log.
37
struct
HeadingStableParams
38
{
39
double
maxDriftRadS
= 0.0087;
// 0.5 deg/s
40
double
windowS
= 5.0;
41
double
timeoutS
= 60.0;
42
// known heading of the parked vehicle (NED, rad); NaN = do not check
43
float
expectedHeadingRad
= std::numeric_limits<float>::quiet_NaN();
44
float
headingTolRad
= 0.26f;
// 15 deg
45
};
46
47
class
CbWaitForHeadingStable
:
public
CbPx4ClientBehaviorBase
48
{
49
public
:
50
explicit
CbWaitForHeadingStable
(
HeadingStableParams
params = {});
51
52
void
onEntry
()
override
;
53
void
onExit
()
override
{}
54
55
private
:
56
HeadingStableParams
params_
;
57
};
58
59
}
// 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::CbWaitForHeadingStable
Definition
cb_wait_for_heading_stable.hpp:48
cl_px4_mr::CbWaitForHeadingStable::params_
HeadingStableParams params_
Definition
cb_wait_for_heading_stable.hpp:56
cl_px4_mr::CbWaitForHeadingStable::CbWaitForHeadingStable
CbWaitForHeadingStable(HeadingStableParams params={})
Definition
cb_wait_for_heading_stable.cpp:35
cl_px4_mr::CbWaitForHeadingStable::onEntry
void onEntry() override
Definition
cb_wait_for_heading_stable.cpp:37
cl_px4_mr::CbWaitForHeadingStable::onExit
void onExit() override
Definition
cb_wait_for_heading_stable.hpp:53
cl_px4_mr
Definition
cl_px4_mr.hpp:30
smacc.hpp
cl_px4_mr::HeadingStableParams
Definition
cb_wait_for_heading_stable.hpp:38
cl_px4_mr::HeadingStableParams::maxDriftRadS
double maxDriftRadS
Definition
cb_wait_for_heading_stable.hpp:39
cl_px4_mr::HeadingStableParams::headingTolRad
float headingTolRad
Definition
cb_wait_for_heading_stable.hpp:44
cl_px4_mr::HeadingStableParams::windowS
double windowS
Definition
cb_wait_for_heading_stable.hpp:40
cl_px4_mr::HeadingStableParams::expectedHeadingRad
float expectedHeadingRad
Definition
cb_wait_for_heading_stable.hpp:43
cl_px4_mr::HeadingStableParams::timeoutS
double timeoutS
Definition
cb_wait_for_heading_stable.hpp:41
Generated by
1.12.0