Recommended Posts

Posted (edited)

How do I make an autopilot mod?  I want to be able to find out what the orientation of the ship is with kerbin, and the orbit parameters.

Edited by ianyikos
Adding extra information

Share this post


Link to post
Share on other sites
Posted (edited)

I have no idea how to measure the error in orientation, but the control algorithm for my previous autopilot mod depended on the angular velocity.  The desired angular velocity about whichever axis depended on the error with respect to that axis, and I varied the angular acceleration to maintain the desired angular velocity, so as you're rotating it smoothly just decelerates on the desired direction, and if the ship is rotating like with its orbit then it just maintains the angular velocity.  But I don't know how to use quaternions to accomplish that.  I just used the down direction and right direction and forward direction to compare to the orientation.  And the orbit direction.  But I could never figure out how to correct the error like the game itself does.  Because it only seems to care about the relative rotation or something, but mine could only depend on the front, down, side directions.  And it doesn't seem to care about the roll axis, only yaw and pitch.  But that makes it even more confusing for me because I couldn't figure out how to find the desired direction in absolute coordinates, unless it was the orbit direction or something.  But the error depends on the angles relative to the forward direction.

Edited by ianyikos

Share this post


Link to post
Share on other sites

var direction = (this.vessel.getworldpos3d() - worldpos where you want to travel to)

this.vessel.rootPart.addforce(direction * speed you want to add to vessel)

The above should at the very least will show you what in the API you should be looking for .... if you don't know how to find the above in the KSP API then you are not ready to make your mod as you'll need some knowledge of the KSP API and Unity in order to get it to work

I assume you know how to write programs/scripts in C# .... if not then this will be another hurdle that you must overcome to make your mod

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now