Jump to content

How do I make the vessel point in a certain direction?


Recommended Posts

  • 2 weeks later...

If you are willing to use the stock SAS system, it can be used to hold a heading when in Stability Assist.  See here for how I got it working.  This is currently rather messy code - I'm going to be splitting it off into its own code eventually.

The EngageAttitudePilot method starts the autopilot.

What I've found is that the SAS heading hold is tied to the inertial frame, so you have to repeatedly update it when you want a planet-relative or orbit-relative heading (I'm doing every Fixed Update, although that may be excessive) - that's what the second 'if' block in PilotFixedUpdate is doing.

Link to comment
Share on other sites

On 12/29/2018 at 6:51 PM, MOARdV said:

If you are willing to use the stock SAS system, it can be used to hold a heading when in Stability Assist.  See here for how I got it working.  This is currently rather messy code - I'm going to be splitting it off into its own code eventually.

The EngageAttitudePilot method starts the autopilot.

What I've found is that the SAS heading hold is tied to the inertial frame, so you have to repeatedly update it when you want a planet-relative or orbit-relative heading (I'm doing every Fixed Update, although that may be excessive) - that's what the second 'if' block in PilotFixedUpdate is doing.

I yoinked the code and it seems to work somewhat. However there are two problems I have with it. First of all, it seems to overshoot all the time, but this should be easy to fix by adjusting the values in around line 242. Second of all though, although Rolling and Pitching seem to work fine, adjusting the Heading makes the craft/navball rotate "straight" to the left/right instead of along an arc.

For example, after setting my target pitch to 45, roll to 0, and heading to 0, the code orients the craft like this:

2b6Ioq5.png

As Increment target heading, I expect the craft to rotate along the green line, but instead it rotates along the blue line. Do you have any idea what could be causing this? I replaced the getReferenceAttitude(activeReference) on line 235 with Quaternion.LookRotation(north, east), where "north" points to the north of the planet and "east" points east. 

 

Edit: IDK why i always find solutions soon after I post about something, but I think this code works for calculating goalOrientation: https://pastebin.com/G8LABpbm

Edited by c4ooo
Link to comment
Share on other sites

19 hours ago, c4ooo said:

I yoinked the code and it seems to work somewhat

Yeah, that code is still kind of rough.  I'm ripping it out some time in the future and moving it into its own class, where I can isolate it from the rest of the MAS functional code (and focus on making it work better).  One of the things I still need to do is change it so it can use a 'don't care' value for roll, since locking roll is not always useful in orbit.

Link to comment
Share on other sites

Yeah, I already know about SAS AutoPilot, I'm the Author of SASAG on CKAN :p

I wanted to rotate a vessel to point a specific direction (East, zero pitch, zero yaw) so I could automate gravity turns and circulation burns, and that's not possible with stock SAS unless it's pointing to a maneuver node.

I'll look over your code, and see if I can find anything useful. thanks

Edited by Xyphos
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...