SMACC2
Loading...
Searching...
No Matches
cb_spiral_up.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 <chrono>
20#include <cmath>
21#include <limits>
22#include <smacc2/smacc.hpp>
23
24namespace cl_px4_mr
25{
26
27class CpTrajectorySetpoint;
28class CpVehicleLocalPosition;
29
30// Helix about a vertical axis: a constant-radius orbit that climbs
31// climbPerOrbitM every revolution until climbTotalM has been gained, nose
32// toward the axis. The orbit starts at the vehicle's current bearing from the
33// centre (fly to a point on the circle first, e.g. with CbGoToLocation) and at
34// startAltitudeM (NaN = the current altitude). Posts success at the top, where
35// the vehicle is on the circle at startAltitude + climbTotal - hand over to
36// CbOrbitLocation at that altitude for level laps.
38{
39 float centerX = 0.0f; // NED north
40 float centerY = 0.0f; // NED east
41 float radiusM = 6.0f;
42 float startAltitudeM = std::numeric_limits<float>::quiet_NaN(); // above the NED origin
43 float climbTotalM = 24.0f;
44 float climbPerOrbitM = 3.0f;
45 float angularVelocityRadS = 0.3f; // +ve = clockwise seen from above (NED angle north -> east)
46};
47
49{
50public:
51 explicit CbSpiralUp(SpiralUpParams params = {});
52
53 void onEntry() override;
54 void onExit() override {}
55 void update() override;
56
57 const SpiralUpParams & params() const { return params_; }
58
59private:
60 void command();
61
63 float startAltitude_ = 0.0f;
64 float startAngle_ = 0.0f;
65 float currentAngle_ = 0.0f;
67 std::chrono::steady_clock::time_point lastUpdateTime_;
68};
69
70} // namespace cl_px4_mr
std::chrono::steady_clock::time_point lastUpdateTime_
void onEntry() override
const SpiralUpParams & params() const
CbSpiralUp(SpiralUpParams params={})
SpiralUpParams params_
void onExit() override
void update() override