Jump to content

How does MechJeb calculate Surface Info: ROLL ?


Recommended Posts

Hi, I am looking for the way MechJeb calculates the Roll of my aircraft in relation to the surface. I am programming an autopilot with k-OS script, and I can't figure out how the vector math comes into play here so that I can make the autopilot recognize its roll attitude to the surface, which is essential for performing turns of any kind. Sadly k-OS lacks anykind of function that would perform this action so I have to code it into my autopilot.

Any help would be apprechiated.

Link to comment
Share on other sites

You can find the vector math for everything Flight Assistant uses here (roll, pitch, and yaw being only the beginning...)

Roll angle is obtained by getting the angle between the vessel relative right vector, and the surface relative right vector (which is the vessel right vector projected onto the surface plane). +ve/-ve is determined by projecting the vessel relative up vector (for planes, that's actually the forward vector) onto the surface right vector using a dot product and taking the sign of the result.

Link to comment
Share on other sites

Tried using those already, but the vector I can generate with those doesnt show up, I can get a up vector, down vector or even pitch vector but those dont help me. I even tried the to get the rotation vector that is shown in the documentation but when I try to make it into a graphical vector showing in game there is nothing, same for pitch roll and yaw, I think they only show up when there is a ship:control:pitch/yaw/roll command.

Link to comment
Share on other sites

Having a look through the kOS documentation, what is wrong with this "<Direction>: PITCH|YAW|ROLL" (I assume direction would be in this case replaced by your vessel facing ie. FACING:ROLL)

Sadly, these were incorrectly named from day 1, leaving those of us who took over kOS after Kevin abandoned it with a backward compatibility problem. They are in fact NOT pitch, yaw, and roll. Not even in the slightest. What they actually are is rotation around X, rotation around Y, and rotation around Z - the the XYZ axes of the Unity Worldspace that KSP uses under the hood. These are of course, completely unrelated to the vessel's own local transform space. They are NOT the vessel's own pitch, yaw, and roll.

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