invoking propagators from within a plugin ...

Development of custom GMAT plugins

invoking propagators from within a plugin ...

Postby marchand » Tue Jul 17, 2012 8:14 pm

I have a plugin, derived from the GmatCommand class, which requires the ability to propagate the state, but propagation is not its primary purpose, it's simply something that must be done to accomplish the goal. That propagation actually happens inside an iterative process, so it gets repeated several times while the corresponding GMAT command is executing. Can anyone offer some thoughts on how I might access that functionality from within the plugin source in the simplest possible manner?

I have been going over the source code, searching for related examples, and I was able to identify three instances of something that might be helpful, but I want to make sure there isn't a simpler approach before I go down that rabbit hole. The three classes I identified are Propagate , RunSimulator, and RunEstimator , the latter two are part of the libEstimation plugin.

Regardless of which of these examples you choose, at some level, each of these classes will ultimately extend the PropagationEnabledCommand class. Inside PropagationEnabledCommand, under the protected variables section, are declarations of pointers to the ODEModel , Propagator, and PropagationStateManager, all of which are used inside the PropagationEnabledCommand. From what I can deduce, the Step method within the latter class is the one that actually performs the propagation and updates the state of the object in GMAT. Is that accurate?

Is there a simpler way of implementing a propagation, inside my plugin, that uses GMAT's propagators? I already have, within the plugin, access to the spacecraft object and all the information I need to drive the propagation. What I'm looking for is the C++ equivalent to the Propagate command I would normally access from the scripting interface, except I want to call it from C++. The results of that need not drive any graphics in GMAT at this point. It would mostly output information to the console.

Thanks.
marchand
 
Posts: 86
Joined: Tue Feb 21, 2012 2:42 pm

Re: invoking propagators from within a plugin ...

Postby jjkparker » Fri Jul 20, 2012 5:42 pm

The answer from our side is that following the examples of the three classes you pointed out is going to be your best bet... especially RunSimulator.
Joel J. K. Parker
Flight dynamics engineer, GMAT team
http://gmatcentral.org
jjkparker
 
Posts: 617
Joined: Thu Jan 07, 2010 9:48 pm
Location: NASA Goddard Space Flight Center, Greenbelt, MD

Re: invoking propagators from within a plugin ...

Postby davidf » Thu Jul 26, 2012 4:08 pm

Joel-

I'm picking up where Belinda left off on this part of our task. I've looked at the classes referenced in the original question and your answer, and I'm not sure that they really show what we're interested in doing. It appears that what we need is in there, but it that it is intermixed with other functions in a way that I'm finding difficult to separate - at least given my current understanding of the overall GMAT structure.

Belinda originally identified three classes that are commands. I think, after some further review, what we really want is to directly access an object of type Propagator, which extends directly from GmatBase. This is an abstract class (i.e. contains pure virtual functions) that forms the base for things like AdamsBashforthMoulton. To be concrete, let's say that I have this in a script (which I've taken from Ex_HohmannTransfer.script):
Code: Select all
%----------------------------------------
%---------- ForceModels and Propagators
%----------------------------------------

Create ForceModel DefaultProp_ForceModel;
GMAT DefaultProp_ForceModel.CentralBody = Earth;
GMAT DefaultProp_ForceModel.PointMasses = {Earth};
GMAT DefaultProp_ForceModel.Drag = None;
GMAT DefaultProp_ForceModel.SRP = Off;
GMAT DefaultProp_ForceModel.RelativisticCorrection = Off;
GMAT DefaultProp_ForceModel.ErrorControl = RSSStep;

%----------------------------------------
%---------- Propagators
%----------------------------------------

Create Propagator DefaultProp;
GMAT DefaultProp.FM = DefaultProp_ForceModel;
GMAT DefaultProp.Type = RungeKutta89;
GMAT DefaultProp.InitialStepSize = 120;
GMAT DefaultProp.Accuracy = 9.999999999999999e-012;
GMAT DefaultProp.MinStep = 0.001;
GMAT DefaultProp.MaxStep = 2700;
GMAT DefaultProp.MaxStepAttempts = 50;
GMAT DefaultProp.StopIfAccuracyIsViolated = true;


I am writing a new command that will take DefaultProp as an argument. Let's say I use the GMAT mechanisms to get a reference and I want to use it to propagate some object that I have defined in my C++ code. I imagine that looks something like this:
Code: Select all
Propagator *p = (Propagator*) FindObject("DefaultProp");
Real dt = 60; // Will propagate this many seconds into future.
p->Step(dt);
Real *state = p->GetState();
Integer lengthOfStateVector = p->GetDimension();


Ideally / hopefuly state now points to an array of Real that contain the elements of my state vector, which has length lengthOfStateVector. Specific questions:
  • Is that right?
  • How do I "connect" the propogator to the actual object - let's say a "Spacecraft" object - that I want to advance?
  • If I want to put this in a loop to consider multiple alternative actions (maybe different candidate burns), do I need to do something to "reset" the propagator's intial time at the beginning of the loop? (I'm guessing that I call SetTime, but I'm not completely clear on what defines t=0.)

Thanks!
davidf
 
Posts: 6
Joined: Tue Jul 10, 2012 2:58 pm


Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 1 guest