Module: 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().

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:

CoarseSunSensor Fault Types

Fault Enumeration

Description

CSSFAULT_OFF

CSS no longer provides a signal (output = 0)

CSSFAULT_STUCK_CURRENT

CSS signal is stuck on value from past timestep

CSSFAULT_STUCK_MAX

CSS signal is stuck on the maximum value

CSSFAULT_STUCK_RAND

CSS signal is stuck on a random value

CSSFAULT_RAND

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.

../../../../_images/moduleDiagramCSS.svg

Figure 1: CoarseSunSensor() Module I/O Illustration

CoarseSunSensor Module I/O Messages

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

../../../../_images/moduleDiagramConstellation.svg

Figure 2: CSSConstellation() Module I/O Illustration

CSSConstellation Module I/O Messages

Msg Variable Name

Msg Type

Description

constellationOutMsg

CSSArraySensorMsgPayload

CSS constellation output message


Enums

enum CSSFaultState_t

Values:

enumerator CSSFAULT_OFF

CSS measurement is set to 0 for all future time

enumerator CSSFAULT_STUCK_CURRENT

CSS measurement is set to current value for all future time

enumerator CSSFAULT_STUCK_MAX

CSS measurement is set to maximum value for all future time

enumerator CSSFAULT_STUCK_RAND

CSS measurement is set to randomly selected value for all future time

enumerator CSSFAULT_RAND

CSS measurement returns uniformly distributed random values between 0 and max

enumerator NOMINAL
class CoarseSunSensor : public SysModel
#include <coarseSunSensor.h>

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 of platform frame P relative to body frame B

Eigen::Vector3d nHat_B

[-] css unit direction vector 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

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

&#8212; BSK Logging

Private Members

SpicePlanetStateMsgPayload sunData

[-] Unused for now, but including it for future

SCStatesMsgPayload stateCurrent

[-] Current SSBI-relative state

EclipseMsgPayload sunVisibilityFactor

[-] scaling parameter from 0 (fully obscured) to 1 (fully visible)

double sunDistanceFactor
GaussMarkov noiseModel

[-] Factor to scale cosine curve magnitude based on solar flux at location

GaussMarkov faultNoiseModel

[-] Gauss Markov noise generation model

Saturate saturateUtility

[-] Gauss Markov noise generation model exclusively for CSS fault

class CSSConstellation : public SysModel
#include <coarseSunSensor.h>

Constellation of coarse sun sensors for aggregating output information.

This class is a thin container on top of the above coarse-sun sensor class.

It is used to aggregate the output messages of the coarse sun-sensors into a a single output for use by downstream models.

Public Functions

CSSConstellation()

[-] Default constructor

The default constructor for the constellation really just clears the sensor list.

~CSSConstellation()

[-] Default Destructor

The default destructor for the constellation just clears the sensor list.

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)

[-] Main update method for CSS constellation

void appendCSS(CoarseSunSensor *newSensor)

[-] Method for adding sensor to list

Public Members

Message<CSSArraySensorMsgPayload> constellationOutMsg

[-] CSS constellation output message

std::vector<CoarseSunSensor*> sensorList

[-] List of coarse sun sensors in constellation

Private Members

CSSArraySensorMsgPayload outputBuffer

[-] buffer used to write output message