Autonomous Trajectory Generation Algorithms for Spacecraft Slew Maneuvers

Spacecraft need to be able to reliably slew quickly and rather than simply commanding a final angle, a trajectory calculated and known throughout a maneuver is preferred. A fully solved trajectory allows for control based off comparing current attitude to a time varying desired attitude, allowing for much better use of control effort and command over slew orientation. This manuscript introduces slew trajectories using sinusoidal functions compared to optimal trajectories using Pontryagin’s method. Use of Pontryagin’s method yields approximately 1.5% lower control effort compared to sinusoidal trajectories. Analysis of the simulated system response demonstrates that correct understanding of the effect of cross-coupling is necessary to avoid unwarranted control costs. Additionally, a combination of feedforward with proportional derivative control generates a system response with 3% reduction in control cost compared to a Feedforward with proportional integral derivative control architecture. Use of a calculated trajectory is shown to reduce control cost by five orders of magnitude and allows for raising of gains by an order of magnitude. When control gains are raised, an eight orders of magnitude lower error is achieved in the slew direction, and rather than an increase in control cost, a decrease by 11.7% is observed. This manuscript concludes that Pontryagin’s method for generating slew trajectories outperforms the use of sinusoidal trajectories and trajectory generation schemes are essential for efficient spacecraft maneuvering.


Introduction
The James Webb telescope depicted in Figure 1 is an example of the paramountcy of attitude trajectories of angular momentum to space mission accomplishment. The James Webb Space telescope (JWST) will study the formation of stars, galaxies, and planets 100-250 million years after the Big Bang. To see the first stars and galaxies of the early universe, JWST must look deep into space, necessitating a need for fine pointing accuracy, one of the reasons JWST is positioned so far away from Earth and the perturbations of the atmosphere. Due to the incredible distance between the JWST and potential imaging targets, pointing errors of mere arcseconds can lead to the telescope field of view not including the intended target, and any spacecraft jitter results in blurry, unusable images. Additionally, the control cost of pointing maneuvers must be considered carefully. Lower control costs result in "cheaper" maneuvers, which can allow for less expensive spacecraft launch, due to mass savings, more possible maneuvers over the spacecraft lifetime due to energy savings, or simply greater error tolerances and recovery capabilities. [1] Image used consistent with NASA policy, "NASA content (images, videos, audio, etc.) are generally not copyrighted and may be used for educational or informational purposes without needing explicit permissions" [2].
The same holds true for near Earth observational satellites. While satellites such as Landsat-9 [3] image targets much closer than JWST does, the increase in magnification power and resolution of such satellites warrants the same need for fine pointing accuracy. Understanding and application of trajectory generation and solution optimality leads to even lower control cost and greater pointing accuracy than has been possible. As pointing accuracy needs increase, attitude trajectories and the provided decrease in pointing error and control cost are vital in making future missions possible.
This manuscript describes two methods of formulating spacecraft attitude slew trajectories and compares various control architectures in performing the generated maneuvers. Rather than the classical formulation of feedback control of a single desired value subtracted from the current state, attention has shifted to more intelligent schemes where the slew trajectory is mapped out for the entire maneuver. Not only does a solved maneuver trajectory allow for more control, customization, and confidence in a control architecture, but also pointing conditions and restraints can be imposed and validated. For example, for a spacecraft to keep a sun-sensor pointed at the sun as best as possible throughout a maneuver. The entire trajectory can be simulated, visualized, and checked ahead of time with a much lower degree of randomness than classical control methods based on final conditions rather than trajectories, might allow. Using trajectories also introduces possibilities for finding optimal solutions, in fuel use, time or distance. One such manner of generating optimal trajectories is by use of Pontryagin's method. In this manuscript, Pontryagin's principle of using necessary conditions of optimality to solve for optimal trajectories in terms of control cost will be examined and contrasted with simpler trajectory generation techniques. Additionally, progress has been generated in the development of deterministic artificial intelligence, a control scheme based on a statement of selfawareness, and optimal parameter learning, to determine the optimal control to follow a desired trajectory [4][5][6]. Naturally, the question arises of the effects of applying optimal trajectory optimization methods to such adaptive feedforward methods of optimal control, as well as other control architectures. This manuscript will derive trajectories to perform a given slew maneuver of 30 degrees yaw, as well as present the formalism behind adaptive control techniques and deterministic artificial intelligence. Section 2 describes the materials and methods used to reveal the results presented in Section 3. Section 4 provides a brief discussion on the results in Section 3. [1] Image used consistent with NASA policy, "NASA content (images, videos, audio, etc.) are generally not copyrighted and may be used for educational or informational purposes without needing explicit permissions" [2].
The same holds true for near Earth observational satellites. While satellites such as Landsat-9 [3] image targets much closer than JWST does, the increase in magnification power and resolution of such satellites warrants the same need for fine pointing accuracy. Understanding and application of trajectory generation and solution optimality leads to even lower control cost and greater pointing accuracy than has been possible. As pointing accuracy needs increase, attitude trajectories and the provided decrease in pointing error and control cost are vital in making future missions possible.
This manuscript describes two methods of formulating spacecraft attitude slew trajectories and compares various control architectures in performing the generated maneuvers. Rather than the classical formulation of feedback control of a single desired value subtracted from the current state, attention has shifted to more intelligent schemes where the slew trajectory is mapped out for the entire maneuver. Not only does a solved maneuver trajectory allow for more control, customization, and confidence in a control architecture, but also pointing conditions and restraints can be imposed and validated. For example, for a spacecraft to keep a sun-sensor pointed at the sun as best as possible throughout a maneuver. The entire trajectory can be simulated, visualized, and checked ahead of time with a much lower degree of randomness than classical control methods based on final conditions rather than trajectories, might allow. Using trajectories also introduces possibilities for finding optimal solutions, in fuel use, time or distance. One such manner of generating optimal trajectories is by use of Pontryagin's method. In this manuscript, Pontryagin's principle of using necessary conditions of optimality to solve for optimal trajectories in terms of control cost will be examined and contrasted with simpler trajectory generation techniques. Additionally, progress has been generated in the development of deterministic artificial intelligence, a control scheme based on a statement of self-awareness, and optimal parameter learning, to determine the optimal control to follow a desired trajectory [4][5][6]. Naturally, the question arises of the effects of applying optimal trajectory optimization methods to such adaptive feedforward methods of optimal control, as well as other control architectures. This manuscript will derive trajectories to perform a given slew maneuver of 30 degrees yaw, as well as present the formalism behind adaptive control techniques and deterministic artificial intelligence. Section 2 describes the materials and methods used to reveal the results presented in Section 3. Section 4 provides a brief discussion on the results in Section 3.
Attitude trajectory adaptation was developed and proposed in [4], but the parameterization suffered from expression in inertial coordinates leading to a high computational burden (thus evaluation of techniques on this basis will remain important). Within just a couple of years, development of the identical technique parameterized in the body frame [5] proved to eliminate a large part of the computational burden. Several years later the burden was reduced still further [6] by 33% and 66% parameter reduction with subsequent experimental validation in [7]. Adaptability is often desirable, but results are sometimes difficult to prove as optimal, minimizing some prescribed cost function. Position and attitude constraints have been simultaneously considered [8] and inherent disturbance rejection as well. Limited control actuation has also been treated [9,10], while optimization has been presented when control moment gyroscopes are used [11], as gyroscope singularity is enormously concerning. Guidance trajectories were derived using only attitude trajectories [12] near small bodies. In 2018, trajectories began to be presented [13] to support the newly proposed deterministic artificial intelligence [14], while at the same time, constrained optimization problems of attitude trajectories were proposed in [15]. Following the former deterministic thread of thinking, deterministic optimal assertion of self-awareness and optimal learning were formulated in [16]. With a renewed focus on attitude trajectory optimization [17], disturbance minimizing trajectories for space robots was just proposed [18]. Finally, convex optimization for trajectory generation [19] was presented amidst a focus on rapid maneuvering agile satellites in constellations [20]. Garcia,et al. [8] highlighted the complicated complexity of optimization of space trajectories generated by the nonlinear, coupled governing equations of motion. Sanyal,et al. [21] emphasized the desirability of analytic, continuous trajectory equations over discontinuous ones from the perspective of proof-of-stability. Walker [15,22] utilized genetic-algorithm-tuned fuzzy controller solutions compared to a similar linear quadratic regulator solution (as opposed to nonlinear solutions presented here).
Chen, et al., [17] illustrated that attitude trajectory optimization can simplify control system design and improve relative performance. In this most recent resurgent strand of research, this manuscript examines convex trajectory optimization using Pontryagin's methods for control minimization [23] and compares several instantiations to comparable variants utilizing the sinusoidal trajectory generation ubiquitously presented in avenues of research in deterministic artificial intelligence expanded in this present treatment.
This work proposes to: 1. Present and derive two methods of autonomous slew trajectory generation, sinusoidal and Pontryagin based generation.

2.
Compare the performance of the derived trajectories when combined with various feedforward and feedback control schemes.

3.
Present two iterations on Pontryagin based trajectory generation and compare the instantiations.

4.
Validate the strength of trajectory-based control schemes over single-state feedback control methods.
The manuscript begins in Section 2 with a re-introduction of sinusoidal trajectory generation before deriving control minimizing (analytic) optimal trajectories using Pontryagin's method of imposing necessary conditions of optimality followed by solution of boundary value problems for families of solutions. A brief presentation of each of the control methods follows. Section 3 presents the results of simulations of the control methods and lastly Section 4 discusses and interprets the results of Section 3.

Autonomous Trajectory Generation
Given an end state, the goal is for the system to autonomously generate a trajectory to follow. Two methods of doing so will be examined, trajectory generation by examining the structure of the problem and solution to efficient spacecraft slews, and trajectory generation using Pontryagin's method, which consists of imposing necessary conditions of optimality Aerospace 2022, 9, 135 4 of 22 to solve for the boundary values of the boundary value problems of optimal state rate and trajectory. The trajectory shall be composed of an initial quiescent period, followed by a slew, and ending in a final quiescent period.

Sinusoidal Trajectories
In response to a commanded slew, a spacecraft should quickly snap to the desired attitude, where the definition of quick is determined by the human controller. If attitude maneuvering were instantaneous, the plot of the spacecraft's attitude representation would appear as a step function in the commanded maneuver channel. However, step functions are not smooth, represent discontinuities, and cannot be easily differentiated. Recognizing an instantaneous slew is impossible and a smooth, differentiable trajectory is optimal, we turn to an analysis of the structure of the problem.
Simple ordinary differential equations of the form . z = Az, such as a state space representation of spacecraft rotational dynamics, can be recognized as a harmonic oscillator, which has the solution of an exponential function of the form z = A exp λt, and can be written as a sinusoidal, z = A sin(ωt) [6]. Given the structure of the solution to the dynamics, an idea is for the commanded slew to follow the sinusoidal structure. Studying the sine wave in Figure 2 demonstrates how a square wave can be approximated by a piecewise trajectory of an initial quiescent period, a sine wave with period approaching zero, and a final quiescent period. As sine waves are smooth and differentiable, sinusoidal structure readily lends itself to a sinusoidal trajectory generation scheme Aerospace 2022, 9,x FOR PEER REVIEW 4 of 28 the structure of the problem and solution to efficient spacecraft slews, and trajectory generation using Pontryagin's method, which consists of imposing necessary conditions of optimality to solve for the boundary values of the boundary value problems of optimal state rate and trajectory. The trajectory shall be composed of an initial quiescent period, followed by a slew, and ending in a final quiescent period.

Sinusoidal Trajectories
In response to a commanded slew, a spacecraft should quickly snap to the desired attitude, where the definition of quick is determined by the human controller. If attitude maneuvering were instantaneous, the plot of the spacecraft's attitude representation would appear as a step function in the commanded maneuver channel. However, step functions are not smooth, represent discontinuities, and cannot be easily differentiated.
Recognizing an instantaneous slew is impossible and a smooth, differentiable trajectory is optimal, we turn to an analysis of the structure of the problem.
Simple ordinary differential equations of the form ̇= , such as a state space representation of spacecraft rotational dynamics, can be recognized as a harmonic oscillator, which has the solution of an exponential function of the form = λt, and can be written as a sinusoidal, = (ωt) [6]. Given the structure of the solution to the dynamics, an idea is for the commanded slew to follow the sinusoidal structure. Studying the sine wave in Figure 2 demonstrates how a square wave can be approximated by a piecewise trajectory of an initial quiescent period, a sine wave with period approaching zero, and a final quiescent period. As sine waves are smooth and differentiable, sinusoidal structure readily lends itself to a sinusoidal trajectory generation scheme A nominal sine curve is depicted above, note the abrupt start at time t = 0. A smooth initiation is preferable to avoid sudden impulsive maneuvers and undesirable resonance of flexible structures such as solar panels. In Figure 2b, at time t = 3T 4 , where T is the sine wave period, we note the smooth ramp up, indicating the derivative is zero and slowly increases rather than an initial derivative demanding immediate velocity. A non-instantaneous derivative reduces strain on the system. Thus time t = 3T/4 is desirable for the slew start. Choosing the quiescent time, Δt quiescent , the maneuver time, Δt maneuver , the sinusoidal trajectory is designed in the following steps.

= sin(ωt)
(1) 1. The maneuver time, Δt maneuver , determines the period of the sine wave. A sine wave takes half the period to go from the lowest value to the highest so the desired period should be twice the slew time. Thus, A nominal sine curve is depicted above, note the abrupt start at time t = 0. A smooth initiation is preferable to avoid sudden impulsive maneuvers and undesirable resonance of flexible structures such as solar panels. In Figure 2b, at time t = 3T 4 , where T is the sine wave period, we note the smooth ramp up, indicating the derivative is zero and slowly increases rather than an initial derivative demanding immediate velocity. A noninstantaneous derivative reduces strain on the system. Thus time t = 3T/4 is desirable for the slew start. Choosing the quiescent time, ∆t quiescent , the maneuver time, ∆t maneuver , the sinusoidal trajectory is designed in the following steps. 1.
The maneuver time, ∆t maneuver , determines the period of the sine wave. A sine wave takes half the period to go from the lowest value to the highest so the desired period should be twice the slew time. Thus, 2.
Phase shift the sine wave such that the desired low point at time t = 3T 4 , is at the desired maneuver start time after the initial ∆t quiescent , recalling a positive phase shift translates the sine wave in the negative direction and a negative phase shift translates the sine wave in the negative direction. We would like to translate the sine wave to Equation (6) can then be easily differentiated to solve for the state, rate, and acceleration.

Optimal Trajectory Using Pontryagin's Method
Another technique of formulating the trajectory is by use of Pontryagin's principle. Pontryagin's principle forms a boundary value problem of the trajectory and makes use of necessary conditions of optimality to solve for the boundary values. The result is an optimal trajectory with respect to the cost function used.

Defining the Problem
The system consists of the 3 degree-of-freedom rotational motion of a rigid body, which when the angular velocity is measured in a non-inertial frame, is represented as Transport theorem (7) where I is the moment of inertia of the body, ..
θ is the second derivative of the state θ, which represents the three body angles, and T is the applied torque in the body frame. The initial states were initialized at zero, and the system was commanded to reach a final state of θ d , or a desired attitude, with a final angular velocity of zero, .
θ(t f ) = 0. The model was built in Matlab Simulink and the block diagram can be found in Appendix A Figure A1.
The trajectory optimization problem begins with the dominant double-integrator dynamics as a quadratic control (DQC) problem, and can be summarized as Equation (8), whose result will yield optimal trajectories that are subsequently utilized to control the transport theorem terms.
The state is given by [θ, ω], the angle of rotation and angular velocity respectively. The value τ is the control torque applied, and I, the inertia of the system, J, the cost function, is the quadratic cost, computed by integrating the square of the applied torque. The quadratic cost represents the amount of work or energy needed to control the system and thus translates readily to quantities such as fuel used and real-world dollars. Note the simplification from Equation (7). In Equation (8), the acceleration should be . ω = τ/I − ω × I, however, the cross-coupling makes the boundary value problem tricky to solve. Instead, the trajectory of each Euler angle can be solved for individually, under the assumption disregarding the cross-coupling effects does not affect optimality. To do so, the inertia matrix must also be manipulated, as the off-axis products of inertia complicates things as well. Three methods were used and compared, one where the principal axes and principal moments of inertia were found and the Euler trajectories found in the principal frame and then converted to the body frame, one where the principal moments of inertia were used but the trajectories not converted from principal to body frame, i.e., of the form . ω 1 = τ 1 /I 1 , where the 1 subscript indicates the first Euler angle and the principal moment of inertia corresponding to the principal axis best aligned with the first body axis. Lastly, the off-axis products of inertia were simply ignored, and the body frame moments of inertia used in calculating the trajectories. These techniques result in independently solvable Euler angle trajectories.

Principles of Pontryagin: Optimal States, Rates, and Controls
Pontryagin's principle consists of forming a boundary value problem by first forming a Hamiltonian function from the given cost function and dynamics, secondly minimizing the Hamiltonian with respect to the states, thirdly taking the derivative of the Hamiltonian with respect to the states to solve for the derivatives of the co-vectors of the states, and if needed, using the transversality of the endpoint Lagrangian to solve for the final values of the co-states and generate enough boundary conditions to solve the boundary value problem.

H: Form the Hamiltoninan
where F, is the running cost function, in general the part of the cost function being continuously integrated, in Equation (8), 1/2τ 2 , λ is the costate vector, given by [λ θ λ ω ], one costate per state, and f(x, u) represents the dynamics of the system, .
x. In Equation (8) the state derivatives are f(x, u) = ω τ Minimize the Hamiltonian Pontryagin's principle states the optimal solution can be found by taking the derivative of the Hamiltonian with respect to the control and setting the result equal to zero. Applying the derivative to Equation (10) and setting it equal to zero results in which gives τ = −λ ω /I.

Adjoint Equation
The next step is to take the derivative of the Hamiltonian with respect to the states and set the result equal to the negative derivative of the co-states. Differentiating Equation (10) with respect to θ and ω results in Terminal Transversality of the Endpoint Lagrangian Conditions necessitating the use of terminal transversality of the endpoint Lagrangian are generally present when there are not enough boundary conditions to solve the boundary value problem formed in the previous steps. The method consists of forming a modified final cost function, E, from the final cost function, (in the problem of DQC, 0), plus the boundary conditions multiplied by unknown Lagrangians. The derivative of E, with respect to the endpoints x f , equals the final values of the co-states. Luckily, for this problem terminal transversality is not required as the boundary value problem can already be solved.

The Boundary Value Problem
The boundary value problem can now be summarized as Solving the problem gives an optimal solution for the state, rate, acceleration, and torque. Substituting the equation for λ ω into the equation for the torque and integrating twice to find the optimal state and rate trajectories, Finally, the final values are used to solve for the coefficients and the solution for the optimal state, rate, and torque is as follows where * denotes the optimal solution. These optimal solutions to the trajectory are plotted in Figure 3 for a 30-degree yaw maneuver.
where * denotes the optimal solution. These optimal solutions to the trajectory are plotted in Figure 3 for a 30-degree yaw maneuver.

Feedback Controllers
A summary of the utilized controllers will be given in Section 2.2 beginning with Section 2.2.1, a standard proportional plus derivative (PD) controller establishing a classical performance benchmark, followed by a proportional plus integral plus derivative (PID) controller. A proportional plus derivative plus integral (PDI) control is introduced next in Section 2.2.3 followed by an enhanced PDI in Section 2.2.4. Feedforward controllers are introduced in Section 2.3 beginning with classical, ideal feedforward control in Section 2.3.1 followed by adaptive feedforward control in Section 2.3.2.

Proportional, Derivative (PD)
Given the desired final conditions are a function of the angle θ and the angular velocity θ̇, which is being driven to zero, a proportional derivative or PD controller is a logical choice. The PD controller computes the input to the plant, or the control as where τ is the control torque composed of the feedback control, K d and K p are the derivative and proportional gains respectively, q and q̇ are the state and state derivative, q d and q ḋ are the desired state and state derivative and the tilde represents the tracking errors, the error between the state and the desired state.

Proportional, Integral, Derivative (PID)
Another classical control choice is the proportional integral derivative controller. The PD controller computes the input to the plant, or the control as where τ is the control torque, composed of the feedback control, K p , K I and K d , are the proportional, integral, and derivative gains respectively, q is the state, and q d q ḋ is the desired state.

Proportional, Derivative, Integral (PDI)
The proportional derivative integral controller differentiates itself from the PID controller by not differentiating the state to get the rate for calculation of the rate error. Instead, the PDI uses the rate from the state estimates directly. Eliminating the differentiation results in less noise in the error signal and smoother control. The PDI controller computes the input to the plant, or the control as displayed in Equation (19).

Feedback Controllers
A summary of the utilized controllers will be given in Section 2.2 beginning with Section 2.2.1, a standard proportional plus derivative (PD) controller establishing a classical performance benchmark, followed by a proportional plus integral plus derivative (PID) controller. A proportional plus derivative plus integral (PDI) control is introduced next in Section 2.2.3 followed by an enhanced PDI in Section 2.2.4. Feedforward controllers are introduced in Section 2.3 beginning with classical, ideal feedforward control in Section 2.3.1 followed by adaptive feedforward control in Section 2.3.2.

Proportional, Derivative (PD)
Given the desired final conditions are a function of the angle θ and the angular velocity . θ, which is being driven to zero, a proportional derivative or PD controller is a logical choice. The PD controller computes the input to the plant, or the control as where τ is the control torque composed of the feedback control, K d and K p are the derivative and proportional gains respectively, q and . q are the state and state derivative, q d and . q d are the desired state and state derivative and the tilde represents the tracking errors, the error between the state and the desired state.

Proportional, Integral, Derivative (PID)
Another classical control choice is the proportional integral derivative controller. The PD controller computes the input to the plant, or the control as where τ is the control torque, composed of the feedback control, K p , K I and K d , are the proportional, integral, and derivative gains respectively, q is the state, and q d . q d is the desired state.

Proportional, Derivative, Integral (PDI)
The proportional derivative integral controller differentiates itself from the PID controller by not differentiating the state to get the rate for calculation of the rate error. Instead, the PDI uses the rate from the state estimates directly. Eliminating the differentiation results in less noise in the error signal and smoother control. The PDI controller computes the input to the plant, or the control as displayed in Equation (19).

Enhanced PDI
Given the non-linearities imposed by the transport theorem cross product in the system dynamics, a proposed improvement is the addition of a cross product term in the feedback control to account for the coupled motion [13]. The Enhanced PDI controller then has the form displayed in Equation (20)

Feedforward Controllers
Feedback controllers are ubiquitously applicable to control systems from initial points to desired final points, utilizing a particular strength of feedback to imbue robustness. On the other hand, particularly when the goal is tracking a prescribed trajectory, tracking controllers are often of the feedforward nature lacking feedback, but instead emphasizing the analytic expressions of the controlled system dynamics and the prescribed desired trajectory. This section describes classical feedforward controllers first followed by nonlinear adaptive feedforward controllers (with a few disparate instantiations including various regression models and deterministic artificial intelligence).

Classical Feedforward Controller
Given the desired state, rate, and accelerations have been solved for, the feedforward control can be defined from an understanding of the system dynamics, and the feedforward control is displayed in Equation (21).
Where the subscript refers to the desired trajectory. The control is formed by plugging in the desired states, rates, and accelerations, into equations of motion in Equation (7), giving us the control that should produce the desired states, rates, and accelerations, given perfect system modeling.

Adaptive Feedforward Development
If the dynamics were exactly always known, given a desired state trajectory, an ideal control could always be formulated and commanded, as in Equation (21), to accomplish the desired maneuver. However, in practicality, determining the inertia dyadic perfectly is very difficult, at best a close estimate is made, resulting in imperfect feedforward control. To better estimate the system and the ideal control, a method of updating the system model based off feedback error is proposed. For inertia matrix [I], Coriolis matrix [C], and applied external torque τ, the equations of motion are where q is the state, and q d the desired state. In more common terms The goal is to break the feedforward torque command into a regression model of a product of a matrix of knowns, [Φ], times a vector of unknowns, {θ}. There are several choices available for the parameterization of {θ}, discussed in Section 2.3.3.
The adaptive aspect is an adaptation of the vector of unknowns, in response to error of the state with respect to the desired trajectory. The rate is defined in Equation (24).
where Γ > 0 and . q is the error in the state derivative with respect to the desired state derivative . q − . q d , as defined above. Equation (24) can be integrated starting from an initial estimate of Θ, to form a continuously learning, adaptive system.
Another choice is to form [Φ] using reference trajectories is in Equation (25): for λ > 0, at which point q d in Equation (23) would be replaced with q r . Reference trajectories serve to compensate for the error in trajectory by giving a "boost". For instance, if the state is lower than the desired state, to ensure the end conditions are still met, the state derivative should be slightly boosted, e.g., if the desired final state is five radians at time, t = 1, the desired state derivative a constant four radians per second, and rather than being at one radian, at time t=0 the state is at zero, then to arrive at the desired final state of five radians, the state derivative will need to be five radians per second assuming linear motion. The reference trajectory should in theory help ensure the final conditions are better met without the need for classical feedback control. Through formulation of a Lyapunov function [4] and Barbarat's lemma [6], control of the form of Equation (23) in conjunction with feedback control of the form of Equation (17), is proven stable, and the state error proven to tend to zero. The proof is omitted here for brevity but can be found in [6].

Regression Modeling 9-Parameter Regression
Parameter regression seeks to write the governing dynamics equations, Equations (2) and (3), as products of a matrix of knowns and a vector of unknowns. While the governing equations of motion are messy and nonlinear in the state, they are linear in terms of the inertia dyadic [I]. Noting the state is already known for control purposes, and the inertia dyadic is the most difficult to estimate, Equation (3) can be separated into a matrix of knowns as a function of the state, and a vector of unknowns, a function of the inertia dyadic and the angular momentum H. The presented 9-parameter regression model is derived in Slotine [4].

6-Parameter Regression
Recalling H = Iω, the nine-parameter model can be simplified to an equivalent six parameter model [6]:

Deterministic Artificial Intelligence
Deterministic Artificial Intelligence begins with the same regression modeling as Adaptive Control, which can be portrayed as a statement of self, as the model is learning the system dynamics that govern itself. However, the crucial difference is the optimal learning of DAI. DAI uses the standard solution to the batch least squares regression problem [14,16] whereΘ is estimated using feedback control, and the estimated states in Φ are provided by a Luenberger Observer. Equation (28) represents optimal learning of the state. Differentiating Equation (28) results in Equation (29).
which allows for the change inΘ to be estimated and then integrated to get a smoother estimation ofΘ. optimal learning expressed in Equations (28) and (29), with the declaration of self-awareness, learns the system parameters and can then be used to make an optimal feedforward control, u ff = ΦΘ.

Luenberger Observer
A Luenberger Observer is used to estimate the control observed to act on the system. Given errors in the estimation of the inertia matrix, the control commanded will not result in the state and rate expected. Therefore, the Luenberger Observer examines the actual state and rate outputted by the plant and uses them to estimate the control responsible for the system response given the estimate of the inertia matrix, resulting in a simulated observer estimation of the control torque. The Luenberger Observer is of the form where e is the error of the observed state. The torque can be extracted as And δu in Equation (29) is found by subtracting the result of Equation (31) from the commanded torque outputted by the chosen controller.

Simulation
A simulation was developed in MATLAB Simulink to examine the difference between feedback control, adaptive feedforward control and feedback plus adaptive feedforward control. A timestep of 0.001 s was used in combination with a fourth-ordered Runge-Kutta integration solver.

Comparison of Sinusoidal and Pontryagin Based Trajectory Generation
All the control methods presented in Section 2 were run, as well as all combinations of feedforward and feedback control techniques. Table 1 shows the system responses when a sinusoidal trajectory was used, and Table 2 shows when Pontryagin's method was used. For both tables a symmetric inertia matrix of [16.67 0 0; 0 16.67 0; 0 0 16.67], representing a small cube sat was used. Due to the symmetry, there were no complications due to cross-coupling.

Non-Symmetrical Inertia Matrix
The analysis in Section 3.1 was repeated with a non-symmetric inertia matrix of [90 10 10; 10 100 −20; 10 −20 250] with results displayed in Table 3. To eliminate the cross-coupling, the method of solving for the trajectory in the principal frame and then converting to the body frame was used.

Pontryagin Cross-Coupling Techniques
Noting the large spikes in cost in Table 4, the analysis of Table 4 was repeated, with Pontryagin trajectory solved by using the principal moments of inertia but not converting from the principal frame to the body and instead assuming the control could be taken to be the same in either frame. The results are in Table 5. Lastly the three techniques for eliminating the cross-coupling in Pontryagin generation of optimal trajectories were compared for several different maneuvers. The maneuvers consisted of [θ f , φ f , ψ f ] where the final desired value for each maneuver was specified. Note K P and K D had to be raised to 100,000 and 10,000 respectively, to eliminate ringing in the second and third maneuvers. DAI + PD was used as the controller; the results are displayed in Table 6.

Constant Trajectory Feedback Control
For comparison, feedback control with a constant trajectory consisting of the desired end-state, was simulated. A PD controller was used with the same gains as in the previous simulations, K P = 100, 000, K D = 1000. The non-symmetric inertial-dyadic presented in Section 3.2 was used. The system response is given in Figure 4. Roll is solid blue, pitch is thick dashed red, yaw is thin dashed yellow (b) Characteristics of the response. * Note, this run time was found to be much lower due to differences in available processing power and when compared to re-simulations of some of the above methods, found to be comparable.

Discussion
Looking at Table 1 and Table 2, note the addition of feedforward decreases the control effort by 0.8% on average. Additionally, the three feedforward techniques seem to perform equally well. Comparing Table 2 with Table 1, Pontryagin trajectory generation Roll is solid blue, pitch is thick dashed red, yaw is thin dashed yellow (b) Characteristics of the response. * Note, this run time was found to be much lower due to differences in available processing power and when compared to re-simulations of some of the above methods, found to be comparable.

Discussion
Looking at Tables 1 and 2, note the addition of feedforward decreases the control effort by 0.8% on average. Additionally, the three feedforward techniques seem to perform equally well. Comparing Table 2 with Table 1, Pontryagin trajectory generation lowers control cost by about 1-1.5%.
Looking at Tables 3 and 4, Pontryagin techniques with feedback incur a lot of control cost. Examining the control torques and trajectories in Figure 5, reveals the Pontryagin method of converting from the principal frame to the body, commands motion in all three axes (see Figure 5e) due to the cross-coupling. Comparing Figure 5e with Figure 5f,d reveals the sinusoidal does not command motion in all three axes.
Aerospace 2022, 9, x FOR PEER REVIEW 16 of 28 Looking at the tracking of the Euler angles in Figure 6, there is significant change in the non-slew directions. Once the slew is over, the error in commanding undesirable motion in the non-slew directions manifests itself in a spike of feedback control, making the control cost abnormally high. When Pontryagin is used without converting back into the body frame from the principal, essentially deriving a trajectory in the non-principal frame, undesirable motion in the non-slew directions was eliminated. In the formulation used in Figure 6 and by virtue of non-zero cross-products of inertia, principal axes were misaligned with the body axes, and while a seemingly fine idea, solving for the trajectory in the principal frame and then converting to the body frame introduces error. The misalignment causes undesired rotation in the body frame when the trajectory is converted, via cross-coupled terms in the inertia dyadic. Looking at the tracking of the Euler angles in Figure 6, there is significant change in the non-slew directions. Once the slew is over, the error in commanding undesirable motion in the non-slew directions manifests itself in a spike of feedback control, making the control cost abnormally high. When Pontryagin is used without converting back into the body frame from the principal, essentially deriving a trajectory in the non-principal frame, undesirable motion in the non-slew directions was eliminated. In the formulation used in Figure 6 and by virtue of non-zero cross-products of inertia, principal axes were misaligned with the body axes, and while a seemingly fine idea, solving for the trajectory in the principal frame and then converting to the body frame introduces error. The misalignment causes undesired rotation in the body frame when the trajectory is converted, via crosscoupled terms in the inertia dyadic. Table 5 proves not converting between principal and body frames fixes the error. Table 5 also demonstrates the flexibility of the control architecture, with low error independent of which axis was being rotated around. The disparity between principal moments of inertia and moments of inertia in the body frame, 81.5970, 105.326, 253.0783, compared with 90, 100, 250, is worth noting. Using the moments of inertia in the body frame to solve for the optimal trajectory in Pontryagin's method applied in the non-principal frame, was predicted to have a detrimental effect, as the control might not be scaled properly. However, Table 6 shows no difference between using principal or non-principal moments of inertia.  Table 5 proves not converting between principal and body frames fixes the error. Table 5 also demonstrates the flexibility of the control architecture, with low error independent of which axis was being rotated around. The disparity between principal moments of inertia and moments of inertia in the body frame, 81.5970, 105.326, 253.0783 ,compared with 90, 100, 250, is worth noting. Using the moments of inertia in the body frame to solve for the optimal trajectory in Pontryagin's method applied in the non-principal frame, was predicted to have a detrimental effect, as the control might not be scaled properly. However, Table 6 shows no difference between using principal or non-principal moments of inertia. Figure 4 shows the stark contrast between using a calculated trajectory and not. Comparing Figure 4b to the PD control in Table 5, note similar final errors in roll pitch and yaw channels, and five orders of magnitude worse control cost. In Table 7, the PD controller gains were raised revealing that use of a calculated trajectory results in better final state error as compared to control without a calculated trajectory. Additionally, in response to elevated gains, control cost rose by a factor of ten in the non-trajectory case (between Figure 4b and the second row of Table 7), however when using Pontryagin optimal trajectory, the control cost actually decreased in response to elevated gains, by 11.7% (comparing the third row of Table 5 and the first row of Table 7) while the error decreased by an order of magnitude in the roll and pitch channels, and seven orders of magnitude in the yaw channel. The use of a calculated trajectory is thus shown to allow for higher gains that result in significantly lower error, and lower control cost. Additionally, the plotted system response with no calculated trajectory in Figure 4a, shows significant overshoot and significant oscillatory motion as compared to using a calculated trajectory. Table 7. Comparison of PD control with and without Pontryagin Optimal Trajectory in non-principal frame with elevated gains of K P = 1,000,000 and K D = 10,000.   Figure 4 shows the stark contrast between using a calculated trajectory and not. Comparing Figure 4b to the PD control in Table 5, note similar final errors in roll pitch and yaw channels, and five orders of magnitude worse control cost. In Table 7, the PD controller gains were raised revealing that use of a calculated trajectory results in better final state error as compared to control without a calculated trajectory. Additionally, in response to elevated gains, control cost rose by a factor of ten in the non-trajectory case (between Figure 4b and the second row of Table 7), however when using Pontryagin optimal trajectory, the control cost actually decreased in response to elevated gains, by 11.7% (comparing the third row of Table 5 and the first row of Table 7) while the error decreased by an order of magnitude in the roll and pitch channels, and seven orders of magnitude in the yaw channel. The use of a calculated trajectory is thus shown to allow for higher gains that result in significantly lower error, and lower control cost. Additionally, the plotted system response with no calculated trajectory in Figure 4a, shows significant overshoot and significant oscillatory motion as compared to using a calculated trajectory. Table 7. Comparison of PD control with and without Pontryagin Optimal Trajectory in non-principal frame with elevated gains of K P = 1, 000, 000 and K D = 10, 000. As for a computational burden analysis, run time was recorded in each of the trials. Unfortunately, run-time was found to be dependent on the hardware the simulation was run on and how much of the CPU was available, resulting in an inability to compare run time across different tables. However, looking at each table individually, no run time different of more than 20% was observed, and no observable patterns found. With more detailed analysis it could be concluded whether any of the control methods used were more computationally demanding than the others, however for the purpose of this study, all control methods were deemed relatively similar in terms of computational burden.

Conclusions
Trajectory generation demonstrates significant decrease in control cost and attitude error as well as allowing for more versatile gain tuning. Pontryagin's method shows promise, lowering control cost slightly over Sinusoidal generation and lays the groundwork for more sophisticated autonomous trajectory generation, by modification of the Hamiltonian (Equations (9) and (10)), such as imposition of pointing restraints, not possible with the sinusoidal method. Proper understanding of cross-coupling dynamical effects proved crucial in the formulation of Pontryagin's method, however proving simple to deal with. Lower pointing errors make missions focused on objects further away, or requiring higher magnification and object resolution, possible, and lower control costs improve the efficiency of such missions, increasing viability.

Future Work
RTOC was not implemented and studied. RTOC inherently uses the trajectory solved for in Pontryagin's method and a comparison of RTOC to control using sinusoidal trajectory generation would be interesting. Additionally, the assumption to solve for each Euler angle trajectory separately using Pontryagin's method, inherently introduces some error. The amount of error in this formulation should be examined. A better approach would be to solve Pontryagin's method for the full coupled dynamics. While there do exist methods to do so, they lie outside of the scope of this work were not attempted.
Of note, results are possible with higher gains and modest increases in cost. However, the investigation of this work was not into achieving the lowest error possible.
The true power of Pontryagin's method lies in the ability to parameterize desired trajectories and solve for optimal solutions. For instance, during a slew a requirement might be specified declaring the spacecraft shall never point in a certain direction. With sinusoidal trajectory generation, there is no way to enforce a requirement on pointing restrictions without analysis of the sinusoidal trajectory and careful design of piecewise maneuvers around restrictions. However, Pontryagin's method allows for such specifications in the formation of the Hamiltonian. Pontryagin's method could significantly reduce control efforts of more complicated maneuvers with pointing restriction. Funding: This research received no external funding. The APC was funded by the corresponding author.
Institutional Review Board Statement: Not applicable.

Informed Consent Statement: Not applicable.
Data Availability Statement: Data may be made available by contacting the corresponding author.

Conflicts of Interest:
The authors declare no conflict of interest. Eigenvalue associated with exponential solution to ordinary differential equations ω Frequency of sinusoidal functions T Period of sinusoidal functions ∆t quiescent User-defined quiescent period (no motion should occur during the quiescent period) ∆t meanuever User-defined duration of maneuver (often established by time-optimization problems) φ

Appendix A
Phase angle of sinusoidal functions  Figure A1. Simulink Model Complete display of all SIMULINK systems and subsystems. Figure A2. Trajectory generation block model.     Also try lengethening simulation to compare more with improved hamiltonian control however this is not necessary for the report.