Closed vrodriguezf closed 10 months ago
I just coded an agent to do this, here: arclab_mit/agents/jason_keyboard_input.py You need to install pynput (pip install pynput), then run it like any other agent, and use H/N, J/L, I/K controls. You can press the keys from any focused window; it will capture all key presses and send it to KSP.
I'm not sure what logs we want, so I didn't add that in yet
I have two questions: Is there any way to activate two different thrusters at the same time using that library? Also, left and right throttles seem to not be inverted so it may be confusing for use (because of the lag that agent has sending actions), was that on purpose?
1: Yes, pynput just tracks key presses, so you can press H and J and it will activate both thrusters 2: I copied the game's controls, from here: https://wiki.kerbalspaceprogram.com/wiki/Key_bindings I think J/L is backwards, if that's what you mean, because the link says J should be left and L should be right, so for right_throttle values, J is -1 and L is +1
Great work! I'll try it out once I come back to town. One question: how do you map numerically pressing a key to the number that you put in the action vector? Just put one value in the specific position of the 4D vector?
Yeah, I store the forward_throttle, right_throttle, and down_throttle values, then these are updated when you press the corresponding key and reset when you release that key (see the if statements in on_key_press and on_key_release). Then every time get_action is called, it looks up these values and puts them in the 4D vector.
Great. The value 0.5 for the time of the action has any relevance at all when the actions are mapped from the keyboard?
no, its just how often the action vector is sent. I thought 0.5 is good, but it can be anything
Well it should affect the "input lag" right? Not that this is an action game precisely, but 0.5 means that if you press two keys in less than 0.5 seconds, only the last one would make it. Not a problem in this case, in my view this value is especially relevant in terms of the frequency with which you get observations from the environment.
Everything clear, i'm closing this, thank you!
Instead of getting logs from external KSP mods, another way of getting logs from games played by a human would be to connect the human controls on the keyboard to a Python script that maps them to actions, and then send the actions to the game through krpc as any other autonomous agent do.