Jump to content

kOS Ship Orientation


Mat2ch

Recommended Posts

Hi,

I'm currently trying to build something like a quadrocopter with kOS. Currently it looks like this:

jhFRsUwh.jpg

Engines are already controlled to keep vertical speed to an adjustable value. Now I want to make it hover without haveing to use SAS, just by individually controlling the engines. But I ran into a problem with the orientation here. I tried several of them SHIP:UP, SHIP:FACING, etc. But I can't find a value which gives me the deviation in a way that I can add it to my controller. I think SHIP:FACING gave me the proper X value, but not the proper value for Z. So I'm stuck here. Does anyone have an example for me?

Thank you!

Link to comment
Share on other sites

It's a little unclear what you're asking for. Do you want to know your velocity vector relative to your ship's current orientation instead of relative to the world?

If so, then you can get the 3 components with just dot products.


set vel to ship:velocity:surface.
set vel_component_in_my_top_direction to VDOT(vel, ship:facing:topvector).
set vel_component_in_my_fore_direction to VDOT(vel, ship:facing:forevector).
set vel_component_in_my_starboard_direction to VDOT(vel, ship:facing:starvector).

Remember that with VAB-built ships, your "fore" direction is actually up on the launchpad, and the "top" direction is actually out the roof of the cabin, and therefore horizontal when aimed nose-up on the launchpad.

Link to comment
Share on other sites

Hello Steve,

thank you for your answer.

Right now I just want to know my angle in the air. E.g. I want to know if it points straight up or if there is some roll or pitch in the vessel.

The next step after that would be controlling roll and pitch to get the relative velocity to 0. But now I'm not sure if I need the first step. I could just cancel out all horizontal velocity and would get the same result, I guess.

Link to comment
Share on other sites

Ok, this approach is not what I need. Canceling out the horizontal velocity only works, if I can limit the angle of attack. Otherwise my controller will try very violently to do this and if it's by crashing into the ground...

I think Angle of Attack is the right keyword. That's what I'm looking for and haven't found yet in the documentation.

Link to comment
Share on other sites

Ok, this approach is not what I need. Canceling out the horizontal velocity only works, if I can limit the angle of attack. Otherwise my controller will try very violently to do this and if it's by crashing into the ground...

I think Angle of Attack is the right keyword. That's what I'm looking for and haven't found yet in the documentation.

Compare your forward vector to the upward vector.

ship:up:vector points right at the center of the sky (the dot in the middle of the blue part of the navball).

ship:facing:forevector points whichever way the nose of your craft is aimed.

Getting the VANG between them tells you how "tilted" your craft is. I THINK that's what you're asking for - you want to limit your tilt and not tilt any further if that angle is too large, I think is what you're saying.

Link to comment
Share on other sites

Hello Steven,

thank you for your answer! And sorry I called you Steve earlier, I missread it and I hope you're not upset...

You are right that is, what I was looking for. Now some more vector magic and I have everything I need. Oh, some sinus and cosinus magic as well.

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