I had some major problems figuring out the correct signs of my torque, and while everything is working now in all configurations, I don't get why. I'm still convinced that it shouldn't, and I want to understand where I'm wrong.
So here's the situation: In IMS2, I have to assign rcs thrusters to thruster groups programmatically, because I don't know where people will place them. The algorithm doing that works really well, but I noticed inconsistencies when starting to hook up my own autopilots. Namely, they all seem to point in the exactly wrong direction. Except when orbiter is using them, then they're perfectly fine.
THis led me to do some measurments with GetTorque() and compare them to my initial assumptions. The result: Those thrusters really should all be pointing in the wrong direction, but are obviously not. Here's how I arrived at that conclusion.
For the initial assignement, I'm calculating torque as t = pos X dir, where pos is the position of the thruster, and dir is the direction of force... I.e. the opposite of the direction the exhaust is pointing towards.
Then I assign the thrusters to various groups based on several computations, but of course one of the most important factors is whether the torque is positive or negative, and in which axis. And I decided this criteria not by numerical analysis, but by situational analysis and experimentation, because I suck at numbers.
So I knew that if a thruster was for example at pos 0 0 8 and dir 0 -1 0, the result of firing it would obviously be the vessel pitching down. So I calculated the torque of this setup, and the result just so happens to be positive around the x-axis.
and so on and so forth, this is how I set up the groups (the entire process is a lot more complicated and ivolves suitability scores for different group based on all axes and stuff, but this is the basic assumption I use).
That all worked really well, until I tried to implement some killrot autopilot code Hlynkacg was kind enough to lend me (because autopilots don't work so well with IMS2 anymore in the latest revision).
Here, of course, the basic assumption is to apply torque that goes contrary to angular velocity, which turned out to be the exact wrong way. And after a few experiments culminating in measuring torque directly with the API, I realised that indeed, negative torque was applied to the vessel when I pitched down.
Now please remember that I made a perfectly valid assumption above when assigning the groups, and the torque, purely numerically calculated, came up positive, and the groups the thrusters are assigned to are perfectly correct, as evident by orbiter being able to use them, and the correct thrusters firing when I engage stock autopilots.
So where am I wrong in this? Why does the torque of (0 0 8) X (0 -1 0) come up as (8 0 0), while the torque applied to the vessel is actually (-8 0 0) * thrust??
Also, why can't I find a way to explain this cleaner? I'm really sorry for the long post...
So here's the situation: In IMS2, I have to assign rcs thrusters to thruster groups programmatically, because I don't know where people will place them. The algorithm doing that works really well, but I noticed inconsistencies when starting to hook up my own autopilots. Namely, they all seem to point in the exactly wrong direction. Except when orbiter is using them, then they're perfectly fine.
THis led me to do some measurments with GetTorque() and compare them to my initial assumptions. The result: Those thrusters really should all be pointing in the wrong direction, but are obviously not. Here's how I arrived at that conclusion.
For the initial assignement, I'm calculating torque as t = pos X dir, where pos is the position of the thruster, and dir is the direction of force... I.e. the opposite of the direction the exhaust is pointing towards.
Then I assign the thrusters to various groups based on several computations, but of course one of the most important factors is whether the torque is positive or negative, and in which axis. And I decided this criteria not by numerical analysis, but by situational analysis and experimentation, because I suck at numbers.
So I knew that if a thruster was for example at pos 0 0 8 and dir 0 -1 0, the result of firing it would obviously be the vessel pitching down. So I calculated the torque of this setup, and the result just so happens to be positive around the x-axis.
and so on and so forth, this is how I set up the groups (the entire process is a lot more complicated and ivolves suitability scores for different group based on all axes and stuff, but this is the basic assumption I use).
That all worked really well, until I tried to implement some killrot autopilot code Hlynkacg was kind enough to lend me (because autopilots don't work so well with IMS2 anymore in the latest revision).
Here, of course, the basic assumption is to apply torque that goes contrary to angular velocity, which turned out to be the exact wrong way. And after a few experiments culminating in measuring torque directly with the API, I realised that indeed, negative torque was applied to the vessel when I pitched down.
Now please remember that I made a perfectly valid assumption above when assigning the groups, and the torque, purely numerically calculated, came up positive, and the groups the thrusters are assigned to are perfectly correct, as evident by orbiter being able to use them, and the correct thrusters firing when I engage stock autopilots.
So where am I wrong in this? Why does the torque of (0 0 8) X (0 -1 0) come up as (8 0 0), while the torque applied to the vessel is actually (-8 0 0) * thrust??
Also, why can't I find a way to explain this cleaner? I'm really sorry for the long post...
Last edited: