plugin that extends Spacecraft class ...

Development of custom GMAT plugins

plugin that extends Spacecraft class ...

Postby marchand » Wed Mar 27, 2013 8:49 pm

I want to create a really simple barebones extension of the Spacecraft class using the GMAT plug-in framework, call it PatchState. The factory subsystem suggests this is possible, through the CreateSpacecraft method. However, I have not been completely successful so far. An explanation follows, and the questions are underlined (three in particular) along the text.

I followed the plug-in documentation below:

as well as the examples, and the existing plug-ins like the fmincon optimizer plugin and the estimation plug-in. However, for some reason, the PatchState object type is not "registering" properly in GMAT.

Consistent with the documentation, I figured a minimal representation would require the GmatPluginFunctions code, the PatchStateFactory code (which includes a call to the CreateSpacecraft method of the factory subsystem), and a PatchState class with the four default C++ methods (constructor, destructor, copy constructor, and assignment operator). The plugin builds fine, and loads without error in GMAT. The factory says it registers the object. However, the PatchState object seems to be unavailable in GMAT anyway. If I try to access it through the scripting interface, by typing:

Code: Select all
 Create PatchState sc;

I get an error regarding an "unknown type". So, somehow the PatchState object is not registering as a legitimate type in gmat. Do the types have to be hardwired into gmatdefs.hpp in order for this to work?

My PatchState constructor calls back to the Spacecraft constructor, just like the FminconOptimizer constructor calls back to the ExternalOptimizer constructor. Inside my constructor, I define:

Code: Select all

Just like inside the FminconOptimizer constructor you have:

Code: Select all

The default C++ methods are consistent with what all the plug-in examples demonstrate. So, I'm not sure why this isnt' working. Any suggestions on what else I may need to do to get GMAT to recognize PatchState as a "type"?

Incidentally, I was able to add a GUI component by appending these lines to the GmatPluginFunctions.cpp code, using the Estimation plug-in as a model:

Code: Select all
   Gmat::PluginResource* GetMenuEntry(Integer index)
      Gmat::PluginResource* res = NULL;

      switch (index)

         case 0:
            res = new Gmat::PluginResource;
            res->nodeName = "PatchStates";
            res->parentNodeName = "";
            res->type = Gmat::SPACECRAFT;
            res->subtype = "PatchState";


      return res;

This allows me to see a "PatchStates" folder in the GMAT gui, but it's not behaving as expected otherwise. For example, in the GUI, if you right-click on Solvers-->Optimizers you'll see "SQP (FminCon)" as an option. When I click ont the Patchstate folder on the GUI, and select "Add" all I see is "Spacecraft" instead of PatchState. I'm not sure why that is.

I did a grep search through the GMAT tree and found that the menu option "SQP (fmincon)" is hardwired into the GUI code, under src/gui/app/ResourceTree.cpp (sigh!). So, the fmincon optimizer plug-in is itself not entirely a plug-in. Curiously, the same cannot be said for the Estimation plug-in, and when I right-click on the Solvers--> Estimators and select Add, I do see an option to add BatchStateEstimatorInv, for instance. There is nothing about the Estimation plug-in that lives in the GUI code, so somehow this managed to work. Then again, I had already documented in an earlier post that the Estimation plug-in GUI is rather buggy (see So.....

I can't tell what I'm doing differently fron FminconOptimizer or the estimation plugin, other than my code is very minimalistic and defines only the four default C++ methods.

Are there any SPECIFIC methods of the parent Spacecraft class that MUST be overriden in a specific format in order for GMAT to recognize my plug-in as a type, which can be accessed from either the scripting interface or the GUI?

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

Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 1 guest