API Question ShiftCG

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,757
Reaction score
2,740
Points
203
Location
Dallas, TX
I am trying to get ShiftCG to function. I looked at the Atlantis code.

Code:
ShiftCG (OFS_LAUNCH_ORBITER-OFS_WITHTANK_ORBITER);
and here:
Code:
ShiftCG (OFS_WITHTANK_ORBITER);

OFS_WITHTANK_ORBITER and OFS_WITHTANK_ORBITER are both Vector3
Code:
const VECTOR3 OFS_ZERO             = { 0.0, 0.0,  0.0  };
const VECTOR3 OFS_LAUNCH_ORBITER   = { 0.0, 6.22,-7.795};
const VECTOR3 OFS_LAUNCH_TANK      = { 0.0,-1.91, 5.72 };
const VECTOR3 OFS_LAUNCH_RIGHTSRB  = { 6.2,-1.91,-5.68 };
const VECTOR3 OFS_LAUNCH_LEFTSRB   = {-6.2,-1.91,-5.68 };
const VECTOR3 OFS_WITHTANK_ORBITER = { 0.0, 4.79,-9.185};
const VECTOR3 OFS_WITHTANK_TANK    = { 0.0,-3.34, 4.33 };
const VECTOR3 ORBITER_DOCKPOS      = { 0.0, 2.44,10.44 };
const VECTOR3 OFS_MMU              = {0,2.44,10.44};

Ok. When I duplicate I get this error:
::ShiftCG' : function does not take 1 arguments

8.51.3.251 voidVESSEL::ShiftCG(constVECTOR3&shift) Shift the centre of gravity of a vessel.
Parameters: shift centre of gravity displacement vector [m]
Note: This function should be called after a vessel has undergone a structural change which resulted in a shift of the vessel’s centre of gravity (CG). Note that in Orbiter, a vessel’s CG coincides by definition always with the origin (0,0,0) of its local reference frame. Therefore, in order to achieve a shift of the CG by shift, this function performs the following actions: • Calls ShiftCentreOfMass (+shift) to align the vessel’s global position with the new CG position. • Calls ShiftMeshes (-shift) to compensate the mesh positions • Applies equivalent shift to all – thruster positions, – docking ports, – attachment points, – explicitly defined light source positions, – and to the cockpit camera position The net effect is a shift of the vessel frame of reference (and thus the CG by +shift, while the mesh positions remain in place in the global frame.
 

martins

Orbiter Founder
Orbiter Founder
Joined
Mar 31, 2008
Messages
2,448
Reaction score
462
Points
83
Website
orbit.medphys.ucl.ac.uk
Ok. When I duplicate I get this error:
::ShiftCG' : function does not take 1 arguments

I don't understand the error message. "::ShiftCG" refers to a function in the global namespace. Did you define a global ShiftCG function? I'm not even sure why the error message would print the two leading colons, rather than just "ShiftCG", but maybe that's to make it clear that it doesn't refer to the class member.

If you defined a global ShiftCG function, then a call to it from within a vessel class might be ambiguous. You can avoid this by explicitly calling this->ShiftCG instead.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,757
Reaction score
2,740
Points
203
Location
Dallas, TX
Thanks. I got it.
Code:
if (key == OAPI_KEY_3)//
{
	
	ShiftCG(CGSHIFTOFFSET);
	

	return 1;
}

Code:
const VECTOR3 CGSHIFTOFFSET = { 0.0, 0, -4 };

I expected a tilt not a shift in direction. Trying to get a 16 degree up tilt.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,757
Reaction score
2,740
Points
203
Location
Dallas, TX
You mean by aerodynamics?
Yes. This vessel had weights on the edge. Then when the weights were dropped the craft then tilted. So just has that shifted the COG.

I want to with a key stroke.
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,663
Reaction score
2,383
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
Yes. This vessel had weights on the edge. Then when the weights were dropped the craft then tilted. So just has that shifted the COG.

I want to with a key stroke.

Yes. You can do that by moving the airfoil definition relative to the CoG as well.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,757
Reaction score
2,740
Points
203
Location
Dallas, TX
Yes. You can do that by moving the airfoil definition relative to the CoG as well.


How?

Since in real life they shift the CoG. that is how it should be done here?

I Thought (dangerous I know:)) that by shifting the Cog in the z direction the craft would tilt back.
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,663
Reaction score
2,383
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
Doesn't happen that way - conservation of impulse applies.

Usually, by shifting the CoG, the CoG shifts also relative to the aerodynamic centre of pressure. But in Orbiter, I am not sure if this is done automatically. I suspect not, since the API docs are not saying so.
 

BrianJ

Addon Developer
Addon Developer
Joined
Apr 19, 2008
Messages
1,680
Reaction score
902
Points
128
Location
Code 347
Doesn't happen that way - conservation of impulse applies.

Usually, by shifting the CoG, the CoG shifts also relative to the aerodynamic centre of pressure. But in Orbiter, I am not sure if this is done automatically. I suspect not, since the API docs are not saying so.
I think ShiftCG() does shift aerofoils relative to CoG, but not sure either. So if you have aerofoils defined, centre of pressure should shift.

How?

Since in real life they shift the CoG. that is how it should be done here?

I Thought (dangerous I know:)) that by shifting the Cog in the z direction the craft would tilt back.
If your vessel is oriented as +Z = "forwards/velocity vector", +Y = "up", then you need to shift the CoG in the -Y direction to cause a "pitch up".

I have a hunch I know which vessel this relates to ;-)
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,757
Reaction score
2,740
Points
203
Location
Dallas, TX
Ok.. I have this:
Code:
const VECTOR3 CGSHIFTOFFSET = { 0.0, -4, 0 };

All that happens is the craft goes up. Still level though
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,663
Reaction score
2,383
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
Ok.. I have this:
Code:
const VECTOR3 CGSHIFTOFFSET = { 0.0, -4, 0 };
All that happens is the craft goes up. Still level though

Yes - what do you expect on the ground? What matters is in aerodynamic flight!

See here:

Command_Module_Aerodynamics.png


Notice the offset CG by the heavy equipment?

That only has effect during aerodynamic flight. But since in Orbiter, you don't shift the CG because CG is origin of the coordinate system, you shift the rest of the spacecraft.
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,663
Reaction score
2,383
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
it is in space. It is orbiting Earth.

Then dropping the ballast has no such effect by itself.

If the spacecraft is spinning, releasing the ballast could change the rotation impulse vector and make the spacecraft tumble around another axis, but it would not rotate and cease to rotate at 18° angle.
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,663
Reaction score
2,383
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
oh. Then how could I do it?

Drop ballast, so the spacecraft is coarse stabilizing at the intended AOA during reentry.

Use RCS for fine tuning the attitude and turning to proper AOA before reentry.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,757
Reaction score
2,740
Points
203
Location
Dallas, TX
But is there a way to check what the CofG shift should be.
This vessel has 2 sets of Ballast. 1 set makes it tilt 16 degrees and then the other level.
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,663
Reaction score
2,383
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
But is there a way to check what the CofG shift should be.
This vessel has 2 sets of Ballast. 1 set makes it tilt 16 degrees and then the other level.

Yes - you keep track of it. Orbiter does not care how your vessel looks like inside, it only cares about how it interacts with the universe.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,757
Reaction score
2,740
Points
203
Location
Dallas, TX
ok. But if i wanted a process.
Like at 1000KM weights drop so CofG shifts to allow a 16 degree tilt.

or should I at 1000KM set RCS to fire until at 16 AOA is set?
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,757
Reaction score
2,740
Points
203
Location
Dallas, TX
This is what I am trying to do. So press a key and the cruise mass drops thus changing the CoG. Then at another time press a key or automatic entry masses are dropped and now CoG is restored and capsule is level.
mslcapsule_zpsb8cmcgr9.jpg
 
Top