API Question Getting thruster group level with no thrusters in group.

meson800

Addon Developer
Addon Developer
Donator
Joined
Aug 6, 2011
Messages
405
Reaction score
2
Points
18
For IMS2, I've made an RCS solver- given the COG and a set of thrusters, it figures out the best way to achieve commanded force/torque. Because of that, the RCS thrusters are not assigned to groups such as THGROUP_ATT_PITCHUP.


The solver works, I just need a way to get the desired thrust levels in each of the default RCS groups, either set by Orbiter autopilots or by the user, to know which values to pass to the solver.

I was originally using VESSEL::GetManualControlLevel() for each of the default groups, but I could only get values for rotations (even in translation mode, GetManualControlLevel was returning values for the rotation thruster groups, but returned all zeros for the translation groups) and it didn't include levels set by MFDs or built-in autopilots.

I then tried VESSEL::GetThrusterGroupLevel, but with no thrusters assigned to the group, I got all zero results.
I'm planning on creating a dummy zero-thrust thruster for each of those groups, and then getting the thruster level of the dummy thrusters, but am I overlooking an API function?
 

jedidia

shoemaker without legs
Addon Developer
Joined
Mar 19, 2008
Messages
10,842
Reaction score
2,105
Points
203
Location
between the planets
Let me see if I understand this correctly: You want to get the manual control level, so you can set the thrust level of the RCS thrusters accordingly using SetThrusterLevel(), right? To be honest, I was using the keyboard for so long that I didn't even think about precise user input handling... generally this would only really come into play with a joystick, right?

Aaaaanyways, If the above assumption is right, then it's only really the control LEVEL you need (you can get whether it's set to translation or rotation by GetAttitudeMode()). Would there actually be a difference whether the level is for rotation or translation? If the manual control level returns something, shouldn't it technically be irrelevant whether that's for translation or rotation?

and it didn't include levels set by MFDs or built-in autopilots.

Well, I think that's kind of the point of GetManualControlLevel():
Returns the thrust level of an attitude thruster group set via keyboard or mouse input.

The problem might indeed be that a ThrusterGroup doesn't have its own level, but just wraps the level of its thrusters. In that case, you'd have to use the dummy thrusters to insure compatibility with MFDs... Orbiter 2015 does provide the API to override the default autopilots as far as I know, but the MFDs would still rely on setting thruster levels directly on the group, so SetThrusterGroupLevel must be made to work any way you turn it...
 

meson800

Addon Developer
Addon Developer
Donator
Joined
Aug 6, 2011
Messages
405
Reaction score
2
Points
18
Let me see if I understand this correctly: You want to get the manual control level, so you can set the thrust level of the RCS thrusters accordingly using SetThrusterLevel(), right? To be honest, I was using the keyboard for so long that I didn't even think about precise user input handling... generally this would only really come into play with a joystick, right?

Aaaaanyways, If the above assumption is right, then it's only really the control LEVEL you need (you can get whether it's set to translation or rotation by GetAttitudeMode()). Would there actually be a difference whether the level is for rotation or translation? If the manual control level returns something, shouldn't it technically be irrelevant whether that's for translation or rotation?

Actually I was looking for a function that returns the sum of all RCS thruster inputs.

The issue with the ManualControlLevel is just that, it doesn't include inputs due to MFDs/Orbiter autopilots.

Using ManualControlLevel, I can nicely rotate the ship around, but when I hit "killrot", nothing happens, because I don't know how Orbiter is trying to use the RCS thrusters.

Using dummy thrusters appears to work, so I guess this point is moot. :lol:

---------- Post added at 10:51 AM ---------- Previous post was at 10:46 AM ----------

I haven't been explaining this very well :uhh:

I need to get two vectors, a desired force/translation vector, and a desired torque/rotation vector. Using ManualControlLevel gets any keyboard input, but (obviously) ignores autopilot input.

GetThrusterGroupLevel didn't appear to work (it always returned 0 for all RCS groups regardless of keyboard input / autopilot status), but I believe that was because each of the builtin RCS thruster groups were empty.

Somewhere internally, I assume Orbiter must add together all the RCS inputs before setting all the thruster groups, but there doesn't appear to be an OAPI function to get those values.

I ended up just going with dummy zero-thrust thrusters and getting their levels to figure out the desiredForce/Torque vectors.

---------- Post added at 10:57 AM ---------- Previous post was at 10:51 AM ----------

Except when engaging killrot while spinning, GetThrusterLevel() returns -1#IND for the dummy thrusters on axes where the rotation rate is 0 :uhh:

For example, if I start the vessel pitching up with no other rotation, then hit killrot, the yaw and bank thrusters return -1#IND.
That immediately transports the ship to NaN space.

---------- Post added at 12:05 PM ---------- Previous post was at 10:57 AM ----------

Ok, the problem is that with the thrust set to zero or some small value ( <10), engaging an autopilot transports to NaN space.

So I'm back to the original question, is there some OAPI function to get what I'm looking for?

If not, I guess I'll just double up the dummy thrusters so they create zero net force, and top off their fake propellant tank every frame.
 
Last edited:

jedidia

shoemaker without legs
Addon Developer
Joined
Mar 19, 2008
Messages
10,842
Reaction score
2,105
Points
203
Location
between the planets
darn, this is getting uncomfortably hacky... Are you sure that just putting the thrusters into groups and use your solution to adjust their max thrust wouldn't be acleaner solution?
 
Top