| Responsible |
|
| Last Updated | 10/12/2025, 12:48:54 PM |
| Last Author | Kai Berszin |
Estimators
Scope
This article describes the state estimation requirements and the Extended Kalman Filter designed for state estimation.
State Estimation Requirements
Internal state of the satellite for the purposes of attitude determination includes:
- 3 DoF Orientation
- Angular velocities Additional information needed:
- Earth's magnetic field at the current location
- The Sun's position relative to the current location This information is provided by the MOPS team in a form of a lookup table based on the current time, which can be obtained through the GNSS antennas. Using the sensors specified earlier we can use the full state EKF documented at Page 13 to 17 in the CubeSpace Commissioning and Operations Manual
Extended Kalman Filter
Accurate estimation of the CubeSat's state, including attitude and angular velocity , is crucial for proper navigation and control. Gyroscope, accelerometer and magnetometer readings are therefore combined into a Dual Kalman Filter to achieve an attitude estimation accuracy of below defined by the communication constraints.
Angular Velocity
Mathematical explanation
The angular velocity estimation is based on this paper using gyroscope and accelerometer readings as the observed measurements. The estimation is further complemented by the sensor biases for each sensor on each axis individually, resulting in the following state vector:

Where is the number of available IMU's. The accelerometer biases consist of one triple less, as the differences between accelerometer readings are considered to be the measurements
Measurement model
The acceleration measured by an accelerometer at position in body frame is described by

Which can be rewritten as

where is the noise with covariance matrix with as the identity matrix of size .
As the angular acceleration is unknown, it's considered an additional noise term in the form of with . Combined with the gyroscope measurements , the measurement equation is given by

Prediction
The prediction of the current state and covariance based on the previously estimated state and covariance is done using:

with

Estimation
The estimation of the current state and covariance based on the predicted state and covariance is done using:
with
Implementation
The simulation can be found in run_files/attitude_estimation/run_angular_velocity_EKF.m and the implementation at angularVelocityEKF.m.
Attitude (Orientation)
Mathematical explanation
The estimated angular velocity is then used as the control input for the attitude estimation based on this source with only magnetometer readings as the measured input. The bias estimation for the magnetometers has been added here as well:
Where is the number of available magnetometers.
Measurement model
The magnetometer measurement can be described as follows
where rotates the expected magnetic measurement from the Earth frame to sensor frame around the attitude . This can be rewritten as
where the noise is described by To be comparable, and have to be normalized
This results in following Jacobian for the measurement model:

Prediction
he prediction of the current state and covariance based on the previously estimated state and covariance is done using:

with

Estimation
The estimation of the current state and covariance based on the predicted state and covariance is done using:

with
Results
The EKF successfully stays within the on noisy measurements and fast changing state.

Implementation
The simulation can be found in run_files/attitude_estimation/run_ekf.m and the implementation of the math at state_estimation/ekf/EKF.m.
Sensor Fault detection
Mathematical explanation
The State estimation pipeline must be resilient to faults in the sensor that could propagate inside the Extended Kalman Filter and make the current estimated state not reliable. For this, we implemented an approach based on this paper using the Innovation covariance. Detecting a large increase in these coefficients signifies that the estimated state is inconsistent with the measurements. The Innovation covariance is calculated as: where is the measurement of the state vector at timestep and is the estimate of the state vector at timestep . We calculate the moving average of these matrices over timesteps:
The values we need to monitor are the diagonal values:
To detect large changes in the elements of , we use the CUSUM algorithm taken from here. During simulation, the means and standard deviations of these coefficients are first learned, then one of three types of faults is added: large additive constant, signal replaced by white noise, and ramp.

The means and standard deviations of are learned over 10 seconds, the moving average window size is 0.2s. The fault is detected at 35.96s and ends at 47.47s.
Sun Detection
This chapter describes how we could use the sun sensors to detect the direction to the Sun.
To accurately calculate a sun vector coming from any direction, full sky coverage is required. This means that a sun sensor would be required on each of the six sides of the CubeSat. So for the majority of cases it is not possible to have three overlapping sun sensor field of views, we will be calculating 2 possible candidates that could be the correct sun sensor with the information from 2 sun sensors with overlapping field of views.
If a third sensor happens to have an overlapping field of view, the angle between the surface normal of the surface with the third sensor will be checked to choose one of the sun sensor candidates.
Mathematical explanation
This example is done with the sun sensor at the center of the +x and the +y surfaces.
To calculate a vector it is important to have 2 points. The sun vector will be at the overlap border of the two cones created by the angles and . The first point, let's call it , is where the cones meet on the xz-plane. Additional known parameters are the half lengths of the satellite surfaces and It is visualized in Figure 1.

From Figure 1 we can derive the formulas:
from which we derive
so we get
For the second point to calculate a vector needs to be in the overlap area of the sun sensor field of views. But since we lack a degree of freedom to definetely know the point so two candidate points and are considered. is the projection of both points onto the xy-plane. Since it needs to be in the overlap area so we fix . From there we calculate , and .

From Figure 2 we can derive the formula and

And from Figure 3 we can observe: and Solving these for and we get and and we also know that .
Finally, we have the points
and . From here we get the sun sensor candidates and with the following formulas: and
Implementation
The simulation is implemented in run_files/sun_detection/run_testSunDetection.m.
It is implemented in an if-else check structure that checks whether any viable combination of sun sensor angles have been read out by the coarse sun sensor object. This is implemented in the file state_estimation/sun_detection/detectSun.m.
If only 2 sun sensors detect the sun, both sun sensor candidate vectors are returned.
The actual calculation of the two sun sensor candidates happens in the file state_estimation/sun_detection/calculateSunVectorWith2CoarseSunSensors.m.
The inputs are the angles and and the surface normals of the surface that the sun sensor is located on. The and parameters are based on the surface of choice. The function is implemented so that this algorithm works with any combination of neighbouring surfaces.
If 3 sun sensors detect the sun only one sun sensor candidate is returned. This check function is implemented in state_estimation/sun_detection/calculateSunVectorWith3CoarseSunSensors.m. This check function calculates the angle between the surface normal of the +z axis and the two sun vector candidates. The one that has an angle that is within the field of view of the sun sensor is chosen as the final sun vector and returned.
Additionally, if only one sensor detects the sun but with an angle smaller than 3 degrees, it returns the surface normal of the sun senosr's corresponding surface as the sun vector.
The getDummySunVector.m returns a simulation scenario of a reference sun vector based on a seed for the simulation.
Magnetic Field Estimation
Mathematical Explanation
The earth's magnetic field can be determined with the measurements of the magnetometers. As the sensors have biases, they have to be subtracted from the measured values to get the actual measurement. The estimate of the magnetic field can then be determined with a weighted least square algorithm as follows: with x being the magnetic field estimate and z the measurements represented as a vector. The matrix H represents the rotation between the magnetometer and the satellite frame. The matrix R is the covariance matrix of the measurements which is used to weight the measurements. The bigger the variance the less the value is weighted for the estimation.
Implementation
The simulation is implemented in run_files/magnetic_field_estimation/run_magneticEstimation.m and algorithm is implemented in state_estimation/magnetic_field_estimation/estimate_magnetic_field.m.