SMACC2
Loading...
Searching...
No Matches
cb_figure_eight.hpp
Go to the documentation of this file.
1// Copyright 2025 Robosoft 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 <chrono>
19#include <cmath>
20#include <smacc2/smacc.hpp>
21
22namespace cl_px4_mr
23{
24
25class CpTrajectorySetpoint;
26
28{
29 float centerX = 0.0f; // NED north, m
30 float centerY = 0.0f; // NED east, m
31 float altitude = 5.0f; // m above the NED origin
32 float size = 5.0f; // m from the centre to a lobe tip
33 float speed = 0.5f; // rate of the curve parameter, rad/s
34 int numLoops = 1;
35};
36
38{
39public:
40 explicit CbFigureEight(const FigureEightParams & params);
41
42 // Override the centre before onEntry (e.g. from the owning state's
43 // runtimeConfigure when the centre is only known at runtime).
44 void setCenter(float centerX, float centerY)
45 {
46 centerX_ = centerX;
47 centerY_ = centerY;
48 }
49 // Rotate the lobe axis (NED yaw, radians; default 0 = lobes north-south).
50 void setHeading(float headingRad) { heading_ = headingRad; }
51
52 void onEntry() override;
53 void onExit() override;
54 void update() override;
55
56private:
57 float centerX_;
58 float centerY_;
59 float altitude_;
60 float size_;
61 float speed_;
63 float heading_ = 0.0f;
64
65 float t_ = 0.0f;
66 std::chrono::steady_clock::time_point lastUpdateTime_;
67};
68
69} // namespace cl_px4_mr
void setCenter(float centerX, float centerY)
CbFigureEight(const FigureEightParams &params)
std::chrono::steady_clock::time_point lastUpdateTime_
void setHeading(float headingRad)