Skip to content

Simulation Terminates Shortly After Running #1149

Description

@drewskwar-ship-it

Hello, I'm pretty new to python and have been asked to start learning Basilisk and Vizard for a project in college. Currently, I'm editing the scenarioDragDeorbit.py file and have encountered an issue after creating instances of the Earth and Sun using spice, where the event to end the simulation will render true shortly after beginning.

    gravFactory.ModelTag = "planets" #names the module
    gravBodies = gravFactory.createBodies("earth", "sun") #creates the earth and sun
    planet = gravBodies["earth"] #planet will call the earth
    sun = gravBodies["sun"] #sun will call the sun
    gravFactory.addBodiesTo(scObject) #tells Basilisk that these bodies will affect the craft
    timeInitString = "2007 JUNE 19 00:28:30.0" #sets our start time
    spiceTimeStringFormat = '%Y %B %d %H:%M:%S.%f' #tells spice what the fuck the above string means
    timeInit = datetime.strptime(timeInitString, spiceTimeStringFormat) #creates time as a module
    mu = planet.mu #sets mu so that the later funcitons wont freak out
    spiceObject = gravFactory.createSpiceInterface(time=timeInitString, epochInMsg=True) #tells spice to tell everything else that this is the time
    spiceObject.zeroBase = "Earth" #sets the earth as the center of the sim
    scSim.AddModelToTask(simTaskName, spiceObject) #adds spice to the sim task

heres the main lines that I edited.

        "Deorbited",
        simulationTimeStep,
        True,
        conditionFunction=lambda self: np.linalg.norm(
            self.spacecraft.scStateOutMsg.read().r_BN_N
        )
        < planet.radEquator + 1000 * deorbitAlt,
        terminal=True,
    )

and then here's the event in question. I'm not exactly sure about what's going on because it seems to be a logic error and I'm not an experienced programmer so some help would be very appreciated. Additionally, if someone could explain the format of the creatNewEvent() function, it would also be very appreciated. attached is the script

scenarioDragDeorbit.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions