Orbiter-Forum  

Go Back   Orbiter-Forum > Orbiter Addons > Addon Support & Bugs > Addon Developer Forums > Space Shuttle Ultra
Register Blogs Orbinauts List Social Groups FAQ Projects Mark Forums Read

Space Shuttle Ultra Support & development threads for Space Shuttle Ultra addon.

Reply
 
Thread Tools
Old 08-26-2014, 10:32 AM   #31
Urwumpe
Certain Super User
 
Urwumpe's Avatar

Default

Quote:
Originally Posted by gattispilot View Post
 Sure you can veto. Well the code is not finish so comments have not been added.
That's not how you do it. Comment before, while AND after you develop the code. Its an accompanying process and you do that for making your own life easier.

Especially, you have many decisions already finished at this stage (why this variable, etc), that you can comment in a final version.

And still, a lot of problems remain from just a very short excerpt of code and a quick review. Keep it clean from the start. You also don't want a surgeon to disinfect his hands after performing the surgery on you, do you?
Urwumpe is offline   Reply With Quote
Old 08-26-2014, 10:49 AM   #32
gattispilot
Addon Developer
 
gattispilot's Avatar
Default

Is this better?
Code:
void IUS1::clbkPostStep(double simt, double simdt, double mjd)
{
	if (GetAttachmentStatus(RM1))//2ND STAGE IS ATTACHED TO 1ST STAGE
	{
		newmass = STAGE1MASS+STAGE2MASS;  //MASS OF STAGE 1 AND STAGE 2 ARE ADDED
		SetEmptyMass  (newmass);    //NEW MASS OF STAGE 2 AND STAGE 1
		ATTACH_status=YES;         //2ND STAGE IS ATTACHED TO 1ST STAGE
		MAX_MAIN_THRUST = 184752.84;  // THRUST OF STAGE 1
		MAX_MAIN_FUEL = 9631;           // FUEL OF STAGE1
		SetThrusterIsp(th_main, 2898);  //SETS ISP OF STAGE 1
		SetThrusterMax0(th_main, 184752.84); //THRUST OF STAGE 1
		AddExhaust(th_main, 10, 1, _V(0, 0, -1.5), _V(0, 0, -1)); //EXHAUST location OF 1ST STAGE
	}
	if (!GetAttachmentStatus(RM1))//2ND STAGE IS NOT ATTACHED TO 1ST STAGE
	{
		
		SetEmptyMass(1170);  //EMPTY MASS OF STAGE 2 ALONE
		ATTACH_status = NO;  //2ND STAGE IS NOT ATTACHED TO 1ST STAGE
		MAX_MAIN_THRUST = 78272.76;  //THRUST OF STAGE 2 ALONE
		MAX_MAIN_FUEL = 2727.45;     //FUEL OF STAGE 2 ALONE
		SetThrusterIsp(th_main, 2977.335);  //SET ISP OF STAGE 2
		SetThrusterMax0(th_main, 78272.76);  //SET MAX THRUST OF STAGE 2 ALONE
		AddExhaust(th_main, 1, 1, _V(0, 0, -1.5), _V(0, 0, -1)); //EXHAUST location OF 2ND STAGE

	}
}
Now thrust and exhaust, mass, isp all change depending on attach status.

but I get this effect.
http://i373.photobucket.com/albums/o...psec480f11.jpg

Last edited by gattispilot; 08-26-2014 at 11:03 AM. Reason: updated code
gattispilot is offline   Reply With Quote
Old 08-26-2014, 10:58 AM   #33
Urwumpe
Certain Super User
 
Urwumpe's Avatar

Default

No. The comments are nice - but you fail to see the big issue:

if(a) {
}
if(!a) {
}

Notice it?

Next, you have exactly the same instructions except some parameters - you could let a function do that for you, for example by grouping the constants into a struct, define a constant struct in the definitions for your vessel in your header file, where you will quickly find it for editing, and passing this constant struct as parameter to an inline function. And why YES and NO instead of true and false?

This all just makes the code extremely terrible to maintain, what you are doing there - and the idea behind open-source software is not dumping bad source code into the public, but have a good public source code to work with.
Urwumpe is offline   Reply With Quote
Old 08-26-2014, 12:11 PM   #34
gattispilot
Addon Developer
 
gattispilot's Avatar
Default

Thanks.

I guess I don't see what is wrong with if attach do something unless it is :
if (a) attach do something
else do something because not attached.

So make a function called "update info". Where it reads the struct data and applys it?
So make a struct of mass, thrust,..... Since I haven't done this before I can look at a sample and figure it out.

But the white exhaust circle is bugging me. I think it is because I am changing the exhaust location, right



http://i373.photobucket.com/albums/o...psec480f11.jpg
gattispilot is offline   Reply With Quote
Old 08-26-2014, 01:47 PM   #35
Urwumpe
Certain Super User
 
Urwumpe's Avatar

Default

Quote:
Originally Posted by gattispilot View Post
 Thanks.

I guess I don't see what is wrong with if attach do something unless it is :
if (a) attach do something
else do something because not attached.
Exactly - because otherwise, you call for the function to be evaluated a second time, despite you already knowing the result. Sometimes, this can be intentional - the compiler won't optimize it away for you in general. But usually, and since you are smarter than the compiler, you tell it have to understand the code properly.

Similar, you have to think about which objects, classes and functions you need for solving your problems. Copy and Paste code can work - but you make yourself more stupid than the compiler that way. Better is using the syntactic tools of the language for explaining the compiler semantic aspects of your program: This function is short and can be copied in place instead of calling it with all the stack frame voodoo around it (inline). Or this variable has to be treated volatile and must not be optimized into a register-only variable. Or this function does not change the attributes of the class (const). Or this function is purely virtual (virtual ... f(...) = 0; ), don't permit use of such an abstract class.

You have MANY ways to tell your compiler what you mean, instead of just what you want to do, and when you create a contradiction by using something differently than declared, the compiler can stop you from committing errors.

Same with writing many comments about your functions before you write a single line of code there. Yes, it stops your creative flow sometimes. But it helps you find errors before you program them. And tools like doxygen (which is used by Orbiter for the API Reference) make it very simple to navigate through the code.
Urwumpe is offline   Reply With Quote
Old 08-26-2014, 01:56 PM   #36
gattispilot
Addon Developer
 
gattispilot's Avatar
Default

ok. Thanks. Never heard of doxygen. But looked it up.

One problem I see is if attach then set exhaust where it should be either at the nozzle of 1st or 2nd stage. I get that white circle.

So in summary:
If attached { get info from struct)
else (get info from struct}

But the set exhaust is the puzzle.
gattispilot is offline   Reply With Quote
Old 08-26-2014, 01:58 PM   #37
Urwumpe
Certain Super User
 
Urwumpe's Avatar

Default

Quote:
Originally Posted by gattispilot View Post
 ok. Thanks. Never heard of doxygen. But looked it up.

One problem I see is if attach then set exhaust where it should be either at the nozzle of 1st or 2nd stage. I get that white circle.

So in summary:
If attached { get info from struct)
else (get info from struct}

But the set exhaust is the puzzle.
Well, what about simply creating two different thrusters, each with its own propellant resource... Oh wait, that's too easy.
Urwumpe is offline   Reply With Quote
Old 08-26-2014, 02:19 PM   #38
gattispilot
Addon Developer
 
gattispilot's Avatar
Default

Quote:
Originally Posted by Urwumpe View Post
 Well, what about simply creating two different thrusters, each with its own propellant resource... Oh wait, that's too easy.
Well yes. But you would need if attach then use thruster0 and if not attach use thruster1, right

The whole rcs is wierd. !2 nozzles and none facing forward/ up. Not sure how pitch would be achieved. Just by firing one side maybe?
gattispilot is offline   Reply With Quote
Old 08-26-2014, 02:23 PM   #39
Urwumpe
Certain Super User
 
Urwumpe's Avatar

Default

Quote:
Originally Posted by gattispilot View Post
 Well yes. But you would need if attach then use thruster0 and if not attach use thruster1, right

The whole rcs is wierd. !2 nozzles and none facing forward/ up. Not sure how pitch would be achieved. Just by firing one side maybe?
Exactly. The RCS is not translation-neutral, since the IUS never needs to dock to a spacecraft. actually, you have 2x6 RCS thrusters there, two redundant systems, each enough for providing pointing and compensating SRM performance.
Urwumpe is offline   Reply With Quote
Old 08-26-2014, 02:44 PM   #40
gattispilot
Addon Developer
 
gattispilot's Avatar
Default

On the mesh there are 2 manifolds that have 4 nozzles. And another set of manifolds that have 2 nozzles that are on the same side.

gattispilot is offline   Reply With Quote
Old 08-26-2014, 02:47 PM   #41
Urwumpe
Certain Super User
 
Urwumpe's Avatar

Default

Quote:
Originally Posted by gattispilot View Post
 On the mesh there are 2 manifolds that have 4 nozzles. And another set of manifolds that have 2 nozzles that are on the same side.
Surprisingly, the real one has the same configuration of thrusters.
Urwumpe is offline   Reply With Quote
Old 08-26-2014, 02:56 PM   #42
gattispilot
Addon Developer
 
gattispilot's Avatar
Default

It is just odd to me.
None of the thruster face up. So for pitch up one side fires both down facing thrusters and for pitch down the other side fires both down facing thrusters.
gattispilot is offline   Reply With Quote
Old 08-26-2014, 03:04 PM   #43
Urwumpe
Certain Super User
 
Urwumpe's Avatar

Default

Quote:
Originally Posted by gattispilot View Post
 It is just odd to me.
None of the thruster face up. So for pitch up one side fires both down facing thrusters and for pitch down the other side fires both down facing thrusters.
Why should a thruster point up? You have only three degrees of freedom, so you minimally need only 2 x 3 thruster for allowing all rotations. One thruster to start a rotation, one to stop it. No reason to care if this causes also a translation.

Especially think of the Space Shuttle there... the nose RCS is shut off during most of the flight and it still works. During re-entry, only the aft RCS systems are active. Why? Because the translations created that way are tolerable.
Urwumpe is offline   Reply With Quote
Old 08-26-2014, 03:08 PM   #44
gattispilot
Addon Developer
 
gattispilot's Avatar
Default

Alright. I When I get home I will see what I can put together. I wonder what those set on the same side do?
gattispilot is offline   Reply With Quote
Old 08-26-2014, 03:16 PM   #45
Urwumpe
Certain Super User
 
Urwumpe's Avatar

Default

Quote:
Originally Posted by gattispilot View Post
 Alright. I When I get home I will see what I can put together. I wonder what those set on the same side do?
Usually: Redundancy. should one RCS system fail, you can still use the other set of 6 thrusters without restrictions.

There can be other reasons as well, but this is usually (80% of all cases) the reason. On the Space Shuttle, you for example have many thrusters grouped together for also (additionally to the redundancy) have a way to regulate how much force you get, by using all or just some pairs on the RCS. Not sure if it was the shuttle, but one spacecraft also extended the lifetime of all thrusters by always using a different set of thrusters for the next impulse.
Urwumpe is offline   Reply With Quote
Reply

  Orbiter-Forum > Orbiter Addons > Addon Support & Bugs > Addon Developer Forums > Space Shuttle Ultra


Thread Tools

Posting Rules
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Jump


All times are GMT. The time now is 04:21 AM.

Quick Links Need Help?


About Us | Rules & Guidelines | TOS Policy | Privacy Policy

Orbiter-Forum is hosted at Orbithangar.com
Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
Copyright 2007 - 2017, Orbiter-Forum.com. All rights reserved.