1 Introduction

Owing to the enormous funding requirements, satellite missions were only conducted by the economically most powerful countries of the world in the first few decades of the space era. However, as a consequence of the explosive technological development, small satellite missions with substantially lower funding requirement – for instance, nano-satellites including as CubeSats – became a viable alternative for traditional large-size and high-cost satellites, which made space an achievable goal also for countries/organizations with less financial resources. The last few decades brought along a lot of such missions with more and more scientific aims being targeted by them.

One of the technological difficulties that needs to be handled in connection with small satellite missions is the accurate determination of the satellite’s actual orientation, i.e. its attitude. While on large-size satellites this information is usually provided by costly, large-size star trackers, which determine the attitude based on the angular distribution of bright stars in their field of view, these systems do not fit the very restricted size and power budget criteria of nano-satellites. In our recent paper [7] we proposed a new, cost-efficient approach to this problem which is based on the utilization of thermal imaging infrasensors. For this purpose we chose the MLX90640 infrasensor of [10], which is a small-size, low-cost sensor having 32\(\times\)24 pixels and a relatively large, 110\(\times\)75 degree field of view. This coverage by a single sensor implies that six of these sensors, placed on the six sides of a cube, could cover the full sphere, see Fig. 4 of [7]. This technology might be suitable to even smaller satellites in similar missions like GRBAlpha [12]. As the spherical projection function of MLX90640 infrasensors (to be used for this purpose) is now known with an overall accuracy of \(\sim 40^\prime\) [7] we now turn to the next step and introduce a simulation model for testing the applicability of our attitude determination approach. As we outline in our recent paper [4], our method is based on a multiplicative extended Kalman filter that uses the information provided by the infrasensors (direction of the Sun and the nadir in the satellite’s coordinate frame), the GPS system (the location of the satellite in the Earth centered coordinate frame) and the MEMS gyroscopes (angular velocity of the satellite) carried by the satellite.

The layout of the paper is the following. In Section 2 we describe the simulation of the satellite dynamics and introduce the multiplicative extended Kalman filter method. We demonstrate our results in Section 3, and we summarize our conclusions in Section 4. A detailed description of the equations used for the Kalman filter can be found in Appendix 1.

2 Simulation model for testing the on-board attitude determination algorithm

The attitude determination algorithm we developed is aimed to run on-board and therefore it needs to be tested for the different situations possible during a space mission. For this purpose we built a simulation model where all parts of the attitude determination process can be tested independently and as a whole as well. The first part of the code simulates the dynamics of the Sun-Earth-satellite system while its second part determines the attitude of the satellite by applying a multiplicative extended Kalman filter to the simulated data provided by the first part of the code. The goal of this process is to see how the recovered attitudes compare to the ’real’ ones.

2.1 Simulation of the satellite dynamics

This part of the code calculates the position and the attitude of the satellite in the Earth centered J2000 reference system (where the X and Z axes point towards the former positions of the vernal equinox and the Earth’s rotation axis in January 1, 2000 at 12:00 TT, respectively) as well as the position of the Sun and the Earth in the satellite’s coordinate system (where the origin of the system is fixed to the center of mass of the cubesat and the axes are parallel to its edges, see Fig. 1). In the code time is expressed in Julian dates and the GPS to J2000 coordinate transformations are implemented as well. The code also determines the ‘night’ part of the orbit, i.e. where the Sun is occulted by the Earth.

Fig. 1
figure 1

The two main coordinate systems used in the simulations. Index i denotes the J2000 system with the Earth in the origin. The \(Z_i\) axis coincides with the rotation axis of the Earth in January 1, 2000 at 12:00 TT while the \(X_i\) axis points to the vernal equinox at the same epoch. The axes of the satellite’s coordinate frame are denoted by index s. The orbital parameters displayed in the figure are \(\Omega\) (longitude of ascending node), i (inclination), \(\omega\) (argument of periapsis) and \(\nu\) (true anomaly)

The orbit of a satellite can be characterized by five orbital elements (\(\Omega\), longitude of ascending node; i, inclination; \(\omega\), argument of periapsis; e, eccentricity; h, altitude of satellite orbit at perigeum; see Fig 1.) which remain constant when assuming a spherical Earth. The actual position of the satellite on this elliptical orbit is given via the true anomaly (\(\nu\)) which is obtained from the Kepler equation. However, the oblateness of the Earth introduces perturbations, from which the \(J_2\) perturbation has the largest magnitude, and therefore it has to be taken into account while simulating the satellite dynamics. The main effect of the \(J_2\) perturbation is on \(\Omega\) and \(\omega\). The time derivatives of these orbital elements are the following [8]:

$$\begin{aligned} \dot{\omega }=\frac{3}{4} n J_2 \left( \frac{R_e}{p} \right) ^2 (5\cos ^2 i -1 ) \end{aligned}$$
(1)
$$\begin{aligned} \dot{\Omega } = -\frac{3}{2} n J_2 \left( \frac{R_e}{p} \right) ^2 \cos i \end{aligned}$$
(2)

where \(R_e\) is the radius of the Earth, \(p=a(1-e^2)\), \(n=\sqrt{GM_e / a^3}\) and \(J_2 \simeq 1.082629 \cdot 10^{-3}\).

Next we discuss the description of the rotation of the satellite. As the variation of the gravitational field is negligible in the range of the satellite’s dimensions and we did not apply any kind of attitude control in our model, the net angular momentum transfer due to external torques is negligible during one orbit. We also assumed that the satellite frame coincides with the principal frame, however, in case it does not, an additional constant rotation needs to be taken into account between the two frames. The time evolution of the attitude then can be determined using Euler’s rotation equation, which describes the evolution of the angular velocity of a rotating rigid body represented in its principal frame (see e.g. [2]):

$$\begin{aligned} \frac{\mathrm {d}}{\mathrm {d}t}\begin{pmatrix} \omega _1 \\ \omega _2 \\ \omega _3 \end{pmatrix}= \begin{pmatrix} \dfrac{I_2-I_3}{I_1}\omega _2\omega _3 \\ \dfrac{I_3-I_1}{I_2}\omega _3\omega _1 \\ \dfrac{I_1-I_2}{I_3}\omega _1\omega _2 \end{pmatrix} . \end{aligned}$$
(3)

where \({\omega }\) is the angular velocity vector of the satellite represented in the principal frame (which coincides with the satellite frame), and \(I_1\), \(I_2\) and \(I_3\) are the moments of inertia corresponding to the x, y and z axes, respectively. Note that Eq. (3) could imply complex motions, such as tumblingFootnote 1, which we can readily reproduce within our model (see supplementary material).

The attitude can then be calculated by an additional integration over the angular velocities. In this work we use unit quaternions to represent the attitude of the satellite as \(\mathrm q^s=\lbrack\mathrm{nsin}(\gamma/2),\cos(\gamma/2)\rbrack^{\mathrm T}\), where \(\mathrm n\) is the axis of the rotation that transforms the J2000 coordinate frame to the satellite frame, \(\gamma\) is the rotation angle and the superscript \(\mathrm {T}\) denotes transposition (quantites represented in the satellite frame are denoted by the superscript ‘s’). The quaternion kinematics is given by the following equation (see e.g., [1, 3]):

$$\dot{\mathrm q}^s=\frac12\mathrm\Omega\left(\omega^s\right)\mathrm q^s,$$
(4)

with the \(4\times 4\) matrix

$$\begin{aligned} \Omega \left( {\omega }^s \right) = \begin{bmatrix} -\mathbf {S}({\omega }^s) &{} {\omega }^s \\ -({\omega }^s)^{\mathrm {T}} &{} 0 \end{bmatrix} , \end{aligned}$$
(5)

where \(\mathbf {S}({\omega }^s)\) is the matrix representation of the cross product (\({\omega }^s\times )\):

$$\begin{aligned} \mathbf {S}({\omega })= \begin{bmatrix} 0 &{} -\omega _3 &{} \omega _2 \\ \omega _3 &{} 0 &{} -\omega _1 \\ -\omega _2 &{} \omega _1 &{} 0 \end{bmatrix} . \end{aligned}$$
(6)

2.2 Attitude determination with Kalman filter

The Kalman filter is an algorithm that provides an efficient way to estimate the state of a dynamic system by a series of measurements with inaccuracies over time [6]. The estimates produced by the algorithm are more accurate than those based on a single measurement alone since the joint probability distribution of the variables is estimated for each discrete time-step of the process. This leads to the minimization of the mean of the squared error of the estimates.

The Kalman filter works in a two-step process with a prediction step (time update) and a measurement step. In the prediction step the filter propagates the estimates of state and uncertainties from current to the next time step. In the measurement step the state of the system is measured with some error and the estimate is updated by the weighted average of the estimate and the measurement, where the weights are determined by the respective uncertainties.

In our specific objective the Kalman filter serves to combine the infrasensor data with the angular velocity information provided by the MEMS gyroscopes. Although the 3 axis MEMS gyroscopes yield an accurate attitude information on a short time period, due to the error accumulation effect known as gyroscope drift an absolute attitude information is required as well, which is provided by the thermal imaging infrasensors in our case. In earlier works this kind of absolute attitude information was usually gathered by a 3-axis magnetometer and an optical Sun sensor (see e.g., [1, 5, 11, 14]). The use of infrasensors is more convenient in the sense that as opposed to magnetometers they can be built-in parts of the satellite and do not need an external boom to be mounted on. The infrasensors determine the direction of the Sun and the nadir in the satellite’s coordinate frame, which vectors are known in the Earth centered reference frame as well owing to the location information provided by the onboard GPS. The rotation that transforms the reference frame to the satellite frame (which is indeed equivalent to the attitude of the satellite) is unequivocally determined by the pair of these two vectors in the two coordinate frames. Hence we get a prediction of the system’s state from the gyroscope which can be corrected by the absolute attitude information provided by the infrasensors.

Since the quaternion kinematics, described by Eq. (4), is nonlinear in the variables \(\omega ^s\) and \(\mathrm q^s\) the utilization of an extended Kalman filter is necessary. We use the Multiplicative Extended Kalman Filter (MEKF) method [9], where a multiplicative error state \(\delta\mathrm q\) is introduced, which represents a small rotation from the predicted attitude – which contains measurement errors – to the actual attitude (from now on we omit superscripts, since everything is understood to be represented in the satellite frame, unless noted otherwise)Footnote 2:

$$\delta\mathrm q=\mathrm q\otimes\widehat{\mathrm q}^{-1},$$
(7)

where the circumflex ’\(^\wedge\)’ denotes the expected (or predicted) value of a quantity. With this multiplicative approach the conservation of the unit quaternion length is guaranteed and the problem of singular covariance matrices, encountered in the additive approach, is avoided as well.

To describe gyroscope measurements we use the model of [9], where in addition to a zero mean Gaussian error \({\eta _\omega }\) a time dependent bias vector \({\beta }\) is also introduced, the motion of which is determined by a random walk. Hence, the measured angular velocity \({\omega }_m\) is given by

$$\begin{aligned} {\omega }_m = {\omega } + {\beta } + {\eta _\omega } , \end{aligned}$$
(8)
$$\begin{aligned} \dot{{\beta }} = {\eta _\beta } , \end{aligned}$$
(9)

where the Gaussian processes \({\eta _\omega }\) and \({\eta _\beta }\) have covariance matrices \(\sigma _\omega ^2 \mathbf {I}_{3\times 3}\) and \(\sigma _\beta ^2 \mathbf {I}_{3\times 3}\), respectively. Therefore the estimated value of the angular momentum is

$$\begin{aligned} \hat{\omega } = {\omega }_m - \hat{{\beta }} . \end{aligned}$$
(10)

The state space model is then given by the equations:

$$\dot{\mathrm q}=\frac12\mathrm\Omega\left(\widehat\omega\right)\mathrm q,$$
(11)
$$\begin{aligned} \dot{{\beta }} = 0 . \end{aligned}$$
(12)

The predicted values of the angular momentum and bias vectors are updated through the Kalman filter using the position of the Sun and the nadir both as seen by the satellite and as calculated in the inertial frame. A vector in the inertial frame is transformed to the satellite frame by

$$\mathrm r^s=\mathrm A(\mathrm q^s)\mathrm r^i.$$
(13)

It can then be shown that a small multiplicative quaternion error \(\delta\mathrm q\) creates a small \(\delta\mathrm r^s\) deviation detemined by the following equation [3]:

$$\delta\mathrm r^s=2\mathrm S\left(\mathrm A\left(\widehat{\mathrm q}^s\right)\mathrm r^i\right)\delta{\mathrm q}_3,$$
(14)

where \(\delta{\mathrm q}_3\) is a three component vector containing the imaginary part of the multiplicative error state \(\delta\mathrm q\). This determines the so called sensitivity matrix, which is then used by the Kalman filter to calculate the multiplicative error state from the \(\delta\mathrm r^s\) quantities.

Since measurements are made at discrete time-steps, to implement these equations one must first discretize the kinematical equations. The Kalman filter then can be applied after each time-step to refine the attitude information predicted by the kinematical equations. The detailed discretized equations can be found in Appendix 1.

3 Simulation results

The applicability of our attitude determination approach is demonstrated by simulating a satellite on Low Earth Orbit (LEO) described by the following parameters:

  • \(\Omega = 0^\circ\), \(i = 60^\circ\), \(\omega = 0^\circ\), \(e = 0.01\), \(h = 650\) km,

  • \(I_1 = 2.75 \times 10^{-4}\) kg m\(^2\), \(I_2 = 2.75 \times 10^{-4}\) kg m\(^2\), \(I_2 = 5.5 \times 10^{-5}\) kg m\(^2\),

  • \(L_0 = [-4.4 \times 10^{-6},\ 1.925 \times 10^{-6},\ -6.05 \times 10^{-7}]\) kg m\(^2\)/s,

where \(L_0\) denotes the initial angular momentum of the satellite in the satellite frame. The chosen \(I_1\), \(I_2\) and \(I_3\) values correspond to a 3U CubeSat with a size of 10x10x30 cm and total mass of 3.3 kg. The initial attitude was selected randomly. Figure 2 shows how the position and the attitude of the satellite changes during 6 hours on such an orbit. The attitude is represented in the form of right ascension (\(\alpha\)), declination (\(\delta\)) and roll (\(\rho\)). The conversion rule between these angles and the quaternion representation of the attitude is given by the following formulas:

$$\begin{aligned} \begin{aligned} \alpha&= \arg (q_1 q_3 + q_2 q_4, q_2 q_3 - q_1 q_4) , \\ \delta&= \arg (q_4^2 + q_3^2 - q_2^2 - q_1^2, 2\sqrt{(q_1^2+q_2^2)(q_3^2+q_4^2)}) , \\ \rho&= \arg (q_1 q_3 - q_2 q_4, -q_2 q_3 - q_1 q_4) , \end{aligned} \end{aligned}$$
(15)

where \(\arg (x,y)\) gives the \(\varphi\) phase factor of the complex number \(x+iy=r\cdot e^{i\varphi }\). Note also that the domain of \(\delta\) is \([0^\circ ,90^\circ ]\), while it is \([0^\circ ,360^\circ )\) for \(\alpha\) and \(\rho\). In the figure shaded areas represent those parts of the orbit where the Sun is occulted by the Earth, i.e. where the number of measured vectors for the MEKF is reduced to one.

Fig. 2
figure 2

The orbit and rotation of the simulated satellite. Its position is described by its altitude, latitude and longitude (left) while its attitude is described by its right ascension (\(\alpha\)), declination (\(\delta\)) and roll (\(\rho\)) (right). For the different parameters that characterize the satellite’s motion we refer to the main text. Shaded areas represent those parts of the orbit where the Sun is occulted by the Earth

Since MEMS gyroscopes are available with various precision we investigated three different cases for attitude determination characterized by three different values for gyroscope drifts. For the largest error case we used \(\sigma _{\omega } = 4.89 \times 10^{-3}\) rad/s\(^{1/2}\) and \(\sigma _{\beta } = 3.14 \times 10^{-4}\) rad/s\(^{3/2}\) as proposed by [1], while for our standard and low-error case we used errors 0.1 and 0.3 times those of the high-error case, respectively. The initial parameters of the MEKF were chosen as follows:

  • \(\beta _0 = [0,0,0]\),

  • \(P_0 = \mathrm {diag}([0.25,0.25,0.25,0.01,0.01,0.01])\).

\(q_0\) was selected randomly and the standard deviation of the measured vectors had been set to 0.012 rad (\(\sim 40'\), in accordance with our previous result on the pointing accuracy of MLX90640 infrasensors) and had been added to the input vectors. Sensor data were sampled at 1 Hz.

Fig. 3
figure 3

The real (orange) and the MEKF recovered (green) attitude for the simulation shown in Fig. 2 for our standard choice of gyroscope error (left), and the error of the attitude determination, i.e. the difference between the real and the recovered attitude elements for the same orbital configuration (right). Shaded areas represent parts of the orbit where the Sun is occulted by the Earth

The recovery of the attitude on the orbit shown in Fig. 2 for our standard choice of gyroscope error is presented in Fig. 3. The left panels of Fig. 3 show that the attitude elements are well recovered when the MEKF works with two input vectors (’day’), i.e. when the infrasensors provide both the direction of the Sun and the Earth (the nadir), while the accuracy breaks down significantly when there is only one input vector (only the nadir direction) available for the MEKF (’night’). This behavior is not surprising, since we are lacking the minimum of two linearly independent vectors necessary to gain information about the absolute attitude of the satellite, and since the bias instability of MEMS gyroscopes is relatively high. The right panels of Fig. 3 show that the difference between the real and the recovered attitude elements may reach 25\(^{\circ }\) during the ’night’ phase in our standard case.

Fig. 4
figure 4

The y and z components of the quaternion error states, as well as the component corresponding to the rotation in the satellite’s orbital plane (left), and the errors of the attitude elements around a ‘night’ to ‘day’ transition (right)

Even though the accuracy of recovering the independent attitude parameters breaks down during ’night’, the errors are correlated even in this case due to the information gained from observing the horizon. This is shown in the left panel of Fig. 4, where we plot the y and z components of the quaternion error states (\(\delta q_y\) and \(\delta q_z\)). As the information about the horizon determines the orientation of the satellite with respect to the orbital plane, the error of the quaternion component that describes the rotation within this plane (\(\delta q_O\)) does not increase during the ’night’ periods. \(\delta q_O\) can be produced as a linear combination of \(\delta q_y\) and \(\delta q_z\) in our example. The right panel of Fig. 4 shows a short time period around a ’night’ to ’day’ transition and how the attitude information is immediately recovered once the Sun is visible again.

We also investigated the statistical behavior of the measurement errors. To do so we initialized our simulation with the same parameters except for the direction of angular momentum vector, which we picked randomly. By starting the simulation from several different initial conditions we collected statistical data about the first ‘day’ and ‘night’ phases.

Fig. 5
figure 5

Probability distributions of the right ascension’s measurement error, i.e. the difference between the real and the recovered values, during ’day’. The different panels show the cases with low (left), standard (middle), and the high (right) gyroscope error. The red curves represent Gaussian fits

Fig. 6
figure 6

Probability distributions of the right ascension’s measurement error during ‘night’. The left, middle and right columns correspond to the cases with low, standard and high gyroscope error, respectively, while the different rows represent different equal-length time segments with the top row being the first and the bottom row the last quarter of the ‘night’ phase

Figure 5 shows the distribution of the right ascension’s measurement error for the ’day’ case with different gyroscope precisions (the other two attitude parameters have similar error distributions). The results show that the recovery has a 1\(\sigma\) error of \(\sim 22'\) in our standard case, while this error is \(\sim 18'\) and \(\sim 32'\) in the low- and high-error cases, respectively. This is an improvement on the \(\sim 40'\) error of the MLX infrasensor’s point source detection accuracy [7], which shows the power of the MEKF method.

In Figure 6 we show the same errors for different parts of the ’night’ phase. We divided the ’night’ period to four equal-length segments to investigate the evolution of the errors and to avoid creating statistics from time periods with qualitatively different behavior. We see that the distribution of errors gets smeared as time progresses, and also with larger gyroscope errors. In the last segment of the high-error case the distribution is completely smeared so that not much information is retained about the real attitude. This is in accordance with the results of [1].

4 Summary

In the present paper we described a simulation model for testing our new concept aimed at determining the attitude of nano-satellites. The attitude was represented by unit quaternions and a MEKF approach was applied to estimate the most probable state (attitude) of the system. In our model the prediction step of the Kalman filter utilizes gyroscope measurements while its measurement step is based on infrasensor measurements and GPS location information which provide the direction of the Sun and the nadir in the satellite and in the J2000 reference frames, respectively.

The results of our simulations show that an attitude accuracy of \(~22'\) is achievable using combined measurements of the infrasensors and MEMS gyroscopes having a conservative drift. This is an improvement on the accuracy of point source detection with the MLX infrasensors [\(\sim 40'\), see 7]. This accuracy is gradually lost when the Sun is occulted by the Earth whereupon it can reach values of \(\sim 15-25^\circ\). The attitude information, however, is recovered within a short time once the Sun is observed again.

During the actual mission the satellites will not have infrasensors on all of their six sides and hence not being able to observe the Sun will be more regular. However, these time periods will be relatively short and the gyroscope drift is expected to be manageable during these intervals.

In this work we simulated a satellite on LEO with an inclination of \(60^\circ\). This is a reasonable choice for a particle detector experiment like a GRB detector because on this orbit the satellite evades high latitudes with increased noise contamination from the polar regions but is able to cover a large area of the sky. However, on such an orbit the illumination conditions may change substantially on the timescales of a few months due to the motion of the Earth around the Sun, as well as due to the orbital precession caused by \(J_2\). However, we consider our simulations to represent the average conditions on such an orbit sufficiently well.

The attitude determination method described in this paper is planned to be used in the CAMELOT mission where the attitude data will also serve as additional information for localizing gamma-ray bursts besides triangulation. An in-orbit demonstration of our experiment is planned to be scheduled for the end of 2022.