How to sync visualization on scenarioAlbedo.py #255
-
I'm trying to alter scenarioAlbedo.py to generate a Vizard file, but the illumination of the Earth doesn't match the CSS values (CSS blackout occurs when over sunlit Earth, CSS values occur in visualization eclipse). What am I missing? Here is my diff for scenarioAlbedo.py from Basilisk.utilities import SimulationBaseClass
from Basilisk.utilities import unitTestSupport # general support file with common unit test functions
import matplotlib.pyplot as plt
-from Basilisk.utilities import macros, simIncludeGravBody
+from Basilisk.utilities import macros, simIncludeGravBody, vizSupport
from Basilisk.simulation import coarseSunSensor
from Basilisk.simulation import albedo
from Basilisk.simulation import eclipse
@@ -246,7 +246,7 @@ def run(show_plots, albedoData, multipleInstrument, multiplePlanet, useEclipse,
# set the simulation time
n = np.sqrt(planet1.mu / oe.a / oe.a / oe.a)
P = 2. * np.pi / n
- simulationTime = macros.sec2nano(0.5 * P)
+ simulationTime = macros.sec2nano(P)
# Set initial spacecraft states
scObject.hub.r_CN_NInit = rN # m - r_CN_N
scObject.hub.v_CN_NInit = vN # m - v_CN_N
@@ -311,6 +311,7 @@ def run(show_plots, albedoData, multipleInstrument, multiplePlanet, useEclipse,
albModule.addInstrumentConfig(config1)
# CSS albedo input message names should be defined after adding instrument to module
CSS1.albedoInMsg.subscribeTo(albModule.albOutMsgs[0])
+ cssList = [CSS1]
if multipleInstrument:
# CSS-2
CSS2 = coarseSunSensor.CoarseSunSensor()
@@ -326,6 +327,10 @@ def run(show_plots, albedoData, multipleInstrument, multiplePlanet, useEclipse,
CSS3.nHat_B = np.array([0., -1., 0.])
albModule.addInstrumentConfig(CSS3.fov, CSS3.nHat_B, CSS3.r_PB_B)
CSS3.albedoInMsg.subscribeTo(albModule.albOutMsgs[2])
+
+ cssList.extend([CSS2, CSS3])
+
+
#
# Add albedo and CSS to task and setup logging before the simulation is initialized
#
@@ -353,6 +358,17 @@ def run(show_plots, albedoData, multipleInstrument, multiplePlanet, useEclipse,
css3Log = CSS3.cssDataOutMsg.recorder()
scSim.AddModelToTask(simTaskName, css3Log)
+
+ # Configure vizard settings
+ vizFile = os.path.realpath(__file__).strip(".py")
+ viz = vizSupport.enableUnityVisualization(scSim, simTaskName, scObject,
+ saveFile=vizFile,
+ cssList=[cssList]
+ )
+
+ vizSupport.setInstrumentGuiSetting(viz, viewCSSPanel=True, viewCSSCoverage=True,
+ viewCSSBoresight=True, showCSSLabels=True)
+
#
# Initialize Simulation
# |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Just noticed it may have something to do with what looks like a dummy planet being used for the eclipse: planetPositionMsg1 = messaging.SpicePlanetStateMsgPayload()
planetPositionMsg1.PositionVector = [0., 0., 0.]
planetPositionMsg1.PlanetName = planetCase1
planetPositionMsg1.J20002Pfix = np.identity(3)
pl1Msg = messaging.SpicePlanetStateMsg().write(planetPositionMsg1)
. . .
if useEclipse:
albModule.eclipseCase = True
eclipseObject = eclipse.Eclipse()
eclipseObject.sunInMsg.subscribeTo(sunMsg)
eclipseObject.addSpacecraftToModel(scObject.scStateOutMsg)
eclipseObject.addPlanetToModel(pl1Msg)
scSim.AddModelToTask(simTaskName, eclipseObject) |
Beta Was this translation helpful? Give feedback.
-
Okay, I figured it out. It's not just the planet1 hard-coded position, but the hard-coded positions for planet1 and the sun. The sun in this scenario is just a sun message with position. I assume Vizard doesn't take that sun message into account since no sun was made with the gravFactory. The fix is to create the sun and Earth using the gravFactory and Spice (see the flyby scenario for example) and then create position messages for the Earth and the sun based on Spice. Based on the Flyby scenario code, this might look like: sunPositionMsg = gravFactory.spiceObject.planetStateOutMsgs[sunIdx]
earthPositionMsg = gravFactory.spiceObject.planetStateOutMsgs[earthIdx] The sun position message then gets used in the CSS input and the Earth position message can be used in the eclipse. |
Beta Was this translation helpful? Give feedback.
Okay, I figured it out. It's not just the planet1 hard-coded position, but the hard-coded positions for planet1 and the sun. The sun in this scenario is just a sun message with position. I assume Vizard doesn't take that sun message into account since no sun was made with the gravFactory. The fix is to create the sun and Earth using the gravFactory and Spice (see the flyby scenario for example) and then create position messages for the Earth and the sun based on Spice. Based on the Flyby scenario code, this might look like:
The sun position me…