Project Blue Streak F3(DLL)

Just comparing the performance of this model with some real world data.
The flight profile includes a vertical rise for 20 seconds, using s=0.5*(11.81m/s^2)*(20)^2 gives me 2360 metres.
This is what I get after 20 seconds of vertical(nearly!) rise, dosen't quite match.

http://i89.photobucket.com/albums/k207/Notebook_04/09061610-14-59PB-01.jpg

I only get .61 Km rather than 2.360 Km?

Anyone see what I'm missing?

Edit: 11.81 is the rocket acceleration, should have subtracted g from that to get the "net" acceleration. this is 2.01m/s^2 ,and gives 402m.
Considering the model gives 13.8m/s^" at launch, this gives 800 metres. Near enough at the moment, I think.



Many thanks, N.

---------- Post added at 12:56 ---------- Previous post was at 10:28 ----------

I want to look at the fuel flow rate, and put this function into the code so far; GetFuelRate.
Code:
[SIZE=2][COLOR=#0000ff]
[SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] BlueStreak::clbkPreStep([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] SimT, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] SimDT, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Mjd){[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Mass = GetMass(); [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//Launch Mass = 96428kg [/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] FuelMass = GetFuelMass();[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Launch Fuel Mass 89260kg[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ISP = GetThrusterIsp(th_main);[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] FuelRate = GetFuelRate();[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Force = PB_MAXMAINTH; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// = 1334000 KN[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Acceleration=Force/Mass;[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Launch acceleration = 1334000/96428 = 13.83m/s/s[/COLOR][/SIZE]
[/COLOR][/SIZE]
[SIZE=2]sprintf(oapiDebugString(), [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"SimT %0.1f ISP %0.1f Acceleration %.2f m/s^2 FuelRate %0.1f Mass %0.1f "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] , SimT, ISP, Acceleration, FuelRate, Mass)[/SIZE]
This works, but the digits are changing too fast to read except for the first one. Is there a preferred way of getting this data every second rather than every clbkPreStep?
Seems a waste to call this every time-step, when its only needed every second or so?

Many thanks, N.
 
Last edited:
This works, but the digits are changing too fast to read except for the first one. Is there a preferred way of getting this data every second rather than every clbkPreStep?
Seems a waste to call this every time-step, when its only needed every second or so?
Like this:
Code:
[FONT=Courier New]#define [/FONT][FONT=Courier New][SIZE=2]DEBUG_UPDATE_INTERVAL 1.0 // update the debug string every second

[/SIZE][/FONT][FONT=Courier New]class BlueStreak:public VESSEL2 {
  //...
private:
  //...
  double nextDebugUpdateTime; // a private member variable that stores when you should next update the debug string
  //...
}

BlueStreak::BlueStreak(/*...*/): VESSEL2(/*...*/),nextDebugUpdateTime(0) // initialise it to zero when the object is created
{//...}

[/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] BlueStreak::clbkPreStep([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] SimT, [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] SimDT, [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] Mjd){[/SIZE][/FONT][FONT=Courier New]
  if (SimT >= nextDebugUpdateTime) {
    [/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] Mass = GetMass();[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000] //Launch Mass = 96428kg [/COLOR][/SIZE]
    [/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] FuelMass = GetFuelMass(); [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Launch Fuel Mass 89260kg[/COLOR][/SIZE]
    [/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] ISP = GetThrusterIsp(th_main);[/SIZE][/FONT][FONT=Courier New]
    [/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] FuelRate = GetFuelRate();[/SIZE][/FONT][FONT=Courier New]
    [/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] Force = PB_MAXMAINTH; [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// = 1334000 KN[/COLOR][/SIZE]
    [/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] Acceleration=Force/Mass;[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Launch acceleration = 1334000/96428 = 13.83m/s/s[/COLOR][/SIZE]
    [/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]sprintf(oapiDebugString(), [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"SimT %0.1f ISP %0.1f Acceleration %.2f m/s^2 FuelRate %0.1f Mass %0.1f "[/COLOR][/SIZE][/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] , SimT, ISP, Acceleration, FuelRate, Mass)
    nextDebugUpdateTime += DEBUG_UPDATE_INTERVAL*oapiGetTimeAcceleration();
  }
//...
}[/FONT]
[/SIZE]
 
Thanks tblaxland, I'll give that a go.

N.

---------- Post added at 14:49 ---------- Previous post was at 13:45 ----------

That works nicely.

This is the latest "class interface" code:-
Code:
[SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]
// ==============================================================
// Shuttle-PB class interface
// ==============================================================
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]class[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] BlueStreak: [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] VESSEL2 {
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]:
BlueStreak (OBJHANDLE hVessel, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] flightmodel)
: VESSEL2 (hVessel, flightmodel),nextDebugUpdateTime(0) {}
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] clbkSetClassCaps (FILEHANDLE cfg);
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] clbkPreStep([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] SimT, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] SimDT, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Mjd);
THRUSTER_HANDLE th_main ;
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]private[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]:
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] nextDebugUpdateTime; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// a private member variable that stores when you should next update the debug string
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]};
[/SIZE]

I see ",nextDebugUpdateTime(0)" is just added to the end of the existing VESSEL2 function. Can any number of functions be added like this? within reason of course.

N.
 
I see ",nextDebugUpdateTime(0)" is just added to the end of the existing VESSEL2 function. Can any number of functions be added like this? within reason of course.

No known limits, but I recommend strongly, to have only as many functions inside a class, as you really need. So called "blob" classes with extremely large numbers of functions happen easily, and are a pain in the ass to maintain and extend.

Better use the powers of object orientation in C++, especially specialization (creating subclasses with extended behavior) and composition (Add objects to a class) are useful tools. ;)
 
Yes, I can see how it could get into a real mess. Looking at other samples, I'm guessing "class interface" should be in a header file?

N.
 
Yes, like all definitions. Use C++ files only for the implementation of stuff, if possible. Of course, the first rule of the book is always, don't get caught playing by the rules. ;)
 
Little chance of that, I haven't got the book, never mind the rules!

I think this ShuttlePB style will do for this simple start. When I get the principles down, maybe move onto using .h files.

N.

---------- Post added at 19:29 ---------- Previous post was at 15:39 ----------

Making it into a two engine rocket, with each having PB_MAXMAINTH/2 thrust.
This works, (if the AddExhaust is commented out, otherwise its interior of the Sun). I don't think it should?

Code:
[SIZE=2]
[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//th_main = CreateThruster (_V(0,0,-4.35), _V(0,0,1), PB_MAXMAINTH, hpr, VAC_MAIN_ISP, NML_MAIN_ISP, P_NML_MAIN_ISP);// original th_main.
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]
th_PackA = CreateThruster (_V(-0.762,0,0), _V(0,0,1), PB_MAXMAINTH/2, hpr, VAC_MAIN_ISP, NML_MAIN_ISP, P_NML_MAIN_ISP);
th_PackB = CreateThruster (_V(0.762,0,0), _V(0,0,1), PB_MAXMAINTH/2, hpr, VAC_MAIN_ISP, NML_MAIN_ISP, P_NML_MAIN_ISP);

th_PackGroup[0] = th_PackA;
th_PackGroup[1] = th_PackB;

th_main = CreateThrusterGroup (th_PackGroup, 2, THGROUP_MAIN);

[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//CreateThrusterGroup (&th_PackB, 1, THGROUP_MAIN);
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//AddExhaust (th_main, 1, 1, _V(-0.762,0,0), _V(0,0,-1));
[/COLOR][/SIZE][/COLOR][/SIZE]

Had to add "th_main" = CreateThrusterGroup(...) this is correct according to page 60 API_Reference document. However the Shuttle_PB gets away with out a th_handle.

Code:
[SIZE=2]
th_group[0] = th_rcs[0];
th_group[1] = th_rcs[2];
th_group[2] = th_rcs[5];
th_group[3] = th_rcs[7];
CreateThrusterGroup (th_group, 4, THGROUP_ATT_PITCHUP);
[/SIZE]

Don't understand how that is?

All help appreciated.

N.
 
CreateThrusterGroup wants an array of thruster handles as input and gives you a thruster group handle as output. The Thruster Group Handle is also the reason why AddExhaust fails - it expects a thruster handle as input.

so, if you would have written

Code:
THRUSTER_HANDLE thPack[2];
in the class definition instead of thPackA and thPackB, you would have had an array of two thruster handles already, replacing the two separate variables.

For using the array, you would have then used the syntax:

Code:
th_Pack[0] = CreateThruster (_V(-0.762,0,0), _V(0,0,1), PB_MAXMAINTH/2, hpr, VAC_MAIN_ISP, NML_MAIN_ISP, P_NML_MAIN_ISP);
th_Pack[1] = CreateThruster (_V(0.762,0,0), _V(0,0,1), PB_MAXMAINTH/2, hpr, VAC_MAIN_ISP, NML_MAIN_ISP, P_NML_MAIN_ISP);
instead. The first element of an array is always [0]. Arrays are also practically open-ended during access, you need always to make sure, you don't try to read or write to an element in the array, which does not exist. If you have two elements in the array, the index 0 and 1 would be correct, 2 (thPack[2]) would be outside the bounds of the array.

This array can be dropped directly into CreateThrusterGroup.
 
Thanks Urwumpe, I'll get on it right away, and then I think I'll go and read some more C++ books!

N.
 
Thanks Urwumpe, I'll get on it right away, and then I think I'll go and read some more C++ books!

N.

You only need the Stroustrup one, the remaining books are for people who have a sub-terrestrial apogee. ;)
 
Well, thats where its heading at the moment;) Getting there bit by bit....oh dear.

N.
 
Well, thats where its heading at the moment;) Getting there bit by bit....oh dear.

Don't worry. It is not as hard as it looks on the first sight. ;)
 
I see ",nextDebugUpdateTime(0)" is just added to the end of the existing VESSEL2 function. Can any number of functions be added like this? within reason of course.
They are not a functions (despite what it looks like :P). The part of the constructor (you know what that is?) to the right of the colon is an initialiser list. What that code means is this:
When an new BlueStreak object is created, call the base class (VESSEL2) constructor with the values hVessel and flightmodel, then set nextDebugUpdateTime to 0, then call any other code in the constructor (ie, contained between the braces {} - you have none in this case).
Whilst you need not use the initialiser list at all (you could be put nextDebugUpdateTime = 0; in the constructor function) it is more efficient to do so.

For more information see here: http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.6
 
Thanks tb, I'll have a read of the link material. Have a vague concept of constructor/destructor, but nothing usefull. This is the longest bit of C++ I've ever done, except for some tutorials.

As in # 28 above, I'm still confused why the ShuttlePB gets away with using the
Code:
CreateThrusterGroup (th_group, 4, THGROUP_ATT_PITCHUP);
without having a "th_somehandle =" before it?

Thakns, N.
 
Well, that'll keep me quiet for a bit!
I thought if that was the way the "Function" worked, you had use the template it gives.
So, for "CreateThrusterGroup (th_group, 4, THGROUP_ATT_PITCHUP);". This works, and the programmer wasn't interested in any return value?

N.
 
Yes. You only need the return value for custom thruster groups types, not for the standard groups.
 
Ah, now the light at the end of the tunnel dawns...

N.

---------- Post added at 11:20 ---------- Previous post was at 10:44 ----------

Making a few test flights at the moment to get some data, and this is a typical one:-

http://s89.photobucket.com/albums/k207/Notebook_04/?action=view&current=BlueStreakF1.flv

Have to pitch over to 80 plus degrees to get the heading onto 90 degress, then approximating 1 degree/second til 30/20 degrees pitch at SimT +90.
Had to use a x10 at one point to keep the .avi small.

The Fuel Flow Rate is varying quite a bit, even though the thrust is constant?

I'm using the KillRott to keep the pitch as steady as I can, would this affect it that much.

N.
 
So, for "CreateThrusterGroup (th_group, 4, THGROUP_ATT_PITCHUP);". This works, and the programmer wasn't interested in any return value?
In slightly more technical terms, the CreateThrusterGroup functions creates a temporary variable on the stack which holds the return value (effectively just a space in memory with the value in it). You can either choose to copy that return value to some other variable (by using the assignment "=" operator) or you can just ignore it. Either way, the temporary variable gets dropped from the stack at the next operation.

EDIT: Urwumpe, you can force a programmer to accept your return value but not force them to do something appropriate with it :P Horses to water, and all that...
 
Back
Top