@@ -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 }
0 commit comments