Advanced Question Adjusting Center of Gravity?

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,724
Reaction score
2,690
Points
203
Location
Dallas, TX
I hope someone can help on this.

On the Endurance but other ships also. If I have 1 lander docked when I applied forward thrust I start to rotate left to right. It is due to docked vessel on one side.

So how can I either adjust the center of gravity or adjust the vector of thrust (Main,Rcs) to adjust for this?
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,624
Reaction score
2,343
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
I hope someone can help on this.

On the Endurance but other ships also. If I have 1 lander docked when I applied forward thrust I start to rotate left to right. It is due to docked vessel on one side.

So how can I either adjust the center of gravity or adjust the vector of thrust (Main,Rcs) to adjust for this?

There is a function to get the superstructure CG. You can use this to calculate the way you apply trust, depending on your strategy.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,724
Reaction score
2,690
Points
203
Location
Dallas, TX
Thanks.

Coordinatetransformations
• void ShiftCentreOfMass (const VECTOR3 &shift) Register a shift in the centre of mass after a structural change (e.g. stage separation).
• void ShiftCG (const VECTOR3 &shift) Shift the centre of gravity of a vessel.
• bool GetSuperstructureCG (VECTOR3 &cg) const
Returns the centre of gravity of the superstructure to which the vessel belongs, if applicable.

So whats a good strategy?
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,724
Reaction score
2,690
Points
203
Location
Dallas, TX
I have this:
Code:
VECTOR3 superStructCG;
	GetSuperstructureCG(superStructCG);
	sprintf(oapiDebugString(), "x %d  y %d   z %d", superStructCG.x, superStructCG.y, superStructCG.z);

With no vessel docked I get 0 0 0

When i dock a DG along the z axis the z value goes -

So how do I shift the COG so it is 0,0,0
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,624
Reaction score
2,343
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
I have this:
Code:
VECTOR3 superStructCG;
    GetSuperstructureCG(superStructCG);
    sprintf(oapiDebugString(), "x %d  y %d   z %d", superStructCG.x, superStructCG.y, superStructCG.z);
With no vessel docked I get 0 0 0

When i dock a DG along the z axis the z value goes -

So how do I shift the COG so it is 0,0,0

undock.

Joke aside, I can't image a case where you can with two spacecraft reach a configuration with cg equal to superstructure cg equal to zero.

Docking a third spacecraft on the opposite end could do that.

What you can do is shift the cg so the thrust forces are balanced at the superstructure cg again.

If possible though its easier to gimbal the engines.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,724
Reaction score
2,690
Points
203
Location
Dallas, TX
ok. By gimbal do you mean to rotate the thrust vector?

With Endurance with 10 docks this is needed so she flys level and straight.

So for mains I have this:
Code:
	th_main[0] = CreateThruster(_V(0, 0, 0), _V(0, 0, 1), MAXMAINTH, tank, ISP);
	thg_main = CreateThrusterGroup(th_main, 1, THGROUP_MAIN);
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,624
Reaction score
2,343
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
ok. By gimbal do you mean to rotate the thrust vector?

With Endurance with 10 docks this is needed so she flys level and straight.

So for mains I have this:
Code:
    th_main[0] = CreateThruster(_V(0, 0, 0), _V(0, 0, 1), MAXMAINTH, tank, ISP);
    thg_main = CreateThrusterGroup(th_main, 1, THGROUP_MAIN);

Yes. Depending on the ratio of the masses, this could mean a strong rotation, maybe too strong too look good. If you use multiple thrusters with large radius from the cg, you can do that with smaller rotations by looking for the whole cloud of possible solutions, you have infinite possible solutions already with a triangle of engines like the space shuttle has.

But that gets math heavy.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,724
Reaction score
2,690
Points
203
Location
Dallas, TX
Thanks. Well besides the main and retro there are 24 RCS.

Code:
	th_rcs[0] = CreateThruster(_V(6, 0, 6), _V(0, -1, 0), MAXRCSTH, tank, ISP);

Does the Atlantis have such a code for examples?
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,724
Reaction score
2,690
Points
203
Location
Dallas, TX
Thanks. No idea what to do then.
it seems this would correct it to 0,0,0
void ShiftCG (const VECTOR3 &shift) Shift the centre of gravity of a vessel.

so if the z factor was less than 0 shift +z in the + direction
 

fred18

Addon Developer
Addon Developer
Donator
Joined
Feb 2, 2012
Messages
1,667
Reaction score
104
Points
78
I'm sorry, I'm not sure I got the question correctly:

you have a vessel with 10 side docking ports, when you have something docked the CG of the stack gets translated so if you thrust forward you get a rotation due to the misalignment of thrust and CG and you want to find a way to avoid the rotation, is that correct?

so if I get it right there are 3 methods:
1) move manually the CG of the stack to align it to the new CG - I think this can mess up a lot of things since the CG is also the coordinates origin of the vessel
2) apply RCS to compensate rotational effects - easiest to do, but it can be done only up to a certain level torque
3) gimbal the engines in order to avoid rotation and use the new direction as the new "forward" - more complicated, most effective.

Is that right? if it's right I can surely help for 2, I can try to help with 3 while with 1 I think it's dangerous for the addon itself, too much risk to jeopardize the whole work.

that's my thought at least
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,724
Reaction score
2,690
Points
203
Location
Dallas, TX
Thanks. Here is how the Endurance docks are laid out

endurancedocks_zpswzox6apw.jpg



As you can see if you have a ship docked on 3 or 4 then when going forward you get a rotation force going.

Sounds like option2 might work
 

fred18

Addon Developer
Addon Developer
Donator
Joined
Feb 2, 2012
Messages
1,667
Reaction score
104
Points
78
I was thinking this: instead of using RCS (fuel consuming) you can add directly a torque force.

My idea of the scheme is this in pseudo code

Code:
if(GetThrusterGroupLevel(THGROUP_MAIN)>0)
{
VECTOR3 Torque;
GetTorqueVector(Torque);
double TorqueLength=length(Torque);
if(Torque.z>0){
AddForce(_V(0,0,TorqueLength),_V(0,0,1));
}else{
AddForce(_V(0,0,TorqueLength),_V(0,0,-1));
}
}

It is pseudocode, I just noted it down rapidly. Also signs could be all wrong, it's the concept that I'm trying to pass: get the torque vector on the ship (it's caused by misalignment of thrust and CG), get its length, apply a force at 1 meters lateral distance from the CG equal to the length of the torque vector to obtain a counter torque balancing the first one. 1 meter left or right depends on the Torque direction (+ or - Z).

I hope it can help you
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,724
Reaction score
2,690
Points
203
Location
Dallas, TX
OK with nothing docked I get 0,0,0 I docked a Deltagliter to 1 or 2 and 0,0,-1181577500. When I thrust I go into a wild pitch.

BEGIN_DOCKLIST
0 3 2.886 0 0 1 0 1 0
0 -3 2.886 0 0 1 0 -1 0
-7.28 0 -0.743 -1 0 0 0 0 -1
7.28 0 -0.743 1 0 0 0 0 -1
 

fred18

Addon Developer
Addon Developer
Donator
Joined
Feb 2, 2012
Messages
1,667
Reaction score
104
Points
78
Can you be a bit more clear and describe more in detail?
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,724
Reaction score
2,690
Points
203
Location
Dallas, TX
ok. here are some screen shots.
no vessel docked and level
endurancedock1a_zpsa1vhdhbq.jpg


a DG docked
endurancedock1b_zpsmnptekig.jpg


And here I apply some forward RCS and I start to pitch up.
endurancedock1c_zpsppxloxsl.jpg


If I apply forward thrust I start to pitch and rotate along the y axis.
 

fred18

Addon Developer
Addon Developer
Donator
Joined
Feb 2, 2012
Messages
1,667
Reaction score
104
Points
78
ok, my point was about this, what is that you get? what are you testing?

the second vector you mentioned I think it's an undefined variable there.

OK with nothing docked I get 0,0,0 I docked a Deltagliter to 1 or 2 and 0,0,-1181577500.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,724
Reaction score
2,690
Points
203
Location
Dallas, TX
OH
Code:
VECTOR3 superStructCG;
	GetSuperstructureCG(superStructCG);
	sprintf(oapiDebugString(), "x %d  y %d   z %d", superStructCG.x, superStructCG.y, superStructCG.z);

Those are the C of G readings, right?
 

fred18

Addon Developer
Addon Developer
Donator
Joined
Feb 2, 2012
Messages
1,667
Reaction score
104
Points
78
My suggestion was not to use it, but just create a counter balancing torque. I think it can work. Did you make a try with that?
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,724
Reaction score
2,690
Points
203
Location
Dallas, TX
yes. That was what I was trying.

Here is a screen shot of the torque vectors
endurancedock1d_zps0pgdpcwj.jpg
 
Top