1 Introduction

Attitude Control is a branch of aeronautical and aerospace engineering which is in charge of controlling the orientation of a spacecraft with respect to an inertial frame of reference.

The aim of the present work is to test an alternative approximation algorithm to the attitude control for satellites. Such algorithm, and its corresponding analysis, has been recently introduced in [10], and differs in its essence from the solutions adopted in previous literature for the same problems. Previous techniques range from those provided by classical control theory: regulators of type PI (Proportional-integral), PD (Proportional-derivative) or PID (Proportional-integral-derivative) [3, 11, 15, 19, 22] to more advanced techniques, including Wave-Based-Control [2, 12, 16], LQR (Linear-quadratic regulator) [6], fuzzy logic [18, 19] or even artificial intelligence and neural networks [1]. In contrast, the algorithm used in this work deals with the fully nonlinear system instead of relying on a linearization. An optimal control problem is written based on a nonlinear model describing the rotational dynamics of a spacecraft. Then, solutions to that optimal control problem are numerically approximated using the above-mentioned method which is based on variational techniques.

Our simulation method is based on two main ingredients:

  1. (1)

    The reformulation of an optimal control as a purely variational problem under point-wise constraints; this can be found in [8].

  2. (2)

    The numerical approximation of variational problems subjected to point-wise constraints; our ideas are taken from [9].

The whole procedure is explained and used for some typical academic and non-academic examples in [10]. While most other approaches require different algorithms for each type of manoeuvre, our method is able to calculate the control that takes the satellite from its initial state to any prescribed final state. This is a consequence of the fact that our algorithm is a general-purpose mechanism that can be applied to any control problem, and, in particular, can be set with any number of combinations of initial and final states. We refer to [8] for full explanations about analytical results and convergence proofs for general problems, though we will state below those facts directly related to our problem.

In [4], Crouch uses geometric control theory to derive controllers for a satellite equipped with gas actuators. In his work [5], Krishnan also considers the problem of attitude control with gas actuators, but in the case of under-actuated satellites (no full control is available on the three axes of the satellite). In [19], Wisniewski studies the attitude control of satellites under magnetic actuation using both linear and non-linear control theory. Moreover, Wisniewski in [20], also studies means of controlling a magnetically actuated spacecraft, this time from the viewpoint of optimal control. The same goal is achieved by Lovera, De Marchi and Bittanti in [7], and by Lovera and Silani in [13], this time from a slightly different perspective: optimal periodic control, this exploits the fact that the local magnetic field vector is almost periodic, with a period of one orbit. In [6], Lovera and Varga developed several methods for discrete-time optimal attitude control.

In Sect. 2, the optimal control problem is derived in detail from the nonlinear equations of motion. We also write down the problem in precise terms and state a main existence result of optimal solutions that can be applied to our particular situation in this contribution. Section 3 focuses on the approximation procedure itself. In addition to providing explanations so that the basis of the approximation method can be better understood, we include comments on the advantages and disadvantages of it as well as a main convergence result. This material is largely adapted from [10]. In Sect. 4, results from selected numerical simulations are presented and discussed. Conclusions are finally presented in Sect. 5.

2 Problem statement

2.1 Reference frames

In order to endow the problem with an adequate theoretical framework, it is necessary to define a set of reference frames in which the equations of motion will be written. The satellite is considered to be a rigid body rotating in space; the set of reference frames is then conveniently defined, following the trends of previous work in literature [3, 14, 15]:

  • Earth centred inertial (ECI) reference frame. The origin of this reference frame is placed at the centre of the Earth. Its Z axis is normal to the equatorial plane and parallel to the Earth’s rotational axis, pointing towards the Earth’s north pole. The X axis points towards the vernal equinox. Finally, the Y axis completes the right-handed orthonormal frame.

  • Earth-centred/earth-fixed (ECEF) reference frame. Its origin is also placed at the centre of mass of the Earth, with the Z axis pointing towards Earth’s north pole. Its X axis is constantly pointing in the direction of the intersection between the Greenwich meridian and the Earth’s equator, and it consequently rotates with the Earth, sharing its angular rate. The Y axis completes the right-handed orthonormal frame.

  • Local-vertical/local-horizontal (LVLH) reference frame—orbital frame. Its origin is located at the centre of mass of the spacecraft. The Z axis points towards the centre of mass of the Earth, aligned with the nadir direction, while the Y axis is parallel to the orbit angular velocity (normal to the equatorial plane). The X axis completes the right-handed orthonormal triad.

  • Body-fixed frame. This frame is similarly placed at the centre of mass of the satellite. However, it is chosen to be aligned with the principal axes of inertia of the spacecraft. The orientation of this frame with respect to the inertial (ECI) frame is described by means of the quaternion parametrization discussed below.

Our main concern will be the relative orientation between the ECI and Body Fixed Frame, as it essentially describes the relative orientation of the satellite with respect to a frame that moves at speeds which are sufficiently low to be considered as inertial. The angular velocities and orientation parameters (quaternions, Euler angles, etc) used from now on describe the orientation of the body fixed frame with respect to the inertial (ECI) frame. However, all four classically defined frames are presented for reference.

2.2 Dynamic equations of motion

The spacecraft is considered to be a rigid body rotating in space. In this situation, the Euler’s equations of motion are written as

$$\begin{aligned} J\varvec{\omega }' + \varvec{\omega }\times J \varvec{\omega } = \varvec{u} \end{aligned}$$
(1)

where J is the tensor of inertia of the spacecraft, \(\varvec{\omega }\) is the angular velocity of the satellite with respect to the inertial frame, and \(\varvec{u}\) is a vector representing the torques exerted on the spacecraft.

We assume that the body fixed frame is aligned with the principal axes of inertia. Therefore, the tensor of inertia results to be diagonal:

$$\begin{aligned} J = \left( \begin{array}{ccc} J_1 &{}\quad 0 &{} \quad 0 \\ 0 &{}\quad J_2 &{}\quad 0 \\ 0 &{}\quad 0 &{}\quad J_3 \end{array}\right) \end{aligned}$$
(2)

To clarify, let us, at this point, recall that Eq. (1), which we have derived from conservation of angular momentum, is essentially a first order, non-linear system of ordinary differential equations. Considering that J is a tensor of size \(3 \times 3\), and writing \(\varvec{\omega }\) and \(\varvec{u}\) as \(3\times 1\) column vectors, the system (1) implies three ordinary differential equations. As we shall see, the torque \(\varvec{u}\) exerted on the satellite will indeed be the control variable, that is to say, a quantity or signal that we can set to our convenience with the aim of modifying the behaviour of the dynamics of the satellite, to control its attitude and angular velocity.

2.3 Kinematic equations of motion

If unit quaternions are used for attitude representation, the dynamics of that attitude is given by [14, 22]:

$$\begin{aligned} \varvec{q}'=\dfrac{1}{2}\Omega (\varvec{\omega })\varvec{q} \end{aligned}$$
(3)

where \(\varvec{q}\) is a column vector of size \(4\times 1\) and \(\varvec{\Omega }\) is the following skew-symmetric matrix:

$$\begin{aligned} \varvec{\Omega }(u_1,u_2,u_3) = \left( \begin{array}{c c c c} 0 &{}\quad u_3 &{}\quad -u_2 &{}\quad u_1 \\ -u_3 &{}\quad 0 &{} \quad u_1 &{}\quad u_2 \\ u_2 &{}\quad -u_ 1 &{}\quad 0 &{} \quad u_3 \\ -u_1 &{}\quad -u_2 &{}\quad -u_3 &{}\quad 0 \\ \end{array}\right) \end{aligned}$$
(4)

Note that if we write \(\varvec{q} = \left( \begin{array}{c}\varvec{\epsilon } \\ \eta \end{array}\right) \), we have

$$\begin{aligned} \left\{ \begin{aligned} \varvec{\epsilon }'&= -\dfrac{1}{2}\varvec{\omega }\times \varvec{\epsilon } + \dfrac{1}{2}\eta \varvec{\omega } \\ \eta '&= - \dfrac{1}{2}\varvec{\omega }^t\varvec{\epsilon } \end{aligned} \right. \end{aligned}$$
(5)

2.4 Optimal control problem

We are in search for an optimal choice of \(\varvec{u}: [0,T]\rightarrow {\mathbb {R}}^3\) in the sense that we are seeking to minimize a functional

$$\begin{aligned} \varvec{u}\longmapsto \int _0^T F(t,\varvec{\omega },\varvec{q},\varvec{u})\ dt \end{aligned}$$
(6)

amongst all possible choices of \(\varvec{u}\), in addition to complying with

$$\begin{aligned} \left\{ \begin{aligned} J \varvec{\omega }'&= -\varvec{\omega }\times J\varvec{\omega } + \varvec{u} \ \ {}&\text {in }[0,T]\\ \varvec{\epsilon }'&= -\dfrac{1}{2}\varvec{\omega }\times \varvec{\epsilon } + \dfrac{1}{2}\eta \varvec{\omega } \ \ {}&\text {in }[0,T]\\ \eta '&= - \dfrac{1}{2}\varvec{\omega }^t\varvec{\epsilon } \ \ {}&\text {in }[0,T] \end{aligned} \right. \end{aligned}$$
(7)

and

$$\begin{aligned} \left\{ \begin{aligned} \varvec{\omega }(0)&= \varvec{\omega }_0,\ \ \varvec{q}(0) = \varvec{q}_0\\ \varvec{\omega }(T)&= \varvec{\omega }_T,\ \ \varvec{q}(T) = \varvec{q}_T \end{aligned} \right. \end{aligned}$$
(8)

where the time interval [0, T], a positive definite diagonal matrix J of order 3, and initial and final conditions \((\varvec{\omega }_0,\varvec{q}_0)\), \((\varvec{\omega }_T,\varvec{q}_T)\) are given data.

More precisely, if we denote

$$\begin{aligned} \begin{aligned} \varvec{x}&= (\varvec{\omega },\varvec{q}) = (\varvec{\omega },\varvec{\epsilon },\eta )\\ \varvec{x}_0&= (\varvec{\omega }_0,\varvec{q}_0) \\ \varvec{x}_T&= (\varvec{\omega }_T,\varvec{q}_T) \end{aligned} \end{aligned}$$
(9)

the optimal control problem can be stated in the usual general form

$$\begin{aligned} \text {Minimize with respect to }\varvec{u}(t):\ \ I(\varvec{u}) = \int _0^T F(t,\varvec{x}(t),\varvec{u}(t))\ dt \end{aligned}$$
(10)

subject to

$$\begin{aligned} \left\{ \begin{aligned}&x'_1 = \omega '_1 = x_2x_3 (J_2-J_3)/J_1 + u_1/J_1 \\&x'_2 = \omega '_2 = x_1x_3 (J_3-J_1)/J_2 + u_2/J_2 \\&x'_3 = \omega '_3 = x_1x_2 (J_1-J_2)/J_3 + u_3/J_3 \\&x'_4 = \epsilon '_1 = (x_1x_7)/2 - (x_2x_6)/2 + (x_3x_5)/2 \\&x'_5 = \epsilon '_2 = (x_1x_6)/2 - (x_3x_4)/2 + (x_2x_7)/2 \\&x'_6 = \epsilon '_3 = (x_2x_4)/2 - (x_1x_5)/2 + (x_3x_7)/2 \\&x'_7 = \eta ' = - (x_1x_4)/2 - (x_2x_5)/2 - (x_3x_6)/2 \end{aligned}\right. \end{aligned}$$
(11)

end-point conditions

$$\begin{aligned} \left\{ \begin{aligned}&\varvec{x}(0) = \varvec{x}_0 \\&\varvec{x}(T) = \varvec{x}_T \end{aligned}\right. \end{aligned}$$
(12)

and a constraint condition for controls of the form

$$\begin{aligned} |\varvec{u}|\le M,\quad M<+\infty \hbox { or }M=+\infty . \end{aligned}$$
(13)

We would like to point out that, even though the developed algorithm is able to deal with a large class of functionals, for the showcased simulations, a quadratic functional on state and control of the type

$$\begin{aligned} I(\varvec{u}) = \dfrac{1}{2} \int _0^T (\varvec{x}^t \varvec{Q} \varvec{x} + \varvec{u}^t \varvec{R} \varvec{u})\,dt \end{aligned}$$
(14)

has been used, where \(\varvec{Q}\) and \(\varvec{R}\) are, respectively, positive definite and positive semidefinite matrices. Furthermore, and for the sake of simplicity, the matrices \(\varvec{Q}\) and \(\varvec{R}\) have been chosen to be diagonal. Their units are such that the cost I is non-dimensional; that is, the first three components of the diagonal of \(\varvec{Q}\) have units of \(\frac{s}{rad^2}\), while the rest are \(\frac{1}{s}\). The matrix \(\varvec{R}\) has units of \(\frac{1}{N^2\,m^2\,s}\).

2.5 The final, precise form of the problem. Analytical facts

With the notation introduced in the previous subsections and given a certain finite time horizon \(T>0\), our problem consists in minimizing the quadratic cost functional

$$\begin{aligned} I(\varvec{u})= & {} \int _0^T F(t,\varvec{x}(t),\varvec{u}(t))\ dt,\quad F(t, \varvec{x}, \varvec{u})= \dfrac{1}{2}(\varvec{x}^t \varvec{Q} \varvec{x} + \varvec{u}^t \varvec{R} \varvec{u}),\nonumber \\ \varvec{x}= & {} (x_1, x_2, x_3, x_4, x_5, x_6, x_7),\quad \varvec{u}=(u_1, u_2, u_3),\nonumber \end{aligned}$$

subject to the state system

$$\begin{aligned} \varvec{x}'(t)=\varvec{F}(\varvec{x}(t))+\varvec{D}\varvec{u},\quad t\in [0, T], \end{aligned}$$

where the quadratic mapping \(\varvec{F}\) and the constant matrix \(\varvec{D}\) are given in (11), and end-point conditions (12) and typical constraints on the size of controls (13) are enforced if \(M<\infty \). Since this is the most typical setting, for the sake of definiteness we will stick to the case \(M<\infty \).

Appropriate spaces for control laws \(\varvec{u}\) are taken from the space

$$\begin{aligned} L^\infty (0, T; {\mathbb {R}}^3),\quad \varvec{K}\equiv \{\varvec{u}\in {\mathbb {R}}^3: |\varvec{u}|\le M\}. \end{aligned}$$

State paths \(\varvec{x}(t)\) coming from solving state system (11), under the initial condition \(\varvec{x}(0)=\varvec{x_0}\), will then be bounded, absolutely continuous paths. For all such feasible pairs \((\varvec{u}, \varvec{x})\), complying also with the final state constraint \(\varvec{x}=\varvec{x_T}\), the cost \(I(\varvec{u})\) will be well-defined and finite. As we focus here in the approximation of optimal control laws, we are not concerned about the controllability issue that consists in understanding for what end-point pairs \((\varvec{x_0}, \varvec{x_T})\), functional \(I(\varvec{u})\) is identically \(+\infty \) for lack of feasible control laws.

The existence of optimal control laws for our problem is a direct consequence of Corollary 3.18 in [10], which, in turn, is a consequence of a genuine variational existence result Theorem 3.17 in that same reference. We explicitly state here such result, in the form of a theorem, for the convenience of readers.

Theorem 2.1

Suppose the following:

  1. (1)

    the set \(\varvec{K}\) of admissibility of controls is closed and convex;

  2. (2)

    the integrand \(F(\varvec{x}, \varvec{u})\) in the cost functional is continuous and convex in the control variable \(\varvec{u}\); and

  3. (3)

    the state law

    $$\begin{aligned} \varvec{x}'=\varvec{f_0}(\varvec{x})+\varvec{f_1}(\varvec{x})\varvec{u} \end{aligned}$$

    is continuous in the state variable \(\varvec{x}\) but linear in the control variable \(\varvec{u}\).

Then the corresponding optimal control problem admits at least one optimal solution.

To enforce uniqueness of solution one is led almost exclusively to the situation of a linear-quadratic problem.

Since hypotheses in this corollary are clearly met for our problem, such a result can be applied to conclude the existence of optimal solutions for the control of satellites according to the model discussed in this contribution. Uniqueness cannot be shown in general.

3 The approximation method

In this section, the method for approximating solutions for the optimal control problem of Sect. 2.4 is briefly presented for the sake of completeness. The algorithm is explained in detail in [10], including explicit results that are stated here for the convenience of readers. The strategy proceeds in two main steps as indicated in the Introduction:

  1. (1)

    an equivalent constrained variational problem is derived from the optimal control problem;

  2. (2)

    such reformulated problem is then numerically approximated: the resulting constrained variational problem is tackled by iteratively approximating solutions of an associated unconstrained problem with an extended integrand that takes into account the presence of constraints by including term that involves exponential barrier functions.

3.1 A variational method for optimal control

Our strategy to solve an optimal control problem under pointwise constraints is to derive an equivalent variational problem in the sense that solutions to the former can be recovered from solutions to the latter. Once the variational problem has been correctly formulated, and its solution found (or numerically approximated, in the case of concern), one can very easily extrapolate the optimal solution of the control problem.

Let us suppose that we are given the following optimal control problem:

$$\begin{aligned} \text {Minimize with respect to } \varvec{u}(t): \ \ \int _0^T F(t,\varvec{x}(t),\varvec{u}(t))\ dt \end{aligned}$$
(15)

subject to

$$\begin{aligned} \left\{ \begin{aligned} \varvec{x}'(t)&= \varvec{f}(t,\varvec{x}(t),\varvec{u}(t))\ \forall t \in [0,T] \\ \varvec{x}(t)&\in \Omega \subset {\mathbb {R}}^N\ \ \forall t\in [0,T] \\ \varvec{u}(t)&\in \varvec{K} \subset {\mathbb {R}}^m\ \ \forall t\in [0,T] \\ \varvec{x}(0)&= \varvec{x}_0 \\ \varvec{x}(T)&= \varvec{x}_T \end{aligned} \right. \end{aligned}$$
(16)

The basic idea is to face an equivalent, purely variational problem with a certain integrand \(\varvec{\psi }\) that is built from the main ingredients of the previous control problem. Roughly, the integrand \(\varvec{\psi }\) is determined through a previous optimization step on the control variable \(\varvec{u}\)

$$\begin{aligned} \varvec{\psi }\left( t, \varvec{x},\varvec{X}\right) =\chi _\Omega (\varvec{x})+\min _{\varvec{u}\in \varvec{K}} \{F(t, \varvec{x}, \varvec{u}): \varvec{X}=\varvec{f}(t, \varvec{x}, \varvec{u})\}, \end{aligned}$$
(17)

where \(\chi _\Omega (\varvec{x})\) takes on a vanishing value if \(\varvec{x}\in \Omega \), and an infinity value, so as to forbid such situation, if \(\varvec{x}\notin \Omega \).

The initial optimal control problem is then equivalent (this can again be checked in [10]) to the following variational problem:

$$\begin{aligned} \text {Minimize with respect to }\varvec{x}(t): \ \ \int _0^T \varvec{\psi } \left( t,\varvec{x}(t),\varvec{x}'(t)\right) \ dt \end{aligned}$$
(18)

subject to

$$\begin{aligned} \left\{ \begin{aligned} \varvec{x}(0)&= \varvec{x}_0 \\ \varvec{x}(T)&= \varvec{x}_T \\ \end{aligned} \right. \end{aligned}$$
(19)

If we are able to solve (approximate) this variational problem, then the solution \(\varvec{u}(t)\) to the optimal control problem can be recovered through the identity

$$\begin{aligned} F(t, \varvec{x}(t), \varvec{u}(t)) = \varvec{\psi }\left( t, \varvec{x}(t),\varvec{x}'(t)\right) \end{aligned}$$
(20)

Suppose we ignore an explicit dependence on time t, do not take into account any restriction set \(\Omega \) for state (this is the situation in our problem), and constraint set \(\varvec{K}\) for controls is either all of space or determined through inequalities

$$\begin{aligned} \varvec{G}(\varvec{u})\le \varvec{0} \end{aligned}$$
(21)

In this case, the place where the integrand \(\varvec{\psi }\) is finite can be identified with a collection of inequalities

$$\begin{aligned} \varvec{\phi }(\varvec{x}, \varvec{X})\le \varvec{0}, \end{aligned}$$

for a suitable mapping \(\varvec{\phi }\), in such a way that the variational version of our control problem can be recast as

$$\begin{aligned} \text {Minimize with respect to }\varvec{x}(t): \ \ \int _0^T \varvec{\psi } \left( \varvec{x}(t),\varvec{x}'(t)\right) \ dt \end{aligned}$$
(22)

subject to

$$\begin{aligned} \varvec{\phi }\left( \varvec{x}(t),\varvec{x}'(t)\right) \le \varvec{0}\hbox { for all }t\in [0, T], \end{aligned}$$
(23)

and

$$\begin{aligned} \left\{ \begin{aligned} \varvec{x}(0)&= \varvec{x}_0 \\ \varvec{x}(T)&= \varvec{x}_T \\ \end{aligned} \right. \end{aligned}$$
(24)

where now the integrand \(\varvec{\psi }\) is a regular, smooth integrand. Moreover, there is an additional mapping \(\varvec{\Gamma }\) associated with the minimization problem defining \(\varvec{\psi }\) in (17) that yields the optimal control law \(\varvec{u}(t)\) once the optimal solution \(\varvec{x}(t)\) of the variational reformulation has been found or reasonably approximated, namely

$$\begin{aligned} \varvec{u}(t)=\varvec{\Gamma }(\varvec{x}(t), \varvec{x}'(t)). \end{aligned}$$
(25)

We therefore see that the whole point of our concern is to propose a mechanism to approximate the optimal solution \(\varvec{x}\) of a variational problem under pointwise constraints of the form (23), in addition to standard end-point conditions. We then proceed to explore the second step of our strategy.

3.2 Approximation under pointwise constraints

This section addresses the approximation of variational problems under point-wise constraints in the form of inequalities. We have changed the notation \(\varvec{\psi }\mapsto F\), \(\varvec{\phi }\rightarrow \varvec{G}\), to stress the fact that we are dealing with a general variational problem under constraints. In order to place things in context, we shall attempt to approximate solutions to the variational problem

$$\begin{aligned} \text {Minimize with respect to } \varvec{x}(t):\ I(\varvec{x}) = \int _0^T F(\varvec{x}(t),\varvec{x}'(t))\ dt \end{aligned}$$
(26)

subject to:

  • end-point conditions \(\varvec{x}(0)=\varvec{x}_0\), \(\varvec{x}(T)=\varvec{x}_T\) and

  • pointwise constraints \(\varvec{G}(\varvec{x}(t),\varvec{x}'(t))\le \varvec{0}\ \forall t \in [0,T]\).

The integrand \(F(\varvec{x},\varvec{X}): {\mathbb {R}}^N \times {\mathbb {R}}^N \longrightarrow {\mathbb {R}}\) and the map \(\varvec{G}:{\mathbb {R}}^N\times {\mathbb {R}}^N\longrightarrow {\mathbb {R}}^m\) are both considered to be smooth. These assumptions, along with the convexity of the integrand \(F(\varvec{x},\varvec{X})\) and of the components \(G_i(\varvec{x}, \varvec{X})\) of \(\varvec{G}(\varvec{x}, \varvec{X})\), are key aspects as regards the following derivations.

Our strategy will be to find solutions to pointwise constrained variational problems by iteratively approximating the solutions of unconstrained (except for end-point conditions) variational problems, which are carefully crafted using the ingredients of the original, pointwise-constrained problem. The functional is augmented by adding a term to the integrand which takes into account how far the solution is from complying with all the constraints: a non-negative term which grows exponentially as \(\varvec{x}\) moves away from complying with all constraints and decreases as all constraints are close to be met.

At each iteration, this term is updated until convergence takes place, that is, until this new functional is minimized. This implies that all the constraints are satisfied.

As will be shown, this augmented integrand relies on the idea of multipliers, which is the main tool employed to deal with constraints.

We introduce the auxiliary map \(\varvec{y}:[0,T]\longrightarrow {\mathbb {R}}^m\). Each component of \(\varvec{y}\)

$$\begin{aligned} y_i(t),\ i=1,2,\ldots ,m \end{aligned}$$

is called a multiplier, which, as we shall see, is in charge of enforcing the constraint

$$\begin{aligned} G_i(\varvec{x}(t),\varvec{x}'(t))\le 0\ \forall t \in [0,T],\ i=1,2,\ldots ,m \end{aligned}$$

Now, we take

$$\begin{aligned} J(\varvec{x},\varvec{y})= \int _0^T \left( F(\varvec{x}(t),\varvec{x}'(t)) + \sum _{k=1}^{m}e^{y_k(t)G_k(\varvec{x}(t),\varvec{x}'(t))}\right) dt \end{aligned}$$
(27)

The algorithm is as follows:

  1. (1)

    Initialization.

    1. (a)

      Set \(\varvec{x}^0(t)\) to an arbitrary but feasible solution. For example:

      $$\begin{aligned} \varvec{x}^0(t) = \dfrac{T-t}{T}\varvec{x}_0 + \dfrac{t}{T}\varvec{x}_T \end{aligned}$$
    2. (b)

      Set the vector of multipliers \(\varvec{y}(t)\) arbitrarily, with positive components. We will normally use

      $$\begin{aligned} y_k^0(t)\equiv 1,\ k=1,2,\ldots ,m \end{aligned}$$
  2. (2)

    Iterative step. If the pair \((\varvec{x}^j, \varvec{y}^j)\) is known, minimize in \(\varvec{x}\), for \(\varvec{y}^j\) fixed, the functional

    $$\begin{aligned} J(\varvec{x},\varvec{y}^j):= \int _0^T \left( F(\varvec{x}(t),\varvec{x}'(t)) + \sum _{k=1}^{m}e^{y_k^j(t)G_k(\varvec{x}(t),\varvec{x}'(t))}\right) \ dt \end{aligned}$$

    approximately, using the techniques presented in the Appendix starting from \(\varvec{x}^j\). Then set \(\varvec{x}^{j+1}\) as the solution to this problem.

  3. (3)

    Updating of multipliers. Compute

    $$\begin{aligned} M = \max \left\{ y_k^j(t) G_k(\varvec{x}^{j+1}(t),(\varvec{x}^{j+1})'(t)):\ t\in [0,T], k=1,2,\ldots ,m \right\} \end{aligned}$$
    1. (a)

      If this quantity M (which plays the role of an indicator of how close the algorithm is to the desired solution that meets all constraints) is smaller than a predefined small constant \(\delta \), then \(\varvec{x}^{j+1}\) is sufficiently close to the solution of the variational problem with pointwise constraints.

    2. (b)

      Otherwise, if \(M>\delta \), update the multipliers according to the following rule.

      $$\begin{aligned} y_k^{j+1}(t) = e^{y_k^j(t)G_k(\varvec{x}^{j+1}(t),(\varvec{x}^{j+1})'(t))}y_k^j(t)\ \forall t\in [0,T],\ k=1,2,\ldots ,m \end{aligned}$$

      Then, set

      $$\begin{aligned} \varvec{y}^j \leftarrow \varvec{y}^{j+1},\ \varvec{x}^j \leftarrow \varvec{x}^{j+1} \end{aligned}$$

      and proceed with Step 2.

A thorough explanation of why this algorithm works reasonably well, and why we can be sure that, if convergence takes place, the solution is in fact sufficiently close to the solution of the constrained variational problem, can be found in [9].

3.2.1 Pointwise constraints in the form of equalities

We have now learned a method to enforce inequality constraints of the form \(\varvec{G}(\varvec{x}(t),\varvec{x}'(t))\le 0\ \forall t \in [0,T]\). However, in certain situations one might also (or alternatively) wish to enforce p equality constraints in the form \(\varvec{g}(\varvec{x}(t),\varvec{x}'(t)) = 0\ \forall t \in [0,T]\), for a smooth map \(\varvec{g}:{\mathbb {R}}^N\times {\mathbb {R}}^N\longrightarrow {\mathbb {R}}^p\). If this is the case, the previous ideas can be modified in such a way that the algorithm will find solutions to the variational problem subject to these equality constraints. This can be done in two different ways:

  1. (1)

    Consider the quantity

    $$\begin{aligned} \dfrac{1}{2}\left| \varvec{g}(\varvec{x},\varvec{X})\right| ^2 \end{aligned}$$

    and solve the variational problem subject to the p additional inequality constraints

    $$\begin{aligned} \dfrac{1}{2}\left| \varvec{g}(\varvec{x}(t),\varvec{x}'(t))\right| ^2 \le 0\ \forall t\in [0,T] \end{aligned}$$
  2. (2)

    Alternatively, we can solve the variational problem which complies with the additional 2p inequality constraints

    $$\begin{aligned} \varvec{g}(\varvec{x}(t),\varvec{x}'(t)) \le 0,\ -\varvec{g}(\varvec{x}(t),\varvec{x}'(t)) \le 0\ \ \forall t \in [0,T] \end{aligned}$$

3.3 Advantages of the method, discretization, and convergence

The numerical approximation of optimal control problems governed by ODEs systems, especially under non-linear state system, and constraints on the size of controls, requires a good deal of expertise to monitor constantly saturation conditions where optimality leads controls to its permitted outer boundary. This is well reflected on the techniques based on penalization and/or barriers; or in the use of the Pontryaguin’s maximum principle. The mechanism proposed in [10] and tested here is based on the approximation of constrained variational principles, as explained in the above subsection, but it is applied recursively and automatically without any special surveillance during the process. On the other hand, since it is a general-purpose procedure it may not be able to compete with other approximation mechanisms better adapted to the particular structure of the problems that are to be examined. Yet, it is our experience that results are in many cases quite reasonable and even competitive. We would like to report on this for the control of satellites that we are investigating here.

As explained above, the approximation method is implemented on the variational reformulation (26) of the initial optimal control problem. Such discretization is set up in the most natural way one can think of through nodal values of variables at the points of a suitable partition of the time interval [0, T]. The optimization performed in this discretized version, labeled by k, of the continuous problem produces a sequence of pairs \((\varvec{y}_k, \varvec{x}_k)\) in suitable and natural finite dimensional subspaces, corresponding to discretizations of continuous multipliers \(\varvec{y}\), accounting for constraints

$$\begin{aligned} \varvec{G}(\varvec{x}(t),\varvec{x}'(t))\le \varvec{0}, \end{aligned}$$

and continuous states \(\varvec{x}\). Discrete pairs \((\varvec{y}_k, \varvec{x}_k)\) are, in turn, the result of a discrete optimization iterative procedure \((\varvec{y}_{k, j}, \varvec{x}_{k, j})\) as \(j\rightarrow \infty \) for each fixed k. In this manner, we have pairs of vectors \((\varvec{y}_{k, j}, \varvec{x}_{k, j})\) with subscript k indicating level of discretization, while subscript j indicates step of the main iterative process.

The convergence of the whole approximation method was also studied in detail in [10]. In particular, Theorem 6.10 in that reference established convergence under appropriate hypotheses on \(F(\varvec{x}, \varvec{X})\) and \(\varvec{G}(\varvec{x},\varvec{X})\). We again state such result for the sake of completeness.

Theorem 3.1

Suppose that the integrand \(F(\varvec{x}, \varvec{X})\) is smooth, and coercive, and the mapping \(\varvec{G}(\varvec{x},\varvec{X})\) is smooth. If for discrete solutions \((\varvec{y}_{k, j}, \varvec{x}_{k, j})\), we have

$$\begin{aligned} \varvec{y}_{k, j}\cdot \varvec{G}(\varvec{x}_{k, j}, \varvec{x}'_{k, j})\rightarrow 0,\quad \varvec{x}_{k, j}\rightarrow \varvec{x}_k, \varvec{y}_{k, j}\ge 0, \end{aligned}$$
(28)

as \(j\rightarrow \infty \) for fixed k, then \(\varvec{x}_k\) converges, as absolutely continuous paths, to a local optimal solution \(\overline{\varvec{x}}\) of problem (26) as \(k\rightarrow \infty \).

Condition (28) becomes a certificate of convergence to a true optimal solution of our problem. If assumptions on the integrand \(F(\varvec{x}, \varvec{X})\) and the mapping \(\varvec{G}(\varvec{x},\varvec{X})\) are strengthened to incorporate (strict) convexity jointly in pairs \((\varvec{x},\varvec{X})\), then the optimal solution becomes global. This is standard. We again refer to [10] for more precise details.

3.4 Our particular situation

It may be enlightening to write down explicitly the map \(\varvec{G}\) corresponding to our specific problem here. According to (11), map \(\varvec{G}\) will have fourteen components \((G_i)\), namely

$$\begin{aligned} G_1= & {} J_1X_1-(J_2-J_3)x_2x_3-M,\quad G_2=-J_1X_1+(J_2-J_3)x_2x_3-M,\nonumber \\ G_3= & {} J_2X_2-(J_3-J_1)x_3x_1-M, \quad G_4=-J_2X_2+(J_3-J_1)x_3x_1-M,\nonumber \\ G_5= & {} J_3X_3-(J_1-J_2)x_1x_2-M,\quad G_6=-J_3X_3+(J_1-J_2)x_1x_2-M,\nonumber \\ G_7= & {} X_4- (x_1x_7)/2 + (x_2x_6)/2 - (x_3x_5)/2,\quad G_8=-X_4+ (x_1x_7)/2 - (x_2x_6)/2 \\ {}{} & {} + (x_3x_5)/2, \nonumber \\ G_9= & {} X_5- (x_1x_6)/2 + (x_3x_4)/2 - (x_2x_7)/2,\quad G_{10}=-X_5+(x_1x_6)/2 - (x_3x_4)/2 \\ {}{} & {} +(x_2x_7)/2, \nonumber \\ G_{11}= & {} X_6- (x_2x_4)/2 + (x_1x_5)/2 - (x_3x_7)/2,\quad G_{12}=-X_6+ (x_2x_4)/2 - (x_1x_5)/2 \\ {}{} & {} + (x_3x_7)/2, \nonumber \\ G_{13}= & {} X_7+ (x_1x_4)/2 + (x_2x_5)/2 + (x_3x_6)/2,\quad G_{14}=-X_7- (x_1x_4)/2 - (x_2x_5)/2 \\ {}{} & {} - (x_3x_6)/2. \nonumber \end{aligned}$$

It is then elementary to check that the fourteen inequalities

$$\begin{aligned} G_i(\varvec{x}, \varvec{x}')\le 0, \quad i=1, 2, \dots , 14 \end{aligned}$$
(29)

are equivalent to having (11) under the size constraint

$$\begin{aligned} |\varvec{u}|\le M. \end{aligned}$$

Moreover, once (29) is valid, the choice \(\varvec{u}=(u_1, u_2, u_3)\) with

$$\begin{aligned} u_1(t)= & {} J_1x'_1(t)-(J_2-J_3)x_2(t)x_3(t),\nonumber \\ u_2(t)= & {} J_2x'_2(t)-(J_3-J_1)x_3(t)x_1(t),\nonumber \\ u_3(t)= & {} J_3x'_3(t)-(J_1-J_2)x_1(t)x_2(t),\nonumber \end{aligned}$$

will produce a feasible control law. If the pair \((\varvec{x}, \varvec{x}')\) is optimal for (22)–(23)–(24), then this control vector \(\varvec{u}\) will be optimal for the initial control problem. Note that these formulas for \(\varvec{u}\) furnish the mapping in (25) for this particular example. It is also elementary to realize that the mapping \(\varvec{G}\) is not convex on the variable \(\varvec{x}\), and so, according to Theorem  3.1, the convergence of the discretized solutions can only be to a local optimal solution. We suspect however that our approximations indeed converge to a global optimal solution.

4 Results and discussion

In this section, we apply the approximation mechanism described in the previous section to our satellite problem. Two simulations are presented. The first consists in a detumbling manoeuvre. In this case, the satellite begins with a tumbling state of motion, that is, the three angular velocities are non-zero. The algorithm then tries to dissipate all the rotational energy. The second manoeuvre, in contrast, consists in moving the satellite from one predefined orientation to another, with both initial and final states having zero angular velocity.

4.1 Detumbling

In this simulation, the satellite starts with a tumbling state of motion \(\varvec{\omega }_0 = (\pi /2,\pi /4,\pi /8) rad/s\), and the algorithm is commanded to dissipate its rotational energy (\(\varvec{\omega }_T = \varvec{0}\ rad/s\)). The algorithm is allowed \(T=4.5s\) to perform the manoeuvre. The parameters used in this simulation are presented in Table 1, while the simulation results are showcased in Table 2.

Table 1 Detumbling manoeuvre—simulation parameters
Table 2 Detumbling manoeuvre—simulation results

Figure 1 shows the control calculated by the algorithm. Figure 2 shows the evolution of the state.

Fig. 1
figure 1

Detumbling manoeuvre–control

Fig. 2
figure 2

Detumbling manoeuvre—state

4.2 Single axis, rest to rest

In this situation, the satellite starts at rest, and is commanded to rotate an angle of \(\pi /2\) around one of its axes. In this case, inequality constraints on control have also been imposed to showcase the ability of the algorithm to deal with this important type of constraints. For instance, it is requested that

$$\begin{aligned} |\varvec{u}|\le 1Nm\quad \text {in } [0,T] \end{aligned}$$
(30)

Figure 3 shows the control calculated by the algorithm for \(T=2.55s\), \(T=2.525s\), \(T=2.52s\), \(T=2.515s\). Similarly, the evolution of the angular velocities and the Euler Angles is presented in Figs. 4 and 5. Table 3 shows the parameters used in the four simulations. In Table 3, the worst results obtained from each of the four simulations are presented

Fig. 3
figure 3

Single axis, rest to rest manoeuvre—control

Fig. 4
figure 4

Single, axis, rest to rest manoeuvre—angular velocities

Fig. 5
figure 5

Single axis, rest to rest manoeuvre—Euler angles

Table 3 Single axis, rest to rest manoeuvre—simulation parameters
Table 4 Single axis, rest to rest manoeuvre—simulation results

This simulation is used to showcase the bang-bang nature of optimal controls as the time interval is reduced–and effectively, as the problem approaches a time-optimal control problem. As the interval [0, T] is shortened, the control abruptly switches between the minimum (\(-1Nm\)) and maximum (1Nm) allowed values.

4.3 Comparison with a linearised model

In this section, we compare our proposed control method to a controller based on a traditional Linear-Quadratic Regulator (LQR) approach. In particular, the method proposed in [21, 22] and later recreated in [17] is used for comparison purposes.

The method is based on the following linearisation of the satellite’s equations of motion, which is used as state law for a Linear-Quadratic Regulator

$$\begin{aligned} \left( \begin{array}{c} \varvec{\omega }' \\ \varvec{\epsilon }' \end{array}\right) = \dfrac{1}{2} \left( \begin{array}{cc} 0_{3\times 3} &{}\quad 0_{3\times 3}\\ I_{3} &{}\quad 0_{3\times 3} \end{array}\right) \left( \begin{array}{c} \varvec{\omega } \\ \varvec{\epsilon } \end{array}\right) + \left( \begin{array}{c} J^{-1} \\ 0_{3\times 3} \end{array}\right) \varvec{u} \end{aligned}$$
(31)

More precisely, the LQR problem consists in searching for paths \(\varvec{u}:[0,T]\rightarrow {\mathbb {R}}^3\), which minimize the functional

$$\begin{aligned} I(\varvec{u}) = \dfrac{1}{2}\int _0^T \left( \varvec{x}^tQ\varvec{x} + \varvec{u}^tR\varvec{u}\right) \ dt \end{aligned}$$
(32)

subject to

$$\begin{aligned} \left\{ \begin{aligned} \varvec{x}'&= A\varvec{x} + B\varvec{u} \ \ \text {in } [0,T]\\ \varvec{x}(0)&= \varvec{x}_0 \\ \varvec{x}(T)&= \varvec{x}_T \end{aligned} \right. \end{aligned}$$
(33)

where

$$\begin{aligned} A = \dfrac{1}{2} \left( \begin{array}{cc} 0_{3\times 3} &{}\quad 0_{3\times 3}\\ I_{3} &{}\quad 0_{3\times 3} \end{array}\right) ,\ B = \left( \begin{array}{c} J^{-1} \\ 0_{3\times 3} \end{array}\right) \end{aligned}$$
(34)

This linear model can be found in [21, 22].

The procedure is as follows: the control is calculated by numerically approximating the solution to the Linear-Quadratic Regulator problem. Then, the calculated control is applied as input to a computer model in which the fully non-linear dynamics are simulated. It is from this model that the orientation and angular velocities are extracted.

Figures 6 and 7  show the results from a simulation performed using the linearised model (32)–(34). It corresponds to a detumbling manoeuvre, configured with the same parameters as the simulation in Sect. 4.1. The results from this simulation are presented in Table 5.

Fig. 6
figure 6

Detumbling manoeuvre using the LQR—control

Fig. 7
figure 7

Detumbling to a fixed orientation—results obtained from the LQR

Table 5 Detumbling manoeuvre using the LQR—simulation results

We can see that the Linear-Quadratic Regulator is not able to steer the system to the desired state.

5 Conclusions

In this paper, we have proposed a non-linear controller for the attitude control of satellites. For that objective, we have proposed a fully non-linear optimal control with an arbitrary integrand and the non-linear evolution law

$$\begin{aligned} \left\{ \begin{aligned} J \varvec{\omega }'&= -\varvec{\omega }\times J\varvec{\omega } + \varvec{u} \\ \varvec{\epsilon }'&= -\dfrac{1}{2}\varvec{\omega }\times \varvec{\epsilon } + \dfrac{1}{2}\eta \varvec{\omega } \\ \eta '&= - \dfrac{1}{2}\varvec{\omega }^T\varvec{\epsilon } \end{aligned} \right. \end{aligned}$$
(35)

which was tackled by means of its variational reformulation.

On the other hand, we have compared its performance to a controller based on a linearisation of the equations of motion of the type

$$\begin{aligned} \varvec{x}' = A\varvec{x} + B\varvec{u} \end{aligned}$$
(36)

which, together with a functional of the type

$$\begin{aligned} \varvec{u}\longmapsto \dfrac{1}{2} \int _0^T \left( \varvec{x}^tQ\varvec{x} + \varvec{u}^tR\varvec{u} \right) \end{aligned}$$
(37)

resulted in a typical LQR that was solved using the numerical methods.

5.1 Advantages of the linearised approach

Both perspectives have their own advantages and disadvantages. We start by formulating a few advantages of the LQR as opposed the non-linear approach:

  • The major advantage of the linear approach is its computation time: Solving an LQR problem is considerably simple (and hence, faster) that finding solutions to a general, non-linear optimal control problem. We have been able to obtain computation times of the order of magnitude of milliseconds to solve the LQR problem, in contrast to the tenths of seconds required to approximate the non-linear optimal control problem on the same computer.Footnote 1 Computation times for the LQR could be reduced even further if explicit feedback control techniques were employed.

  • Solving the LQR does not require the user to keep track of convergence parameters, as it is not an iterative method, unlike the non-linear model.

This makes the LQR a more suitable algorithm for implementation in a system that requires near to real-time response, but that is willing to sacrifice accuracy for the sake of quick response times.

5.2 Advantages of our mehtod

The advantages of the proposed method are:

  • The non-linear model allows a much broader class of integrands, in contrast to the LQR, which is restricted to a quadratic integrand on time and control.

  • It is arbitrarily accurate for any choice of initial and final state. Its accuracy can be improved by simply lowering the convergence threshold of the algorithm, which essentially dictates when the algorithm decides that the solution it has found is sufficiently close to be optimal and to comply with all constraints. In contrast, the LQR can be used exclusively for very fine manoeuvres, and its accuracy is dependent on initial and final conditions.

  • The non-linear model makes it possible to enforce a wide variety of constraints: from pointwise equality and inequality constraints to natural boundary conditions, through global integral constraints and fixed boundary conditions.

  • The non-linear algorithm enables the user to perform complicated manoeuvres that could not be carried out with almost any other conventional method: for example, detumbling and steering the satellite to an arbitrary orientation can be achieved with a single manoeuvre. This is impossible for most other control methods, in which two manoeuvres would have to be employed separately.