Skip to content

Commit 7eb0cd3

Browse files
authored
Merge pull request #1011 from AVSLab/feature/eclipse-access
Eclipse Access
2 parents 2e17452 + c07722c commit 7eb0cd3

7 files changed

Lines changed: 46 additions & 8 deletions

File tree

docs/source/Support/bskReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Version |release|
4242
using ``uint64_t`` time values and then converted to a double.
4343
- Enhance how ``uint64_t`` values are converted to doubles. BSK now warns if the time value is large enough such
4444
that the conversion method has a loss of precision in this process.
45+
- Support including an eclipse message in :ref:`SpacecraftLocation` to more accurately determine illumination.
4546

4647

4748
Version 2.7.0 (April 20, 2025)

src/architecture/msgPayloadDefC/AccessMsgPayload.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#define ACCESSSIMMSG_H
2222

2323
/*! @brief Message that defines access to spacecraft from a groundLocation, providing access, range, and elevation with
24-
* repect to a ground location.
24+
* respect to a ground location.
2525
*/
2626
typedef struct {
2727
uint64_t hasAccess;//!< [-] 1 when the writer has access to a spacecraft; 0 otherwise.
@@ -33,6 +33,7 @@ typedef struct {
3333
double az_dot; //!< [rad/s] Azimuth angle rate for a given spacecraft in the SEZ rotating frame.
3434
double r_BL_L[3]; //!<[m] Spacecraft position relative to the groundLocation in the SEZ frame.
3535
double v_BL_L[3]; //!<[m/s] SEZ relative time derivative of r_BL vector in SEZ vector components.
36+
uint64_t hasIllumination;//!< [-] 1 when illumination constraints are met; 0 otherwise.
3637
double sunIncidenceAngle; //!<[rad] Angle between bore-sight and Sun vector
3738
double scViewAngle; //!<[rad] Angle between bore-sight and deputy SC vector
3839
}AccessMsgPayload;

src/architecture/msgPayloadDefC/EclipseMsgPayload.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
//!@brief Eclipse shadow factor message definition.
2525
typedef struct {
26-
double shadowFactor; //!< Proportion of shadowing due to eclipse
26+
double shadowFactor; //!< Proportion of illumination due to eclipse. 0 = fully shadowed, 1 = fully illuminated.
2727
}EclipseMsgPayload;
2828

2929

src/simulation/environment/spacecraftLocation/spacecraftLocation.cpp

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ SpacecraftLocation::SpacecraftLocation()
3636
this->aHat_B.fill(0.0);
3737
this->theta = -1.0;
3838
this->theta_solar = -1.0;
39+
this->min_shadow_factor = -1.0;
3940

4041
this->planetState = this->planetInMsg.zeroMsgPayload;
4142
this->planetState.J20002Pfix[0][0] = 1;
@@ -85,7 +86,7 @@ SpacecraftLocation::Reset(uint64_t CurrentSimNanos)
8586
}
8687

8788
if (this->theta_solar >= 0.0) {
88-
if (this->aHat_B.norm() < 0.001){
89+
if (this->aHat_B.norm() < 0.001) {
8990
bskLogger.bskLog(BSK_ERROR, "SpacecraftLocation must set aHat_B if you specify theta_solar");
9091
}
9192
}
@@ -152,11 +153,20 @@ SpacecraftLocation::ReadMessages()
152153
sunRead = this->sunInMsg.isWritten();
153154
this->sunData = this->sunInMsg();
154155
} else {
155-
sunRead = false;
156156
this->r_HN_N.setZero();
157157
}
158158

159-
return (planetRead && scRead && sunRead);
159+
//! - Zero eclipse information
160+
this->eclipseInMsgData = eclipseInMsg.zeroMsgPayload;
161+
162+
bool eclipseRead = true;
163+
if (this->eclipseInMsg.isLinked()) {
164+
eclipseRead = this->eclipseInMsg.isWritten();
165+
this->eclipseInMsgData = this->eclipseInMsg();
166+
}
167+
168+
169+
return (planetRead && scRead && sunRead && eclipseRead);
160170
}
161171

162172
/*! write module messages
@@ -243,7 +253,13 @@ SpacecraftLocation::computeAccess()
243253
}
244254
}
245255

256+
this->accessMsgBuffer.at(c).hasIllumination = 0; // default to no illumination
257+
258+
// Check illumination if sun message is present
246259
if (this->sunInMsg.isLinked()) {
260+
// Assume illumination conditions are met; then check for unmet conditions
261+
this->accessMsgBuffer.at(c).hasIllumination = 1;
262+
247263
// aHat vector in inertial frame
248264
Eigen::Vector3d aHat_N = dcm_NB * this->aHat_B;
249265

@@ -262,6 +278,15 @@ SpacecraftLocation::computeAccess()
262278
if (this->theta_solar >= 0.0) {
263279
if (sunIncidenceAngle > this->theta_solar) {
264280
this->accessMsgBuffer.at(c).hasAccess = 0; // outside solar cone
281+
this->accessMsgBuffer.at(c).hasIllumination = 0;
282+
}
283+
}
284+
285+
// Check if eclipse is valid
286+
if (this->eclipseInMsg.isLinked() && this->min_shadow_factor > 0.0) {
287+
if (eclipseInMsgData.shadowFactor < this->min_shadow_factor) {
288+
this->accessMsgBuffer.at(c).hasAccess = 0;
289+
this->accessMsgBuffer.at(c).hasIllumination = 0;
265290
}
266291
}
267292
}

src/simulation/environment/spacecraftLocation/spacecraftLocation.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
#include "architecture/messaging/messaging.h"
2929
#include "architecture/msgPayloadDefC/AccessMsgPayload.h"
30+
#include "architecture/msgPayloadDefC/EclipseMsgPayload.h"
3031
#include "architecture/msgPayloadDefC/SCStatesMsgPayload.h"
3132
#include "architecture/msgPayloadDefC/SpicePlanetStateMsgPayload.h"
3233

@@ -55,10 +56,12 @@ class SpacecraftLocation : public SysModel
5556
Eigen::Vector3d aHat_B; //!< [] (optional) unit direction vector of the sensor/communication boresight axis
5657
double theta; //!< [r] (optional) sensor/communication half-cone angle, must be set if shat_B is specified
5758
double theta_solar; //!< [r] (optional) illumination half-cone angle, treating aHat_B as the surface normal
59+
double min_shadow_factor; //!< [] (optional) minimum amount of illumination due to eclipse necessary to observe
5860

5961
ReadFunctor<SCStatesMsgPayload> primaryScStateInMsg; //!< primary spacecraft input message
60-
ReadFunctor<SpicePlanetStateMsgPayload> planetInMsg; //!< planet state input message
61-
ReadFunctor<SpicePlanetStateMsgPayload> sunInMsg; //!< [-] sun data input message
62+
ReadFunctor<SpicePlanetStateMsgPayload> planetInMsg; //!< (optional) planet state input message
63+
ReadFunctor<SpicePlanetStateMsgPayload> sunInMsg; //!< (optional) sun data input message
64+
ReadFunctor<EclipseMsgPayload> eclipseInMsg; //!< (optional) eclipse input message
6265
std::vector<Message<AccessMsgPayload>*> accessOutMsgs; //!< vector of ground location access messages
6366
std::vector<ReadFunctor<SCStatesMsgPayload>> scStateInMsgs; //!< vector of other sc state input messages
6467
Eigen::Vector3d
@@ -72,6 +75,7 @@ class SpacecraftLocation : public SysModel
7275
SCStatesMsgPayload primaryScStatesBuffer; //!< buffer of primary spacecraft states
7376
SpicePlanetStateMsgPayload planetState; //!< buffer of planet data
7477
SpicePlanetStateMsgPayload sunData; //!< buffer of sun data
78+
EclipseMsgPayload eclipseInMsgData; //!< buffer of eclipse data
7579

7680
Eigen::Matrix3d dcm_PN; //!< Rotation matrix from inertial frame N to planet-centered to planet-fixed frame P
7781
Eigen::Vector3d r_PN_N; //!< [m] Planet to inertial frame origin vector.

src/simulation/environment/spacecraftLocation/spacecraftLocation.i

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ struct SpicePlanetStateMsg_C;
4040
struct SCStatesMsg_C;
4141
%include "architecture/msgPayloadDefC/AccessMsgPayload.h"
4242
struct AccessMsg_C;
43+
%include "architecture/msgPayloadDefC/EclipseMsgPayload.h"
44+
struct EclipseMsg_C;
4345

4446
%pythoncode %{
4547
import sys

src/simulation/environment/spacecraftLocation/spacecraftLocation.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ provides information on what this message is used for.
3838
- vector of other spacecraft state input messages. These are set through ``addSpacecraftToModel()``
3939
* - sunInMsg
4040
- :ref:`SpicePlanetStateMsgPayload`
41-
- (optional) sun state input message. Used for illumination checking if the message is connected and `theta_solar` is set.
41+
- (optional) sun state input message. Used for illumination checking if the message is connected and ``theta_solar`` is set.
42+
* - eclipseInMsg
43+
- :ref:`EclipseMsgPayload`
44+
- (optional) eclipse input message. Used for illumination checking if the message is connected and ``min_shadow_factor`` is set.
4245
* - accessOutMsgs
4346
- :ref:`AccessMsgPayload`
4447
- output vector of ground location access messages
@@ -120,6 +123,8 @@ If the ``sunInMsg`` is connected and :math:`\theta_{\text{solar,max}}` is set, t
120123
.. math::
121124
\arccos \left( \hat{\bf a} \cdot \hat{\bf s} \right) = \theta_{\text{solar}} \le \theta_{\text{solar,max}}
122125
126+
If an eclipse message is connected and ``min_shadow_factor`` is set, the module will also check that the shadow factor is above this threshold.
127+
123128
User Guide
124129
----------
125130
A new instance of ``spacecraftLocation``, alongside necessary user-supplied parameters, can be created by calling:

0 commit comments

Comments
 (0)