Comparison of TRIAD+EKF and TRIAD+UKF Algorithms for
Nanosatellite Attitude Estimation
MEHMET ASIM GOKCAY
Hezârfen Aeronautics and Astronautics Technologies Institute for Space Sciences
Turkish National Defense University
Yeşilyurt, 34149, Bakırköy, Istanbul
TURKEY
CHINGIZ HAJIYEV
Faculty of Aeronautics and Astronautics
Istanbul Technical University
Ayazağa, 34469, Maslak, Istanbul
TURKEY
Abstract: - Two most commonly used sensors on nanosatellites are magnetometer and sun sensor. In this paper,
magnetometer and sun sensor measurements are combined gyro measurements to produce enhanced attitude
estimation. Tri-Axial Attitude Determination (TRIAD) algorithm is used with Kalman filter to form a complete
attitude filter. Sun sensor and magnetometer measurements are selected as inputs to TRIAD algorithm and
output is fed to Kalman filter as a measurement. Two different Kalman filters, extended and unscented, are
used with TRIAD algorithm. A comparison is given between performances of both Kalman filter.
Key-Words: Nanosatellite, Magnetometer, Sun Sensor, Kalman Filter, Attitude Estimation.
Received: May 15, 2021. Revised: March 4, 2022. Accepted: April 8, 2022. Published: May 4, 2022.
1 Introduction
Increasing demand for the space operations,
space industry turns its face to cost effective
solutions. Small satellites, due to their size and cost,
are receiving interest from many organizations. The
amount of attitude determination and control
equipment that can be placed in small satellites are
considerably lower than the regular size satellite.
Kalman filter has been the backbone of the
space industry since the publication of the Dr.
Kalman’s work [1]. Many different versions of the
Kalman filter have been derived. Harold Black
published an algorithm called Tri-Axial Attitude
Determination (TRIAD) in 1964 [2]. It is the earliest
algorithm that was published to find satellite attitude
with two measurements. In 1965, Grace Wahba
suggested her famous problem [3]. Solution
methods such as q-method [4] and Quest algorithm
have been widely used [5]. A computationally
expensive method, SVD, is also published [6].
Many of the mentioned methods are coupled with
Kalman filters for higher accuracy [7], [8]. In this
work algebraic method is used with sun sensor and
magnetometer measurements.
EKF is probably the most used version of
the Kalman filter [9]. One of the earliest work of
Kalman filter for attitude determination used Euler
angle rotations [10]. It is known that all three-
parameter representations of the special orthogonal
group suffer from singularity and discontinuity
problems. To overcome this challenge new
representation methods have been studied [11].
Quaternions have become the most used form of the
attitude representations. Euler angles, Rodrigues and
modified Rodrigues parameters are avoided for most
of the agile missions due to their singularity
problems. In the last two decades new approaches
have been suggested for replacing EKF. Unscented
Kalman filter is one of them [12]. UKF uses the
unscented transformation to achieve high-order
approximations of the nonlinear functions in order
to estimate mean and covariance of the state vector.
Filter uses predefined number of sigma points to
approximate Gaussian distribution. Each of the
sigma points are propagated through the propagation
functions [12, 13].
In this work, using common sensors, couple
of filters are design to overcome to attitude
determination problem. Two of most common
sensors that are being used in nanosatellites are
WSEAS TRANSACTIONS on SYSTEMS and CONTROL
DOI: 10.37394/23203.2022.17.23
Mehmet Asim Gokcay, Chingiz Hajiyev
E-ISSN: 2224-2856
201
Volume 17, 2022
magnetometers and sun sensors. Magnetic dipole
model is selected for magnetic field model. VSOP87
theory is used for sun direction vector [14]. Using
these two models, sensor measurement models have
been established. For attitude representation of the
spacecraft Euler angles are selected. TRIAD
algorithm is used for combining sun sensor and
magnetometer measurements. Body angles that are
produced by TRIAD are used as linear
measurements to the Kalman filter. Algorithm is
constructed for both Extended and Unscented
Kalman filters for comparison.
2 Mathematical Model
Satellite kinematic, dynamic and sensor
models are derived in this section.
2.1 Satellite Kinematic and Dynamic Model
Firstly, for kinematic model, rate equations
are given below
uv
cos sin
(1)
uv
( sin cos )sec
(2)
u v w
tan ( sin cos )
(3)
where
is the roll angle about
x
axis,
is the
pitch angle about
y
axis,
is the yaw angle about
z
axis,
u
,
v
and
w
are the components of
BR
ω
vector in body frame with respect to the reference
frame.
Rotations need to be defined with respect to
inertial frame.
ux
v y 0
wz
w0
wA
w0

(4)
where
x
w
,
y
w
and
z
w
are the components of vector
w
in body frame with respect to the inertial frame,
A is the attitude transformation matrix composed of
Euler angles,
03
r

defines the orbital angular
velocity with respect to the inertial frame,
is the
gravitational constant of the Earth and r is the
distance between center of mass of the satellite and
the Earth,
rr
.
Attitude dynamics is related with time
derivative of the angular momentum vector. If the
origin of the body frame is selected as the center of
mass, then
c
h Jw
(5)
where h is the angular momentum vector, J is the
moment of inertia matrix.
Relation between time derivative of the
angular momentum and the angular velocity is
c b c
h h w (h )
(6)
where hb is the time derivative of angular
momentum in body-fixed frame.
Rewriting derivative equations for discrete
time we have,
k 1 k
x x z y y z m
x
t
w w w w J J T
J
(7)
k 1 k
y y x z z x m
y
t
w w w w J J T
J
(8)
k 1 k
z z x y x y m
z
t
w w w w J J T
J
(9)
where Tm is the external torque and
t
is the
sampling time interval.
Equations above describe the satellite attitude
motion.
2.2 Sensor Models
Magnetometer is the most commonly used
sensor particularly in nanosatellite applications. For
magnetic field vector, dipole model is used. Sensor
model is given below,
x1
y 2 m m
z3
B ( , , , t) B (t)
B ( , , , t) A B (t) b
B ( , , , t) B (t)


(10)
where B1(t), B2(t) and B3(t) indicates Earth magnetic
field vector components in orbit frame,
Bx(
, , , t
), By(
, , , t
) and Bz(
, , , t
) show
the Earth magnetic field vector components in body
frame as a function of body angles and time. The
magnetometer bias vector is given as
T
m x y z
b b b b
. Bias vector is modeled via the
expression below:
m
b0
. (11)
WSEAS TRANSACTIONS on SYSTEMS and CONTROL
DOI: 10.37394/23203.2022.17.23
Mehmet Asim Gokcay, Chingiz Hajiyev
E-ISSN: 2224-2856
202
Volume 17, 2022
The noise term,
m,
is added linearly to the model
and modeled as zero mean Gaussian white noise
with the characteristic of
T2
1 k 1 j 3 x 3 m kj
E
(12)
where I3x3 is the identity matrix,
m
is the standard
deviation of magnetometer errors and
kj
is the
Kronecker symbol.
In order to construct a sun sensor model,
sun direction vector is used. Using VSOP87 theory,
a direction cosine matrix is calculated which shows
the sun’s position relative to Earth in ECI frame
[14].
x1
y2
3
z
BE
B E s
E
B
ss
s A s
s
s

 
 
 
 


(13)
Construction of sun direction vector, sE, requires
two assumptions. Comparing the distance between
Sun-Earth, 1 AU, and Earth-satellite, satellite
altitude is negligible. Therefore, satellite’s sun
direction vector is always parallel to Earth’s sun
direction vector. The other assumption is taking the
right ascension node of Sun’s orbit as zero. The sun
direction vector,
ecliptic
E ecliptic
ecliptic
cos
s sin cos
sin sin







(14)
The noise term,
s,
is added linearly to the model
and modeled as zero mean Gaussian white noise
with the characteristic of
T2
1k 1 j 3 x 3 s kj
E


(15)
where I3x3 is the identity matrix,
s
is the standard
deviation of sun sensor errors.
The gyro model is constructed with satellite
dynamic equations. A commonly used model for
gyro measurements given by
BI BI g g
b
(16)
where
g
b
is the gyro bias vector and the
g
modeled as zero mean Gaussian white noise with
the characteristic of
T2
1k 1 j 3 x 3 g kj
E


(17)
where I3x3 is the identity matrix,
g
is the standard
deviation of gyro errors. Gyro bias vector is
modeled as,
g
b0
. (18)
3 Filter Design
3.1 TRIAD
A rotation matrix describes the attitude of a
spacecraft with respect to a known reference frame.
It takes at least two measured vectors to determine
the orientation of the vehicle. The algebraic method
constructs two triads of orthonormal vectors, two
triads are expressed by sun sensor and
magnetometer unit vectors in body and reference
frames. Let magnetometer measurement vector is
denoted by B and sun sensor vector is denoted by S.
For initial base vector, sun sensor is selected.
uS
v S B / S B
r u v

(19)
It is important to note that two vectors, S and B
cannot be parallel,
S.B 1
. Constructing the
direction cosine matrix,

T
r r r b b brb
A u v w u v w
(20)
Final step of the TRIAD is to find error covariance
of the algorithm
2 T 2 T
2T
m b b s b b
s b b
S S B B
P v v
SB


(21)
Body angles and error covariances that are obtained
from TRIAD algorithm are used as measurement
inputs to the Kalman filter. These results are
combined with gyro measurements in order to
achieve better accuracy.
3.2 Extended Kalman Filter
In 1960, Dr. Kalman published his famous
paper “A new Approach to Linear Filtering and
Prediction”. It represented a sequential solution to
the time-varying filtering problem. The filter is
particularly good for dynamical systems and also
removed the non-dynamical requirements of Weiner
filter [1]. The extended Kalman filter uses the first
WSEAS TRANSACTIONS on SYSTEMS and CONTROL
DOI: 10.37394/23203.2022.17.23
Mehmet Asim Gokcay, Chingiz Hajiyev
E-ISSN: 2224-2856
203
Volume 17, 2022
order Taylor series linearization for non-linear
systems. This process requires two assumptions.
Propagation and measurement functions must be
differentiable. Filter algorithm is given below.
Propagation of state vector is conducted with
equation,
k k 1
ˆˆ
x f x

(22)
Equation of state estimation,
k k k k
ˆˆ
x x K z h x
(23)
Here, h is the measurement function and K is the
Kalman gain,
1
TT
kk
K P H HP H R




(24)
where R is the covariance matrix of measurement
error, H is the measurement matrix of system,
k
P
is
the covariance matrix of extrapolation error.
Covariances of both extrapolation and filtering
errors are given below. For error equations,
Jacobian matrix
F
is needed. Jacobian matrix can
be constructed by taking partial derivatives of
propagation function with respect to state variables
T
k k 1
FP F QP

(25)
kk
P I KH P


(26)
where F is the Jacobian matrix and Q is the
covariance matrix of process noise.
3.3 Unscented Kalman Filter
EKF, due to nature of the first-degree
linearization, is not as accurate for highly linear
systems. Jacobians are hard to derive and the
linearization needs very short time intervals
otherwise filter becomes unstable. But this comes
with the computational power gets higher. The main
idea behind the UKF is distributions are easier to
approximate from nonlinear functions [13].
Therefore, it introduces “sigma points”. With these
points, filter removes need for derivation of
Jacobian matrix and it is more robust to the initial
estimation errors [15]. Sigma point can be obtained
by [16]
0x
(27)
ik
i
x L P i 1,....L

(28)
ik
iL
x L P i L 1,....2L

(29)
is denotation for the sigma vector. In order to
capture the true nature of the reflection, sigma
points are weighted
( m )
0
W
L
(30)
( c ) 2
0
W1
L

(31)
(m ) (c)
ii
WW
(32)
where
2LL
is the scaling parameter,
is the secondary scaling parameter,
determines how spread the sigma points are and is
used to incorporate prior knowledge for x. Using the
weights, propagated state matrix can be determined
by,
2L
(m)
k i i
i0
ˆ
x W Y
(33)
And propagated covariance
2L T
(c )
k i i k i k
i0
ˆˆ
P W Y x Y x Q
(34)
where Q is the process noise. Obtaining the Kalman
gain is similar to EKF. Hence,
1
xy yy
K P P
(35)
where Pxy and Pyy are,
2L T
(c)
yy i i k i k
i0
ˆˆ
P W Z z Z z R

(36)
2L T
(c)
xy i i k i k
i0
ˆˆ
P W Y z Z z

(37)
The last part is to update both state and covariance
matrix with measurements
k k k k
ˆ ˆ ˆ
x x K z z

(38)
T
k k yy
P P KP K

(39)
where zk is the measurement vector.
4 Simulation
Simulations are performed with a
hypothetical nanosatellite with principal moment of
inertia J = diag(2.1x10e-3 2x10e-3 1.9x10e-3).
WSEAS TRANSACTIONS on SYSTEMS and CONTROL
DOI: 10.37394/23203.2022.17.23
Mehmet Asim Gokcay, Chingiz Hajiyev
E-ISSN: 2224-2856
204
Volume 17, 2022
Simulations are conducted with a sampling time of 1
second. Orbit of the satellite is a circular orbit with
an altitude of 400 km. Argument of perigee of the
orbit is 207.4 degrees and inclination of the orbit is
97.65 degrees.
Figures below give attitude estimations in
terms of Euler angles. First figure shows estimation
with only TRIAD algorithm. Figure 1 and 2 show
attitude estimations combining TRIAD and two
different Kalman filters
Fig. 1: TRIAD-EKF attitude estimation
Fig. 2: TRIAD - UKF attitude estimation
Mean square errors of each method are
given in Table 1.
Table 1: RMSE values
Roll (deg)
Pitch (deg)
Yaw (deg)
TRIAD
6.2395
7.2175
11.4611
EKF
4.5339
5.4990
10.5363
UKF
3.4718
6.1306
10.7370
RMSE results clearly show that Kalman
filters increase quality of estimation compared to
TRIAD-only algorithm. Both extended and
unscented Kalman filters estimated similarly. The
only significant difference in RMSE values is at roll
estimation.
5 Conclusion
Algebraic method, even though it is an aging
algorithm, can estimate satellite attitude well. The
sun sensor and magnetometer are selected for inputs
to algebraic method because of their wide usage in
space industry. Many different filtering algorithms
are presented to this day but proven algorithms are
still getting attention from engineers. Extended
Kalman filter proves itself on many missions.
Therefore, selecting the EKF for this work was a
must. As expected, it performs really well on
simulations especially in low initial angular velocity
cases. UKF is known for its superiority to EKF
when dealing with nonlinear functions. In many
simulations attempts, UKF performed relatively
same as EKF.
References:
[1] Kalman, R.E. (1960). A new approach to linear
filtering and prediction problems. Journal of
Fluids Engineering, Transactions of the ASME.
82(1), 35–45.
[2] Black, H.D. (1964). A passive system for
determining the attitude of a satellite. AIAA
Journal. 2(7), 1350–1351.
[3] Wahba, G. (1965). A Least Squares Estimate of
Satellite Attitude. SIAM Review. 7(3),409-409.
[4] Wertz, J. (1978). Spacecraft attitude
determination and control. Dordrecht: Kluwer
Academic Publishers.
[5] Shuster, M.D. and Oh, S.D. (1981). Three-axis
attitude determination from vector
observations. Journal of Guidance, Control, and
Dynamics. 4(1), 70–77.
[6] Landis, M. (1988). Attitude Determination
Using Vector Observations and the Singular
Value Decomposition. Journal of the
Astronautical Sciences. 36(3), 245–258.
WSEAS TRANSACTIONS on SYSTEMS and CONTROL
DOI: 10.37394/23203.2022.17.23
Mehmet Asim Gokcay, Chingiz Hajiyev
E-ISSN: 2224-2856
205
Volume 17, 2022
[7] Cilden-Guler, D., Soken, H. E., Hajiyev, C.
(2018). SVD-Aided UKF for Estimation of
Nanosatellite Rotational Motion Parameters.
WSEAS Transactions on Signal Processing.
(14), 27-35.
[8] Cilden Guler , D. and Hajiyev, C. (2017).
Gyroless Attitude Determination of
Nanosatellites Single-Frame Methods and
Kalman Filtering Approach. Saarbrücken:
LAMBERT Academic Publishing.
[9] Schmidt, S.F. (1981). The Kalman filter : Its
recognition and development for aerospace
applications. Journal of Guidance, Control, and
Dynamics. 4(1), 4–7.
[10] Farrell, J.L. (1970). Attitude determination by
Kalman filtering. Automatica. 6(3), 419–430.
[11] Shuster, M.D. (1993). Survey of attitude
representations. Journal of the Astronautical
Sciences. 41(4), 439–517.
[12] Julier, S.J., Uhlmann, J.K. and Durrant-Whyte,
H.F. (1995). New approach for filtering
nonlinear systems. Proceedings of the
American Control Conference. 3(June), 1628
1632.
[13] Van Der Merwe, R. and Wan, E.A. (2001). The
square-root unscented Kalman filter for state
and parameter-estimation. ICASSP, IEEE
International Conference on Acoustics, Speech
and Signal Processing - Proceedings. 6, 3461–
3464.
[14] Bretagnon, P. and Francou, G. (1988).
Planetary Theories in rectangular and spherical
variables. VSOP87 solution. Astronomy and
Astrophysics. 202, pp.309-315.
[15] Crassidis, J.L. and Markley, F.L. (2003).
Unscented filtering for spacecraft attitude
estimation. AIAA Guidance, Navigation, and
Control Conference and Exhibit. 26(4).
[16] Wan, E.A. and Van Der Merwe, R. (2000). The
unscented Kalman filter for nonlinear
estimation. IEEE 2000 Adaptive Systems for
Signal Processing, Communications, and
Control Symposium, AS-SPCC 2000., 153–
158.
Creative Commons Attribution License 4.0
(Attribution 4.0 International, CC BY 4.0)
This article is published under the terms of the Creative
Commons Attribution License 4.0
https://creativecommons.org/licenses/by/4.0/deed.en_US
WSEAS TRANSACTIONS on SYSTEMS and CONTROL
DOI: 10.37394/23203.2022.17.23
Mehmet Asim Gokcay, Chingiz Hajiyev
E-ISSN: 2224-2856
206
Volume 17, 2022