A problem while shifting CG

santy86

New member
Joined
Apr 22, 2008
Messages
114
Reaction score
0
Points
0
Location
Amsterdam
Hi,
I would like to ask how to shift the center of gravity when i add an additional mesh.

I explain:
I add a first mesh representing the first stage of a rocket and the CG is automatically determined by orbiter. When i add the second stage mesh on the top of the first Orbiter does not update the position of CG.

2nd problem:
When I start the scenario the mesh never stays on the top of the launch pad (Cape Canaveral LC39) but appears always inside it :huh: . In addition if I launch the rocket and immediately after I turn off he engine, the rocket jumps instantaneously in the sky at a crazy speed :blink:

Does somebody know some solution for these problems??

Thanks a lot, :thumbup:
Santy
 
For problem #2,
Have you tried changing the TouchDownPoints? It sounds like they have a wrong offset.

For the 1st problem, you can use the ShiftCG() function so you can change the center of gravity manually, but I'm not sure if it can be done automatically? See the Atlantis example in the SDK at the Separate functions. API reference page 87.

regards,
mcduck
 
Problem #1 might also have to do with your center of origin involving your mesh. If this is the case, the center of that mesh will be at ground level on the launch pad.

To fix this (if indeed it's the case), you need to move your mesh (in Anim8or or whatever you're using) from "Center on Origin" to "Stand on Origin." This should fix the problem.
 
Hi All,

I'm trying to use ShiftCG to simulate fuel weight transfer to set aircraft trim. I'm linking the VECTOR3 translation vector to a Fuel Gauge "double" (i22), but nothing seems to happen:

const VECTOR3 offsetcog = {0.0, 0.0,i22}; //in "Some vessel parameters"
Code:
[FONT=Arial][COLOR=darkgreen]// Fuel Guage Animation [2][/COLOR][/FONT]
 
[FONT=Arial]fuel_proc = (GetPropellantMass (hpr1) + 20000)/20000;[/FONT]
[FONT=Arial]i22 = fuel_proc / 2;[/FONT]
 
[FONT=Arial]if (i22 <0) i22 = 0;[/FONT]
 
[FONT=Arial][COLOR=darkgreen]//if (i22 > 1) i22 = 1;[/COLOR][/FONT]
 
[FONT=Arial]SetAnimation (anim_fuel2, i22);[/FONT]
 
 
 
[FONT=Arial][COLOR=darkgreen]// CoG Meter Animation[/COLOR][/FONT]
 
[FONT=Arial]if (i22 > 0)[/FONT]
[FONT=Arial]{[/FONT]
[FONT=Arial]meter = i22 ;[/FONT]
[FONT=Arial]SetAnimation (anim_cogmeter, meter);[/FONT]
[FONT=Arial]ShiftCG(offsetcog);[/FONT]
[FONT=Arial]if (i22 > 50) i22 = 50;[/FONT]
[FONT=Arial]}[/FONT]


Any ideas ???
(Bear in mind, I might sound like I'm familiar with C++ but I'm BASIC !):P

Regards,
JMW
 
As you shift CoG and Animation against each other, there should be nothing happening.

Leave the animation away, ShiftCG automatically moves all meshes and animations.
 
Hi Urwumpe,

The animation is for a fuel gauge (included to show where i22 comes from).
Is it interfering with the ShiftCG ?
I know ShiftCG shifts meshes/thrusters etc, but the animation is just for the fuel gauge.
Or should ShiftCG be outside the { } sequence?
Or am I misunderstanding you?

Thanks,
JMW
Is there a call to "GetCG" or equivalent? (This so I can have a real CG gauge instead of my fake one)
 
Last edited:
Ah ok... i thought you have this as animation of the shifted CoG, because you included it.

You should keep in mind, that you shift the CoG in every call by the same amount. Also, as offsetcog is constant, it will very likely not change as you intent it, but remain constant. You only change the variable i22.
 
Ummmm..
Tried various things but can't get any shift of cg.
Although what does happen is camera "focus" goes haywire sometimes, zooming out uncontrollably!
I read that ShiftCG changes this, so does this mean that CG is actually moving??
As I said, I'm trying to get a system of setting aircraft trim by shifting fuel around the tanks (Concorde style)
I know this is vague, but has anyone had experience of this?

Help !
JMW
 

Code:
[SIZE=2][SIZE=2][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][FONT=Arial]const[/FONT][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][FONT=Arial] VECTOR3 offsetcog = {0.0, 0.0,i22}; [COLOR=darkgreen]//in[/COLOR] "[SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]Some vessel parameters"
[/COLOR][/SIZE][/COLOR][/SIZE][/FONT] [/SIZE][/SIZE][/SIZE]
The problem is here. What this is saying is that when the program starts, offsetcog is assigned the value {0.0, 0.0, <whatever i22 has at the time>}. There is no link created between offsetcog and i22. The value of i22 at the time that code runs (the beginning of the program) is set as the z-coordinate of offsetcog, and offsetcog will never change. Remove the "const" and try this:
Code:
[FONT=Arial][COLOR=darkgreen]// CoG Meter Animation[/COLOR][/FONT]
 
[FONT=Arial]if (i22 > 0)[/FONT]
[FONT=Arial]{[/FONT]
[FONT=Arial]meter = i22 ;[/FONT]
[FONT=Arial]SetAnimation (anim_cogmeter, meter);[/FONT]
[FONT=Arial][B]offsetcog.z = i22;[/B][/FONT]
[FONT=Arial]ShiftCG(offsetcog);[/FONT]
[FONT=Arial]if (i22 > 50) i22 = 50;[/FONT]
[FONT=Arial]}[/FONT]
 
Tried your suggestion as above, but comes with error:

1>.\Concorde.cpp(670) : error C2065: 'offsetcog' : undeclared identifier
1>.\Concorde.cpp(670) : error C2228: left of '.z' must have class/struct/union
1> type is ''unknown-type''

Tried creating identifier 'offsetcog' and removing '.z' then get:

1>.\Concorde.cpp(671) : error C2664: 'VESSEL::ShiftCG' : cannot convert parameter 1 from 'double' to 'const VECTOR3 &'
1> Reason: cannot convert from 'double' to 'const VECTOR3'
1> No constructor could take the source type, or constructor overload resolution was ambiguous

Can't figure how to get one in the 'loop' and keep the other 'out':(
Any more suggestions would be welcome.
JMW
 
Tried your suggestion as above, but comes with error:

1>.\Concorde.cpp(670) : error C2065: 'offsetcog' : undeclared identifier
1>.\Concorde.cpp(670) : error C2228: left of '.z' must have class/struct/union
1> type is ''unknown-type''

Tried creating identifier 'offsetcog' and removing '.z' then get:

1>.\Concorde.cpp(671) : error C2664: 'VESSEL::ShiftCG' : cannot convert parameter 1 from 'double' to 'const VECTOR3 &'
1> Reason: cannot convert from 'double' to 'const VECTOR3'
1> No constructor could take the source type, or constructor overload resolution was ambiguous

Can't figure how to get one in the 'loop' and keep the other 'out':(
Any more suggestions would be welcome.
JMW

Why did you remove the declaration of offsetcog? I just said to remove the const from it. If you must, do this:
Code:
[FONT=Arial][COLOR=#006400]// CoG Meter Animation[/COLOR][/FONT]
 
[FONT=Arial]if (i22 > 0)[/FONT]
[FONT=Arial]{[/FONT]
[FONT=Arial]meter = i22 ;[/FONT]
[FONT=Arial]SetAnimation (anim_cogmeter, meter);[/FONT]
[FONT=Arial][B]VECTOR3 offsetcog = {0, 0, i22};[/B][/FONT]
[FONT=Arial]ShiftCG(offsetcog);[/FONT]
[FONT=Arial]if (i22 > 50) i22 = 50;[/FONT]
[FONT=Arial]}[/FONT]
 
OK - it compiles. Thanks Hielor.
But I'm now getting the plane (In external view) disapearing into the distance. If I go to internal (generic cockpit) view, and back out again, the plane is back - but zooms off into the distance again.(All without any thrust !):rofl::(
Some sort of control loop needed huh.?
I thought the
"if
(i22 > 50) i22 = 50;"
would do that.
I think I'm going to bed.
If anyone in another time zone would like to contribute, I'd be grateful tommorrow.
JMW
 
I thought the
"if (i22 > 50) i22 = 50;"
would do that.

It will, if you have that before the line where you use i22 in the vector.

Do this:
Code:
[FONT=Arial]if (i22 > 0)[/FONT]
[FONT=Arial]{[/FONT]
[FONT=Arial]  [B]if (i22 > 50) i22 = 50;[/B][/FONT]
[FONT=Arial]  meter = i22 ;[/FONT]
[FONT=Arial]  SetAnimation (anim_cogmeter, meter);[/FONT]
[FONT=Arial][B]  VECTOR3 offsetcog = {0, 0, i22};[/B][/FONT]
[FONT=Arial]  ShiftCG(offsetcog);[/FONT]
[FONT=Arial]}[/FONT]
[FONT=Arial]
[/FONT]
 
My objective;
I'm still trying to achieve a shift in cg with fuel movement, to set aircraft flight trim.

Last code tried is this:
Code:
// Fuel Guage Animation [2]
 
fuel_proc = (GetPropellantMass (hpr1) + 20000)/20000;
i22 = fuel_proc / 2;
 
if (i22 <0) i22 = 0;
 
if (i22 > 1) i22 = 1;
 
SetAnimation (anim_fuel2, i22);
 
 
// CoG Meter Animation & CGShift
if (i22 > 10) i22 = 10;
 
offsetcog.z = i22*10;
 
if (i22 > i30) ShiftCG (offsetcog);
if (i22 < i30) ShiftCG (-offsetcog);
 
i30 = i22;

Problem is, not only does this not cause a change in trim, but there is an uncontrollable "zooming out" of the camera in external view, and various strange effects in internal.

I've tried ShiftCentreOfMass as an alternative, and various Camera settings, but with no success.

Can anyone take pity and help me compile a code to achieve my objective please?
I'm not gonna be around for much longer tonight, but any suggestions I will pick up tommorrow.

Thanks in anticipation,
JMW
 
My objective;
I'm still trying to achieve a shift in cg with fuel movement, to set aircraft flight trim.

Last code tried is this:


Problem is, not only does this not cause a change in trim, but there is an uncontrollable "zooming out" of the camera in external view, and various strange effects in internal.

I've tried ShiftCentreOfMass as an alternative, and various Camera settings, but with no success.

Can anyone take pity and help me compile a code to achieve my objective please?
I'm not gonna be around for much longer tonight, but any suggestions I will pick up tommorrow.

Thanks in anticipation,
JMW

The problem is that ShiftCG takes a vector relative to the current location. You're on the right track, but you need to calculate the "i22" as the difference in meters between the last location and the next location.

Also, please please PLEASE use better names than "i22" and "i30". Always use descriptive names for variables. It will make your life a whole lot easier, and make it easier for people helping you to see what you're trying to do.

Try this:
Code:
// Fuel Guage Animation [2]
 
fuel_proc = (GetPropellantMass (hpr1) + 20000)/20000;
i22 = fuel_proc / 2;
 
if (i22 <0) i22 = 0;
 
if (i22 > 1) i22 = 1;
 
SetAnimation (anim_fuel2, i22);
 
 
// CoG Meter Animation & CGShift
offsetcog.z = i22*10 - i30;
ShiftCG (offsetcog);
i30 = i22;
 
Thanks Hielor,
I still have the zooming out problem. (Don't know whether CG is shifting - is there a call I can use to get a visual on this?)
Trouble is, can't show you what problem is by recording it, 'cause you don't have the module.
Code:
// CoG Meter Animation & CGShift
 
 
offsetcog.z = fuel_change*10 - last_fuel_change;
//offsetcog.z = fuel_change*10;
//ShiftCG (offsetcog);
 
if (fuel_change > last_fuel_change) ShiftCG (offsetcog);
 
if (fuel_change < last_fuel_change) ShiftCG (-offsetcog);
 
 
last_fuel_change = fuel_change;
 
 
if (fuel_change > 0)
 
{
meter = fuel_change ;
 
SetAnimation (anim_cogmeter, meter);
I tried as you suggested, but still the same so have gone back to other code to see if that worked with your offfset.z format. But no joy.
Is there no way I can compensate for camera movement, or am I going down the wrong track?
I've changed the variable names as you suggested - hope this helps.

Regards,
JMW
 
Thanks Hielor,
I still have the zooming out problem. (Don't know whether CG is shifting - is there a call I can use to get a visual on this?)
In sim, hit F4, click Visual Helpers, tick Planetarium Mode, tick Vessels. This will put a little yellow box around where your vessel's centre of gravity is in external view.

Code:
// CoG Meter Animation & CGShift
 
offsetcog.z = fuel_change*10 - last_fuel_change;
This is a problem, because even if the fuel doesn't change, offsetcog.z will be non-zero. Do you mean to do this, perhaps:
Code:
offsetcog.z = (fuel_change - last_fuel_change)*10;
Code:
if (fuel_change > last_fuel_change) ShiftCG (offsetcog);
 
if (fuel_change < last_fuel_change) ShiftCG (-offsetcog);
This means that the cog always shifts in the +Z direction, whether the fuel change is positive or negative. That doesn't make sense why you would want that, but then I can't see how you are deriving fuel_change.

Is there no way I can compensate for camera movement, or am I going down the wrong track?
The external camera will always be centred on your vessel's cog, except if you move the cog in large steps (the camera has a function to smooth the movement when panning from one spot to another after a ShiftCG call).
 
getting to the end of my brain power and knowledge (not very great either!)
This is where I am at the moment:
Still can't get the CoG to shift(if TBLAXLAND's box denotes where it is)
Code:
// Fuel Guage Animation [2]
 
fuel_proc = (GetPropellantMass (hpr1) + 20000)/20000;
fuel_change = fuel_proc / 2;
 
SetAnimation (anim_fuel2, fuel_change);
 
 
// CoG Meter Animation & CGShift
 
offsetcog.z = (fuel_change - last_fuel_change)*180;
 
ShiftCentreOfMass(offsetcog); // or ShiftCg(offsetcog);
 
 
last_fuel_change = fuel_change;

Why doesn't my little yellow box move!??
JMW
 
Why doesn't my little yellow box move!??
Move relative to what? It shouldn't move relative to the camera because the camera always stays centred on the CoG. Based on your latest code snippet, the CoG should move 90m in the -Z direction, relative to the mesh, as the fuel tank goes from full to empty.

Did you check that fuel is being used from hpr1? Use the debugger to check the return value of GetPropellentMass.

You shouldn't be using ShiftCentreOfMass for this application because it will not shift your thruster positions, etc (use ShiftCG instead).
 
Back
Top