PrivateFlip

[1.6] Davon Throttle Control systems mod [v088]

Recommended Posts

Cool mod! Does it work with dtobi's shuttle engines mod?

Edit: did some testing, and no unfortunately... The mod has naturally angled engines(that can be pitched to any angle), which means it's possible for you to have a fuel tank attached without a rocket, but this mod can't angle the rockets to stabilise(here's a pic to help you understand)

http://i.imgur.com/8imE3dj.png

As you can see when i decouple the boosters there will be a tank full of fuel and no rocket.

It would be awesome to see support for this kind of thing!(pitch-able vectoring etc.) Again great mod, just doesn't like working with shuttles :P

But why do you even need this mod for that shuttle? It should be able to adjust itself, using just what dtobi made.

EDIT: Oh, and this mod is going to be useful. Like, REALLY useful.

Share this post


Link to post
Share on other sites
One thing I noticed trying this out just now is that using the centered thrust stops my sepatrons from firing. A normal run with mechjeb in control they fire off with each staging as usual. I put the control part for this on, configured the booster motors for centered thrust and the sepatrons don't fire when staging. I tried setting the sepatrons as 'ignore' and the net off but it still doesn't fire them.

Thank you for reporting this Ratzap, this has been corrected.

Share this post


Link to post
Share on other sites
But why do you even need this mod for that shuttle? It should be able to adjust itself, using just what dtobi made.

EDIT: Oh, and this mod is going to be useful. Like, REALLY useful.

It doesn't auto adjust, it's almost impossible to get right :/

Share this post


Link to post
Share on other sites

I have to report a bug.

If i have installed a basic jet engine on my shuttle. The diferential thrust module activates it when I thrust up before staging on the launchpad. (Before I press *space* to lift off)

I'm not sure if it gives thrust though but the grafics and sound of the activated jet engine can be seen and be heared.

And I think your module does not count in solid rocket boosters. But I havn't tested it further.

Share this post


Link to post
Share on other sites
I have to report a bug.

If i have installed a basic jet engine on my shuttle. The diferential thrust module activates it when I thrust up before staging on the launchpad. (Before I press *space* to lift off)

I'm not sure if it gives thrust though but the grafics and sound of the activated jet engine can be seen and be heared.

And I think your module does not count in solid rocket boosters. But I havn't tested it further.

Thank you for reporting this.

-Mod has been modified so jet engines don't spool up before activation, they didn't provide thrust but now graphics and sound should be similar.

-Solid boosters are now correctly taken into account for CoT calculation.

Share this post


Link to post
Share on other sites

This works nicely for turbine and rocket engines alike, but doesn't seem to work on the multi-mode engines, such as the stock rapier engine or the B9 Sabre engines. Any chance of adding support for these?

Share this post


Link to post
Share on other sites

These engines do use a different partmodules although there are many similarities. I wouldn´t be surprised if these new engine partmodules would become the standard for all engines at some point, so it is my intention to get the support for these sooner rather than later. (Not before the coming weekend, but maybe in a week or so)

Share this post


Link to post
Share on other sites

I did not read all,and so far i only have seen shuttle/rockets.

But will this basically work for VTOL?

I remember a mod that would do some throttle for VTOL.but it was a 2 engine mod only.

Share this post


Link to post
Share on other sites
You know it says mayor instead of major in the title of the thread, right?

Well, it IS a thrust governor...

Terrible, terrible puns aside, this looks like just what I need. It would be fantastic if you could have the extra throttle controls made to resemble the stock throttle gauge, and add key-binding to them as well.

Share this post


Link to post
Share on other sites
I look forward to it, with baited breath.

completed it this week, hope to do final testing this weekend.

I did not read all,and so far i only have seen shuttle/rockets.

But will this basically work for VTOL?

I remember a mod that would do some throttle for VTOL.but it was a 2 engine mod only.

It depends on the design and your expectations.

If you have dedicated vertical engines you can have the center thrust balance those while setting the horizontal engines to be ignored by the center thrust mode. You would still need to manually adjust the thrust to for example hover and have some other means to control the orientation of the plane.

Share this post


Link to post
Share on other sites

This is the testing version of this mod

dropbox download link

source code part of download, released under GPL (GNU General Public License)

The reason for having a separate testing version for this plugin is that I prefer making small incremental changes than building towards a big new release over a longer time. Because the need to test all different components even after making small changes due to the interdependence between them, I find myself kinda putting of making changes and adding features despite the fact I really like to work on it.

In general this testing version will contain the features requested by often a single user or small additions i make on my own account. It will be a little buggier at times but the idea is that the user who requested the new feature will accept this in exchange for a faster implementation, other who did not want the feature will have a more stable version, and I will be motivated to add some new stuff instead of being burdened by the prospect to test every throttle setting, center thrust, engine type/layout combination.

23-feb-2014 this testing version contains an overhaul of the center thrust mode.

-it has a drastically faster response time to sudden changes in the Center of Thrust: the system is now fast enough to compensate mid-flight engine failures in an reasonable time (and will probably be even faster in future updates)

-the size off the adjustments is now dynamically regulated: this means the user no more has to choose and set an adjustment size and the size of the adjustment is continuously adapted to the vessel and it's current situation.

05-mar-2014

-bugfixes

25-mar-2014

-bugfix

Edited by PrivateFlip

Share this post


Link to post
Share on other sites

That's great - thank you.

It is looking a whole lot better: The menu options are now available in mixed-mode and fixed mode engines. I encountered the following issues:

1. Direction depends on all engines having the same direction of thrust. Is it not possible to pick up the direction of thrust for each engine, and calculate the moment of torque on the center of mass for each engine from that?

2. It is doing something strange when there are more than 4 engines. I put 6 engines onto 2 Rockomax 64 tanks, almost evenly distributed. The center engines run at minimal thrust (around 20%). I expected the center engines to be maxed out, with either the engines at the back or the front maxed out, and the remaining pair reduced to establish the balance.

3. Mechjeb vessel info is showing max acceleration and current acceleration in the order of micrometers, which does not happen without the plugin.

I have not had enough to test further, although I have found that engines mounted at a slight angle seem to go haywire: I cannot keep the vessel balanced, no matter what RCS thrusters I have installed.

I have no idea what sort of information is available from KSP, so I'm not sure if this is possible or realistic: Instead of working on a trial-end-error basis for the individual throttle control for each engine, is it not possible to calculate the required thrust to net out torque, based on the current maximum thrust? If the current maximum thrust is, say, 160kN, and you need it to be 80kN in order to establish a balance, then setting the throttle for that engine to 50% should get you spot on? I guess what I'm trying to ask is: Is the relationship between throttle and thrust linear, based on the engines maximum thrust for a given speed/atmospheric pressure?

Edited by spearsp

Share this post


Link to post
Share on other sites
2. It is doing something strange when there are more than 4 engines. I put 6 engines onto 2 Rockomax 64 tanks, almost evenly distributed. The center engines run at minimal thrust (around 20%). I expected the center engines to be maxed out, with either the engines at the back or the front maxed out, and the remaining pair reduced to establish the balance.

I would like to investigate this, but based on your description I can't really picture the engine outlay. (as a fix you could set the back and front engines as designated and set the center thrust to only use designated engines.)

3. Mechjeb vessel info is showing max acceleration and current acceleration in the order of micrometers, which does not happen without the plugin.

I do not know what is causing this but i suspect it goes something like this: The max thrust of engines is often a nice round number and thrust percentage, under stock conditions, is a nice discrete number. This could results relatively rounded outcomes. This plugin can and does set the throttle levels of individual engines with a much higher precision which leads to longer outcomes. There's probably little to really fix these type of inter mod bugs, the developer of mechjeb is not going to implement rounding because some niche mod is causing longer outcomes, nor am I willing to make more discrete adjustments to prevent display issues in mechjeb.

1. Direction depends on all engines having the same direction of thrust. Is it not possible to pick up the direction of thrust for each engine, and calculate the moment of torque on the center of mass for each engine from that?
I have not had enough to test further, although I have found that engines mounted at a slight angle seem to go haywire: I cannot keep the vessel balanced, no matter what RCS thrusters I have installed.

The center thrust mode in this mod reduces the balance problem to a two dimensional plane. This limits the application to engines which are to be balanced to all face in the same direction.

I have no idea what sort of information is available from KSP, so I'm not sure if this is possible or realistic: Instead of working on a trial-end-error basis for the individual throttle control for each engine, is it not possible to calculate the required thrust to net out torque, based on the current maximum thrust? If the current maximum thrust is, say, 160kN, and you need it to be 80kN in order to establish a balance, then setting the throttle for that engine to 50% should get you spot on? I guess what I'm trying to ask is: Is the relationship between throttle and thrust linear, based on the engines maximum thrust for a given speed/atmospheric pressure?

The relationship between throttle and thrust is linear. However the issue does not lie in setting the engine to a specific thrust, but in calculating to what thrust an engine should be set. All the information, like engine direction, is all available and accesible in KSP, and like you suggested this could be used to calculate the moment of torque of every engine. ZRM's Kerbcom Avionics proved it is realistic to use such information to calculate the exact thrust for every engine in three dimensions, so you do have a good grip on the situation. Unfortunately I am not an expert mathematician like ZRM.

Share this post


Link to post
Share on other sites
I would like to investigate this, but based on your description I can't really picture the engine outlay. (as a fix you could set the back and front engines as designated and set the center thrust to only use designated engines.)

I'll PM my craft file to you. Basically a shuttle, with two B9 SABRE engines on a rotatron, slightly aft of the center of mass, and two pure turbine engines surface-mounted just behind the nose.

the developer of mechjeb is not going to implement rounding...

I'll ping Mechjeb about this. You never know.

ZRM's Kerbcom Avionics proved it is realistic to use such information to calculate the exact thrust for every engine in three dimensions, so you do have a good grip on the situation. Unfortunately I am not an expert mathematician like ZRM

ZRM's solution is much closer to the mark, but there are several issues with it: He's not using a solution for individual moments of torque for each engine, because it does not support engines orientated along any axis - they need to be offset. This makes his solution unusable in my designs. The second problem is that there appears to be no way to override using differential thrust on the engines as a phased array for the gimble. That's a really nice concept when using rocket engines, but fails hopelessly when using turbines. Also, ZRM appears to have retreated, so I don't know when he's going to be updating KerbCom for .23 and multi-mode engines.

I am busy studying your code. I'm about halfway through, although it is hard reading code when I don't entirely understand the context and my C# aint that strong, although I did manage to find some documentation on the forum. My plan is to find some stock code online to calculate torque moments about a point, and then see how this can be implemented in the code. I'm happy to help you with the maths - it's just that C# is not my language. I'll let you know my findings.

Share this post


Link to post
Share on other sites

With a long and sordid history in vehicle tracking and GIS systems, it is not as hard as it looks. But I need some help getting there:

1. I've managed to find the CoM on the Vessel, but have no idea how this is represented in Vector3. Is this just an x;y;z array?

2. For the life of me, I cannot see how to find the position and orientation of a part wrt the rest of the vessel.

3. I'm also struggling to find out the direction of thrust for the engine. I've read elsewhere that the thrust is along the z-axis, but how does this work on engines like the B9 VTOL engine, or other engines whose thrust vector can be altered in flight?

I'm going to get cracking on the maths in the meantime. This may take a couple of days...

Share this post


Link to post
Share on other sites
With a long and sordid history in vehicle tracking and GIS systems, it is not as hard as it looks. But I need some help getting there:

1. I've managed to find the CoM on the Vessel, but have no idea how this is represented in Vector3. Is this just an x;y;z array?

Yip, you can do something like vessel.Com[0], vessel.Com[1] or vessel.Com[2] to get x, y and z. This location not be in relation to the vessel itself.

2. For the life of me, I cannot see how to find the position and orientation of a part wrt the rest of the vessel.

you do this with:

vessel.ReferenceTransform.InverseTransformPoint(part.transform.position)

so the distance along the x-axis to the CoM is something like this

(vessel.ReferenceTransform.InverseTransformPoint(p.transform.position)[x] - vessel.ReferenceTransform.InverseTransformPoint(vessel.CoM )[x]);

for direction there is Transform.InverseTransformDirection

relevant unity documentation

3. I'm also struggling to find out the direction of thrust for the engine. I've read elsewhere that the thrust is along the z-axis, but how does this work on engines like the B9 VTOL engine, or other engines whose thrust vector can be altered in flight?

To find the directions of thrust you would look for the thrust transforms in engines, this is a separate transform you add to engines which decides the direction of the thrust. So thrust is not necessarily along the z-axis of a part and that z-axis remark likely refers to the thrust transform.

foreach (Transform tr in ModuleEngines.thrustTransforms)
{
tr.rotation
}

In the my code look for the adjust() function. Slightly above is a brief comment which describes how the center thrust works and below are the relevant functions you would be interested in. All the other code before it is just GUI, saving and loading of profiles, keyboard and joystick support for throttles etcetera.

Share this post


Link to post
Share on other sites

Very helpful - thanks. You see, I would never have got that.

So I've drawn lots of pictures and looked at this from several angles, and am slowly coming up with a plan. It occurred to me, pondering the pictures, that if you can resolve the forces in each plane (XY, XZ, YZ), then the calculation becomes a whole lot easier. This seems to be the most intuitive approach. Still working on common sense rather than Mathematics, it also occurs to me that:

1. If a solution cannot be found that satisfies a balance on all three planes, then there is no solution.

2. Where there are engines perpendicular to the plane, they have no effect on the torque on that plane. In other words, a solution on the XY plane may have multiple values, or "Don't Care" elements, where engines are parallel to the Z axis.

Using the Euler angles in the thrust transform, you can determine the engine's angle to each axis. This is an assumption - please correct me if I'm wrong. I really cannot get my head around quaternions.

If Euler angles (A; B; C) are the angles around the (x; y; z) axes respectively, then the force applied on the XY plane by an engine can be calculated as Thrust * CosA * CosB, where C is the direction of the resulting vector on the plane. We can then continue the torque calculation in 2D space, which renders the problem down to high-school mathematics.

The approach, then, is to solve each plane, skipping engines that are perpendicular to the plane in the calculation of the required adjustment. Then take the resulting values and check that the net torque is still zero on all three planes. If it is, then there is a solution, otherwise there is not. By way of example, take a space plane with two engines symmetrically mounted on the sides of the fuselage, below the center of mass. I'm working on the assumption that Z is the direction of travel, X is horizontal across the direction of travel and Y is vertical. On the XZ plane, then (i.e. looking top down), there is a solution: As long as the engines have the same thrust, the net torque will be zero. Since the engines are parallel to the direction of travel, there are no forces on the XY plane, so all solutions will work. On the YZ plane (side view), however, both engines contribute torque in the same direction, so there is no solution.

Add another engine to the top of the fuselage. Now, there is still a solution on XZ, although the 3rd engine has no effect on torque, because its thrust vector goes straight through the center of mass. The other two engines still need to apply equal thrust to maintain balance. XY still has no forces. on YZ, the combined torque from the first two engines need to offset the torque from the new top engine. There is a solution on YZ. Then go back to XY and XZ, and make sure that the solution found for YZ hasn't thrown off the balance in one of the other two planes, and we're set.

Any thoughts?

Share this post


Link to post
Share on other sites
Very helpful - thanks. You see, I would never have got that.

So I've drawn lots of pictures and looked at this from several angles, and am slowly coming up with a plan. It occurred to me, pondering the pictures, that if you can resolve the forces in each plane (XY, XZ, YZ), then the calculation becomes a whole lot easier. This seems to be the most intuitive approach. Still working on common sense rather than Mathematics, it also occurs to me that:

1. If a solution cannot be found that satisfies a balance on all three planes, then there is no solution.

2. Where there are engines perpendicular to the plane, they have no effect on the torque on that plane. In other words, a solution on the XY plane may have multiple values, or "Don't Care" elements, where engines are parallel to the Z axis.

Using the Euler angles in the thrust transform, you can determine the engine's angle to each axis. This is an assumption - please correct me if I'm wrong. I really cannot get my head around quaternions.

Yes this is possible. You can also assume that all other basic input you would need for this 'problem', like angles, positions and thrust, can directly derived from the game or calculated.

If Euler angles (A; B; C) are the angles around the (x; y; z) axes respectively, then the force applied on the XY plane by an engine can be calculated as Thrust * CosA * CosB, where C is the direction of the resulting vector on the plane. We can then continue the torque calculation in 2D space, which renders the problem down to high-school mathematics.

The approach, then, is to solve each plane, skipping engines that are perpendicular to the plane in the calculation of the required adjustment. Then take the resulting values and check that the net torque is still zero on all three planes. If it is, then there is a solution, otherwise there is not. By way of example, take a space plane with two engines symmetrically mounted on the sides of the fuselage, below the center of mass. I'm working on the assumption that Z is the direction of travel, X is horizontal across the direction of travel and Y is vertical. On the XZ plane, then (i.e. looking top down), there is a solution: As long as the engines have the same thrust, the net torque will be zero. Since the engines are parallel to the direction of travel, there are no forces on the XY plane, so all solutions will work. On the YZ plane (side view), however, both engines contribute torque in the same direction, so there is no solution.

Add another engine to the top of the fuselage. Now, there is still a solution on XZ, although the 3rd engine has no effect on torque, because its thrust vector goes straight through the center of mass. The other two engines still need to apply equal thrust to maintain balance. XY still has no forces. on YZ, the combined torque from the first two engines need to offset the torque from the new top engine. There is a solution on YZ. Then go back to XY and XZ, and make sure that the solution found for YZ hasn't thrown off the balance in one of the other two planes, and we're set.

Any thoughts?

Yes. Your approach seems to rely on the assumption it can be reduced to three 2D planes which can be solved separately or at least sequentially by first solving one and then the others and then maybe checking if the first one is still okay.

Intuitively, in the sense that I haven't really analyzed it, I do not think you can solve the problem like that. The best way for me to articulate this intuition without resolving to calculations is to wonder how a human would approach balancing a complex configuration of engines in three dimensions. This would include engines with none right angles to the vessel. You can imagine a specific configuration in which the obvious engine which would balance thrust in one plane would not be a good decision because of the impact it would have on the others, therefore the planes cannot be looked at separate.

You can verify this by taking the whole thing one dimension lower and try to solve a two dimensional problem by only considering one dimension at a time.

(Yot down 3-5 dots semi randomly around the origin of a graph, call the origin the CoM, give the engines a starting thrust and try imagine how you would solve it.

When you look at this two dimensional graph it would be easy to see which engines would probably pave have to be tuned down to center the CoT on the CoM.

Now limit yourself to only take into consideration one dimension, so only look at the X coordinates of the engines, CoT, in respect to the CoM. It will be quickly apparent the engine(s) which might look like the obvious pick to be adjusted to balance this one dimension would actually be suboptimal or bad picks when taking into account the two dimensional picture. Not in all cases, obviously, but there would be a non trivial amount of engine configurations in which this was the case.

Balancing the Y dimension after balancing X would not solve the problem or bring you closer to a solution and cycling between dimension would only have you go around in circles.

These type of things tend to translate well to higher dimensional and therefore you probably can't solve a three dimensional problem by solving three two dimensional planes separately, unless all engines are at right angles and did not effect more than one plane.

Share this post


Link to post
Share on other sites

I don't entirely agree with your logic. Torque will always occur on a plane, whether you're working in 2 or 3 dimensions, and I am certain that if a solution satisfies all three axial planes, that it is a valid solution. When I'm trying to balance a plane by eye-balling it, this is effectively what I'm doing - checking that it is balanced from the left, from the top and from the back. However, that said, it's not you that I need to convince, but the results of the solution. And even once I have the Maths all worked out, I have no idea what sort of algorithms I'm going to use to combine the planes into a workable solution.

Whether or not this is the right approach for this problem remains to be seen. I am hoping that by the end of the calculation, I will end up with a set of simultaneous equations resolved as a ratio that each engine must contribute to the overall thrust in order to maintain equilibrium, but I'm not seeing a way of doing this without using a brute force approach. I'm afraid I've stalled on this for the moment: Demands at work are astronomical at present, but I plan to spend some time on it next weekend, when things have quietened down a bit.

Any idea what has happened to KerbCom Avionics? He seems to have fallen off the grid.

Share this post


Link to post
Share on other sites

Don't know exactly what happened to KerbCom. There's a another throttle control mod out by the way. It does involve calculating torque of each engine, so you might be interested in checking it out, although it takes a different approach from there on out.

Share this post


Link to post
Share on other sites
This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.