zitron-git / KSPSerialIO

Kerbal Space Program Serial Port IO plugin
60 stars 44 forks source link

Add orbital vectors to data packet #10

Closed phardy closed 8 years ago

phardy commented 8 years ago

I think this still needs a little bit of work, but wanted to open a PR now to get some feedback on the approach.

This change adds new fields for:

All of these are relative to the pitch, heading and roll of the active vessel, making rendering them on an FDAI or similar display fairly straightforward.

The existing pitch, heading and roll fields were sent as 4-byte floats, some in the range 0-360 and some in the range -180 to 180. This PR maps all angle data, including the existing fields, to an integer range 0-65535 and sends them as 2-byte unsigned ints. This still gives a resolution of about 0.05 degrees while saving space. Data packet size with this change is 209 bytes.

I've confirmed that the magnitude for the new fields is what I'd expect. But suspect they're inverted. It may be easier to render them on the arduino end if we first invert them before sending. But to be honest I'm still working on a working implementation for rendering this data. I'll have a much better opinion on that in the coming week or two.

zitron-git commented 8 years ago

Sorry for the late reply, I got a bit of a flu at the moment.

This looks pretty awesome, thanks for all the work. We just need to make sure to tell people the changes to fixed point to avoid WTF moments, and yeah I agree if for some reason the values look inverted just invert them in the plugin code. It would be nice to have some example arduino code to convert from fixed point to float, but I presume you already have these?

Also I should probably update the code to the latest version before we do the merge thing.

phardy commented 8 years ago

And sorry for my delayed response, real life getting in the way. :) Agree wholeheartedly on the arduino code side. My current implementation is a function to convert back to a float between 0-360 degrees. Happy to tidy that up and pass it along with some sample usage. Give me a little more time and I can update your example sketch to do something useful with it.

zitron-git commented 8 years ago

Sounds good, let me know when you are ready to merge the PR.

phardy commented 8 years ago

I'm going to close this for now. Turns out it's the wrong approach, and I've mostly completely rewritten it anyway. New PR coming when I have something worth looking at. :P

zitron-git commented 8 years ago

Ok, sounds good. Just FYI, I am in the middle of moving house right now, won't be able to do a whole lot for a while.