# Safety-Aware Optimal Attitude Pointing for Low-Thrust Satellites
## 2 Methods
### Trajectory Generation  
We determined the solution \(g(t)\in G\) of the left-invariant differential system (1) that satisfies the boundary conditions:  
\[R(0)=R_{0},\quad R(T_{f})=R_{F} \tag{9}\]  
while minimizing the expression:  
\[\mathcal{J}=\frac{1}{2}\int_{0}^{T_{f}}(c_{1}\omega_{1}^{2}+c_{2}\omega_{2}^{2} +c_{3}\omega_{3}^{2})dt. \tag{10}\]  
This cost \(\mathcal{J}\) in Equation (10) allows one to define a large class of trajectories where the weights of the cost function can be chosen to alter the shape of the path between two prescribed boundary configurations. A standard geometric control theory approach was used to generate these trajectories to minimize a cost \(\mathcal{J}\); for context, as for the nomenclature used in this section, the reader is directed to Appendix A, as well as any reader unfamiliar with geometric control theory. As stated in Appendix A, to determine the optimal trajectory minimizing the cost \(\mathcal{J}\), we required integrating the kinematic equations (Equation (1)) and the extremal equations (Equation (A2)) simultaneously in the real-time interval \([0,T_{f}]\). To do this, we used numerical integration in the following way: setting:  
\[P_{1}=M_{1},\ P_{2}=M_{2},\ P_{3}=M_{3} \tag{11}\]  
then by the PMP, the optimal values of the velocities are given by:  
\[\omega_{1}=P_{1}/c_{1},\quad\omega_{2}=P_{2}/c_{2},\quad\omega_{3}=P_{3}/c_{3} \tag{12}\]  
and for \(g\) in \(SO(3)\), the solution of the kinematic equation, we may assign:  
\[ \begin{bmatrix}P_{4}&P_{5}&P_{6}\\ P_{7}&P_{8}&P_{9}\\ P_{10}&P_{11}&P_{12}\end{bmatrix} = \begin{bmatrix}g_{11}&g_{12}&g_{12}\\ g_{21}&g_{22}&g_{23}\\ g_{31}&g_{32}&g_{33}\end{bmatrix} . \tag{13}\]  
Using the fact that from (1):  
\[\hat{R}=R(u_{1}A_{1}+u_{2}A_{2}+u_{3}A_{3}), \tag{14}\]  
(where \(R(t)\) denotes the desired trajectory), we may express the kinematic and extremal equations together in vector form:  
\[ \begin{array}{rcl}\frac{dP_{1}}{dt}&=&-P_{2}P_{3}/c_{2}+P_{2}P_{3}/c_{3}\\ \frac{dP_{2}}{dt}&=&P_{1}P_{3}/c_{1}-P_{1}P_{3}/c_{3}\\ \frac{dP_{3}}{dt}&=&-P_{1}P_{2}/c_{1}+P_{1}P_{2}/c_{2}\\ \frac{dP_{4}}{dt}&=&P_{4}\\ &\vdots\\ \frac{dP_{12}}{dt}&=&P_{12}.\end{array}  \tag{15}\]  
The initial value is given by:  
\[P_{0}=[\lambda_{0},R_{0}^{11},R_{0}^{12},\ldots,R_{0}^{33}]^{T} \tag{16}\]where \(R_{0}^{ij}\) are the \(i,j\) components of the matrix \(R_{0}\) in Equation (9), and \(\lambda_{0}=[p_{1}^{0},\ldots,p_{3}^{0},M_{1}^{0},\)\(\ldots,M_{3}^{0}]\), the unknown initial vector for the extremal equations. Integrating (15) starting from \(P_{0}\) with an initial guess for \(\lambda_{0}\) and rearranging the solution \(P_{7},\ldots,P_{22}\) using the function:  
\[\Phi:\mathbb{R}^{16}\to\mathbb{R}^{4\times 4},\quad\Phi([x_{1},x_{2},\ldots,x_{ 16}])= \begin{bmatrix}x_{1}&x_{4}&x_{7}\\ x_{2}&x_{5}&x_{8}\\ x_{3}&x_{6}&x_{9}\end{bmatrix}  \tag{17}\]  
we then obtained the \(\Phi([P_{4}(t),\ldots,P_{12}(t)])=R(t)\), the matrix that gives the optimal solution in the configuration space. Note: we are aware that for integrating Equation (1) developed on a matrix Lie group, symplectic integration is preferred over a numerical integration of (15). However, we calculated the deviation from the Lie group over the time interval \([0,T_{f}]\) used in the simulations presented in Section 2 by calculating the norm of the difference of \(R(t)R(t)^{T}\) and the identity matrix over the whole of the trajectory to determine if the structure of \(SO(3)\) was preserved. Figure 3 shows that the difference is of the order of magnitude of \(10^{-13}\), while Figures 4 and 5 also strongly suggest this result since the curves remain on the surface of the sphere throughout the maneuver. Figure 4: Correcting for a bright spot. The initial trajectories constructed between the points (**a**) in determining the pointing-constraint trajectory described by the parameters in Path 1 and the same trajectories after choosing the \(c_{i}\) values using reinforcement learning (**b**).