Module: magneticFieldBase¶
Executive Summary¶
General magnetic field base class used to calculate the magnetic field above a planet using multiple models. The MagneticField class is used to calculate the magnetic field vector above a body using multiple models. This base class is used to hold relevant planetary magnetic field properties to compute answers for a given set of spacecraft locations relative to a specified planet. Specific magnetic field models are implemented as classes that inherit from this base class. Planetary parameters, including position and input message, are settable by the user. In a given simulation, each planet of interest should have only one magnetic field model associated with it linked to the spacecraft in orbit about that body.
Each magnetic field is attached to a specific planet, but provides support for
multiple spacecraft through addSpacecraftToModel()
.
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.
Msg Variable Name |
Msg Type |
Description |
---|---|---|
scStateInMsgs |
vector of spacecraft state input messages |
|
envOutMsgs |
vector of magnetic density output messages |
|
planetPosInMsg |
(optional) planet state input message. If not provided the planet state is zero information. |
|
epochInMsg |
(optional) epoch date/time input message |
-
class MagneticFieldBase : public SysModel¶
- #include <magneticFieldBase.h>
magnetic field base class
Public Functions
-
MagneticFieldBase()¶
This method initializes some basic parameters for the module.
- Returns
void
-
~MagneticFieldBase()¶
Destructor.
- Returns
void
-
void Reset(uint64_t CurrentSimNanos)¶
This method is used to reset the module.
- Returns
void
-
void addSpacecraftToModel(Message<SCStatesMsgPayload> *tmpScMsg)¶
Adds the spacecraft message name to a vector of sc message names and automatically creates an output message name.
- Parameters
tmpScMsg – A spacecraft state message name.
- Returns
void
-
void UpdateState(uint64_t CurrentSimNanos)¶
Computes the current local magnetic field for each spacecraft and writes their respective messages.
- Parameters
CurrentSimNanos – The current simulation time in nanoseconds
- Returns
void
Public Members
-
std::vector<ReadFunctor<SCStatesMsgPayload>> scStateInMsgs¶
Vector of the spacecraft position/velocity input message.
-
std::vector<Message<MagneticFieldMsgPayload>*> envOutMsgs¶
Vector of message names to be written out by the environment.
-
ReadFunctor<SpicePlanetStateMsgPayload> planetPosInMsg¶
Message name for the planet’s SPICE position message.
-
ReadFunctor<EpochMsgPayload> epochInMsg¶
(optional) epoch date/time input message
-
double envMinReach¶
[m] Minimum planet-relative position needed for the environment to work, default is off (neg. value)
-
double envMaxReach¶
[m] Maximum distance at which the environment will be calculated, default is off (neg. value)
-
double planetRadius¶
[m] Radius of the planet
-
BSKLogger bskLogger¶
BSK Logging
Protected Functions
-
void writeMessages(uint64_t CurrentClock)¶
This method is used to write the output magnetic field messages whose names are established in AddSpacecraftToModel.
- Parameters
CurrentClock – The current time used for time-stamping the message
- Returns
void
-
bool readMessages()¶
This method is used to read the incoming command message and set the associated spacecraft positions for computing the atmosphere.
- Returns
void
-
void updateLocalMagField(double currentTime)¶
This method is used to update the local magnetic field based on each spacecraft’s position.
- Returns
void
-
void updateRelativePos(SpicePlanetStateMsgPayload *planetState, SCStatesMsgPayload *scState)¶
This method is used to determine the spacecraft position vector relative to the planet.
- Parameters
planetState – A space planetstate message struct.
scState – A spacecraft states message struct.
- Returns
void
-
virtual void evaluateMagneticFieldModel(MagneticFieldMsgPayload *msg, double currentTime) = 0¶
class method
-
virtual void customReset(uint64_t CurrentClock)¶
Custom Reset() method. This allows a child class to add additional functionality to the Reset() method
- Returns
void
-
virtual void customWriteMessages(uint64_t CurrentClock)¶
Custom output message writing method. This allows a child class to add additional functionality.
- Returns
void
-
virtual bool customReadMessages()¶
Custom output input reading method. This allows a child class to add additional functionality.
- Returns
void
-
virtual void customSetEpochFromVariable()¶
Custom customSetEpochFromVariable() method. This allows a child class to specify how the module epoch information is set by a module variable.
- Returns
void
Protected Attributes
-
Eigen::Vector3d r_BP_N¶
[m] sc position vector relative to planet in inertial N frame components
-
Eigen::Vector3d r_BP_P¶
[m] sc position vector relative to planet in planet-fixed frame components
-
double orbitRadius¶
[m] sc orbit radius about planet
-
std::vector<MagneticFieldMsgPayload> magFieldOutBuffer¶
Message buffer for magnetic field messages
-
std::vector<SCStatesMsgPayload> scStates¶
vector of the spacecraft state messages
-
SpicePlanetStateMsgPayload planetState¶
planet state message
-
struct tm epochDateTime¶
time/date structure containing the epoch information using a Gregorian calendar
-
MagneticFieldBase()¶