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
ok. Then I am at a lost:(

So the purpose is to set the direction of the main thrusters to adjust to compensate for docked vessels, dead engine,....., right?

so is the angular moment the offset of true flight?
 

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. Then I am at a lost:(

So the purpose is to set the direction of the main thrusters to adjust to compensate for docked vessels, dead engine,....., right?

so is the angular moment the offset of true flight?

No, angular momentum is in reality this:

https://en.wikipedia.org/wiki/Angular_momentum#Scalar_.E2.80.94_angular_momentum_in_two_dimensions

This one calculates torque(which is a moment), torque is (incorrectly saying) the angular equivalent to linear force.

(Definition: Moment is a combination of a physical quantity and a distance)

https://en.wikipedia.org/wiki/Torque#Definition_and_relation_to_angular_momentum

Force over time is momentum.
Torque over time is angular momentum.

An "angular moment" would mean an "angular torque" in this case... and torque is always "angular".
 
Last edited:

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,724
Reaction score
2,690
Points
203
Location
Dallas, TX
Ok
from this"Vector — angular momentum in three dimensions"


So the angular momentum is what is making the ship not go straight?
 

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
from this"Vector — angular momentum in three dimensions"


So the angular momentum is what is making the ship not go straight?

Angular momentum is the current rotation of the ship. It is the momentum that makes you spin faster on your office chair, when you pull your arms to your body - same momentum, different moments of inertia, different rotation rate.

Torque is what changes the angular momentum. When you apply a force on a spacecraft, which is not acting on the CG directly and not parallel to the radius vector (the vector from cg to the point of attack of the force), you not just get the expected linear acceleration on the ship, but also a change of the rotation rates.

Note: Torque itself has no effect on the trajectory of the spacecraft. But since you need a force to create a torque, you can have an effect on the spacecrafts trajectory by the force, if you are not having a counterforce to neutralize it (which is why you need at least two RCS thrusters for rotations if you don't want to also get translations)
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,724
Reaction score
2,690
Points
203
Location
Dallas, TX
So to go straight the Angular Momemtum needs to 0?

So the torque is what is changing the direction, right

So then gimbal the engines to counter the torque?
 

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
So to go straight the Angular Momemtum needs to 0?

Yes. But since this also means that the angular rates are zero, you can maybe see a simpler way to get to your goal.

So the torque is what is changing the direction, right

Yes. It changes how fast the attitude changes every second. But it is not the only way to change the attitude rates (you can also change the principal moments of inertia for changing them)

So then gimbal the engines to counter the torque?

Good idea, but still wrong understanding: If you gimbal the engines, you change the torque that they produce.

Correct understanding: If you have an attitude rate different to the one you actually want (for example zero), you gimbal the engines to produce a torque that changes the angular momentum and thus changes the attitude rates.

Now, you can of course calculate the needed torque with a complex mathematical model of your spacecraft and its dynamics. That is possible, but relies on you really knowing how your spacecraft is like.

Or you use a simpler adaptive function, that does not know your spacecraft well, but learns to provide good torque targets for your spacecraft. That is what a PID controller does.

The P or proportional part is essentially what is steering your spacecraft. You have a deviation (often called error in controller theory) and the reaction is a proportional reaction to that deviation.

The I or integral part makes the controller adaptive. It measures the accumulated difference between current rate and target rate and increases the output reaction as the accumulated error increases. It is also the component that can cause most problems in computer implementations.

The D or differential part allows you to dampen changes to the deviation. Either your own reaction by letting the spacecraft turn slower when a strong controller output might cause a strong overshoot past the target. or if some outside effect requires a fast reaction (for example turbulence of thrust oscillations, but also docking events). The D part reacts faster than the P component and muuuuch faster than the I part. But the D part can not make an existing error go to zero, it only reacts to changes to the error and tries to keep the error constant.

together, as sum of all three components, the PID function lets you calculate a good torque value that is maybe never perfect, but then also works good with very complex spacecraft. The PID function itself is simple, but the art is finding good coefficients for it. The function is adaptive, but like always, it works best in a region that it is defined by its coefficients for. The better you optimize the coefficients, the more precise and faster the reaction can be. But it also means that the PID function can even get unstable in some bad combinations of spacecraft state and change of attitude rates outside this optimized region.

Generally, a PID function only works for one axis. You need one each for pitch, yaw and roll. If you have strong changes in the spacecraft configuration, you also have special sets of PID functions for each configuration (think of staging of a rocket), so you always stay with your PID function in the state, that it works best.

The next step then would be, to take the output of the PID functions and let the thrusters react accordingly. If your bank PID function tells you to rotate to the left, you need to select the correct thrusters and gimbal them in the correct direction... the best way is to define this yourself, though there are magic functions around that calculate a solution for the available thrusters and the desired torque vector. These functions just need more CPU time and their flexibility is often not needed.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,724
Reaction score
2,690
Points
203
Location
Dallas, TX
Ok. Sounds complicated. Wouldn't this need to be done to all rcs and mains?
 

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. Sounds complicated. Wouldn't this need to be done to all rcs and mains?

RCS only if you need so, for example for an autopilot, like Orbiter also does internally for its commands. Same for mains. If you for example plan to fly straight without manually steering the thrust vectors, you need it, since it essentially is a kind of an autopilot.

Yes, it is complicated because of the theory behind. The code is simple. And it is MUCH simpler than calculating the correct thrust directions for all possible CG positions for the next time step to be propagated.
 

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. Thanks.
Where to begin? I got the 2 thrusters made

Begin with just pitch channel, I would say. Only engine up or engine down. And keyboard bindings for increasing or decreasing the target pitch rate.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,724
Reaction score
2,690
Points
203
Location
Dallas, TX
ok. So how does it know that it is pitching up or down? to adjust them?

So if pitch up then the thruster get pitched down, right
 

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. So how does it know that it is pitching up or down? to adjust them?

So if pitch up then the thruster get pitched down, right

You know that you can query the attitude rates of your spacecraft in Orbiter? Just use the Pitch data. Its in radians/s (which I recommend to use internally because the math of your CPU is in radians as well, but for display and control, it is more common to use degrees/s)
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,724
Reaction score
2,690
Points
203
Location
Dallas, TX
Yes. I was thinking it was something else.

So Get the pitch and counter it with the vectored thrust? Which vector?

I guess this is assuming I did not want pitch, right?

Thanks
 

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
Yes. I was thinking it was something else.

So Get the pitch and counter it with the vectored thrust? Which vector?

I guess this is assuming I did not want pitch, right?

Thanks

Yes. You want actually pitch rate in this context.

In guidance, you often use fuzzy logic for calculating the pitch rate you need for getting to an desired target pitch angle. No need for a PID controller there.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,724
Reaction score
2,690
Points
203
Location
Dallas, TX
Ok. So if going level the desired pitch angle would be 0, right?
So if it isn't 0 do something

the something would be pitching up/down the thrusters, right
 

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. So if going level the desired pitch angle would be 0, right?
So if it isn't 0 do something

the something would be pitching up/down the thrusters, right

No. Think in rate of change. 0 = 0°/s change of the pitch angle.

If you have this working, you can start building an autopilot to control pitch angle, which uses the autopilot for pitch rate by giving it target rates.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,724
Reaction score
2,690
Points
203
Location
Dallas, TX
Ok. So would I hit a key to engage this.

and it would lock in the pitch. So get the pitch and if pitch is different adjust thruster to maintain that pitch
 

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. So would I hit a key to engage this.

and it would lock in the pitch. So get the pitch and if pitch is different adjust thruster to maintain that pitch

locking the pitch is (almost) the same like keeping pitch rate = 0°/s. Maybe you should first of all achieve this.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,724
Reaction score
2,690
Points
203
Location
Dallas, TX
Ok so I need to get the pitch and see if is different that the set angle, right

So if the pitch desired is +5 degrees and the actual pitch is 0 then pitch up to 5, right?

Not sure about how to get the vector to adjust the thrusters too.
 

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 so I need to get the pitch and see if is different that the set angle, right

So if the pitch desired is +5 degrees and the actual pitch is 0 then pitch up to 5, right?

Not sure about how to get the vector to adjust the thrusters too.

gattispilot, Urwumpe, do you read?
 
Top