Problems with callfunction() [long!]

MATLAB-specific help discussions.

Problems with callfunction() [long!]

Postby jem » Mon Jul 13, 2009 10:09 pm

Hello,

I'll start with a general idea of what I am trying to do:
In a targeting loop, I want to use "GMAN" to execute a maneuver with a GMAT-suggested
|dV> ("ket" used to denote a vector) and return the new spacecraft state. My mission
segment looks something like:
.
.
.
Target DefaultDC;
Vary DefaultDC(DefaultIB.Element1 = 0);
Vary DefaultDC(DefaultIB.Element2 = 0);
Vary DefaultDC(DefaultIB.Element3 = 0);
Maneuver DefaultIB(DefaultSC);
GMAT [SC_STATE] = bar(SC_STATE, IB_X, IB_Y, IB_Z); % This function configures a call to GMAN and
% returns the spacecraft state.
Achieve DefaultDC(DefaultSC.Earth.VX = ORM1A(5));
Achieve DefaultDC(DefaultSC.Earth.VY = ORM1A(6));
Achieve DefaultDC(DefaultSC.Earth.VZ = ORM1A(7));
EndTarget; % For targeter DefaultDC
.
.
.
Where I have shortened some lines for brevity and I have created variables
for the |dV> due to issues listed below.

I am running GMAT (v.Jun 17 2009 17:22:10) on Win XP Professional/2002/sp 3.

While I am able to have the matlab function (R2008b) pass variables and execute,
I have the following difficulties:

1> I cannot use GMAT-defined variables (e.g., DefaultSC.X or DefaultIB.Element1)
directly in the function argument list. When I do so and try to build my script,
I get a very cryptic message: Errors were found in the script... I am able to
accomplish something useful by using user-defined variables, but then I run
into more problems--see the next item.

2> If I put more than 10 variables (which I need for all the information which needs
to pass through) in the argument list, I get a windows (Dr. Watson/"General
Protection Fault"-type) error when the matlab function is called.

3> If I try to pack this information in an array, I run into several other types of
problems:
a) I cannot assign a GMAN-defined variable to an array element. I get an
error:
1: **** ERROR **** GmatBase Exception Thrown: The object named "DefaultSC" of type "Spacecraft" has no parameter defined with "UTCModJulian" in line:
" 148: GMAT SC_STATE(1,1) = DefaultSC.UTCModJulian;"

which is bogus, because I have no problem assigning this to a regular variable
and passing it to a matlab function.

b) If I try to use intermediate, user-defined variables assigned through an array, the
values of the GMAT-defined variables do not show up in the function, I just get
zeros, where as just passing through with user-defined variables, I see that the
values updated.

My only work around seems to be to use separate matlab functions for different segments of
the spacecraft state data, which are collected into a file for the ultimate call to GMAN. It
seems to be a lot of work and rife with potential error.

Is there a better way forward? I need a solution quickly as I am rapidly getting close to being
on the critical path of the overall project.

Thanks in advance for any assistance you can offer.

Cheers,

Jeff
______________________________________________________________________
Jeff Marchese Space Sciences Laboratory
THEMIS Flight Dynamics Analyst University of California
jem ssl berkeley ed-you 7 Gauss Way, A228
Berkeley, CA 94720-7450
jem
 
Posts: 3
Joined: Mon Jul 13, 2009 8:58 pm

Re: Problems with callfunction() [long!]

Postby shughes » Wed Jul 15, 2009 9:26 pm

jem wrote: 2> If I put more than 10 variables (which I need for all the information which needs
to pass through) in the argument list, I get a windows (Dr. Watson/"General
Protection Fault"-type) error when the matlab function is called.


This is a nasty bug that we should fix. Would you mind creating a bugzilla account (http://pows003.gsfc.nasa.gov/bugzilla/) and checking it in so we can fix it?


More on the other issues soon.
shughes
 
Posts: 443
Joined: Mon Jun 09, 2008 6:27 pm

Re: Problems with callfunction() [long!]

Postby shughes » Wed Jul 15, 2009 9:40 pm

You can send entire spacecraft objects and entire maneuver objects to matlab. Let me know if that works for you problem... Here is an example

Code: Select all
Create Spacecraft DefaultSC;
Create ForceModel DefaultProp_ForceModel;
Create Propagator DefaultProp;
Create ImpulsiveBurn DefaultIB;
Create MatlabFunction SendDataToMatlab;
Create Variable flag

%----------------------------------------
%---------- Mission Sequence
%----------------------------------------
[flag] = SendDataToMatlab(DefaultSC,DefaultIB);

Propagate DefaultProp(DefaultSC) {DefaultSC.ElapsedSecs = 8640.0};


shughes
 
Posts: 443
Joined: Mon Jun 09, 2008 6:27 pm

Re: Problems with callfunction() [long!]

Postby shughes » Wed Jul 15, 2009 9:46 pm

jem wrote:
Target DefaultDC;
Vary DefaultDC(DefaultIB.Element1 = 0);
Vary DefaultDC(DefaultIB.Element2 = 0);
Vary DefaultDC(DefaultIB.Element3 = 0);
Maneuver DefaultIB(DefaultSC);
GMAT [SC_STATE] = bar(SC_STATE, IB_X, IB_Y, IB_Z); % This function configures a call to GMAN and
% returns the spacecraft state.
Achieve DefaultDC(DefaultSC.Earth.VX = ORM1A(5));
Achieve DefaultDC(DefaultSC.Earth.VY = ORM1A(6));
Achieve DefaultDC(DefaultSC.Earth.VZ = ORM1A(7));
EndTarget; % For targeter DefaultDC


I'm a little concerned that the differential corrector will not converge for this problem depending upon what GMAN is doing and what is contained in the ORMA1A array. Is ORM1A data coming back from GMAN? If you have trouble getting it to converge can you let me know more about what happens in the Targe loop?
shughes
 
Posts: 443
Joined: Mon Jun 09, 2008 6:27 pm

Re: Problems with callfunction() [long!]

Postby jem » Fri Aug 14, 2009 7:51 pm

Sorry for the delay in replying. I didn't received the e-mails from the follow-up posts
and I have been too busy with other tasks to check the message board (I made the
mistake of relying on the e-mails).

> I have posted the argument passing bug to bugzilla.

> Passing the whole objects, ala:
Code: Select all
GMAT [flag] = SendDataToMatlab(DefaultSC, DefaultIB);


works well. Thanks for the tip!

> Don't worry about the rest of the code I posted, too much. I am mostly using it as
a test bed for testing my data passing. I promise I won't change the target *goals* in
the called function.

Thanks again for your help.

Jeff
jem
 
Posts: 3
Joined: Mon Jul 13, 2009 8:58 pm


Return to MATLAB Help

Who is online

Users browsing this forum: No registered users and 2 guests

cron