Project Blue Streak F3(DLL)

Notebook

Addon Developer
Addon Developer
News Reporter
Donator
Joined
Nov 20, 2007
Messages
11,962
Reaction score
765
Points
188
Starting this off by modifying the ShuttlePB.dll. Have got it compiling on Visual C++ 2008 Express Edition with help from OrbiterWiki, and the Vessel tutorial.

Just modified three constants

Code:
[SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// ==============================================================[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]// Some vessel parameters[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]// ==============================================================[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] PB_FUELMASS = 89260; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//750.0;[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] PB_ISP = 248; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//5e4;[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] PB_MAXMAINTH = 1334000; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//3e4;[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] PB_MAXHOVERTH = 1.5e4;[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] PB_MAXRCSTH = 2e2;[/SIZE]

and using the debug string to show FuelRate and FuelMass

Code:
[SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// ==============================================================[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]// API callback interface[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]// ==============================================================[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ShuttlePB::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] FuelRate = GetFuelRate () ;[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] FuelMass = GetFuelMass () ;[/SIZE]
 
[SIZE=2]sprintf(oapiDebugString(),[/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"SimT %f Fuel Rate %f Fuel Mass %f"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2],SimT,FuelRate,FuelMass);[/SIZE]
[SIZE=2]}[/SIZE]

That all seems to work, but the fuel rate is about 10 times what it should be, and only lasts 15 seconds. Does get up to Mach 2 horizontally though...

This is at t=0
http://i89.photobucket.com/albums/k207/Notebook_04/09061013-34-01PB-01.jpg
and this at t=10
http://i89.photobucket.com/albums/k207/Notebook_04/09061013-35-20PB-01.jpg

I'm using fuel mass=89260kg, and thrust=1334KN(two engines).

Anyone any ideas?

Many thanks, N.
 
Last edited:
You don't use metric units.

Short and simple. ISP in seconds is wrong. Orbiter uses ISP in m/s (or more correctly N*s/kg). For conversion, just multiply the value in seconds with 9.81 m/s² (s * m/s² = m/s = Ns/kg)

And better replace all occurences of "ShuttlePB" in the code with "BlueStreak" to remind you which project you do. Are you aware of the concept of splitting a multi-staged rocket into multiple logical stages of constant structural mass?
 
AH! thanks for that Urwumpe. I'll change the names as well.

Are you aware of the concept of splitting a multi-staged rocket into multiple logical stages of constant structural mass?

Luckily F1 is single stage, so hopfully its not a problem...yet;)

Many thanks, N.

---------- Post added at 17:26 ---------- Previous post was at 14:12 ----------

I'm getting an
error C2065: 'th_main' : undeclared identifier
when this is compiled:-
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] FuelRate = GetFuelRate () ;[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] FuelMass = GetFuelMass () ;[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ISP = GetThrusterIsp(th_main);[/SIZE]
[SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//double ISP = GetISP();[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]sprintf(oapiDebugString(),[/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"SimT %0.1f ISP %0.1f Fuel Mass %.0f"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2],SimT,ISP,FuelMass);[/SIZE]
[SIZE=2]}[/SIZE]

The GetISP() works fine. I thought th_main was declared here?
Code:
[SIZE=2]th_main = CreateThruster (_V(0,0,-4.35), _V(0,0,1), PB_MAXMAINTH, hpr, VAC_MAIN_ISP, NML_MAIN_ISP, P_NML_MAIN );[/SIZE]
I think I've the constants in correctly
Code:
[SIZE=2][COLOR=#0000ff]
[SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] PB_FUELMASS = 89260; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//750.0;[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] PB_MAXMAINTH = 1334000; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// 2*RZ_2 engine //3e4;[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] PB_ISP = 2433; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// = 248s * g //5e4;[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] VAC_MAIN_ISP = 2796;[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// ISP(vac)[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] NML_MAIN_ISP = 2433;[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// ISP(sl)[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] P_NML_MAIN = 101.4e3;[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] PB_MAXHOVERTH = 1.5e4;[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] PB_MAXRCSTH = 2e4; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//2e2;[/COLOR][/SIZE]
[/COLOR][/SIZE]

All help appreciated.

N.
 
Don't forget you also need to replace the "ShuttlePB" in the expression:

"class ShuttlePB: public VESSEL2" by "class BlueStreak: public VESSEL2"

The expression starting with "class" is a class definition, in C++ you have to define all symbols you use before you use them. Also, you need to define the variables in the "scope" in which you need them.

In this case, you should have a "THRUSTER_HANDLE th_main" in your class definition without any further modification of the visibility, which means that you can only see the variable from within the class BlueStreak.

For example to explain the important concepts

Code:
class Alpha: public Beta {
THRUSTER_HANDLE th_main;
protected:
int m_stage;
public:
Alpha();
int getStage() const;
};

In this example, Alpha is a subclass of Beta, and will inherit all variables and functions from Beta, but only those being public or protected will be visible in Alpha. You can use an Alpha instead of an Beta, but not the other way around (as Beta has less "capabilities" than Alpha)

th_main is only visible to the class Alpha. That means you can use it in the implementation of the functions Alpha() and getStage(), but not from the outside.

Alpha and getStage are public (as they are defined following a "public:" statement) and can be thus used from outside the class. For example by the expression "return new Alpha();" which creates a new object of the class Alpha.

Any confusion? If not, than you have not understood it.
 
Any confusion? If not, than you have not understood it.
:lol:

Thanks Urwumpe, I shall have a read, and try and get my head around that lot, and try again.
Printed off the .cpp file, its only four pages. Didn't notice the colour highlighting in the IDE, my printer did though, and the colour cartridge has run out.
I suppose I could fill in the missing greens and blues with crayons...


Many thanks
N.
 
:lol:

Thanks Urwumpe, I shall have a read, and try and get my head around that lot, and try again.
Printed off the .cpp file, its only four pages. Didn't notice the colour highlighting in the IDE, my printer did though, and the colour cartridge has run out.
I suppose I could fill in the missing greens and blues with crayons...


Many thanks
N.

Let me give you a small hint for understanding source codes easier: Download and install doxygen. Comes now with a fine GUI and allows you to turn the source code of any C++ file into hyper referenced HTML files (and many other formats).

If you just want to understand the raw ShuttlePB sources, I can make you a PDF with doxygen from them, but if you plan to do more development in the future, doxygen is worth it.
 
Thamks Urwumpe, I'll just stick with the PB stuff for the moment. Too soon for me to get into documentation...Just crashes to desktop at the moment.

I' can't get into http://www.doxygen.org/ at the moment, no connection for me.

Edit : Link came good later, I'll download and have a look.

N.

---------- Post added at 19:36 ---------- Previous post was at 06:19 ----------

After some time... I find I had to remove the "th_main" from the BlueStreak class after it had been declared in the "Shuttle-PB class interface", as Urwumpe's info above. It works, but I don't know why!

Here is the current code:-
Code:
[SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]
// ==============================================================
// ORBITER MODULE: BlueStreak
// Part of the ORBITER SDK
// Copyright (C) 2002-2004 Martin Schweiger
// All rights reserved
//
// BlueStreak.cpp
// Control module for BlueStreak vessel class
//
// Notes:
// This is an example for a "minimal" vessel implementation which
// only overloads the clbkSetClassCaps method to define vessel
// capabilities and otherwise uses the default VESSEL class
// behaviour.
// ==============================================================
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]#define[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] STRICT
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]#define[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ORBITER_MODULE
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]#include[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"orbitersdk.h"
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// ==============================================================
// Some vessel parameters
// ==============================================================
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] PB_FUELMASS = 89260; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//750.0;
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] PB_MAXMAINTH = 1334000; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//2*RZ_2 //3e4;
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] PB_ISP = 2433; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// = 248s * g //5e4;
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] VAC_MAIN_ISP = 2796; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// ISP(vac)
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] NML_MAIN_ISP = 2433; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// ISP(sl)
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] P_NML_MAIN_ISP = 101.4e3;
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] PB_MAXHOVERTH = 1.5e4;
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] PB_MAXRCSTH = 2e4; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//2e2;
// Calculate lift coefficient [Cl] as a function of aoa (angle of attack) over -Pi ... Pi
// Implemented here as a piecewise linear function
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] LiftCoeff ([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] aoa)
{
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] nlift = 9;
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]static[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] AOA[nlift] = {-180*RAD,-60*RAD,-30*RAD,-1*RAD,15*RAD,20*RAD,25*RAD,60*RAD,180*RAD};
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]static[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] CL[nlift] = { 0, 0, -0.1, 0, 0.2, 0.25, 0.2, 0, 0};
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]static[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] SCL[nlift] = {(CL[1]-CL[0])/(AOA[1]-AOA[0]), (CL[2]-CL[1])/(AOA[2]-AOA[1]),
(CL[3]-CL[2])/(AOA[3]-AOA[2]), (CL[4]-CL[3])/(AOA[4]-AOA[3]),
(CL[5]-CL[4])/(AOA[5]-AOA[4]), (CL[6]-CL[5])/(AOA[6]-AOA[5]),
(CL[7]-CL[6])/(AOA[7]-AOA[6]), (CL[8]-CL[7])/(AOA[8]-AOA[7])};
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] i;
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]for[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (i = 0; i < nlift-1 && AOA[i+1] < aoa; i++);
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] CL[i] + (aoa-AOA[i])*SCL[i];
}
[/SIZE][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) {}
[/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=#008000][SIZE=2][COLOR=#008000]// ==============================================================
// Overloaded callback functions
// ==============================================================
// --------------------------------------------------------------
// Set the capabilities of the vessel class
// --------------------------------------------------------------
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] BlueStreak::clbkSetClassCaps (FILEHANDLE cfg)
{
THRUSTER_HANDLE th_hover, th_rcs[14], th_group[4];
[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// physical specs
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]SetSize (3.5);
SetEmptyMass (500.0);
SetCW (0.3, 0.3, 0.6, 0.9);
SetWingAspect (0.7);
SetWingEffectiveness (2.5);
SetCrossSections (_V(10.5,15.0,5.8));
SetRotDrag (_V(0.6,0.6,0.35));
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (GetFlightModel() >= 1) {
SetPitchMomentScale (1e-4);
SetBankMomentScale (1e-4);
}
SetPMI (_V(2.28,2.31,0.79));
SetTrimScale (0.05);
SetCameraOffset (_V(0,0.8,0));
SetLiftCoeffFunc (LiftCoeff);
SetDockParams (_V(0,1.3,-1), _V(0,1,0), _V(0,0,-1));
SetTouchdownPoints (_V(0,-1.5,2), _V(-1,-1.5,-1.5), _V(1,-1.5,-1.5));
[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// propellant resources
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]PROPELLANT_HANDLE hpr = CreatePropellantResource (PB_FUELMASS);
[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//Debug
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/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);

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);
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ISP = GetThrusterIsp(th_main);
[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// ***************** thruster definitions *******************
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]PARTICLESTREAMSPEC contrail_main = {
0, 5.0, 16, 200, 0.15, 1.0, 5, 3.0, PARTICLESTREAMSPEC::DIFFUSE,
PARTICLESTREAMSPEC::LVL_PSQRT, 0, 2,
PARTICLESTREAMSPEC::ATM_PLOG, 1e-4, 1
};
PARTICLESTREAMSPEC contrail_hover = {
0, 5.0, 8, 200, 0.15, 1.0, 5, 3.0, PARTICLESTREAMSPEC::DIFFUSE,
PARTICLESTREAMSPEC::LVL_PSQRT, 0, 2,
PARTICLESTREAMSPEC::ATM_PLOG, 1e-4, 1
};
PARTICLESTREAMSPEC exhaust_main = {
0, 2.0, 20, 200, 0.05, 0.1, 8, 1.0, PARTICLESTREAMSPEC::EMISSIVE,
PARTICLESTREAMSPEC::LVL_SQRT, 0, 1,
PARTICLESTREAMSPEC::ATM_PLOG, 1e-5, 0.1
};
PARTICLESTREAMSPEC exhaust_hover = {
0, 2.0, 10, 200, 0.05, 0.05, 8, 1.0, PARTICLESTREAMSPEC::EMISSIVE,
PARTICLESTREAMSPEC::LVL_SQRT, 0, 1,
PARTICLESTREAMSPEC::ATM_PLOG, 1e-5, 0.1
};
[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//th_main = CreateThruster (_V(0,0,-4.35), _V(0,0,1), PB_MAXMAINTH, hpr, PB_ISP);
[/COLOR][/SIZE][/COLOR][/SIZE][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);
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]CreateThrusterGroup (&th_main, 1, THGROUP_MAIN);
AddExhaust (th_main, 8, 1, _V(0,0.3,-4.35), _V(0,0,-1));
th_hover = CreateThruster (_V(0,-1.5,0), _V(0,1,0), PB_MAXHOVERTH, hpr, PB_ISP);
CreateThrusterGroup (&th_hover, 1, THGROUP_HOVER);
AddExhaust (th_hover, 8, 1, _V(0,-1.5,1), _V(0,-1,0));
AddExhaust (th_hover, 8, 1, _V(0,-1.5,-1), _V(0,-1,0));
AddExhaustStream (th_hover, _V(0,-3, 1), &contrail_hover);
AddExhaustStream (th_hover, _V(0,-3,-1), &contrail_hover);
AddExhaustStream (th_main, _V(0,0.3,-10), &contrail_main);
AddExhaustStream (th_hover, _V(0,-2, 1), &exhaust_hover);
AddExhaustStream (th_hover, _V(0,-2,-1), &exhaust_hover);
AddExhaustStream (th_main, _V(0,0.3,-5), &exhaust_main);
th_rcs[ 0] = CreateThruster (_V( 1,0, 3), _V(0, 1,0), PB_MAXRCSTH, hpr, PB_ISP);
th_rcs[ 1] = CreateThruster (_V( 1,0, 3), _V(0,-1,0), PB_MAXRCSTH, hpr, PB_ISP);
th_rcs[ 2] = CreateThruster (_V(-1,0, 3), _V(0, 1,0), PB_MAXRCSTH, hpr, PB_ISP);
th_rcs[ 3] = CreateThruster (_V(-1,0, 3), _V(0,-1,0), PB_MAXRCSTH, hpr, PB_ISP);
th_rcs[ 4] = CreateThruster (_V( 1,0,-3), _V(0, 1,0), PB_MAXRCSTH, hpr, PB_ISP);
th_rcs[ 5] = CreateThruster (_V( 1,0,-3), _V(0,-1,0), PB_MAXRCSTH, hpr, PB_ISP);
th_rcs[ 6] = CreateThruster (_V(-1,0,-3), _V(0, 1,0), PB_MAXRCSTH, hpr, PB_ISP);
th_rcs[ 7] = CreateThruster (_V(-1,0,-3), _V(0,-1,0), PB_MAXRCSTH, hpr, PB_ISP);
th_rcs[ 8] = CreateThruster (_V( 1,0, 3), _V(-1,0,0), PB_MAXRCSTH, hpr, PB_ISP);
th_rcs[ 9] = CreateThruster (_V(-1,0, 3), _V( 1,0,0), PB_MAXRCSTH, hpr, PB_ISP);
th_rcs[10] = CreateThruster (_V( 1,0,-3), _V(-1,0,0), PB_MAXRCSTH, hpr, PB_ISP);
th_rcs[11] = CreateThruster (_V(-1,0,-3), _V( 1,0,0), PB_MAXRCSTH, hpr, PB_ISP);
th_rcs[12] = CreateThruster (_V( 0,0,-3), _V(0,0, 1), PB_MAXRCSTH, hpr, PB_ISP);
th_rcs[13] = CreateThruster (_V( 0,0, 3), _V(0,0,-1), PB_MAXRCSTH, hpr, PB_ISP);
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);
th_group[0] = th_rcs[1];
th_group[1] = th_rcs[3];
th_group[2] = th_rcs[4];
th_group[3] = th_rcs[6];
CreateThrusterGroup (th_group, 4, THGROUP_ATT_PITCHDOWN);
th_group[0] = th_rcs[0];
th_group[1] = th_rcs[4];
th_group[2] = th_rcs[3];
th_group[3] = th_rcs[7];
CreateThrusterGroup (th_group, 4, THGROUP_ATT_BANKLEFT);
th_group[0] = th_rcs[1];
th_group[1] = th_rcs[5];
th_group[2] = th_rcs[2];
th_group[3] = th_rcs[6];
CreateThrusterGroup (th_group, 4, THGROUP_ATT_BANKRIGHT);
th_group[0] = th_rcs[0];
th_group[1] = th_rcs[4];
th_group[2] = th_rcs[2];
th_group[3] = th_rcs[6];
CreateThrusterGroup (th_group, 4, THGROUP_ATT_UP);
th_group[0] = th_rcs[1];
th_group[1] = th_rcs[5];
th_group[2] = th_rcs[3];
th_group[3] = th_rcs[7];
CreateThrusterGroup (th_group, 4, THGROUP_ATT_DOWN);
th_group[0] = th_rcs[8];
th_group[1] = th_rcs[11];
CreateThrusterGroup (th_group, 2, THGROUP_ATT_YAWLEFT);
th_group[0] = th_rcs[9];
th_group[1] = th_rcs[10];
CreateThrusterGroup (th_group, 2, THGROUP_ATT_YAWRIGHT);
th_group[0] = th_rcs[8];
th_group[1] = th_rcs[10];
CreateThrusterGroup (th_group, 2, THGROUP_ATT_LEFT);
th_group[0] = th_rcs[9];
th_group[1] = th_rcs[11];
CreateThrusterGroup (th_group, 2, THGROUP_ATT_RIGHT);
CreateThrusterGroup (th_rcs+12, 1, THGROUP_ATT_FORWARD);
CreateThrusterGroup (th_rcs+13, 1, THGROUP_ATT_BACK);
[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// visual specs
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]AddMesh ([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"BlueStreak"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);
}
[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// ==============================================================
// API callback interface
// ==============================================================
[/COLOR][/SIZE][/COLOR][/SIZE][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] FuelRate = GetFuelRate();
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] FuelMass = GetFuelMass();
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ISP = GetThrusterIsp(th_main);
[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//double ISP = GetISP();
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//ISP=ISP/2;
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]sprintf(oapiDebugString(), [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"SimT %0.1f ISP %0.1f FuelMass %.0f"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], SimT, ISP, FuelMass);
}
[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// --------------------------------------------------------------
// Vessel initialisation
// --------------------------------------------------------------
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]DLLCLBK VESSEL *ovcInit (OBJHANDLE hvessel, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] flightmodel)
{
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] BlueStreak (hvessel, flightmodel);
}
[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// --------------------------------------------------------------
// Vessel cleanup
// --------------------------------------------------------------
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]DLLCLBK [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ovcExit (VESSEL *vessel)
{
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (vessel) [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]delete[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (BlueStreak*)vessel;
}
[/SIZE]

So it is reading the ISP with altitude:-
http://i89.photobucket.com/albums/k207/Notebook_04/09061119-17-35PB-01.jpg
http://i89.photobucket.com/albums/k207/Notebook_04/09061119-16-39PB-01.jpg

A couple of questions/
How can I tell what the class interface needs? It wanted the Thruster_Handle, but only for main_th?
Why didn't I have to put the GetThrusterIsp() function into the class interface?

All inputs apperciated.

N.





 
Last edited:
Because GetThrusterISP is already defined in the class VESSEL.

You have to remember:

VESSEL2 inherited all functions and variables from VESSEL
BlueStreak inherited all functions and variables from VESSEL2.

This relation is transitive and thus: BlueStreak also has all functions and variables from VESSEL. ;)
 
Thanks for that Urwumpe, it may sink in after awhile...

Next task, modifying the thrust/altitude behaviour. Should be fun.

N.
 
Looking at the CreateThruster function, and how it alters the thrust with altitude:-

http://i89.photobucket.com/albums/k207/Notebook_04/BlueStreakCreateThruster.jpg
I had the RZ2 engine data from a previous document.

It has extra thrust for a lot of the flight time, lift-off compared to the real thing, should I worry about this? It would be nice to get it as accurate as reasonable, would I have to write my own function, or would it be easier to modify the ISP or thrust in flight?

Many thanks, N.
 
Orbiters modeling of the ISP by ambient pressure should be pretty much the real thing for you. Don't you run at 100% thrust all the time? You only need special functions if you have strong variations in mass flow and chamber pressure, if both is constant Orbiters model is pretty accurate.
 
Indeed 100% all the time! And why not!!!!? :lol:
Considering my p(h) is not accurate, so the thrust of the RZ_2 won't be accurate, and its results are within 10% of Orbiter data, then Orbiter CreateThruster(lots of paramaters) is the function I should use?
Thats where its going to fly in the end.

Just trying to keep the Mathcad in sync with what I'm trying to do in C++ stuff.
I now see the need for documentation!

Next task, rotating the PB 90 degrees to a tail-sitter.

Many thanks, N.
 
Last edited:
Tail-sitter = either use attachments to connect the launcher to the launch complex or put all three touchdown points in the same plane, parallel to the XY plane (= all three points have the same z coordinate).
 
No, that cross product is just the definition of on which side of the triangle formed by the three TD points is up.
 
OK, so as long as I get a positive value for the Y element in the cross-product, orbiter will be happy?
I ask, because I thought I could get away with just putting 2metres for all the Z elements. Orbiter didn't like that,

http://i89.photobucket.com/albums/k207/Notebook_04/09061410-19-57PB-01.jpg

and when I checked the cross products were elements were all zero.

It appeared to be working, the ShuttlePB was sitting on its tail, and lifted-off verically, marvellous! When it came back to ground level, the mesh turned white, and the Earth dissapeared. Don't know where it went, or me either!
Time for some matrix algebra then...what fun.

N.
 
OK, so as long as I get a positive value for the Y element in the cross-product, orbiter will be happy?
I ask, because I thought I could get away with just putting 2metres for all the Z elements. Orbiter didn't like that,

http://i89.photobucket.com/albums/k207/Notebook_04/09061410-19-57PB-01.jpg

and when I checked the cross products were elements were all zero.
That sounds like the vectors defining the touchdown points were either pointing in the same direction or in directly opposite directions, in which case the cross product is a null vector and Orbiter can't determine an "up" direction and undefined behaviour will result, as you found out. No positive "Y" value is required but some value is required. For a tail sitter, you want the cross product to be some scalar multiple (doesn't matter what value) of the vector {0,0,1}.
 
Thanks tblaxland, I think I'm confusing the co-ordinates. The "Up" vector is in Orbiters world, not the vessels'? So the vessels' Z vector should match the "Up" vector in Orbiter.

N.
 
Thanks tblaxland, I think I'm confusing the co-ordinates. The "Up" vector is in Orbiters world, not the vessels'? So the vessels' Z vector should match the "Up" vector in Orbiter.
Yes, except I think we are talking in slightly different languages :P

Let me try and it explain it in different words. When your vessel enters a landed state, Orbiter calculates the direction of the "up" vector from the touchdown points. This vector is measured against the vessel's coordinate frame. Orbiter will rotate your vessel so that the "up" vector is perpendicular to the local ground plane for the position on the planet where you happen to be landed.
 
Ok, that makes sense. Just have to make the numbers work now!

N.

---------- Post added at 09:22 ---------- Previous post was at 08:59 ----------

Well, its nearly there...

http://i89.photobucket.com/albums/k207/Notebook_04/Touchdown.jpg

N.

---------- Post added at 09:57 ---------- Previous post was at 09:22 ----------

For BlueStreak with a radius of 1.524 metres, I used these values for the touchdown points.
Code:
[SIZE=2]
[SIZE=2]SetTouchdownPoints (_V(0,-1.524,-5), _V(-1.32,-0.762,-5), _V(1.32,-0.762,-5));
[/SIZE][/SIZE]
Kept the nose-wheel at the x = zero, and assumed the other two at 120 degrees from that to get equally spaced points. Took the sin and cos of the radius to get the x and y values.
That works, its pointing the right way now!


Is this the correct orientation of the vessel axis for a tail-sitter, looking down from the nose?

http://i89.photobucket.com/albums/k207/Notebook_04/VesselAxes.jpg

All help appreciated.
 
Back
Top