coarseSunSensor#
Executive Summary#
This class is designed to model the state of a single coarse sun sensor attached to a spacecraft. It emulates the “counts” that will typically be output by the ADC on board of a spacecraft.
The module
PDF Description
contains further information on this module’s function,
how to run it, as well as testing.
The corruption types are outlined in this
PDF Description
.
Warning
Be careful when generating CSS objects in a loop or using a function! It is often convenient to initialize many CSS’ with the same attributes using a loop with a function like setupCSS(CSS)
where setupCSS
initializes the field of view, sensor noise, min / max outputs, etc. If you do this, be sure to disown the memory in Python so the object doesn’t get accidentally garbage collected or freed for use. You can disown the memory though cssObject.this.disown()
.
It is possible to define an asymmetrical field of view for the CSS. This is useful when trying to simulate baffles that partially limit the field of view of the sensor in a certain direction, usually to avoid reflected sunlight fo enter the view of the CSS. This requires not only the definition of the CSS boresight vector \(\boldsymbol{\hat{n}}\), but also two additional unit vectors \(\boldsymbol{\hat{l}}\) and \(\boldsymbol{\hat{m}}\) that define a full CSS frame. This custom field of view is modeled as the combination of two pseudo-ellipses in the \((l,m)\) plane. The resulting planar, closed curve is projected onto the unit sphere surface in the positive \(\boldsymbol{\hat{n}}\) direction. The custom field of view can be set up as follows:
CSS = coarseSunSensor.CoarseSunSensor()
CSS.modelTag = "coarseSunSensor"
CSS.scaleFactor = 1
CSS.lHat_B = lHat_B
CSS.mHat_B = mHat_B
CSS.nHat_B = nHat_B
CSS.customFov = True
CSS.fovXi = xi
CSS.fovEta = eta
CSS.fovZeta = zeta
CSS.n1 = n1
CSS.n2 = n2
where \(\xi\) indicates the half-angle field of view in the \(+\boldsymbol{\hat{m}}\) direction, \(\eta\) indicates the half-angle field of view in the \(-\boldsymbol{\hat{m}}\) direction, and \(\zeta\) indicates the half-angle field of view in the positive \(\pm \boldsymbol{\hat{l}}\) direction. By design, the field of view is symmetric with respect to the \((l,n)\) plane. The coefficients \(n_1\) and \(n_2\) are warping coefficients that allow to obtain more rectangular shapes for the two half ellipsoids as \(n_1, n_2 >> 2\). Setting \(n_1 = n_2 = 2\) ensures that the half ellipsoids are, in fact, half ellipses; setting \(\xi = \eta = \zeta\) returns a regular conical field of view.
The coarse sun sensor module also supports user-enabled faulty behavior by assigning a values to the .faultState
member of a given sensor. An example of such call would is cssSensor.faultState = coarse_sun_sensor.CSSFAULT_OFF
where cssSensor
is an instantiated sensor, and coarse_sun_sensor
is the imported module.
The module currently supports the following faults:
Fault Enumeration |
Description |
---|---|
|
CSS no longer provides a signal (output = 0) |
|
CSS signal is stuck on value from past timestep |
|
CSS signal is stuck on the maximum value |
|
CSS signal is stuck on a random value |
|
CSS produces random values |
Message Connection Descriptions#
The following table lists all the module input and output messages. The module msg connection is set by the user from python. The msg type contains a link to the message structure definition, while the description provides information on what this message is used for.
Figure 1: CoarseSunSensor()
Module I/O Illustration#
Msg Variable Name |
Msg Type |
Description |
---|---|---|
sunInMsg |
SpicePlanetStateMsgPayload |
input message for sun data |
stateInMsg |
SCStatesMsgPayload |
input message for spacecraft state |
cssDataOutMsg |
CSSRawDataMsgPayload |
output message for CSS output data |
cssConfigLogOutMsg |
CSSConfigLogMsgPayload |
output message for CSS configuration log data |
sunEclipseInMsg |
EclipseMsgPayload |
(optional) input message for sun eclipse state message |
albedoInMsg |
AlbedoMsgPayload |
(optional) input message for albedo message |
Figure 2: CSSConstellation()
Module I/O Illustration#
Msg Variable Name |
Msg Type |
Description |
---|---|---|
constellationOutMsg |
CSSArraySensorMsgPayload |
CSS constellation output message |
Class CoarseSunSensor#
-
class CoarseSunSensor : public SysModel#
coarse sun sensor class
Public Functions
-
CoarseSunSensor()#
Initialize a bunch of defaults in the constructor. Is this the right thing to do?
-
~CoarseSunSensor()#
There is nothing to do in the default destructor.
-
void reset(uint64_t CurrentClock)#
Method for reseting the module.
This method is used to reset the module.
- Parameters:
currentSimNanos – The current simulation time from the architecture
- Returns:
void
-
void updateState(uint64_t currentSimNanos)#
method to update state for runtime
This method is called at a specified rate by the architecture. It makes the calls to compute the current sun information and write the output message for the rest of the model.
- Parameters:
currentSimNanos – The current simulation time from the architecture
-
void setUnitDirectionVectorWithPerturbation(double cssThetaPerturb, double cssPhiPerturb)#
utility method to perturb CSS unit vector
Set the unit direction vector (in the body frame) with applied azimuth and elevation angle perturbations.
- Parameters:
cssPhiPerturb – [in] [rad] css elevation angle, measured positive toward the body z axis from the x-y plane
cssThetaPerturb – [in] [rad] css azimuth angle, measured positive from the body +x axis around the +z axis
-
void setBodyToPlatformDCM(double yaw, double pitch, double roll)#
utility method to configure the platform DCM
Set the direction cosine matrix body to css platform tranformation with 3-2-1 angle set.
- Parameters:
yaw – (radians) third axis rotation about body +z
pitch – (radians) second axis rotation about interim frame +y
roll – (radians) first axis rotation about platform frame +x
-
void readInputMessages()#
method to read the input messages
-
void computeSunData()#
method to get the sun vector information
This method computes the sun-vector heading information in the vehicle body frame.
-
void computeTrueOutput()#
method to compute the true sun-fraction of CSS
This method computes the true sensed values for the sensor
-
void applySensorErrors()#
method to set the actual output of the sensor with scaling/kelly
This method takes the true observed cosine value and converts it over to an errored value. It applies noise to the truth.
-
void scaleSensorValues()#
scale the sensor values
-
void applySaturation()#
apply saturation effects to sensed output (floor and ceiling)
-
void writeOutputMessages(uint64_t Clock)#
method to write the output message to the system
This method writes the output message. The output message contains the current output of the CSS converted over to some discrete “counts” to emulate ADC conversion of S/C.
- Parameters:
Clock – The current simulation time
Public Members
-
ReadFunctor<SpicePlanetStateMsgPayload> sunInMsg#
[-] input message for sun data
-
ReadFunctor<SCStatesMsgPayload> stateInMsg#
[-] input message for spacecraft state
-
Message<CSSRawDataMsgPayload> cssDataOutMsg#
[-] output message for CSS output data
-
Message<CSSConfigLogMsgPayload> cssConfigLogOutMsg#
[-] output message for CSS configuration log data
-
ReadFunctor<EclipseMsgPayload> sunEclipseInMsg#
[-] (optional) input message for sun eclipse state message
-
ReadFunctor<AlbedoMsgPayload> albedoInMsg#
[-] (optional) input message for albedo message
-
CSSFaultState_t faultState#
[-] Specification used if state is set to COMPONENT_FAULT */
-
double theta#
[rad] css azimuth angle, measured positive from the body +x axis around the +z axis
-
double phi#
[rad] css elevation angle, measured positive toward the body +z axis from the x-y plane
-
double B2P321Angles[3]#
[-] 321 Euler angles for body to platform
-
Eigen::Matrix3d dcm_PB#
[-] DCM from platform frame P to body frame B
-
Eigen::Vector3d lHat_B#
[-] css unit direction vector 1 in body frame components
-
Eigen::Vector3d mHat_B#
[-] css unit direction vector 2 in body frame components
-
Eigen::Vector3d nHat_B#
[-] css unit direction vector 3 in body frame components
-
Eigen::Vector3d sHat_B#
[-] unit vector to sun in B
-
double albedoValue = -1.0#
[-] albedo irradiance measurement
-
double scaleFactor#
[-] scale factor applied to sensor (common + individual multipliers)
-
double pastValue#
[-] measurement from last update (used only for faults)
-
double trueValue#
[-] solar irradiance measurement without perturbations
-
double sensedValue#
[-] solar irradiance measurement including perturbations
-
double kellyFactor#
[-] Kelly curve fit for output cosine curve
-
double fov#
[-] rad, field of view half angle
-
double fovXi#
[rad] half-angle fov along the +lHat direction
-
double fovEta#
[rad] half-angle fov along the -lHat direction
-
double fovZeta#
[rad] half-angle fov along the ±mHat direction
-
double n1 = 2#
[-] ellipse warping coefficient in the +lHat direction
-
double n2 = 2#
[-] ellipse warping coefficient in the -lHat direction
-
Eigen::Vector3d r_B#
[m] position vector in body frame
-
Eigen::Vector3d r_PB_B#
[m] misalignment of CSS platform wrt spacecraft body frame
-
double senBias#
[-] Sensor bias value
-
double senNoiseStd#
[-] Sensor noise value
-
double faultNoiseStd#
[-] Sensor noise value if CSSFAULT_RAND is triggered
-
double maxOutput#
[-] maximum output (ceiling) for saturation application
-
double minOutput#
[-] minimum output (floor) for saturation application
-
double walkBounds#
[-] Gauss Markov walk bounds
-
double kPower#
[-] Power factor for kelly curve
-
int CSSGroupID = -1#
[-] (optional) CSS group id identifier, -1 means it is not set and default is used
-
BSKLogger bskLogger#
— BSK Logging
-
CoarseSunSensor()#