Jump to content

[1.3] kOS Scriptable Autopilot System v1.1.3.0


erendrake

Recommended Posts

Thanks Laie ill see what I can do to figure it out. In the meantime though..

That's exactly whats happening. Even when I switch to the other vessel ( which btw doesn't have a kOs part on it if that could be something. ). I hear the staging click when kOs is set to stage, but the staging itself fails. Whether or not that's exactly what your looking for to diagnose the problem im not sure.

Maybe you didn't see my update edit to my previous post in time. There is a bug I think in the mod's code. Does your camera vessel have any stages on IT? If not, then I think I know the cause. It's trying to stage on the current vessel you're looking at (the camera vessel) instead of staging its own vessel. The clicking is the result of your camera vessel not having anything to stage.

(I think).

- - - Updated - - -

@Steven Madding: could you please also drop me a hint how I look into future patches and nodes? If it can't be done that's alright, at least I know that I can stop trying.

Patches: SHIP:PATCHES returns a List() of orbit patches the ship is predicted to enter, assuming no maneuvers (assuming it's just going to ignore maneuvers and just go on current momentum only).

Nodes: You're correct that there doesn't seem to be a way to access this at the moment. There should be. Make an issue for it on the github. (I'm knee deep in telnet right now and really don't want to switch gears).

Link to comment
Share on other sites

issue with detaching a kOS-enabled probe core from a ship, doesn't matter if it's a ship with local command or another probe core

If someone can confirm this I will add it to the GitHub tracker.

I can't find any definitive list of features regarding RT2 support here on the thread or in the docs. What exactly does enabling RT2 in the settings window entail these days? I can use the part module interface to tell if I am connected or not, or in the process of transmitting data, but I can't see a way to know what the signal delay time is

Still looking for details on this

Link to comment
Share on other sites

Why limit the scope to just :GetField? Why not just allow a script to print whatever string it feels like to a PostScreenMessage, regardless of whether it's coming from a :GETFIELD or something else? Just implement it at the basic string level and you get :getfield for free that way, along with all sorts of other stuff.

Heads up display text progress.

Ok. I got it working the way you suggested. > hudtxt "Hello World" so far.

I had one question.

Looking at the code I got the impression there may only be provisions to parse up to 3 variables. Is that so?

Because I can control more aspects. Text size, text color, italics, maybe more, but size and colour would be cool.

So my command line is going to be hudtxt ("Hello World", float duration, ScreenMessageStyle.UPPER_LEFT, pink, int size).

Maybe it should just allow the canned styles.

Comments?

6EBpeHX.png

qh0xWHT.png

Edited by Dr_Goddard
added pics
Link to comment
Share on other sites

You know what we need? We need a beep. just a "beep" command that returns a beep.

There are lots of beeps in space. And a computer without beeps, well, it's not very computery is it?

Agreed. Noted. By the way I happen to be in the middle of implementing kOS terminal make/model abstraction, to work with the telnet feature (so it detects your terminal type and then loads one of a number of mappers designed to translate from a generic set of made-up control character codes kOS will use internally into /out of the character codes that terminal happens to use). As part of this I could implement the use of the ASCII(7) Character for old-school style "beep"ing when you are working on a telnet terminal.

Link to comment
Share on other sites

If someone can confirm this I will add it to the GitHub tracker.

I also get the bug you described, in my modded install with kOS processors added to probe cores and command pods. When I undock, sometimes the kOS processors on the "new" vessel (however KSP determines this) throw a repeated error (below) until I save and reload.

At interpreter

<<--EOF

^

Link to comment
Share on other sites

Looking at the code I got the impression there may only be provisions to parse up to 3 variables. Is that so?

If you are referring to the classes like the OneArgsSuffix, TwoArgsSuffix, and so on, they just only went up to 2 because at the time that was all we needed. There's no reason you can't subclass and add a ThreeArgsSuffux, FourArgsSuffix, and so on that follow the same general pattern.

If you are trying to create a function that operates the older way (as a direct function call, without being a suffix member) with more args, look up how the function vecdrawargs is implemented. It takes lots of arguments. It's just a matter of popping them from the stack in the reverse order of how they got pushed (last argument first).

Edited by Steven Mading
Link to comment
Share on other sites

If you are referring to the classes like the OneArgsSuffix, TwoArgsSuffix, and so on, they just only went up to 2 because at the time that was all we needed. There's no reason you can't subclass and add a ThreeArgsSuffux, FourArgsSuffix, and so on that follow the same general pattern.

If you are trying to create a function that operates the older way (as a direct function call, without being a suffix member) with more args, look up how the function vecdrawargs is implemented. It takes lots of arguments. It's just a matter of popping them from the stack in the reverse order of how they got pushed (last argument first).

Awesome stuff! Even if after the first two reads my brain got off two stops early. I love this stuff. OneArgsSuffix, TwoArgsSuffix, and so on... YES.

I traced the $h1t out of the programs to learn how it all worked. Never touched c# before last week, now I see I can write mods too (like a noob).

Hey, if I get this done and it passes muster i can post it to github somehow?

It would be cool to get my name up there. My son would be so proud of me.

He programs I-phone apps professionally.

I'll have a look through the suffix methods, but I can do the old method like you explained.

Hey, an interactive debugger would help cr@ploads. Is there a way?

P

Link to comment
Share on other sites

Awesome stuff! Even if after the first two reads my brain got off two stops early. I love this stuff. OneArgsSuffix, TwoArgsSuffix, and so on... YES.

Glad you like it. I hadn't done any C# before kOS, mostly because I didn't like the prospect of a programming language where whatever Microsoft says just de-facto becomes the standard because they said so. They really didn't have a good track record with that sort of thing before C#. But I had used a lot of other languages a LOT before C# and I have to admit that it's a lot better than I expected it to be. There's still cases where I get annoyed with it, but I do recognize that the things I get annoyed by are not *really* embedded inside the language definition itself. They're the social conventions on top of it, and as such they're not really the language's fault itself. (Things like people's idea of the "right" way to indent things, or when there's 2 equivalent ways to write the same statement, which one is "better", etc.) These aren't built into the language, but they do tend to be built into IDEs and refinement tools like Resharper, and as such the whole community of C# programmers have become trained to take those conventions as gospel. If you're someone with a long history using other languages before C#, some of those conventions don't quite feel right.

Hey, an interactive debugger would help cr@ploads. Is there a way?

P

It would help, but I can imagine it would be an enormously hard thing to create because of how the CPU executes in kOS. So much of what kOS is doing is coming from querying the actual game's API that stepping through your code a line at a time would give drastically different results. (i.e. you have 4 lines of code that query your ships' position, velocity, status, etc. If you step through them one at a time, you either must freeze KSP *itself* as you do so, or you'll end up getting values from different physics tics when debugging which isn't how it behaves when run live.)

Link to comment
Share on other sites

I'm looking for a small script that points my craft in the direction I want to go - but I only have lat/long. Kinda like an autopilot I guess.

I'm at xxx north, yyy east, but I want to be at www north and zzz east. Which direction do I point my craft given my desired direction could be anyone of 360 degrees? Anyone done that?

Link to comment
Share on other sites

I'm looking for a small script that points my craft in the direction I want to go - but I only have lat/long. Kinda like an autopilot I guess.

I'm at xxx north, yyy east, but I want to be at www north and zzz east. Which direction do I point my craft given my desired direction could be anyone of 360 degrees? Anyone done that?

To get you started, I'd suggest using the latlng() function to create a geocoordinates structure of your destination. Then use that to get either the heading or the vector to that position. If you get the vector, convert it to a horizontal direction using some vector math. You'll need to update them continuously, as your heading will change as you move around the globe. Here's some example code using the heading method:


SET destination TO latlng(www,zzz).

//to point at a heading (with 0 pitch)
LOCK steering TO heading(destination:heading,0).

I didn't test this, but something like it ought to work.

Link to comment
Share on other sites

This function allows text and variables from kOS to be posted as screen messages similar to the ones KSP displays in the upper left, upper middle, upper right, lower right, and lower middle of the screen.

It also controls variables like colour, size, display time. Additional variables can be entered in the text line as HTML tags.

Link to comment
Share on other sites

This function allows text and variables from kOS to be posted as screen messages similar to the ones KSP displays in the upper left, upper middle, upper right, lower right, and lower middle of the screen.

It also controls variables like colour, size, display time. Additional variables can be entered in the text line as HTML tags.

Shut up and take my money!

Link to comment
Share on other sites

So a few weeks ago, I hacked on a small project that translates .net cil to kOS assembly, which essentially allows you to write a subset of C# that will run on the kOS virtual CPU.

6cjrkEV.png

There's still a lot of things that need implementing, but I'm wondering what the interest levels are for this and if I should continue working on it. Thoughts? (I intend it to be eventually opensource, but as it's a tiny very-broken bit of code right now, I haven't put it on github yet)

Also, I have quite a few questions about kOS that I can't figure out by looking at the source code, so I would really appreciate it if a kOS dev member would poke me on irc (#kspmodders, I'm also khyperia on there).

Link to comment
Share on other sites

So a few weeks ago, I hacked on a small project that translates .net cil to kOS assembly, which essentially allows you to write a subset of C# that will run on the kOS virtual CPU.

http://i.imgur.com/6cjrkEV.png

There's still a lot of things that need implementing, but I'm wondering what the interest levels are for this and if I should continue working on it. Thoughts? (I intend it to be eventually opensource, but as it's a tiny very-broken bit of code right now, I haven't put it on github yet)

Also, I have quite a few questions about kOS that I can't figure out by looking at the source code, so I would really appreciate it if a kOS dev member would poke me on irc (#kspmodders, I'm also khyperia on there).

I might be on there later tonight.

[ Edit: Those sorts of vague promises are really annoying aren't they? Let me change that to, I WILL be on. I'll make a promise. how about, say, 6:00pm CDT (that's timezone UTC-6, for those not familiar with US timezone namings).]

I've always thought that it should in principle be possible to compile some other languages down into the opcodes, but only in a seriously limited way that's missing half the language (the opcodes we currently have can't support user-defined structures, for example, or classes, etc.)

I'm glad to see someone is giving it a try. It sort of forces us to kick ourselves and get going on making kerboscript itself better. I'd be curious to see how you're doing local variables like the "var q = 20;". The variable dictionary is currently one large global namespace and that's it. I suppose you could fake it with name mangling, but those solutions tend to create problems for recursion (since there's not *really* a stack of namespaces).

To a large extent the reason kerboscript doesn't support a lot of stuff is because what's under the hood in the opcodes doesn't either. I'd be happy to work on adding better stuff to the underlying opcodes so support such things, but lately I've had my head wrapped up in other parts of kOS. kOS is a project that *could* go on forever if you want it to. (There's a zillion things it would be cool to implement, and not enough time to do them all.) For the last few weeks I've been dealing with the terminal and making it less hard-coded and more remote-worthy, and Erendrake has been just waaaay too busy to do much on it himself, so progress has been slow the last few weeks.

Link to comment
Share on other sites

For the last few weeks I've been dealing with the terminal and making it less hard-coded and more remote-worthy,

I'm really looking forward to this because the big terminal screen in the way all the time really detracts from the experience.

I've been thinking we need a script command to close the terminal window. Poor man's autorun.

Edited by Dr_Goddard
autocorrect is retarded
Link to comment
Share on other sites

I can't find any definitive list of features regarding RT2 support here on the thread or in the docs. What exactly does enabling RT2 in the settings window entail these days? I can use the part module interface to tell if I am connected or not, or in the process of transmitting data, but I can't see a way to know what the signal delay time is

Anyone? Bueller?

Link to comment
Share on other sites

Is anybody else finding that SHIP:ANGULARVEL's behavior doesn't match the documentation?

When I use it, it seems to be defined in terms of the ship's FACING direction, rather than the SHIP-RAW coordinate system: regardless of how I orient my ship, if I put it in a pure counterclockwise roll, ANGULARVEL is parallel with SHIP-RAW +Y (rather than being parallel with the ship's FACING). Similarly, yaw left corresponds to +Z, and pitch down corresponds to +X. Notice also that the sign of the Z component is backwards: in a left-handed coordinate system a positive yaw should correspond to a right turn, not a left. Notice also how Y and Z are reversed: the Y component represents rotation about the Z axis, and vice-versa.

Here's a demo script that makes it obvious:

SET angular TO VECDRAWARGS(V(0,0,0), SHIP:ANGULARVEL, RGB(1,0,0), "Reported Angular Velocity", 1, TRUE).
LOCK corrected_angvec TO SHIP:FACING * V(SHIP:ANGULARVEL:X, -(SHIP:ANGULARVEL:Z), SHIP:ANGULARVEL:Y).
SET corrected TO VECDRAWARGS(V(0,0,0), corrected_angvec, RGB(0,1,0), "Corrected Angular Velocity", 1, TRUE).
UNTIL FALSE {
SET corrected:VEC TO corrected_angvec.
SET angular:VEC TO SHIP:ANGULARVEL.
}

When I run this script, I can put my ship through any crazy mix of rotations, and the "corrected" angular velocity vector seems to stay parallel to the axis of rotation, whereas the "reported" vector can be arbitrarily wrong.

Does anyone else get the same behavior? Am I confused somehow, and this is what's supposed to happen?

Link to comment
Share on other sites

Is anybody else finding that SHIP:ANGULARVEL's behavior doesn't match the documentation?

When I use it, it seems to be defined in terms of the ship's FACING direction, rather than the SHIP-RAW coordinate system: regardless of how I orient my ship, if I put it in a pure counterclockwise roll, ANGULARVEL is parallel with SHIP-RAW +Y (rather than being parallel with the ship's FACING). Similarly, yaw left corresponds to +Z, and pitch down corresponds to +X. Notice also that the sign of the Z component is backwards: in a left-handed coordinate system a positive yaw should correspond to a right turn, not a left. Notice also how Y and Z are reversed: the Y component represents rotation about the Z axis, and vice-versa.

Here's a demo script that makes it obvious:

SET angular TO VECDRAWARGS(V(0,0,0), SHIP:ANGULARVEL, RGB(1,0,0), "Reported Angular Velocity", 1, TRUE).
LOCK corrected_angvec TO SHIP:FACING * V(SHIP:ANGULARVEL:X, -(SHIP:ANGULARVEL:Z), SHIP:ANGULARVEL:Y).
SET corrected TO VECDRAWARGS(V(0,0,0), corrected_angvec, RGB(0,1,0), "Corrected Angular Velocity", 1, TRUE).
UNTIL FALSE {
SET corrected:VEC TO corrected_angvec.
SET angular:VEC TO SHIP:ANGULARVEL.
}

When I run this script, I can put my ship through any crazy mix of rotations, and the "corrected" angular velocity vector seems to stay parallel to the axis of rotation, whereas the "reported" vector can be arbitrarily wrong.

Does anyone else get the same behavior? Am I confused somehow, and this is what's supposed to happen?

The KSP API is internally inconsistent with which axis is which sometimes. (Don't get me started on trying to deal with CelestialBody, which can't make up it's damn mind and keeps swapping them depending on what method you're calling).

So it's entirely believable that rotational velocity it's messed up this way. It could very well be. So my question is this: I could make it be consistent with ship:raw. I could make the change but then it would be a while before it got released. So, are you the only one who has used it? If its just you, then I think I should change it. If there's a lot of people who used it the broken way then there's backward compatibility problems.

Edited by Steven Mading
Link to comment
Share on other sites

The KSP API is internally inconsistent with which axis is which sometimes. (Don't get me started on trying to deal with CelestialBody, which can't make up it's damn mind and keeps swapping them depending on what method you're calling).

I get the sinking feeling that means you can't even tell me if my correction is actually correct.

So it's entirely believable that rotational velocity it's messed up this way. It could very well be. So my question is this: I could make it be consistent with ship:raw. I could make the change but then it would be a while before it got released. So, are you the only one who has used it? If its just you, then I think I should change it. If there's a lot of people who used it the broken way then there's backward compatibility problems.

I obviously can't say for sure, but I'd be surprised if many people had used it, because it's really hard to figure out. It took me a lot of trial and error to get that demo script, and I'm not even sure it's correct. I did find this post, whose author seems to have discovered and worked around the mixed-up axes back when ANGULARVEL was a Rotation.

Edit: Oh, the good news is I've figured out the answer to the question in the docs: ANGULARVEL is not degrees per second, it's in radians per second. That's actually convenient, because if the angular velocity is in radians, the tangential velocity at some radius is just the cross product of the angular velocity with the radius; if it was in degrees you'd have to rescale.

Edited by thegreatgonz
Link to comment
Share on other sites

Oh, the good news is I've figured out the answer to the question in the docs: ANGULARVEL is not degrees per second, it's in radians per second. That's actually convenient, because if the angular velocity is in radians, the tangential velocity at some radius is just the cross product of the angular velocity with the radius; if it was in degrees you'd have to rescale.

Yeah I'm a bit unclear myself about whether that's good or bad. On the one hand consistency across all of kOS is a good idea and degrees are used everywhere else to keep things easy for the non math-nerds. On the other hand radians are usually mathematically better for most things.

Link to comment
Share on other sites

A Teaser. This stuff isn't ready yet. There's a lot of weird edge cases I have to work out (like having the telnet open when you switch scenes back to the space center, tends to keep the server still connected to the now missing kOS computer).

But I'm getting close. I can feel it's sooooo nearly done.

RIStldD.png

Edited by Steven Mading
imgur link was broken
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...