Jump to content

Is there any throttle ramp-up time?


Recommended Posts

I'm trying to code a precise script using the KRPC API and was wondering (as the title says) if there is any throttle ramp-up time? So how long does it take from setting the throttle to 1 to actually having that throttle? I guess at maximum it is on the scale of a few physics ticks but at mun orbital speed a tick are already 20 m.

Link to comment
Share on other sites

This is based on a number of things.  As Boris-Barboris mentioned, part of it is based on where the code is triggered from.  Another part of it is the engine itself.  If its a Jet Engine, then yes, there is a delay from throttle to actual thrust.  As far as I have seen, there is also a small delay for Liquid fuel engines, as hitting Z doesn't immediately go to full throttle, it rapidly increases throttle till max.  The same is true for hitting X, it doesn't *immediately* kill throttle, it takes a couple of frames to do so.

Link to comment
Share on other sites

Thanks for your replies! I should have been more specific: I only look at rocket engines right now.

In the meantime I also realized that I should be able to actually measure the time it takes using a small KRPC script. The script waits until I click a button. It then sets the throttle to 1.0 and waits until it actually is 1.0. Finally, it prints the time difference to the console. Here is the code:

Spoiler

from __future__ import division
import krpc
import time


RPC_PORT = 50002        # ports used for the KRPC connection
STREAM_PORT = 50003     # default: RPC_PORT = 50000, STREAM_PORT = 50001


# -------
# initialize connection to KSP
conn = krpc.connect(name='Test', rpc_port=RPC_PORT, stream_port=STREAM_PORT)

# ---
# set up UI
# ---
canvas = conn.ui.stock_canvas
screen_size = canvas.rect_transform.size
panel = canvas.add_panel()
panel_size = (200, 100)
panel.rect_transform.size = panel_size
panel.rect_transform.position = (screen_size[0]//2-panel_size[0]//2-10, 0)

# add a button
button = panel.add_button('Test')
button.rect_transform.size = (panel_size[0]-20, 30)
button.rect_transform.position = (0, 0)

# add stream to monitor button state
button_clicked = conn.add_stream(getattr, button, 'clicked')

sc = conn.space_center
vessel = sc.active_vessel
control = vessel.control
ut = conn.add_stream(getattr, sc, 'ut')
throttle = conn.add_stream(getattr, control, 'throttle')
t0 = 0.0
t1 = 0.0

while True:
    if button_clicked():
        button.clicked = False
        time.sleep(0.1)
        t0 = ut()
        control.throttle = 1.0
        while throttle() < 0.9:
            print ut()-t0
            time.sleep(0.001)
        t1 = ut()
        control.throttle = 0.0
        
        print '\ndelta_t = %.4f' % (t1-t0)

 

This time difference is always 60 ms! I guess this is exactly 3 physics ticks as the in-game time ut() increases in steps of 20 ms. Is this plausible to you?

Link to comment
Share on other sites

1 hour ago, marcnesium-iv said:

Is this plausible to you?

Yes, this sounds about right for hitting one of the hotkeys that sets the throttle to full, or zero. You also get the throttle lever animation and everything, kRPC doesn't bypass all of that.

But for completeness sake, you should perhaps try the tweakables as well: Open throttle, then measure how long it takes for engine.max_thrust to get from zero to full. Or toggle the engine on/off. I'd half expect that this would be instantaneous, but never bothered to find out.

Edited by Laie
Link to comment
Share on other sites

Thanks for your input!

On 10/20/2019 at 5:47 PM, Laie said:

But for completeness sake, you should perhaps try the tweakables as well: Open throttle, then measure how long it takes for engine.max_thrust to get from zero to full. Or toggle the engine on/off. I'd half expect that this would be instantaneous, but never bothered to find out.

engine.max_thrust seems to be independent from the throttle. But, as you expected, I can confirm now that toggling the engine is instantaneous-- at least in most cases. Sometimes (in my case 3 times out of 50) it takes one tick to activate the engine. So for my code I'll use your method.

What I also noticed is that the throttle lever animation is not completely locked to the actual throttle. When I did my previous measurements (throttle 0.0 -> 1.0 -> 0.0) the lever would go only up to 50% and then down to zero.

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...