Jump to content

djungelorm

Members
  • Posts

    379
  • Joined

  • Last visited

Everything posted by djungelorm

  1. Ahhh you found a bug! According to the docs it should return the inclination in radians, but it's doing the conversion incorrectly. This workaround should give you the inclination in degrees: vessel.orbit.inclindation * (math.pi / 180.0)
  2. I'm afraid not. Will add it to the next release. This isn't possible for parts in general, but is for docking ports. I guess we need to add something similar to kOS. If you have the Docking Port Alignment Indicator mod, you can get the name of a docking port using DockingPort.Name (http://krpc.github.io/krpc/csharp/api/space-center/parts.html#property-KRPC.Client.Services.SpaceCenter.DockingPort.Name)
  3. kRPC v0.3.5 has been released! The major changes are: Overhauled the autopilot, so it should handle vessels of different sizes better. It auto-tunes the PID parameters based on vessel MoI and torque, and uses a different approach for the target angular velocity calculation. I wrote a tutorial on how it works, how to configure it and the maths behind it here: http://krpc.github.io/krpc/tutorials/autopilot.html Support for KSP 1.1.3 Added science parts - allows you to run experiments, transmit the data etc. http://krpc.github.io/krpc/csharp/api/space-center/parts.html#experiment Full changelog available here: https://github.com/krpc/krpc/releases/tag/v0.3.5 Enjoy!
  4. kRPC v0.3.5 has been released! The major changes are: Overhauled the autopilot, so it should handle vessels of different sizes better. It auto-tunes the PID parameters based on vessel MoI and torque, and uses a different approach for the target angular velocity calculation. I wrote a tutorial on how it works, how to configure it and the maths behind it here: http://krpc.github.io/krpc/tutorials/autopilot.html Support for KSP 1.1.3 Added science parts - allows you to run experiments, transmit the data etc. http://krpc.github.io/krpc/csharp/api/space-center/parts.html#experiment Full changelog available here: https://github.com/krpc/krpc/releases/tag/v0.3.5 Enjoy!
  5. Propellant ratios are the amount of each fuel that an engine burns. For example, if a engine has ratios where Liquid Fuel is 0.6 and Oxidizer is 0.4, then that means for every 0.6 units of Liquid Fuel the engine burns, it burns 0.4 units of Oxidizer. The values themselves are unit-less. They are also scaled so they sum to 1.
  6. Thanks - I really enjoy working on it It is quite a handful to manage all the different languages and tools, but the bazel build system really helps a lot with that. I use it to run unit tests for all the different clients and the server code. The tests are written in a variety of ways, e.g. nunit for the C# code, googletest for C++, unittest module for python... The server dll is written in such a way that it can be linked it into a little "TestServer" executable that runs a server with a bunch of test RPCs. The client tests then run their tests against this test server. This means that you don't need to run KSP to run the tests, and they can also be run by Travis CI whenever I push code changes. There are also tests for the services (the bit of the project that does require KSP to be running). For these I use python scripts (using unittest and the python client). For example: https://github.com/krpc/krpc/tree/master/service/SpaceCenter/test To run them, I load up KSP with kRPC installed, then run the scripts, which connect and then test all the different bits of the API. Its quite fun to run them and watch it do things in game as it works through the tests. The API documentation is all automatically generated from the comments in the C# code. This is very useful as it means the documentation is written right next to the actual code! These generated docs are then combined with some handwritten stuff (e.g. the tutorials) and built using Sphinx into both the website and the PDF that comes in the download. As for action groups, they're here: http://krpc.github.io/krpc/csharp/api/space-center/control.html#method-KRPC.Client.Services.SpaceCenter.Control.GetActionGroup
  7. Yep you can already do this! (As long as it's in physics range of the active vessel)
  8. Nice idea! Should be possible to add receipt of a stream of pictures. Could potentially do it by encoding images as JPEGs and sending the raw bytes to the client program (the kRPC protocol supports sending arrays of bytes). I'm a bit busy trying to get a new version out before I disappear on holiday for two weeks, but can look into this more once I'm back. There is a websockets server for javascript on its way, but as for php I have no plan to implement a client for that language. However, if you like you could write your own client: http://krpc.github.io/krpc/communication-protocol.html
  9. I've finally gotten my head around the mathematics necessary to improve the autopilot and make it autotune itself based on the vessels MoI and available torque. No more overshoot or waiting ages for the oscillations to subside! I'm keen for people to test it out before I release it as it will replace the existing autopilot. If you're interested, there are more details and download links on this github ticket: https://github.com/krpc/krpc/issues/289
  10. You could get the position of the target vessel in the current vessels reference frame (in which the current vessel is at position (0,0,0)) then take the magnitude of that vector. For example: import krpc, math conn = krpc.connect() vessel = conn.space_center.active_vessel target = conn.space_center.target_vessel if target is None: print 'No target set!' else: position = target.position(vessel.reference_frame) distance = math.sqrt (position[0]*position[0] + position[1]*position[1] + position[2]*position[2]) print distance, 'meters'
  11. We're working on it There is an experimental websockets server here: https://github.com/krpc/krpc/issues/123 There is no JS client yet as such, but if you don't mind doing the protocol buffer communication yourself it is usable. There are also plans to add gRPC support which will enable use of many more languages too.
  12. Got it working import krpc conn = krpc.connect() vessel = conn.space_center.active_vessel tanks = {} # gets list of remaining xenon tanks def gettank(): global tanks tanks = {} for part in vessel.parts.all: if 'XenonGas' in part.resources.names: tanks[part] = part.decouple_stage # decouple all empty tanks def removeemptytank(): for decoupler in vessel.parts.decouplers: if decoupler.part.children[0].resources.amount('XenonGas') == 0: decoupler.decouple() gettank() enabletank() # enable next tank def enabletank(): for tank in tanks: if tanks[tank] == max(tanks.values()): for resource in tank.resources.with_resource('XenonGas'): resource.enabled = True return # main loop while True: gettank() removeemptytank() enabletank() I had to change a few things to get it to work: It gets the tanks based on what resource they contain, rather than the part name (bit more extensible - and worked with my example craft that used a different xenon tank) The values in the tanks dictionary are set to part.decouple_stage (the number of stage the decoupler attached to the tank fires in). Your previous code was setting the value to the tanks depth in the parts tree - which isn't what we want. In my example craft this value was 3 for every tank! enabletank() uses the resources object to check the amount of xenon - bit cleaner than using the mass of the part After decoupling a tank it calls gettank() to recompute the list of tanks, otherwise the script will try to inspect a decoupled part, causing a NullReferenceException Also, the resource API struck me as slightly clunky - I think it would be good to add a tank.resources.enabled property to future versions of the mod that can be used to enable/disable all the resources in a part. That would avoid having to use the for loop to set the XenonGas resource to enabled.
  13. Ahhhh this old chestnut The reference frame passed to vessel.flight() is fixed relative to the vessel => speed is 0. There's a note about this in the docs: http://krpc.github.io/krpc/python/api/space-center/vessel.html#SpaceCenter.Vessel.flight Also see here for an example: http://krpc.github.io/krpc/tutorials/reference-frames.html#orbital-speed
  14. Thanks Surface altitude is above the land and surface of the sea, bedrock is above the land and the sea bed.
  15. @Kahuette has been busy making a Haskell client and it's now ready for show time! You can check it out here: https://github.com/Cahu/krpc-hs
  16. @joeindian Looks like you might have an outdated version of the python client? There are a bunch of methods missing in your output from dir(conn.krpc) as well. Can you run the following to confirm: import krpc conn = krpc.connect() print 'client version', krpc.__version__ print 'server version', conn.krpc.get_status().version for service in conn.krpc.get_services().services: if service.name == 'KRPC': print 'KRPC procedures:', [x.name for x in service.procedures] print 'KRPC enumerations:', [x.name for x in service.enumerations] If you installed the client using pip, you can upgrade to the latest version by running pip install upgrade krpc
  17. Unfortunately the answer is "no, not yet" to all three questions 1 and 2 sound like trivial additions, so will try and get them into the next version. I've not had time to look into KSP's science API at all yet. Definitely on the todo list. A few people are wanting to at least be able to interact with the science pop up window, so I think a good starting point would be to get that working first, and later flesh it out into a more complete API that simplifies the running of experiments (without having to go through part module events as @drhay53 was mentioning). It's very possible that there is a bug with resources.enabled = true. This feature was added quite recently, so is probably not the most stable. I don't have much time right now to look into it, but will have a look later this week.
  18. Unfortunately the servo's per vessel stuff didn't make it into 0.3.4 - you caught me just before I was going to release it - the color and field setters only just made it in! Will add this in 0.3.5. Just tested this on KSP 1.1.2 with kRPC 0.3.4 and it worked fine for me! What version of the python client are you using? You figured this out then I take it I should have mentioned the 0.3.4 changelog that draw_direction and friends have been moved to the new Drawing service. The new API is documented here: http://krpc.github.io/krpc/python/api/drawing/drawing.html and an example here: http://krpc.github.io/krpc/tutorials/reference-frames.html#visual-debugging
  19. v0.3.4 has been released! Here are the highlights: Major server performance improvements. Finally got round to running the code through a profiler, and managed to significantly reduced the memory pressure caused by the main server loop. This means that the game no longer stutters every few seconds when the garbage collector kicks in. Added functionality to draw lines, polygons and text in the game scene (http://krpc.github.io/krpc/csharp/api/drawing.html) Added functionality to add and interact with custom UI elements. Tutorial here: http://krpc.github.io/krpc/tutorials/user-interface.html The full changelog can be found here @Survius - I've also added a getter and setter for light colors and methods to set fields in part modules. I've had a quick look at your Infernal Robotics issue - looks like you can get the vessel for a servo group, so should be able to add some APIs for getting the servo groups for a specific vessel. I'll investigate getting the part for a servo too. You also mentioned writing some sort of REST API to get interaction from a browser. I actually have a websockets server implemented (but hasn't made it into the release just yet). We just need to get a JS client to work and it'll be good to go. Websockets is a more suitable protocol for doing RPC calls from a browser. There's some discussion here if you're interested: https://github.com/krpc/krpc/issues/123
  20. v0.3.4 has been released! Here are the highlights: Major server performance improvements. Finally got round to running the code through a profiler, and managed to significantly reduced the memory pressure caused by the main server loop. This means that the game no longer stutters every few seconds when the garbage collector kicks in. Added functionality to draw lines, polygons and text in the game scene (http://krpc.github.io/krpc/csharp/api/drawing.html) Added functionality to add and interact with custom UI elements. Tutorial here: http://krpc.github.io/krpc/tutorials/user-interface.html The full changelog can be found here
  21. Hi, I'm the kRPC developer - this sounds like a cool project! I probably wouldn't use this myself (I prefer writing my scripts using the python API) but am happy to lend assistance if you decide to take this further. You got me thinking - could you automatically generate the plugin? I publish a JSON file for each of the kRPC DLLs (for example https://krpc.s3.amazonaws.com/deploy/v0.3.3/429.1/GameData/kRPC/KRPC.SpaceCenter.json) which lists all of the RPCs that they provide. I currently use these "definition files" to automatically generate the documentation website, and stub code for the client libraries. You could probably do something similar to generate the available nodes and any glue code for the Connect I/O plugin.
  22. The part module objects let you access arbitrary fields, events and actions for parts, so if there isn't direct API for it you can sometimes access functionality via that. Details can be found here: http://krpc.github.io/krpc/java/api/space-center/parts.html#module Unfortunately this doesn't allow you to set light colors or brake strengths. It does allow you to read the brake strength from a field in ModuleWheelBrakes, but can't set it at the moment. Adding some RPCs for light colors should be a trivial addition so I'll add that in the next release (which baring any last minute issues should be available in a few hours !). The APIs for wheels, landing legs etc. needs an overhaul to expose all the new 1.1 functionality. When 1.1 was released I just updated it so that the pre-existing functionality worked but haven't gotten around to adding the new features.
  23. Ooo nasty. Looks very similar to this: https://github.com/pypa/pip/issues/2903 There is a bug in pip that means it doesn't work when there are Cyrillic characters in the computers hostname. Not sure how you could fix this... Maybe make sure you've got the latest version of pip, or try using python3? or change your hostname to use ascii characters until they fix it?
  24. Looks like you are trying to run pip from within an interactive python session. You need to run it from plain-old command prompt. Also you don't need to download the zip manually. Pip will do that for you. Steps: 1) Open Start -> cmd 2) Then run: C:\Python27\Scripts\pip.exe install krpc Hope that helps!
×
×
  • Create New...