Jump to content

[1.6] Davon Throttle Control systems mod [v088]


PrivateFlip

Recommended Posts

Quote
Davon TC systems supply advanced throttle control capabilities. This includes but is not limited to separate, additional throttles to which individual engines can be slaved and several settings which modify the response of individual engines to throttle input. Allows saving of configuration in separate profile for use in multiple ships. Using technology of a bygone era it also supplies a very functional center thrust mode which adjusts the thrust of individual engines so as to balance asymmetrical or otherwise imbalanced craft and optionally supplies some throttle steering functionality.

Download on Kerbal CurseForge

Download on Space Dock

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

zPOSIxs.png

===============================

-As of now there are a also number of modes for individual engines. In addition to the Limit Thrust option already provided there is an Level Thrust option which has the engine level of at a certain percentage of its maximum thrust. There is also an extra functionality to apply these modes to all engines of the similar model/type to save time.

-The mod supplies four additional throttles to which individual engines can be slaved.

-There is a center thrust mode which adjust individual engines so the Center of Thrust onto is aligned with the Center of Mass. This balances the thrust of a ship and should make asymmetrical ships more feasible.

-The center thrust mode also supplies a throttle steering option. When throttle steering is enabled the center thrust mode also offsets the Center of Thrust based on input from controls and SAS. This allows steering of the vessel in combination with controls and stabilization of the vessel in combination with SAS

-It is possible to save the configuration of engines and all settings in a profile for a vessel. The profile can be loaded again to other vessels of the same type.

See manual for details

A video by Scott Manley using the mod to attempt an engines only landing with a B9 Strugatsky.

 

 

Shuttle using the center thrust mode by SkyHook:

MsJOGPZ.png

Edited by PrivateFlip
Link to comment
Share on other sites

The new mod template I have been working on demonstrates per-ship settings (in a save) - feel free to nick code to enable that feature ;)

Also, this seems to partly duplicate another project, but I am not sure if that one has been abandoned or not. If it is still going, you could probably learn from this guy - he really sounds like he knows his stuff (Well the maths side at least).

Link to comment
Share on other sites

The new mod template I have been working on demonstrates per-ship settings (in a save) - feel free to nick code to enable that feature ;)

Also, this seems to partly duplicate another project, but I am not sure if that one has been abandoned or not. If it is still going, you could probably learn from this guy - he really sounds like he knows his stuff (Well the maths side at least).

Dang, you're right! The project isn't abandoned and if the mod indeed is able to adjust RCS in the way they say, main engines must be child's play from there on. They're mentioning they're completely replaced ModuleRCS on RCS parts, which is a lot more elegant than how I did this one.

Thanks for the heads-up EvilC.

Link to comment
Share on other sites

Dang, you're right! The project isn't abandoned and if the mod indeed is able to adjust RCS in the way they say, main engines must be child's play from there on. They're mentioning they're completely replaced ModuleRCS on RCS parts, which is a lot more elegant than how I did this one.

Thanks for the heads-up EvilC.

No, I have not abandoned it. It is just taking a while to get right. The RCS balancing is working perfectly (and with very good performance) right now. I'm waiting until I get the engine balancing working correctly before I release it all, though. It's funny you mention that main engines must be "child's play". In fact they're turning out to be the hardest part. I'm trying to get it to work right now. Don't forget that engines have gimbal control, a minThrust parameter (mainly for SRBs) and over all this the user wants something that behaves as expected with automatic calibration (I learnt this from comments on my first release). And since quite often you have more DOF limitations with engines than with RCS (you may have RCS ports covering all directions on a vessel and distributed well around the COM, but engines only pointing in one direction and on one side of the vessel), the solver has to compromise in some situations.

If you look at my dev thread you will see that I have solved all the technical problems, e.g. performance, control ownership when docking or decoupling, etc. So once the engine balancing is done, the plugin should be a stable, useful addition for most KSP players.

Link to comment
Share on other sites

No, I have not abandoned it. It is just taking a while to get right. The RCS balancing is working perfectly (and with very good performance) right now. I'm waiting until I get the engine balancing working correctly before I release it all, though. It's funny you mention that main engines must be "child's play". In fact they're turning out to be the hardest part. I'm trying to get it to work right now. Don't forget that engines have gimbal control, a minThrust parameter (mainly for SRBs) and over all this the user wants something that behaves as expected with automatic calibration (I learnt this from comments on my first release). And since quite often you have more DOF limitations with engines than with RCS (you may have RCS ports covering all directions on a vessel and distributed well around the COM, but engines only pointing in one direction and on one side of the vessel), the solver has to compromise in some situations.

Yes, I've been looking into what my own steps forward would be as in a making generic algorithm to get it CoT on the CoM and it is more complicated than when I made those comments yesterday. It was 4:30 in the morning for me when I made the comments after a long day. Haven't looked at your source code yet, but I'm pretty sure your implementation is a lot more sophisticated than what I would have been going for. It would come down to the player choosing one of six directions the engines where facing, ignore gimbal, and then using a combination of a some smart but simple engine adjusting algorithm to move the CoT incrementally towards the CoM over several cycles, in the remaining 2D plain.

If you look at my dev thread you will see that I have solved all the technical problems, e.g. performance, control ownership when docking or decoupling, etc. So once the engine balancing is done, the plugin should be a stable, useful addition for most KSP players.

Sounds good, great work!

Link to comment
Share on other sites

I have updated the plugin. It now adjusts the ModuleEngines.currentThrottle instead of the MaxThrust to achieve its effect. I tried to use currentThrottle before but it didn't work until i came across ruffus's Throttle Steering mod which did use currentThrottle (the trick is to set useEngineResponseTime to True). It now correctly handles heat, animation and sound, which is nice.

Despite the fact there is already a similar project in the works I decided to finish this one anyway. One of the side effects of the relative simplicity of this mod compared to ZRM's KerbCom Avionics Coordinated is that it shouldn't take me too much time otherwise I wouldn't have bothered.

The option to automatically adjust the thrust of engines to keep an asymmetrical ship stable is actually almost done except for one super annoying hurdle. For some reason I can't figure out how to get the position of a part in relation to the vessel as in a position which remains the same as the ship turns, this is necessary to determine where an engine is located. The rest is pretty much done so if anyone has ideas please help, because I'm truly stuck.

Edited by PrivateFlip
spelling errors
Link to comment
Share on other sites

I have updated the plugin it now adjusts the ModuleEngines.currentThrottle instead of the MaxThrust to achieve its effect. I tried to use currentThrottle before but it didn't work until i came across ruffus's Throttle Steering mod which did use currentThrottle (the trick is to set useEngineResponseTime to True). It now correctly handles heat, animation and sound, which is is nice.

The way it is done in Throttle Steering is not exactly correct, as far as I can tell. You need to replicate the response time effect and also stop ModuleEngines from fighting you by setting the engine's own engineAccelerationSpeed and engineDecelerationSpeed to zero. So when you hijack the engine, you should do something like this:


useEngineResponseTime = engine.useEngineResponseTime;
if (useEngineResponseTime)
{
engineAccelerationSpeed = engine.engineAccelerationSpeed;
engineDecelerationSpeed = engine.engineDecelerationSpeed;
}
engine.useEngineResponseTime = true;
engine.engineAccelerationSpeed = 0.0f;
engine.engineDecelerationSpeed = 0.0f;

And then, every fixed update, you should do something like this:


if (useEngineResponseTime)
{
if (engine.currentThrottle > throttle)
engine.currentThrottle = Mathf.Lerp(engine.currentThrottle, throttle, engineDecelerationSpeed * Time.deltaTime);
else
engine.currentThrottle = Mathf.Lerp(engine.currentThrottle, throttle, engineAccelerationSpeed * Time.deltaTime);
}
else
{
engine.currentThrottle = throttle;
}

where throttle is the desired throttle to set. I'm pretty sure this is practically the same as how the game does it - engine thrust definitely changes at an exponential rate to meet the current throttle, and the behaviour seems identical to me, after some timing tests on the jet engines.

The option to automatically adjust the thrust of engines to keep an asymmetrical ship stable is actually almost done except for one super annoying hurdle. For some reason I can't figure out how to get the position of a part in relation to the vessel as in a position which remains the same as the ship turns, this is necessary to determine where an engine is located. The rest is pretty much done so if anyone has ideas please help, because I'm truly stuck.

I work in the vessel.transform space. Just transform positions with vessel.transform.InverseTransformPoint and directions with vessel.transform.InverseTransformDirection. If you do this with both engine positions/directions, the COM and the user input via the vessel.ReferenceTransform (the command module reference frame), everything is in the same coordinate space for solving the system. If you really want everything in a constant frame, use vessel.ReferenceTransform.

P.S. My mod is called "KerbCom Avionics". The "coordinated" part is part of the particular feature name, "Coordinated RCS".

Edited by ZRM
Link to comment
Share on other sites

The way it is done in Throttle Steering is not exactly correct, as far as I can tell. You need to replicate the response time effect and also stop ModuleEngines from fighting you by setting the engine's own engineAccelerationSpeed and engineDecelerationSpeed to zero. So when you hijack the engine, you should do something like this:


useEngineResponseTime = engine.useEngineResponseTime;
if (useEngineResponseTime)
{
engineAccelerationSpeed = engine.engineAccelerationSpeed;
engineDecelerationSpeed = engine.engineDecelerationSpeed;
}
engine.useEngineResponseTime = true;
engine.engineAccelerationSpeed = 0.0f;
engine.engineDecelerationSpeed = 0.0f;

And then, every fixed update, you should do something like this:


if (useEngineResponseTime)
{
if (engine.currentThrottle > throttle)
engine.currentThrottle = Mathf.Lerp(engine.currentThrottle, throttle, engineDecelerationSpeed * Time.deltaTime);
else
engine.currentThrottle = Mathf.Lerp(engine.currentThrottle, throttle, engineAccelerationSpeed * Time.deltaTime);
}
else
{
engine.currentThrottle = throttle;
}

where throttle is the desired throttle to set. I'm pretty sure this is practically the same as how the game does it - engine thrust definitely changes at an exponential rate to meet the current throttle, and the behaviour seems identical to me, after some timing tests on the jet engines.

You do notice the main throttle fighting you but the effect isn't overly pronounced, which was good because I knew no way to fix it, although I can imagine it is a vital factor for what you are trying to achieve. So what you do is first eliminate the ModuleEngines' influence to stop it from fighting and then simulate this acceleration speed yourself.

I work in the vessel.transform space. Just transform positions with vessel.transform.InverseTransformPoint and directions with vessel.transform.InverseTransformDirection. If you do this with both engine positions/directions, the COM and the user input via the vessel.ReferenceTransform (the command module reference frame), everything is in the same coordinate space for solving the system. If you really want everything in a constant frame, use vessel.ReferenceTransform. ...

Got it to work with:

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

You have no idea how long I have been trying to find a solution, maybe close to six hours in total. I did try to use InverseTransformPoint and InverseTransformDirection but whatever i did there was always something wrong.

Granted, most of my fiddlings were of the form:

part.transform.InverseTransformPoint(Local.Com)

:D it all makes sense now.

But seriously, I'm incredibly thankful! My math skill probably precludes me returning the favor in any meaningful way, but if you need help with testing be sure to ask.

Edited by PrivateFlip
Link to comment
Share on other sites

The center thrust mode is now crudely working and seems be able to balance simple craft. I have not updated the download yet this is just a status update.

The module acts on angular momentum. Because of this it is by nature responsive: there first needs to be a deviation to correct.

Does steering cause angular momentum? It does. Initially the vessel gave enormous countersteer making it uncontrollable. To make the the vessel steerable I've had to implement dampening which turns of the plugin while steering (dampening is default set to 1 = complete, with a duration of half a second). In addition i had to make the dampening linger after a steering input to allow to not make the momentum of the last input to cause a correction. This does necessitate the user to end his steering action as stable as possible. Any steering momentum remaining after the dampening duration will be incorrectly corrected. It also requires you to let the vessel from a relatively stable direction "fall" for a time longer than this duration to allow the plugin to make correction as balance changes by depleting fuel.

Ships with small imbalances, like the on below, can take off with relatively little effort.

On the module:

-push scan to initiate the module

-push Center Thrust to open the center thrust configuration window

In the window:

-select "All" (to select all engines to take part in corrections)

-press Update to implement settings

-press On

And you're ready to launch by slowly increasing thrust.

ship1.png

this ship has been imbalanced by a differential thrust module, not a good design choice

In ships in which it is clear which engines will be the engines which will produce over thrust you can single out these engines. After pressing scan on the module, select the engine push Set engine to open the engine configuration window and set this engine as a designated center thrust engine. In the center thrust configuration window you would then select "Designated" instead of "All"

Ships like the ones below present problems for the plugin. Due to the high imbalance and the fact that this module is responsive causing it to take time to find the balance. Time you don't have. You can increase the 'Adjustment size' to fifty but this leads to wobbling due to massive overcompensation which often only postpones a crash. The only way to do it neatly is setting the engine to a CenterThrust and giving it a startup value with is closer to the balancing thust. This value has to be found by trial and error.

For the ship below the mainsail had to be set to start out at somewhere around 65-75%.

ship2.png

ship3.png

Did flew this last one into orbit eventually. This would be impossible without the module. It does requires constant attention because of instability and might cause high blood pressure. On more than one occasion during testing I found myself forgetting to set the focus back to the main screen after making a small update in the config window which caused any keyboard input to keep going to the window. These brief distraction were often enough to completely loose control of the vessel.

One way to mitigate some of these issues would be to base the plugin at least partly on the actual center of thrust, my initial idea, but this value is unfortunately not readily available. With ZRM's mod on the horizon, the work to compute this value or something approaching it would probably be a waste of effort.

Edited by PrivateFlip
Link to comment
Share on other sites

  • 2 weeks later...

Have you considered using the node target or the navball ascent guidance to determine deviation? That would be useful in manual flight and also sync your mod very well with the MechJeb autopilot.

I'm interested in using the mod as a safeguard against fuel imbalances and engines cutting out asymmetrically. I think it might also be useful to do asymmetric staging. I haven't had much luck using it in that way yet.

Link to comment
Share on other sites

Have you considered using the node target or the navball ascent guidance to determine deviation? That would be useful in manual flight and also sync your mod very well with the MechJeb autopilot.

Hadn't considered that yet. The functionality I'm assuming you want is for the engines to be adjusted to maintain a certain course either the last heading the user put the ship on or a target heading. It sounds obvious enough and would improve usability dramatically if it works. I will look into it.

I'm interested in using the mod as a safeguard against fuel imbalances and engines cutting out asymmetrically. I think it might also be useful to do asymmetric staging. I haven't had much luck using it in that way yet.

Countering fuel imbalances should be well within the capabilities but it is in no way fast enough to adjust to engines cutting out mid flight.

I would be interested to know what problems you encountered with asymmetric staging. (If you haven't you should definitely read the manual.)

Link to comment
Share on other sites

So forgive me if it has being asked before but will this help balance a vtol aircraft if the vertical lift engines are not balanced right? Well Ill download and try it anyway.

You could. You would have to make sure you set the vertical engines to Center Thrust mode and select the option to only use designated engines (see manual).

But you might want to try out KerbCom Avionics instead. Because it adjust engines in a more sophisticated manner it'll give you higher performance with greater ease of use than my mod.

Link to comment
Share on other sites

Great! Now i can throw away my own home-made EngineThrustController plugin. :D

The PercentageThrottle mode seems to be perfect to fit my needs...

One question though, is there any possibility that the plugin will save the preset thrust configurations during editor stage?

Link to comment
Share on other sites

Great! Now i can throw away my own home-made EngineThrustController plugin. :D

The PercentageThrottle mode seems to be perfect to fit my needs...

One question though, is there any possibility that the plugin will save the preset thrust configurations during editor stage?

Out of curiosity, what did you're own plugin do exactly?

Well no, this is not possible. It would require you to be able to set all these option in the VAB, which currently is not possible because parts, to the best of my knowledge, can't be saved with custom configuration in editor mode.

But I assume you're asking this because you want to have a default configuration loaded up at launch because you have a standard ship which you use repeatedly and you don't want to set the configuration for the launch of each vessel. This is possible although it does require a little effort. Let me quote the manual: :)


#6 Saving and loading
The configuration of individual engines is not automatically saved while saving
the game. To save these settings you can open the module configuration window
and press “Save Engine Configuration†before pressing F5. After loading the ship
you can press “Load Engine Configuration†after activating the module.

#8 Creating a default ship profile
This is not really a feature but might come in handy for those who have a
standardized ship.
To create a default launch profile for a particular ship you can save a configuration
as described in paragraph 6. Then save the game. Open the quicksave file and look
for the variable 'savedEngCon'. Copy the long line behind this variable to the same
variable in the part.cfg. When using this part you can now load up the standard
engine configuration for the ship as described in paragraph 6.

I do understand this is far from user friendly. If this ends up being a huge bummer for a lot of people I could add some additional functionality allowing users to save a configuration under a named profile so it can be loaded and used by other ships.

Link to comment
Share on other sites

Out of curiosity, what did you're own plugin do exactly?

Well no, this is not possible. It would require you to be able to set all these option in the VAB, which currently is not possible because parts, to the best of my knowledge, can't be saved with custom configuration in editor mode.

It is possible. Check out how Modular Fuel System and B9 cargo bays work.

Link to comment
Share on other sites

It is possible. Check out how Modular Fuel System and B9 cargo bays work.

Checking out Modular Fuel System's source code now, I'll think i'll go for the option to save engine configuration in a manner it can be loaded by other ships instead of implementing something like this. But thanks for pointing that out.

Link to comment
Share on other sites

  • 2 weeks later...
  • 3 weeks later...

Update

-Profiles now saves all configuration not just engine settings

-Revised GUI, reducing number of buttons to push to operate the module, simplifying operation.

-Center thrust mode can now function while ship is controlled from every command module, not just the module itself.

The earlier version required the user to check a number of settings for every launch. Forgetting one would result in failure without giving any indication the module wasn't in the correct state. This has now been largely revised by creating changing the logic behind the user interface so most of these steps are performed automatically. Also changed how the module integrated it's navigational data and position of engines so the vessel can be controlled from other command module of the ship supplied the user indicates the direction the engines are facing in relation to this module.

Edited by PrivateFlip
Link to comment
Share on other sites

  • 2 weeks later...

So I wanted to find a mod to keep turbojets at max power and vary rockets with throttle. And this is fantastic mod. Even too good in fact. It completely eliminates throttle response when engaged. So turbojets dont spool up.

Basically eliminating the reason why I wanted to keep turbojets at fixed throttle.

Now testing mechjeb landing with turbojets...

Which goes badly as mechjeb thinks jets are doing 225kn but are really doing 112kn...

Edited by Radam
Link to comment
Share on other sites

So I wanted to find a mod to keep turbojets at max power and vary rockets with throttle. And this is fantastic mod. Even too good in fact. It completely eliminates throttle response when engaged. So turbojets dont spool up.

Basically eliminating the reason why I wanted to keep turbojets at fixed throttle.

First of all thank you for the feedback, it's always nice to know someone is using your work.

The effect you mention is a known issue/feature. It could change it back to the normal behavior, but this made the center thrust mode more acute. However from the feedback I've gotten from people actually using this mod nobody appears to be using this mode, which is interesting because it was the reason to make the mod in the first place, so I might change it to approach the normal behavior in future updates.

Link to comment
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.

×
×
  • Create New...