Auterion App SDK
Auterion SDK is a library that can be used by AuterionOS apps to communicate with the system.
Loading...
Searching...
No Matches
global_frame_goto_control.hpp
1/****************************************************************************
2 *
3 * Copyright 2024 Auterion AG. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice, this
9 * list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 *
15 * 3. Neither the name of the copyright holder nor the names of its contributors
16 * may be used to endorse or promote products derived from this software without
17 * specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 ****************************************************************************/
32
33#pragma once
34
35#include <eigen3/Eigen/Eigen>
36#include <functional>
37#include <memory>
38#include <variant>
39
40#include "../../auterion.hpp"
41#include "local_frame_goto_control.hpp"
42
43namespace auterion {
44namespace multicopter {
55 private:
56 Eigen::Vector3d _global_position_lat_lon_amsl = {
57 NAN, NAN, NAN};
58 float _heading_enu_rad = NAN;
59 GotoControlLimits _limits{NAN, NAN, NAN};
60
61 public:
65 class Config {
66 public:
67 Config(const GotoControlLimits& limits = GotoControlLimits()) : _default_limits(limits) {}
68
69 inline GotoControlLimits getDefaultLimits() const { return _default_limits; }
70
71 private:
72 GotoControlLimits _default_limits;
73 };
74
75 GlobalFrameGotoSetpoint() = default;
76
77 GlobalFrameGotoSetpoint(const Eigen::Vector3d& global_position_lat_lon_amsl,
78 const float heading_rad = NAN)
79 : _global_position_lat_lon_amsl(global_position_lat_lon_amsl),
80 _heading_enu_rad(heading_rad) {}
81
82 GlobalFrameGotoSetpoint(const Eigen::Vector2d& global_position_lat_lon,
83 const float heading_rad = NAN)
84 : _global_position_lat_lon_amsl(
85 {global_position_lat_lon.x(), global_position_lat_lon.y(), NAN}),
86 _heading_enu_rad(heading_rad) {}
87
88 inline Eigen::Vector3d getPosition() const { return _global_position_lat_lon_amsl; }
89
90 inline float getHeading() const { return _heading_enu_rad; }
91
92 inline GotoControlLimits getLimits() const { return _limits; }
93
94 GlobalFrameGotoSetpoint& withPosition(const Eigen::Vector3d& global_position_lat_lon_amsl) {
95 _global_position_lat_lon_amsl = global_position_lat_lon_amsl;
96 return *this;
97 }
98
99 GlobalFrameGotoSetpoint& withPosition(const Eigen::Vector2d& global_position_lat_lon) {
100 _global_position_lat_lon_amsl.x() = global_position_lat_lon.x();
101 _global_position_lat_lon_amsl.y() = global_position_lat_lon.y();
102 return *this;
103 }
104
105 GlobalFrameGotoSetpoint& withHeading(const float heading_rad) {
106 _heading_enu_rad = heading_rad;
107 return *this;
108 }
109
110 GlobalFrameGotoSetpoint& withAltitude(const double z) {
111 _global_position_lat_lon_amsl.z() = z;
112 return *this;
113 }
114
115 GlobalFrameGotoSetpoint& withSpeedControlLimit(const GotoControlLimits& limits) {
116 _limits = limits;
117 return *this;
118 }
119
120 GlobalFrameGotoSetpoint& withMaxHorizontalSpeed(const float max_horizontal_speed_m_s_) {
121 _limits.withMaxHorizontalSpeed(max_horizontal_speed_m_s_);
122 return *this;
123 }
124
125 GlobalFrameGotoSetpoint& withMaxVerticalSpeed(const float max_vertical_speed_m_s_) {
126 _limits.withMaxVerticalSpeed(max_vertical_speed_m_s_);
127 return *this;
128 }
129
130 GlobalFrameGotoSetpoint& withMaxHeadingRate(const float max_heading_rate_rad_s_) {
131 _limits.withMaxHeadingRate(max_heading_rate_rad_s_);
132 return *this;
133 }
134};
135
137} // namespace multicopter
138} // namespace auterion
Sets controller's default speed limits for global goto setpoint.
Definition global_frame_goto_control.hpp:65
Represents a setpoint for controlling the global frame position and heading.
Definition global_frame_goto_control.hpp:54
Represents the desired speed limit of the vehicle when controlled with a goto setpoint.
Definition local_frame_goto_control.hpp:53