betaFeedback

WorksEngineering

Robust LEO Attitude Determination via Sun-Horizon Fusion Using Factor Graph Optimization

Abstract

Accurate attitude determination is essential for small satellites in Low Earth Orbit (LEO). A low-cost is to fuse gyroscope and Sun sensor measurements with the nadir direction measured from the Earth horizon by a visible-spectrum camera. However, the horizon in RGB images is degraded by atmospheric scattering, clouds, sun glare, and motion blur, so that the accuracy of the nadir measurement varies from image to image. Conventional image-based horizon sensors extract the horizon with fixed thresholds and edge detectors and assume a constant measurement noise, which assigns the same confidence to degraded and accurate measurements. This work presents an attitude determination framework in which a neural network not only detects the horizon but also predicts how accurately it is localized. A U-Net segments the Earth in the camera image, and an uncertainty head trained with a Gaussian negative log-likelihood loss predicts the standard deviation of the horizon location at each pixel. These per-pixel uncertainties weight the least-squares fit of the horizon cone and are propagated into the covariance of the measured nadir direction, so that each image provides a nadir measurement together with its own covariance and the attitude estimation becomes robust to degraded images. The horizon measurements are fused with the Sun sensor and gyroscope measurements in a sliding-window factor graph optimization, which estimates the attitude on SO(3) together with the gyroscope bias. Rather than using an conventional extended Kalman filter, Sliding Window Factor Graph Optimization is used to naturally incorporates sensors operating at different with varying updated measurement covariances.

Introduction

Attitude determination is a fundamental function of a spacecraft, since the pointing of its payloads, antennas, and solar arrays relies on the knowledge of its orientation [1]. Small satellites in Low Earth Orbit (LEO) typically determine their attitude by combining low-cost sensors, including Sun sensors [2, 3], magnetometers, gyroscopes, and Earth horizon sensors [4]. Since a single direction measurement constrains only two of the three rotational degrees of freedom, the attitude is determined from at least two non-collinear directions.

Earth horizon sensors measure the nadir direction by detecting the boundary between the Earth and space. Since the early days of spaceflight, they have mostly operated in the long-wave infrared [4, 5], where the Earth is bright during both sunlight and eclipse [6], and the carbon dioxide absorption band of the atmosphere yields a stable horizon profile [4]. On small satellites, static infrared thermopiles have been flown together with Sun sensors [3] and used to compute the nadir direction analytically [6]. Imaging sensors, in contrast, observe many horizon points, from which the nadir direction can be estimated directly [5, 7], and Deng et al. [8] applied such an approach to a wide field-of-view infrared camera with the same localization noise assumed for all horizon points. However, dedicated infrared sensors increase the cost and development time of a mission.

Visible-spectrum cameras, on the other hand, are inexpensive and offer higher resolution [5]. Saadat [9] repurposed a spacecraft inspection camera as a horizon sensor, and Braun and Barf [10], whose work is the closest to ours, fused camera-based nadir and Sun directions with inertial and GNSS measurements in an error-state Kalman filter. The main difficulty of visible-spectrum horizon sensing is that the atmosphere does not produce a sharp brightness discontinuity at the horizon, but scatters sunlight and creates an apparent unpredictable horizon thickness [5]. In addition, clouds, sun glare, and spacecraft structures in the field of view corrupt the detected horizon [9, 10], so that the accuracy of the measured nadir direction varies considerably from image to image. However, both approaches extract the horizon with fixed thresholds, and neither measurement model reflects the quality of the individual image.

In parallel, deep learning has improved both the extraction of information from images and the quantification of its uncertainty. Bayesian deep learning enables a network to predict the uncertainty of its outputs [11, 12], and such learned uncertainties have been shown to improve the robustness and accuracy of pose graph optimization in visual odometry [13]. For horizon detection onboard aircraft, deep semantic segmentation has recently shown higher robustness under clouds and glare [14], but it does not indicate when its prediction is unreliable.

For the fusion of attitude measurements, the extended Kalman filter (EKF) has long been the workhorse of spacecraft attitude estimation [15, 16]. Factor graph optimization (FGO), in contrast, jointly estimates the states within a time window and iteratively relinearizes the measurement models, which improves accuracy over the EKF and naturally accommodates asynchronous sensors [17, 18, 19].

Table 1 summarizes the horizon-based approaches most closely related to this work. To the best of our knowledge, no previous work learns the horizon localization uncertainty from the image and propagates it into the measurement covariance of an attitude estimator.

WorkSpectrumHorizon extractionHorizon measurement uncertaintyEstimation
Nguyen et al. [6]InfraredThermopile readingsNot modeledSingle epoch
Deng et al. [8]InfraredHorizon points in imageConstant pixel noiseSingle epoch
Saadat [9]VisibleFixed threshold, Canny edgesNot modeledSingle epoch
Braun and Barf [10]VisibleFixed threshold, contour tracingConstant pixel noiseError-state Kalman filter
Kapuscinski and Szczerba [14] (aircraft)VisibleDeep segmentationNot modeledSingle epoch
This workVisibleDeep segmentationLearned per-pixel uncertaintySliding-window FGO

Table 1. Comparison of horizon-based approaches related to this work.

To address this gap, this paper considers a small satellite in LEO equipped with a three-axis gyroscope, Sun sensors mounted on its faces, and a body-fixed RGB camera that observes the Earth horizon. The objective is to estimate the attitude and the gyroscope bias of the spacecraft from the asynchronous gyroscope, horizon, and Sun measurements while accounting for the image-dependent accuracy of the horizon measurements. The spacecraft position is assumed to be known, e.g., from a GNSS receiver, so that the reference nadir direction and, together with the solar ephemeris, the reference Sun direction are available in the Earth-fixed frame. Moreover, the Earth is modeled as a sphere, the camera is calibrated with a known mounting relative to the spacecraft body, and the spacecraft operates in sunlight with the illuminated horizon in the camera field of view, since neither the visible-spectrum camera nor the Sun sensors can operate in eclipse. Missions that require attitude determination during eclipse would need additional sensors, which are beyond the low-cost scope of this study.

The main contributions of this study are summarized as follows:

  • An uncertainty-aware horizon sensor for visible-spectrum cameras, in which a neural network detects the horizon and predicts its localization uncertainty at each pixel, and these uncertainties are propagated into the covariance of the measured nadir direction. Unlike the constant noise models in [8, 10], this covariance varies from image to image.

  • A sliding-window FGO that fuses the uncertainty-aware horizon measurements with Sun sensor and gyroscope measurements to estimate the attitude and the gyroscope bias, as an alternative to the EKF commonly used for spacecraft attitude estimation.

  • A publicly available dataset of real and synthetic RGB horizon images with manually labeled Earth regions.

The remainder of the paper is organized as follows. Section 2 introduces the notation, the attitude kinematics, and the fundamentals of FGO. Section 3 presents the horizon detection network, the uncertainty-aware nadir measurement, the Sun sensor model, and the sliding-window estimator. Section 4 describe the simulation environment and present results, and Section 5 concludes the paper.

Preliminaries

In this section, we establish the notation used throughout the paper and present the attitude kinematics, the sensor measurement models, and the fundamentals of factor graph optimization.

Notations

A rotation matrix Rαβ∈SO⁡(3)R_{\alpha}^{\beta} \in\operatorname{SO}(3) transforms vector coordinates from frame Fα\mathcal{F}_{\alpha} to frame Fβ\mathcal{F}_{\beta}, and qαβq_{\alpha}^{\beta} denotes the corresponding unit quaternion, i.e., Rαβ=R(qαβ)R_{\alpha}^{\beta}=R(q_{\alpha}^{\beta}). A vector vαβγ\boldsymbol{v}_{\alpha\beta}^{\gamma} denotes a quantity of frame Fβ\mathcal{F}_{\beta} with respect to frame Fα\mathcal{F}_{\alpha}, resolved in frame Fγ\mathcal{F}_{\gamma}. Direction vectors that are not associated with a pair of frames, such as the Sun and nadir directions, carry only the superscript of the resolving frame, e.g., sbs^{b}. The frames used in this work are: ii (Earth-Centered inertial frame aligned with the International Celestial Reference Frame, ICRF), ee (Earth-Centered Earth-Fixed, ECEF), bb (spacecraft body), and cc (camera, whose xx- and yy-axes point right and down in the image plane and whose zz-axis lies along the optical axis).

Scalars are denoted by italic letters, vectors by bold lowercase letters, and matrices by bold uppercase letters. A quantity evaluated at the discrete time instant tkt_k carries the subscript kk, and (˙)(\dot{}) denotes the time derivative. The accents (ˉ)(\bar{}), (^)(\hat{}), and (~)(\tilde{}) denote nominal, estimated, and measured quantities, respectively, while δ(⋅)\delta(\cdot) denotes an error quantity. The n×nn \times n identity matrix is denoted by InI_n. and the n×mn \times m zero matrix by 0n×m\mathbf{0}_{n\times m}, with 0n≜0n×n\mathbf{0}_n \triangleq\mathbf{0}_{n\times n}. The transpose is denoted by (⋅)⊤(\cdot)^\top and the Euclidean norm by ∥⋅∥\lVert\cdot\rVert. For a vector v∈R3\mathbf{v} \in\mathbb{R}^3, (v)i(\mathbf{v})_i denotes its ii-th component, where i∈{x,y,z}i \in\{x,y,z\}, and S2≜{u∈R3:∥u∥=1}\mathbb{S}^2 \triangleq\{\mathbf{u} \in\mathbb{R}^3 : \lVert\mathbf{u}\rVert= 1\} denotes the unit sphere.

The skew-symmetric matrix [a]×[\mathbf{a}]_\times is defined such that [a]×b=a×b[\mathbf{a}]_\times\mathbf{b} = \mathbf{a} \times\mathbf{b}. Quaternions are written with the scalar part first, and the operator ⊗\otimes denotes the Hamilton product of two quaternions. The exponential map Exp⁡:R3→SO⁡(3)\operatorname{Exp} : \mathbb{R}^3 \to\operatorname{SO}(3), Exp⁡(ϕ)=exp⁡([ϕ]×)\operatorname{Exp}(\boldsymbol{\phi}) = \exp([\boldsymbol{\phi}]_\times), converts a rotation vector ϕ\boldsymbol{\phi} into a rotation matrix, and Log⁡:SO⁡(3)→R3\operatorname{Log} : \operatorname{SO}(3) \to\mathbb{R}^3 denotes its inverse. Finally, N(μ,Σ)\mathcal{N}(\boldsymbol{\mu},\boldsymbol{\Sigma}) denotes a Gaussian distribution with mean μ\boldsymbol{\mu} and covariance Σ\boldsymbol{\Sigma}, and ∥r∥Σ2≜r⊤Σ−1r\lVert\mathbf{r}\rVert_{\boldsymbol{\Sigma}}^2 \triangleq\mathbf{r}^\top\boldsymbol{\Sigma}^{-1}\mathbf{r} denotes the squared Mahalanobis norm.

State Kinematics

The spacecraft attitude is parameterized by the body-to-ECEF rotation, denoted by q≜qbe\mathbf{q} \triangleq\mathbf{q}^e_b and R≜Rbe=R(q)\mathbf{R} \triangleq\mathbf{R}^e_b = \mathbf{R}(\mathbf{q}). The true-state kinematics are given by [20]

q˙=12q⊗[0ωebb],β˙=ηu,(1)\begin{aligned} \dot{\mathbf{q}} &= \frac{1}{2}\mathbf{q}\otimes\begin{bmatrix}0\\\boldsymbol{\omega}^b_{eb}\end{bmatrix},\\ \dot{\boldsymbol{\beta}} &= \boldsymbol{\eta}_u, \tag*{(1)} \end{aligned}

where the angular velocity ωebb\boldsymbol{\omega}^b_{eb} is the input to the motion model, obtained from the gyroscope measurement ω~ibb\widetilde{\boldsymbol{\omega}}^b_{ib} and the Earth rotation rate ωiee\boldsymbol{\omega}^e_{ie} as follows

ω~ibb=ωibb+β+ηv,ωebb=ωibb−R⊤ωiee=ω~ibb−β−ηv−R⊤ωiee.(2)\begin{aligned} \widetilde{\boldsymbol{\omega}}^b_{ib} &= \boldsymbol{\omega}^b_{ib}+\boldsymbol{\beta}+\boldsymbol{\eta}_v,\\ \boldsymbol{\omega}^b_{eb} &= \boldsymbol{\omega}^b_{ib}-\mathbf{R}^\top\boldsymbol{\omega}^e_{ie}\\ &= \widetilde{\boldsymbol{\omega}}^b_{ib}-\boldsymbol{\beta}-\boldsymbol{\eta}_v-\mathbf{R}^\top\boldsymbol{\omega}^e_{ie}. \tag*{(2)} \end{aligned}

where ωiee=[0 0 ωE]⊤\boldsymbol{\omega}^e_{ie} = [0\ 0\ \omega_E]^\top is the Earth rotation rate with ωE=7.292115×10−5 rad/s\omega_E = 7.292115 \times10^{-5}\,\mathrm{rad/s}, and β∈R3\boldsymbol{\beta} \in\mathbb{R}^3 is the gyroscope bias modeled as a random walk. The terms ηv\boldsymbol{\eta}_v and ηu\boldsymbol{\eta}_u are zero-mean Gaussian white noises with power spectral densities σv2I3\sigma_v^2\mathbf{I}_3 and σu2I3\sigma_u^2\mathbf{I}_3, corresponding to the angle random walk and the rate random walk of the gyroscope, respectively.

To construct a state estimator, the true state x=(q,β)\mathbf{x} = (\mathbf{q},\boldsymbol{\beta}) is decomposed into a nominal state xˉ=(qˉ,βˉ)\bar{\mathbf{x}} = (\bar{\mathbf{q}},\bar{\boldsymbol{\beta}}) and an error state δx\delta\mathbf{x} [20]. The nominal state results from the integration of the gyroscope readings and is given by

qˉ˙=12qˉ⊗[0ωˉebb],(3)\dot{\bar{\mathbf{q}}} = \frac{1}{2}\bar{\mathbf{q}}\otimes\begin{bmatrix}0\\\bar{\boldsymbol{\omega}}^b_{eb}\end{bmatrix}, \tag*{(3)}
βˉ˙=03×1,\dot{\bar{\boldsymbol{\beta}}} = \mathbf{0}_{3\times1},

where the nominal input is the bias-compensated angular velocity

ωˉebb=ω~ibb−βˉ−Rˉ⊤ωiee,(4)\bar{\boldsymbol{\omega}}^b_{eb} = \widetilde{\boldsymbol{\omega}}^b_{ib} - \bar{\boldsymbol{\beta}} - \bar{\mathbf{R}}^\top\boldsymbol{\omega}^e_{ie}, \tag*{(4)}

with Rˉ=R(qˉ)\bar{\mathbf{R}} = \mathbf{R}(\bar{\mathbf{q}}).

Meanwhile, the error-state vector is defined as

δx≜[δθ⊤δβ⊤]⊤∈R6,(5)\delta\mathbf{x} \triangleq\begin{bmatrix}\delta\boldsymbol{\theta}^\top& \delta\boldsymbol{\beta}^\top\end{bmatrix}^\top\in\mathbb{R}^6, \tag*{(5)}

where δθ\delta\boldsymbol{\theta} is the attitude error and δβ\delta\boldsymbol{\beta} is the gyroscope bias error. The composition x=xˉ⊕δx\mathbf{x} = \bar{\mathbf{x}} \oplus\delta\mathbf{x} is given by

R=RˉExp⁡(δθ),β=βˉ+δβ,(6)\begin{aligned} \mathbf{R} &= \bar{\mathbf{R}}\operatorname{Exp}(\delta\boldsymbol{\theta}),\\ \boldsymbol{\beta} &= \bar{\boldsymbol{\beta}}+\delta\boldsymbol{\beta}, \tag*{(6)} \end{aligned}

or equivalently q=qˉ⊗δq\mathbf{q} = \bar{\mathbf{q}}\otimes\delta\mathbf{q} with δq≈[1 12δθ⊤]⊤\delta\mathbf{q} \approx[1\ \frac{1}{2}\delta\boldsymbol{\theta}^\top]^\top. Substituting (6) into (1)–(2), comparing the result with (3)–(4), and retaining first-order terms, the error-state kinematics are obtained as [20]

δθ˙=−[ωˉebb]×δθ−δβ−ηv+h.o.t.,δβ˙=ηu,(7)\begin{aligned} \dot{\delta\boldsymbol{\theta}} &= -[\bar{\boldsymbol{\omega}}^b_{eb}]_\times\delta\boldsymbol{\theta}-\delta\boldsymbol{\beta}-\boldsymbol{\eta}_v+\text{h.o.t.},\\ \dot{\delta\boldsymbol{\beta}} &= \boldsymbol{\eta}_u, \tag*{(7)} \end{aligned}

where the higher-order terms (h.o.t.)(\text{h.o.t.}) are ignored. Moreover, the first-order term −[Rˉ⊤ωiee]×δθ-[\bar{\mathbf{R}}^\top\boldsymbol{\omega}^e_{ie}]_\times\delta\boldsymbol{\theta}, which stems from resolving the Earth rate in Fb\mathcal{F}_b with the perturbed attitude, is neglected since its magnitude scales with ωE\omega_E.

In matrix form, (7) is written as

δx˙=A(t)δx+Gη,(8)\dot{\delta\mathbf{x}} = \mathbf{A}(t)\delta\mathbf{x}+\mathbf{G}\boldsymbol{\eta}, \tag*{(8)}

where η≜[ηv⊤ ηu⊤]⊤\boldsymbol{\eta} \triangleq[\boldsymbol{\eta}_v^\top\ \boldsymbol{\eta}_u^\top]^\top, and

A(t)=[−[ωˉebb]×−I30303],G=[−I30303I3].(9)\mathbf{A}(t)=\begin{bmatrix}-[\bar{\boldsymbol{\omega}}^b_{eb}]_\times&-\mathbf{I}_3\\\mathbf{0}_3&\mathbf{0}_3\end{bmatrix},\qquad \mathbf{G}=\begin{bmatrix}-\mathbf{I}_3&\mathbf{0}_3\\\mathbf{0}_3&\mathbf{I}_3\end{bmatrix}. \tag*{(9)}

The nominal kinematics (3) and the error-state dynamics (8) are discretized in § 3.3 to form the gyroscope factor that connects consecutive states in the factor graph.

Factor Graph Optimization

A factor graph is a bipartite graph that represents the factorization of a probability density function, where variable nodes correspond to the unknown states and factor nodes correspond to the probabilistic constraints imposed on these states by measurements and prior information [21]. In this work, the variable nodes are the states xk=(qk,βk)\boldsymbol{x}_k = (\boldsymbol{q}_k, \boldsymbol{\beta}_k) at the discrete time instants tkt_k.

Let X\mathcal{X} denote the set of states and Z\mathcal{Z} the set of measurements. The maximum a posteriori (MAP) estimate of the states is

X^=arg max⁡X p(X∣Z)=arg max⁡X ∏jfj(Xj),(10)\hat{\mathcal{X}} = \underset{\mathcal{X}}{\operatorname{arg\,max}}\ p(\mathcal{X} \mid\mathcal{Z}) = \underset{\mathcal{X}}{\operatorname{arg\,max}}\ \prod_j f_j(\mathcal{X}_j), \tag*{(10)}

where each factor fjf_j depends only on a subset of states Xj⊆X\mathcal{X}_j \subseteq\mathcal{X}. Under the Gaussian noise assumption, each factor takes the form fj(Xj)∝exp⁡(−12∥rj(Xj)∥Σj2)f_j(\mathcal{X}_j) \propto\exp\left(-\frac{1}{2}\lVert\boldsymbol{r}_j(\mathcal{X}_j) \rVert^2_{\boldsymbol{\Sigma}_j}\right), where rj\boldsymbol{r}_j is the residual of the factor and Σj\boldsymbol{\Sigma}_j is its covariance. Taking the negative logarithm of (10), the MAP estimation reduces to the nonlinear least-squares problem

X^=arg min⁡X ∑j∥rj(Xj)∥Σj2.(11)\hat{\mathcal{X}} = \underset{\mathcal{X}}{\operatorname{arg\,min}}\ \sum_j \lVert\boldsymbol{r}_j(\mathcal{X}_j) \rVert^2_{\boldsymbol{\Sigma}_j}. \tag*{(11)}

Since the attitude evolves on SO⁡(3)\operatorname{SO}(3), (11) is solved over the error states rather than over the quaternions [22]. Each residual is linearized around the nominal states Xˉ\bar{\mathcal{X}} as

rj(Xˉj⊕δXj)≈rj(Xˉj)+JjδXj,(12)\boldsymbol{r}_j(\bar{\mathcal{X}}_j \oplus\delta\mathcal{X}_j) \approx\boldsymbol{r}_j(\bar{\mathcal{X}}_j) + \boldsymbol{J}_j \delta\mathcal{X}_j, \tag*{(12)}

where δXj\delta\mathcal{X}_j stacks the error states of Xj\mathcal{X}_j, the operator ⊕\oplus is applied to each state as in (6), and Jj=∂rj/∂δXj\boldsymbol{J}_j = \partial\boldsymbol{r}_j/\partial\delta\mathcal{X}_j is evaluated at δXj=0\delta\mathcal{X}_j = 0. Substituting (12) into (11) yields the Gauss–Newton normal equations

H δX∗=−g,(13)\boldsymbol{H}\,\delta\mathcal{X}^{*} = -\boldsymbol{g}, \tag*{(13)}

with

H=∑jJjTΣj−1Jj,g=∑jJjTΣj−1rj(Xˉj).(14)\begin{aligned} \boldsymbol{H} &= \sum_j \boldsymbol{J}_j^{\mathsf{T}}\boldsymbol{\Sigma}_j^{-1}\boldsymbol{J}_j,\\ \boldsymbol{g} &= \sum_j \boldsymbol{J}_j^{\mathsf{T}}\boldsymbol{\Sigma}_j^{-1}\boldsymbol{r}_j(\bar{\mathcal{X}}_j). \tag*{(14)} \end{aligned}

where each Jj\boldsymbol{J}_j is placed into the columns of the states it involves, and H\boldsymbol{H} is the information matrix. The solution δX∗\delta\mathcal{X}^{*} updates the nominal states as Xˉ←Xˉ⊕δX∗\bar{\mathcal{X}} \leftarrow\bar{\mathcal{X}} \oplus\delta\mathcal{X}^{*}, after which the error states are reset to zero, and the procedure is repeated until convergence.

Since the number of states grows over time, a sliding window that retains only the WW most recent states, Xk={xk−W+1,…,xk}\mathcal{X}_k = \{\boldsymbol{x}_{k-W+1}, \ldots, \boldsymbol{x}_k\}, is used to bound the computational cost [17, 23]. When a new state is added, the oldest state xm\boldsymbol{x}_m is marginalized rather than discarded, so that its information is retained. To this end, only the factors connected to xm\boldsymbol{x}_m are linearized, and the resulting normal equations are partitioned as

\begin{bmatrix} \boldsymbol{H}_{mm} & \boldsymbol{H}_{mr}\\ \boldsymbol{H}_{rm} & \boldsymbol{H}_{rr} \end{bmatrix} \begin{bmatrix} \delta\boldsymbol{x}_m\\ \delta\boldsymbol{x}_r \end{bmatrix} = -\begin{bmatrix} \boldsymbol{g}_m\\ \boldsymbol{g}_r \end{bmatrix}, \tag*{(15)}\end{bmatrix}

where the subscript rr denotes the remaining states connected to xm\boldsymbol{x}_m. Eliminating δxm\delta\boldsymbol{x}_m through the Schur complement gives

Hmarg=Hrr−HrmHmm−1Hmr,gmarg=gr−HrmHmm−1gm,(16)\begin{aligned} \boldsymbol{H}_{\mathrm{marg}} &= \boldsymbol{H}_{rr} - \boldsymbol{H}_{rm}\boldsymbol{H}_{mm}^{-1}\boldsymbol{H}_{mr},\\ \boldsymbol{g}_{\mathrm{marg}} &= \boldsymbol{g}_r - \boldsymbol{H}_{rm}\boldsymbol{H}_{mm}^{-1}\boldsymbol{g}_m, \tag*{(16)} \end{aligned}

which define a marginalization prior factor on the remaining states with the residual and covariance

rmarg=Xr⊖Xˉrlin+Hmarg−1gmarg,Σmarg=Hmarg−1,(17)\begin{aligned} \boldsymbol{r}_{\mathrm{marg}} &= \mathcal{X}_r \ominus\bar{\mathcal{X}}_r^{\mathrm{lin}} + \boldsymbol{H}_{\mathrm{marg}}^{-1}\boldsymbol{g}_{\mathrm{marg}},\\ \boldsymbol{\Sigma}_{\mathrm{marg}} &= \boldsymbol{H}_{\mathrm{marg}}^{-1}, \tag*{(17)} \end{aligned}

where Xˉrlin\bar{\mathcal{X}}_r^{\mathrm{lin}} denotes the nominal states at which the marginalization is performed, and ⊖\ominus is the inverse of ⊕\oplus, i.e., x⊖xˉ=[Log⁡(RˉTR)  (β−βˉ)T]T\boldsymbol{x} \ominus\bar{\boldsymbol{x}} = [\operatorname{Log}(\bar{\boldsymbol{R}}^{\mathsf{T}}\boldsymbol{R})\ \ (\boldsymbol{\beta} - \bar{\boldsymbol{\beta}})^{\mathsf{T}}]^{\mathsf{T}}. The factors connected to xm\boldsymbol{x}_m are then removed from the graph and replaced by this prior factor.

Methodology

The proposed framework consists of two stages, as illustrated in Figure 1. First, the horizon sensor in § 3.1 and the Sun sensor in § 3.2 provide the nadir and Sun directions in Fb\mathcal{F}_b, each with its own covariance. Then, the sliding-window FGO in § 3.3 fuses these measurements with the gyroscope measurements to estimate the attitude and the gyroscope bias.

Sliding-window factor graph for spacecraft attitude and gyroscope-bias estimation

Figure 1. Sliding-window factor graph for spacecraft attitude and gyroscope-bias estimation, showing the motion factors between consecutive states and the asynchronous Sun and horizon measurement factors.

Horizon Detector Neural Net

The horizon sensor provides the nadir direction in Fb\mathcal{F}_b and its covariance from a single RGB image. In this section, we first describe how the nadir direction is determined from horizon points in the image, then present the neural network that detects the horizon and predicts its localization uncertainty, and finally combine them into an uncertainty-aware nadir measurement.

Horizon-Based Nadir Determination

The horizon sensor determines the nadir direction from the apparent Earth limb in a camera image [5, 10]. Modeling the Earth as a sphere of radius RER_E, the lines of sight from the spacecraft that are tangent to the Earth form a right circular cone whose axis is the nadir direction, as illustrated in Figure 2, where OcO_c denotes the origin of Fc\mathcal{F}_c and OeO_e the center of the Earth. The half-angle ρ\rho of this cone satisfies sin⁡ρ=RE/∥pebe∥\sin\rho= R_E/\lVert\boldsymbol{p}^{e}_{eb}\rVert, where pebe\boldsymbol{p}^{e}_{eb} is the spacecraft position. Let uℓ∈R2\boldsymbol{u}_{\ell} \in\mathbb{R}^{2}, ℓ=1,…,N\ell= 1,\ldots,N, denote the pixel coordinates of the detected horizon points. For a pinhole camera with focal length ff and principal point c∈R2\boldsymbol{c} \in\mathbb{R}^{2}, both in pixels, the line of sight of the ℓ\ell-th horizon point resolved in Fc\mathcal{F}_c is

Geometry of horizon-based nadir determination

Figure 2. Geometry of horizon-based nadir determination. The camera-frame nadir direction nc\boldsymbol{n}^{c} points from the camera origin OcO_c toward the Earth center OeO_e, while ψℓ\boldsymbol{\psi}_{\ell} denotes the line-of-sight vector associated with the ℓ\ell-th detected horizon pixel. The collection of horizon lines of sight forms the apparent Earth-limb cone about nc\boldsymbol{n}^{c}.

ψℓ=[(uℓ−c)Tf]T.(18)\boldsymbol{\psi}_{\ell} = \begin{bmatrix}(\boldsymbol{u}_{\ell}-\boldsymbol{c})^{\mathsf{T}} & f\end{bmatrix}^{\mathsf{T}}. \tag*{(18)}

Since every line of sight lies on the horizon cone, the nadir direction nc\boldsymbol{n}^{c} satisfies

ψℓTnc=∥ψℓ∥cos⁡ρ,ℓ=1,…,N,(19)\boldsymbol{\psi}_{\ell}^{\mathsf{T}}\boldsymbol{n}^{c} = \lVert\boldsymbol{\psi}_{\ell}\rVert\cos\rho,\qquad\ell= 1,\ldots,N, \tag*{(19)}

which is linear in nc\boldsymbol{n}^{c} [7, 10]. Stacking (19) for all horizon points gives Mnc=d\boldsymbol{M}\boldsymbol{n}^{c}=\boldsymbol{d}, where M=[ψ1 ⋯ ψN]T\boldsymbol{M}=[\boldsymbol{\psi}_{1}\ \cdots\ \boldsymbol{\psi}_{N}]^{\mathsf{T}} and d=cos⁡ρ [∥ψ1∥ ⋯ ∥ψN∥]T\boldsymbol{d}=\cos\rho\,[\lVert\boldsymbol{\psi}_{1}\rVert\ \cdots\ \lVert\boldsymbol{\psi}_{N}\rVert]^{\mathsf{T}}, with the least-squares solution

nc=(MTM)−1MTd.(20)\boldsymbol{n}^{c}=(\boldsymbol{M}^{\mathsf{T}}\boldsymbol{M})^{-1}\boldsymbol{M}^{\mathsf{T}}\boldsymbol{d}. \tag*{(20)}

The direction of (20) does not depend on ρ\rho, since d\boldsymbol{d} scales linearly with cos⁡ρ\cos\rho. The measured nadir direction in Fb\mathcal{F}_b is then

n~b=Rcbnc∥nc∥,(21)\widetilde{\boldsymbol{n}}^{b}=\boldsymbol{R}^{b}_{c}\frac{\boldsymbol{n}^{c}}{\lVert\boldsymbol{n}^{c}\rVert}, \tag*{(21)}

where Rcb\boldsymbol{R}^{b}_{c} is the known camera mounting rotation relative to body frame.

Earth Segmentation Network

The accuracy of the nadir direction depends on how precisely the horizon points are localized, which is challenging in real imagery due to clouds, atmospheric glow, and illumination changes near the terminator. To this end, the horizon is extracted from an Earth/non-Earth segmentation predicted by a neural network. We adopt a U-Net

architecture [24] with a ResNet-34 encoder [25] pretrained on ImageNet. For each pixel u\mathbf{u} of an RGB image, the network outputs the probability pu∈[0,1]p_{\mathbf{u}} \in[0,1] that the pixel belongs to the Earth, and the predicted mask is obtained by thresholding pup_{\mathbf{u}} at 0.5. The network is trained with the loss

Lseg=12LBCE+12LDice,(22)\mathcal{L}_{\mathrm{seg}} = \frac{1}{2}\mathcal{L}_{\mathrm{BCE}} + \frac{1}{2}\mathcal{L}_{\mathrm{Dice}}, \tag*{(22)}

where the binary cross-entropy and Dice losses [26] are

LBCE=−1∣I∣∑u∈I[yulog⁡pu+(1−yu)log⁡(1−pu)],(23)\mathcal{L}_{\mathrm{BCE}} = -\frac{1}{|\mathcal{I}|}\sum_{\mathbf{u}\in\mathcal{I}}\left[y_{\mathbf{u}}\log p_{\mathbf{u}} + (1-y_{\mathbf{u}})\log(1-p_{\mathbf{u}})\right], \tag*{(23)}
LDice=1−2∑u∈Ipuyu∑u∈I(pu+yu),(24)\mathcal{L}_{\mathrm{Dice}} = 1 - \frac{2\sum_{\mathbf{u}\in\mathcal{I}}p_{\mathbf{u}}y_{\mathbf{u}}}{\sum_{\mathbf{u}\in\mathcal{I}}(p_{\mathbf{u}}+y_{\mathbf{u}})}, \tag*{(24)}

yu∈{0,1}y_{\mathbf{u}} \in\{0,1\} is the ground-truth label, and I\mathcal{I} is the set of pixels in a training batch. The cross-entropy term calibrates the per-pixel probabilities, whereas the Dice term measures the region overlap, which prevents the thin horizon boundary from being dominated by the large and easily classified interior regions.

The network is trained on a dataset of 550 RGB horizon images, consisting of 400 real images collected from publicly available sources on the internet and 150 synthetic images rendered in Unreal Engine 5 [27]. The real images cover diverse imaging conditions, such as clouds and spacecraft structures partially occluding the view. All images are manually labeled into Earth and non-Earth regions, which provide the ground-truth labels yuy_{\mathbf{u}}. The network is first trained on the real images and then fine-tuned on the synthetic images, mixed with real ones, to adapt it to the rendered camera images used in the simulations of § 4.1. The dataset is publicly available at https://doi.org/10.5281/zenodo.22756476.

10.5281/zenodo.22756476

Learned Horizon Uncertainty

The segmentation network provides the location of the horizon but not how accurately it is localized. Therefore, a lightweight convolutional head, fed by the final decoder features in parallel to the segmentation output, is trained to predict the per-pixel log-variance su=log⁡σu2s_{\mathbf{u}} = \log\sigma_{\mathbf{u}}^{2}, where σu\sigma_{\mathbf{u}} is the standard deviation of the horizon localization error in pixels. The regression target is obtained from signed distance maps. Let DupredD_{\mathbf{u}}^{\mathrm{pred}} and DugtD_{\mathbf{u}}^{\mathrm{gt}} denote the signed distances, in pixels, from pixel u\mathbf{u} to the boundaries of the predicted and ground-truth masks, respectively, with positive values inside the Earth region. The residual

eu=Dupred−Dugt(25)e_{\mathbf{u}} = D_{\mathbf{u}}^{\mathrm{pred}} - D_{\mathbf{u}}^{\mathrm{gt}} \tag*{(25)}

is the perpendicular offset between the predicted and true horizons, and it vanishes for a perfect prediction. The head is trained with the Gaussian negative log-likelihood loss [12, 13]

Lσ=1∣S∣∑u∈S[eu2exp⁡(−su)+su],(26)\mathcal{L}_{\sigma} = \frac{1}{|\mathcal{S}|}\sum_{\mathbf{u}\in\mathcal{S}}\left[e_{\mathbf{u}}^{2}\exp(-s_{\mathbf{u}}) + s_{\mathbf{u}}\right], \tag*{(26)}

where S={u∈I:∣Dupred∣≤τ, ∣eu∣≤emax⁡}\mathcal{S} = \{\mathbf{u} \in\mathcal{I} : |D_{\mathbf{u}}^{\mathrm{pred}}| \le\tau,\ |e_{\mathbf{u}}| \le e_{\max}\} contains the pixels within a distance τ\tau of the predicted horizon, excluding gross segmentation failures with ∣eu∣>emax⁡|e_{\mathbf{u}}| > e_{\max}. The supervision is applied around the predicted horizon rather than the ground-truth horizon, since the uncertainty is queried at the predicted horizon points during inference. Moreover, the segmentation network is frozen while the head is trained. Hence, eue_{\mathbf{u}} is a fixed target, which prevents the uncertainty from being inflated on difficult pixels instead of the prediction being improved, and the segmentation accuracy remains unchanged.

The head in (26) captures the aleatoric uncertainty of the horizon location. The epistemic uncertainty of the segmentation network can additionally be obtained by Monte Carlo (MC) dropout [11]. With dropout active in the decoder, NMCN_{\mathrm{MC}} stochastic forward passes produce the probability maps pu(t)p_{\mathbf{u}^{(t)}}, t=1,…,NMCt=1,\ldots,N_{\mathrm{MC}}. Linearizing the pu=0.5p_{\mathbf{u}}=0.5 level set, the resulting horizon displacement has the standard deviation σuepis=std⁡t(pu(t))/∥∇pˉu∥\sigma_{\mathbf{u}}^{\mathrm{epis}} = \operatorname{std}_{t}(p_{\mathbf{u}}^{(t)})/\lVert\nabla\bar{p}_{\mathbf{u}}\rVert, where std⁡t(⋅)\operatorname{std}_{t}(\cdot) is the sample standard deviation over the passes and pˉu\bar{p}_{\mathbf{u}} is the mean probability, and the total uncertainty becomes σu2+(σuepis)2\sigma_{\mathbf{u}}^{2}+(\sigma_{\mathbf{u}}^{\mathrm{epis}})^{2}. In this work, a single forward pass (NMC=1N_{\mathrm{MC}}=1) is used for computational efficiency, for which σuepis=0\sigma_{\mathbf{u}}^{\mathrm{epis}}=0.

Figure 3 shows the horizon and its uncertainty predicted by the network on a real Earth-limb image. The predicted uncertainty remains low along the unobstructed horizon, whereas it increases where the robotic arms and the solar array of the spacecraft occlude the limb and the predicted horizon becomes unreliable.

Horizon segmentation and its predicted uncertainty on a real Earth-limb image

Figure 3. Horizon segmentation and its predicted uncertainty on a real Earth-limb image. (a) Raw RGB image. (b) Horizon predicted by the NN, overlaid with the pixel-wise uncertainty σ\sigma (in pixels) in a narrow band around it. Horizon pixel colors range from white (low σ\sigma, high confidence) to dark red (high σ\sigma, low confidence).

Uncertainty-Aware Nadir Measurement

At inference, the horizon points {uℓ}ℓ=1N\{\mathbf{u}_{\ell}\}_{\ell=1}^{N} are extracted from the predicted mask by tracing the boundary of the Earth region connected to the image border, splitting it at the image border, and selecting the resulting arc whose outer side is the darkest, i.e., deep space. The predicted standard deviation at each horizon point, σℓ≜σuℓ\sigma_{\ell} \triangleq\sigma_{\mathbf{u}_{\ell}}, is then read from the uncertainty map.

The least-squares solution (20) weights all horizon points equally. Instead, the predicted uncertainties are used to weight them. Let ϵℓ=ψℓTnc−∥ψℓ∥cos⁡ρ\epsilon_{\ell} = \psi_{\ell}^{T}\mathbf{n}^{c} - \lVert\psi_{\ell}\rVert\cos\rho denote the residual of (19). A localization error δuℓ\delta\mathbf{u}_{\ell} of the ℓ\ell-th horizon point perturbs this residual to first order as δϵℓ=hℓTδuℓ\delta\epsilon_{\ell} = \mathbf{h}_{\ell}^{\mathsf{T}}\delta\mathbf{u}_{\ell}, with

hℓ=∂ϵℓ∂uℓ=[(nc)x(nc)y]=cos⁡ρ∥ψℓ∥(uℓ−c).(27)\mathbf{h}_{\ell} = \frac{\partial\epsilon_{\ell}}{\partial\mathbf{u}_{\ell}} = \begin{bmatrix}(\mathbf{n}^{c})_{x} \\ (\mathbf{n}^{c})_{y}\end{bmatrix} = \frac{\cos\rho}{\lVert\boldsymbol{\psi}_{\ell}\rVert}(\mathbf{u}_{\ell}-\mathbf{c}). \tag*{(27)}

Since hℓ\mathbf{h}_{\ell} is normal to the projected horizon curve, only the component of δuℓ\delta\mathbf{u}_{\ell} perpendicular to the horizon affects ϵℓ\epsilon_{\ell}, which is precisely the localization error whose standard deviation σℓ\sigma_{\ell} is predicted by the network. Assuming independent errors among the horizon points, the covariance of the residuals is Σϵ=diag⁡(σ12∥h1∥2,…,σN2∥hN∥2)\boldsymbol{\Sigma}_{\epsilon} = \operatorname{diag}(\sigma_{1}^{2}\lVert\mathbf{h}_{1}\rVert^{2},\ldots,\sigma_{N}^{2}\lVert\mathbf{h}_{N}\rVert^{2}), and the weighted least-squares solution and its covariance are

nc=(MTΣϵ−1M)−1MTΣϵ−1d,\mathbf{n}^{c} = \left(\mathbf{M}^{\mathsf{T}}\boldsymbol{\Sigma}_{\epsilon}^{-1}\mathbf{M}\right)^{-1}\mathbf{M}^{\mathsf{T}}\boldsymbol{\Sigma}_{\epsilon}^{-1}\mathbf{d},
Σnc=(MTΣϵ−1M)−1.(28)\boldsymbol{\Sigma}_{n}^{c} = \left(\mathbf{M}^{\mathsf{T}}\boldsymbol{\Sigma}_{\epsilon}^{-1}\mathbf{M}\right)^{-1}. \tag*{(28)}

Since hℓ\mathbf{h}_{\ell} depends on nc\mathbf{n}^{c}, (28) is solved iteratively, starting from (20). As a result, horizon points with large predicted uncertainty contribute less to the nadir estimate, and Σnc\boldsymbol{\Sigma}_{n}^{c} grows when the visible horizon arc is short or nearly straight, i.e., when MTΣϵ−1M\mathbf{M}^{\mathsf{T}}\boldsymbol{\Sigma}_{\epsilon}^{-1}\mathbf{M} becomes ill-conditioned.

The measured nadir direction is expressed in Fb\mathcal{F}_{b} by (21), and its covariance by Σnb=RcbΣnc(Rcb)T\boldsymbol{\Sigma}_{n}^{b} = \mathbf{R}_{c}^{b}\boldsymbol{\Sigma}_{n}^{c}(\mathbf{R}_{c}^{b})^{\mathsf{T}}. Since n~b∈S2\tilde{\mathbf{n}}^{b} \in\mathbb{S}^{2} has only two degrees of freedom, the component of Σnb\boldsymbol{\Sigma}_{n}^{b} along the nadir direction represents a scale uncertainty rather than an angular error. The covariance used in the FGO is therefore obtained by projecting Σnb\boldsymbol{\Sigma}_{n}^{b} onto the tangent plane of S2\mathbb{S}^{2} at the nadir direction,

Σh=TTΣnbT∈R2×2,(29)\boldsymbol{\Sigma}_{h} = \mathbf{T}^{\mathsf{T}}\boldsymbol{\Sigma}_{n}^{b}\mathbf{T} \in\mathbb{R}^{2 \times2}, \tag*{(29)}

where T=[t1 t2]∈R3×2\mathbf{T} = [\mathbf{t}_{1}\ \mathbf{t}_{2}] \in\mathbb{R}^{3 \times2}, with TTT=I2\mathbf{T}^{\mathsf{T}}\mathbf{T} = \mathbf{I}_{2}, is the orthonormal tangent-plane basis that is also used to form the horizon factor residual in § 3.3. Consequently, Σh\boldsymbol{\Sigma}_{h} varies from frame to frame with the predicted uncertainties and the visible horizon geometry.

Sun Sensor

The spacecraft carries one coarse Sun sensor head on each of its six faces, so that the Sun is observed from any attitude. Each head consists of Nd=12N_{d} = 12 photodiodes arranged on a polyhedral surface, whose design and angular response calibration are adopted from [28] and are not repeated here. The diode normals nkb\mathbf{n}_{k}^{b}, k=1,…,6Ndk = 1,\ldots,6N_{d}, are known in Fb\mathcal{F}_{b} from the mounting rotations of the heads.

Let sb∈S2\mathbf{s}^{b} \in\mathbb{S}^{2} denote the true Sun direction in Fb\mathcal{F}_{b} and αk=arccos⁡((nkb)Tsb)\alpha_{k} = \arccos((\mathbf{n}_{k}^{b})^{\mathsf{T}}\mathbf{s}^{b}) the incidence angle of the kk-th diode. Its normalized output follows the angular response g(α)=max⁡(cos⁡α,0)g(\alpha) = \max(\cos\alpha,0) and is corrupted by an angular error νk∼N(0,σα2)\nu_{k} \sim\mathcal{N}(0,\sigma_{\alpha}^{2}), which lumps the mounting misalignment and the albedo-induced distortion of the incidence angle, and by a readout error εk∼N(0,σy2)\varepsilon_{k} \sim\mathcal{N}(0,\sigma_{y}^{2}) of the digitized diode current,

y~k=g(αk+νk)+εk.(30)\tilde{y}_{k} = g(\alpha_{k}+\nu_{k})+\varepsilon_{k}. \tag*{(30)}

A diode is declared lit and retained when its measured incidence angle α~k=g−1(y~k)\tilde{\alpha}_{k}=g^{-1}(\tilde{y}_{k}) lies within the reliable half-cone αmax⁡\alpha_{\max} of the head, which discards the grazing readings where the response is flat and the albedo contamination is strongest.

The quantity that is linear in the Sun direction is not the diode output but its cosine, since cos⁡αk=(nkb)Tsb\cos\alpha_k = (\mathbf{n}_k^b)^{\mathsf{T}}\mathbf{s}^b. Inverting the response of each lit diode therefore gives a linear observation c~k=cos⁡α~k\tilde{c}_k = \cos\tilde{\alpha}_k, whose variance follows from propagating the two error terms of (30) to first order,

σc,k2=(sin⁡α~kσα)2+σy2,(31)\sigma_{c,k}^{2} = \left(\sin\tilde{\alpha}_k \sigma_{\alpha}\right)^2 + \sigma_y^2, \tag*{(31)}

where the angular term vanishes at normal incidence, so that the readout term prevents an unbounded weight there. Stacking the lit diodes into N=[n1b ⋯ ]TN = [\mathbf{n}_1^b \ \cdots]^{\mathsf{T}} and c~\tilde{\mathbf{c}}, and weighting them by W=diag⁡(σc,k−2)W = \operatorname{diag}(\sigma_{c,k}^{-2}), the Sun direction and its covariance follow from a single weighted least-squares solve,

vb=(NTWN)−1NTWc~,\mathbf{v}^b = (N^{\mathsf{T}}WN)^{-1}N^{\mathsf{T}}W\tilde{\mathbf{c}},
Σvb=(NTWN)−1.(32)\Sigma_v^b = (N^{\mathsf{T}}WN)^{-1}. \tag*{(32)}

All heads observe the same Sun direction, so (32) pools every lit diode regardless of its face, instead of solving each head separately and averaging the resulting unit vectors as in common coarse Sun sensor implementations, which discards the cross-head geometry and the per-diode weights. A sample is accepted only when at least three diodes are lit and NTWNN^{\mathsf{T}}WN is well conditioned, since two lit diodes admit two mirrored solutions and nearly coplanar diode normals leave the out-of-plane component unobservable.

As in Section 3.1.4, the measured Sun direction is obtained by normalizing (32),

s~b=vb∥vb∥,(33)\tilde{\mathbf{s}}^b = \frac{\mathbf{v}^b}{\lVert\mathbf{v}^b\rVert}, \tag*{(33)}

and its covariance is propagated through the normalization and projected onto the tangent plane of S2\mathbb{S}^2,

Σs=1∥vb∥2TsTPΣvbPTTs∈R2×2,(34)\Sigma_s = \frac{1}{\lVert\mathbf{v}^b\rVert^2}T_s^{\mathsf{T}}P\Sigma_v^bP^{\mathsf{T}}T_s \in\mathbb{R}^{2\times2}, \tag*{(34)}

with P=I3−s~b(s~b)TP = I_3 - \tilde{\mathbf{s}}^b(\tilde{\mathbf{s}}^b)^{\mathsf{T}} and Ts∈R3×2T_s \in\mathbb{R}^{3\times2} the orthonormal tangent-plane basis of the Sun factor residual in Section 3.3.3. The removed radial component is an illumination-scale uncertainty that carries no directional information.

State Estimation Factor Graph Optimization

The attitude and the gyroscope bias are estimated using the sliding-window FGO introduced in Section 2.3. The states are defined at node times tkt_k, which are created at a lower rate than the gyroscope sampling rate, so that a window of WW states spans a time interval long enough to contain horizon and Sun measurements. The set of states within the window at time tkt_k is

Xk={xk−W+1,…,xk},xj=(qj,βj).(35)\mathcal{X}_k = \{\mathbf{x}_{k-W+1}, \ldots, \mathbf{x}_k\}, \qquad\mathbf{x}_j = (\mathbf{q}_j,\boldsymbol{\beta}_j). \tag*{(35)}

The structure of the factor graph is shown in Figure 1. Consecutive states are connected by gyroscope factors, whereas horizon and Sun factors are attached to the states that correspond to the time stamps of the measurements, and the information of the marginalized states is retained by the prior factor (17). Accordingly, the states within the window are estimated by solving

X^k=arg⁡min⁡Xk{∥rp∥Σp2+∑j=k−W+1k−1∥rg,j∥Σg,j2+∑j∈Kh∥rh,j∥Σh,j2+∑j∈Ks∥rs,j∥Σs,j2},(36)\hat{\mathcal{X}}_k = \underset{\mathcal{X}_k}{\arg\min}\left\{\lVert\mathbf{r}_p\rVert_{\Sigma_p}^2 + \sum_{j=k-W+1}^{k-1}\lVert\mathbf{r}_{g,j}\rVert_{\Sigma_{g,j}}^2 + \sum_{j\in\mathcal{K}_h}\lVert\mathbf{r}_{h,j}\rVert_{\Sigma_{h,j}}^2 + \sum_{j\in\mathcal{K}_s}\lVert\mathbf{r}_{s,j}\rVert_{\Sigma_{s,j}}^2\right\}, \tag*{(36)}

where rg,j\mathbf{r}_{g,j}, rh,j\mathbf{r}_{h,j}, and rs,j\mathbf{r}_{s,j} are the residuals of the gyroscope, horizon, and Sun factors with covariances QjQ_j, Σh,j\Sigma_{h,j}, and Σs,j\Sigma_{s,j}, respectively, and Kh\mathcal{K}_h and Ks\mathcal{K}_s are the sets of state indices in the window with horizon and Sun measurements. The prior residual rp\mathbf{r}_p is given by the initial prior x0⊖xinit\mathbf{x}_0 \ominus\mathbf{x}_{\mathrm{init}} with covariance Σ0\Sigma_0 until the first state is marginalized, and by the marginalization prior (17) afterwards.

Whenever a new node is created, its nominal state is predicted by integrating the gyroscope measurements through (3), the oldest state is marginalized if the window is full, and the new factors are added to the graph. Then, (36) is solved by the Gauss–Newton iterations in (13), and the newest state x^k\hat{\mathbf{x}}_k provides the attitude estimate at tkt_k.

Gyroscope Factor

The gyroscope factor constrains two consecutive states xk\mathbf{x}_k and xk+1\mathbf{x}_{k+1}, separated by Δt=tk+1−tk\Delta t = t_{k+1}-t_k, through the attitude kinematics. Let ω~k\tilde{\boldsymbol{\omega}}_k denote the mean of the gyroscope measurements over [tk,tk+1)[t_k,t_{k+1}). Assuming a constant angular velocity over Δt\Delta t, the discretization of (3)–(4) yields the relative rotation

ΔR~k(βk)=Exp⁡((ω~k−βk−RˉkTωiei)Δt).(37)\Delta\tilde{R}_k(\boldsymbol{\beta}_k) = \operatorname{Exp}\left((\tilde{\boldsymbol{\omega}}_k-\boldsymbol{\beta}_k-\bar{R}_k^{\mathsf{T}}\boldsymbol{\omega}_{ie}^i)\Delta t\right). \tag*{(37)}

The residual of the gyroscope factor is defined as

rg,k=[Log⁡(Rk+1TRkΔR~k(βk))βk−βk+1]∈R6,(38)\mathbf{r}_{g,k} = \begin{bmatrix} \operatorname{Log}\left(R_{k+1}^{\mathsf{T}}R_k\Delta\tilde{R}_k(\boldsymbol{\beta}_k)\right)\\ \boldsymbol{\beta}_k-\boldsymbol{\beta}_{k+1} \end{bmatrix} \in\mathbb{R}^{6}, \tag*{(38)}

where the first component is the rotation between the attitude propagated from xk\mathbf{x}_k and the attitude of xk+1\mathbf{x}_{k+1}, and the second component enforces the random-walk model of the bias. Perturbing (38) with (6), the Jacobians with respect to to the error states are obtained to first order as

∂rg,k∂δxk=[ΔRkT−Δt I303I3],∂rg,k∂δxk+1=−I6,(39)\begin{aligned} \frac{\partial\mathbf{r}_{g,k}}{\partial\delta\mathbf{x}_k} &= \begin{bmatrix} \Delta\mathbf{R}_k^{\mathsf{T}} & -\Delta t\,\mathbf{I}_3 \\ \mathbf{0}_3 & \mathbf{I}_3 \end{bmatrix},\\ \frac{\partial\mathbf{r}_{g,k}}{\partial\delta\mathbf{x}_{k+1}} &= -\mathbf{I}_6, \tag*{(39)} \end{aligned}

where ∂rg,k/∂δxk\partial\mathbf{r}_{g,k}/\partial\delta\mathbf{x}_k coincides, to first order, with the state transition matrix of (8) over Δt\Delta t. The covariance of the residual follows from the discretization of the process noise in (8) [20]

Qk=[QθθQθβQθβQββ],(40)\mathbf{Q}_k = \begin{bmatrix} \mathbf{Q}_{\theta\theta} & \mathbf{Q}_{\theta\beta} \\ \mathbf{Q}_{\theta\beta} & \mathbf{Q}_{\beta\beta} \end{bmatrix}, \tag*{(40)}

with Qθθ=(σv2Δt+13σu2Δt3)I3\mathbf{Q}_{\theta\theta} = \left(\sigma_v^2\Delta t + \frac{1}{3}\sigma_u^2\Delta t^3\right)\mathbf{I}_3, Qθβ=−12σu2Δt2I3\mathbf{Q}_{\theta\beta} = -\frac{1}{2}\sigma_u^2\Delta t^2\mathbf{I}_3, and Qββ=σu2ΔtI3\mathbf{Q}_{\beta\beta} = \sigma_u^2\Delta t\mathbf{I}_3.

Horizon Factor

The horizon factor relates the measured nadir direction n~kb\tilde{\mathbf{n}}_k^b in (21) to the attitude of the state xk\mathbf{x}_k. Assuming that the spacecraft position is known, the reference nadir direction in Fe\mathcal{F}_e is

nke=−pebe(tk)∥pebe(tk)∥,(41)\mathbf{n}_k^e = -\frac{\mathbf{p}_{eb}^e(t_k)}{\left\lVert\mathbf{p}_{eb}^e(t_k) \right\rVert}, \tag*{(41)}

and the predicted nadir direction in Fb\mathcal{F}_b is RkTnke\mathbf{R}_k^{\mathsf{T}}\mathbf{n}_k^e. Since both directions lie on S2\mathbb{S}^2, the residual is defined in the tangent plane at the nominal prediction nˉkb=RˉkTnke\bar{\mathbf{n}}_k^b = \bar{\mathbf{R}}_k^{\mathsf{T}}\mathbf{n}_k^e as

rh,k=TkT(n~kb−RkTnke)∈R2,(42)\mathbf{r}_{h,k} = \mathbf{T}_k^{\mathsf{T}}\left(\tilde{\mathbf{n}}_k^b - \mathbf{R}_k^{\mathsf{T}}\mathbf{n}_k^e\right) \in\mathbb{R}^2, \tag*{(42)}

where Tk∈R3×2\mathbf{T}_k \in\mathbb{R}^{3\times2} is an orthonormal basis of the tangent plane at nˉkb\bar{\mathbf{n}}_k^b. The projection removes the radial component which carries no directional information. Substituting (6), the predicted direction becomes RkTnke≈nˉkb+[nˉkb]×δθk\mathbf{R}_k^{\mathsf{T}}\mathbf{n}_k^e \approx\bar{\mathbf{n}}_k^b + [\bar{\mathbf{n}}_k^b]_\times\delta\boldsymbol{\theta}_k, which gives the Jacobian

∂rh,k∂δxk=[−TkT[nˉkb]×02×3].(43)\frac{\partial\mathbf{r}_{h,k}}{\partial\delta\mathbf{x}_k} = \left[ -\mathbf{T}_k^{\mathsf{T}}[\bar{\mathbf{n}}_k^b]_\times \quad \mathbf{0}_{2\times3} \right]. \tag*{(43)}

The covariance of the residual is the learned tangent-plane covariance Σh,k\mathbf{\Sigma}_{h,k} in (29) from NN. Since Σh,k\mathbf{\Sigma}_{h,k} grows with the predicted horizon uncertainties, horizon factors from degraded images receive less weight in (36), which makes the estimator robust to such measurements. Moreover, since [nˉkb]×nˉkb=03×1[\bar{\mathbf{n}}_k^b]_\times\bar{\mathbf{n}}_k^b=\mathbf{0}_{3\times1}, the horizon factor does not constrain rotations about the nadir direction, which are instead observed through the Sun factor whenever the Sun and nadir directions are not collinear.

Sun Sensor Factor

The Sun factor is constructed in the same way as the horizon factor. The reference Sun direction ske\mathbf{s}_k^e is obtained from the solar ephemeris at tkt_k, and with the nominal prediction sˉkb=RˉkTske\bar{\mathbf{s}}_k^b=\bar{\mathbf{R}}_k^{\mathsf{T}}\mathbf{s}_k^e and an orthonormal tangent-plane basis Ts,k\mathbf{T}_{s,k} at sˉkb\bar{\mathbf{s}}_k^b, the residual and its Jacobian follow from (42)–(43) with the nadir direction replaced by the Sun direction,

rs,k=Ts,kT(s~kb−RkTske)∈R2,(44)\mathbf{r}_{s,k} = \mathbf{T}_{s,k}^{\mathsf{T}}\left(\tilde{\mathbf{s}}_k^b-\mathbf{R}_k^{\mathsf{T}}\mathbf{s}_k^e\right)\in\mathbb{R}^2, \tag*{(44)}
∂rs,k∂δxk=[−Ts,kT[sˉkb]×02×3],(45)\frac{\partial\mathbf{r}_{s,k}}{\partial\delta\mathbf{x}_k} = \left[ -\mathbf{T}_{s,k}^{\mathsf{T}}[\bar{\mathbf{s}}_k^b]_\times \quad \mathbf{0}_{2\times3} \right], \tag*{(45)}

where s~kb\tilde{\mathbf{s}}_k^b is the measured Sun direction (33) and the covariance of the residual is the per-sample tangent-plane covariance Σs,k\mathbf{\Sigma}_{s,k} in (34).

Since [sˉkb]×sˉkb=03×1[\bar{\mathbf{s}}_k^b]_\times\bar{\mathbf{s}}_k^b=\mathbf{0}_{3\times1}, the Sun factor leaves rotations about the Sun direction unconstrained. The two direction factors are thus complementary, and their combined information is full rank in the attitude block unless the Sun and nadir directions become collinear.

Results

In this section, we first describe the simulation environment and then present the attitude and gyroscope bias estimation results of the proposed framework.

Simulation Environment

The proposed framework is evaluated in a simulation environment developed in MATLAB/Simulink, in which the orbital motion, the attitude dynamics, and the onboard sensors of the spacecraft are modeled. The camera images are rendered in Unreal Engine 5 [27], which is co-simulated with Simulink, as shown in Figure 4. The simulation parameters are summarized in Table 2.

Earth limb and small satellite rendered in Unreal Engine 5

Figure 4. Earth limb and small satellite are rendered in Unreal Engine 5.

ParameterValue
Orbit
Start epoch20 March 2021, 09:37 UTC
Altitude, eccentricity500 km, 0.001
Inclination, RAAN90∘90^\circ, 90∘90^\circ
Argument of perigee, true anomaly0∘0^\circ, 0∘0^\circ
Duration500 s
Gyroscope (100 Hz)
Noise density σv\sigma_v10−410^{-4} (rad/s)/Hz\sqrt{\mathrm{Hz}}
Rate random walk σu\sigma_u10−510^{-5} (rad/s)Hz\sqrt{\mathrm{Hz}}
Initial bias[0.057,−0.057,0.115]T[0.057, -0.057, 0.115]^\mathsf{T} deg/s
Sun sensor (2 Hz)
Angular error σα\sigma_\alpha0.1∘0.1^\circ
Readout error σy\sigma_y10−310^{-3}
Reliable half-cone αmax⁡\alpha_{\max}55∘55^\circ
Camera (1 Hz)
Resolution640×480640 \times480 px
Horizontal field of view78.3∘78.3^\circ
Pixel error1 px
Estimator
Node rate, window size WW10 Hz, 20
Initial attitude error[0.6,−0.7,0.8]T[0.6, -0.7, 0.8]^\mathsf{T} deg
Initial bias estimate[0.020,−0.019,0.018]T[0.020, -0.019, 0.018]^\mathsf{T} deg/s
Prior standard deviation (attitude, bias)5∘5^\circ, 1 deg/s

Table 2. Simulation parameters.

The spacecraft is placed in a near-circular polar orbit at an altitude of 500 km, and the simulation starts on 20 March 2021 at 09:37 UTC and lasts 500 s. The orbit is initialized such that its plane is nearly perpendicular to the Sun direction. Consequently, the Sun and nadir directions remain far from collinear, so that the horizon and Sun factors jointly constrain all three rotational degrees of freedom, as discussed in § 3.3.3, and the spacecraft stays in sunlight throughout the simulation.

The gyroscope measurements are generated by (2) at 100 Hz, including the bias random walk, and the Sun sensor measurements are generated at 2 Hz by the model described in § 3.2. The camera captures images at 1 Hz, and its axes are aligned with Fb\mathcal{F}_b, i.e., Rcb=I3\mathbf{R}_c^b=\mathbf{I}_3. The nodes of the factor graph are created at 10 Hz with a window size of W=20W = 20, so that each window spans 2 s. The spacecraft position required by (41) is taken from the simulated orbit, and the true attitude and gyroscope bias of the simulation serve as the ground truth. The estimator is initialized with the attitude error and the gyroscope bias estimate listed in Table 2.

Attitude Estimation Results

Figure 5 and Figure 6 show the attitude error δθ\delta\boldsymbol{\theta} and the gyroscope bias error δβ\delta\boldsymbol{\beta} over the simulation, where the attitude error is expressed as the rotation vector between the true and estimated attitudes. Starting from the initial errors in Table 2, the sliding-window FGO successfully estimates all three components of both the attitude and the gyroscope bias. This agrees with the observability discussed in § 3.3.3: the horizon factors constrain the rotations about the axes perpendicular to the nadir direction, the Sun factors additionally constrain the rotation about the nadir direction, and the gyroscope factors, which relate the attitudes of consecutive nodes, render the gyroscope bias observable.

Attitude estimation error about the x-, y-, and z-axes of $\mathcal{F}_b$

Figure 5. Attitude estimation error δθ\delta\boldsymbol{\theta} about the xx-, yy-, and zz-axes of Fb\mathcal{F}_b.

Gyroscope bias estimation error about the x-, y-, and z-axes of $\mathcal{F}_b$

Figure 6. Gyroscope bias estimation error δβ\delta\boldsymbol{\beta} about the xx-, yy-, and zz-axes of Fb\mathcal{F}_b.

Conclusion & Future Work

Conclusion & Future Work

This paper presented a low-cost attitude determination framework for small satellites in LEO, in which a neural network detects the Earth horizon in RGB images and predicts its localization uncertainty at each pixel. These uncertainties are propagated into the covariance of the measured nadir direction, which is fused with the Sun sensor and gyroscope measurements in a sliding-window FGO, so that the attitude estimation is robust to degraded horizon measurements. Simulations with camera images rendered in Unreal Engine 5 showed that the framework successfully estimates all three components of both the attitude and the gyroscope bias.

In future work, the same learning-based approach will be applied to the Sun sensor, so that the uncertainty of each Sun measurement, e.g., due to Earth albedo, is also predicted by a neural network. Moreover, the framework will be evaluated on data recorded during a real spacecraft flight. Finally, the spherical Earth assumption will be relaxed by accounting for the Earth oblateness [8], and the epistemic uncertainty of the network will be included through MC dropout when the onboard computational resources allow.

References

  1. [1]F. Landis Markley and John L. Crassidis. Fundamentals of Spacecraft Attitude Determination and Control. Springer, New York, 2014.
  2. [2]Pablo Ortega, Gema López-Rodríguez, Jordi Ricart, Manuel Domínguez, Luis M Castañer, José M Quero, Cristina L Tarrida, Juan García, Manuel Reina, Ana Gras, et al. A miniaturized two axis sun sensor for attitude control of nano-satellites. IEEE Sensors Journal, 10(10):1623–1632, 2010.DOI
  3. [3]Siegfried W. Janson, Brian S. Hardy, Andrew Y. Chin, Daniel L. Rumsey, Daniel A. Ehrlich, and David A. Hinkley. Attitude control on the pico satellite solar cell testbed-2. In 26th Annual AIAA/USU Conference on Small Satellites, number SSC12-II-1. AIAA/USU Small Satellite Conference, 2012.
  4. [4]RW Astheimer. High precision attitude determination by sensing the earth and lunar horizon in the infrared. Automatica, 7(1):83–88, 1971.
  5. [5]John A Christian. A tutorial on horizon-based optical navigation and attitude determination with space imaging systems. IEEE Access, 9:19819–19853, 2021.DOI
  6. [6]Tam Nguyen, Kerri Cahoy, and Anne Marinan. Attitude determination for small satellites with infrared earth horizon sensors. Journal of Spacecraft and Rockets, 55(6):1466–1475, 2018.DOI
  7. [7]John A Christian and Shane B Robinson. Noniterative horizon-based optical navigation via cholessky factorization. Journal of Guidance, Control, and Dynamics, 39(12):2757–2765, 2016.DOI
  8. [8]Huajian Deng, Hao Wang, Yang Liu, and Zhonghe Jin. Large field-of-view infrared horizon sensor attitude correction for earth’s oblateness. Journal of Guidance, Control, and Dynamics, 46(10):2024–2032, 2023.DOI
  9. [9]Atilla Saadat. Attitude determination with self-inspection cameras purposed as earth horizon sensors. In 36th Annual Small Satellite Conference, number SSC22-VII-03. Space Flight Laboratory, University of Toronto Institute for Aerospace Studies, 2022.DOI
  10. [10]Benjamin Braun and Jochen Barf. Image processing based horizon sensor for estimating the orientation of sounding rockets, launch vehicles and spacecraft: B. braun and j. barf. CEAS Space Journal, 15(3):509–533, 2023.DOI
  11. [11]Yarin Gal and Zoubin Ghahramani. Dropout as a bayesian approximation: Representing model uncertainty in deep learning. In international conference on machine learning, pages 1050–1059. PMLR, 2016.arxiv.org/abs/1506.02142
  12. [12]Alex Kendall and Yarin Gal. What uncertainties do we need in bayesian deep learning for computer vision? Advances in neural information processing systems, 30, 2017.arxiv.org/abs/1703.04977
  13. [13]Yuheng Qiu, Yutian Chen, Zihao Zhang, Wenshan Wang, and Sebastian Scherer. Mac-vo: Metrics-aware covariance for learning-based stereo visual odometry mac-vo. github. io. In 2025 IEEE International Conference on Robotics and Automation (ICRA), pages 3803–3814. IEEE, 2025.
  14. [14]Tomasz Kapuscinski and Piotr Szczerba. Vision-based horizon detection for in-flight aircraft operations using fused deeplab v3+ models with diverse backbone networks. Engineering Applications of Artificial Intelligence, 165:113553, 2026.DOI
  15. [15]Ern J Lefferts, F Landis Markley, and Malcolm D Shuster. Kalman filtering for spacecraft attitude estimation. Journal of Guidance, control, and Dynamics, 5(5):417–429, 1982.
  16. [16]John L Crassidis, F Landis Markley, and Yang Cheng. Survey of nonlinear attitude estimation methods. Journal of guidance, control, and dynamics, 30(1):12–28, 2007.DOI
  17. [17]Gabe Sibley, Larry Matthies, and Gaurav Sukhatme. Sliding window filter with application to planetary landing. Journal of field robotics, 27(5):587–608, 2010.DOI
  18. [18]Weisong Wen, Tim Pfeifer, Xiwei Bai, and Li-ta Hsu. Factor graph optimization for gnss/ins integration: A comparison with the extended kalman filter. Navigation, 68(2):315–331, 2021.DOI
  19. [19]Clark Taylor and Jason Gross. Factor graphs for navigation applications: A tutorial. NAVIGATION: Journal of the Institute of Navigation, 71(3), 2024.DOI
  20. [20]Joan Sola. Quaternion kinematics for the error-state kalman filter. arXiv preprint arXiv:1711.02508, 2017.arxiv.org/abs/1711.02508
  21. [21]Frank Dellaert and Michael Kaess. Factor graphs for robot perception. Foundations and Trends® in Robotics, 6(1-2):1–139, 2017.
  22. [22]Christian Forster, Luca Carlone, Frank Dellaert, and Davide Scaramuzza. On-manifold preintegration for real-time visual–inertial odometry. IEEE transactions on robotics, 33(1):1–21, 2016.DOI
  23. [23]Stefan Leutenegger, Simon Lynen, Michael Bosse, Roland Siegwart, and Paul Furgale. Keyframe-based visual–inertial odometry using nonlinear optimization. The International Journal of Robotics Research, 34(3):314–334, 2015.DOI
  24. [24]Olaf Ronneberger, Philipp Fischer, and Thomas Brox. U-net: Convolutional networks for biomedical image segmentation. In International Conference on Medical image computing and computer-assisted intervention, pages 234–241. Springer, 2015.arxiv.org/abs/1505.04597
  25. [25]Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 770–778, 2016.arxiv.org/abs/1512.03385
  26. [26]Fausto Milletari, Nassir Navab, and Seyed-Ahmad Ahmadi. V-net: Fully convolutional neural networks for volumetric medical image segmentation. In 2016 fourth international conference on 3D vision (3DV), pages 565–571. Ieee, 2016.arxiv.org/abs/1606.04797
  27. [27]Epic Games. Unreal engine 5. https://www.unrealengine.com, 2022.
  28. [28]Sabire Betül Çınar and Ramazan Yeniçeri. Low-cost sun vector estimation – least squares optimization in polyhedral photodiode arrays. In 2025 12th International Conference on Electrical and Electronics Engineering (ICEEE), pages 225–229. IEEE, 2025.

Paper details

vlnc:W_c8ac7zcx
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 0

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Engineering

Not recorded for this paper

View statement
Looking for related papers…
Contents