Orbiter-Forum  

Go Back   Orbiter-Forum > Orbiter Space Flight Simulator > Orbiter SDK
Register Blogs Orbinauts List Social Groups FAQ Projects Mark Forums Read

Orbiter SDK Orbiter software developers post your questions and answers about the SDK, the API interface, LUA, meshing, etc.

Reply
 
Thread Tools
Old 12-02-2018, 10:52 AM   #1
fred18
Addon Developer

Default GetForceVector, GetLinearMoment, clbkPreStep, I really need help to understand...

All right, so I am facing a very weird situation and I need some help to understand.

I need to get the force vectors of a series of vessels in the sim at each time step and to compute some additional forces to add to them.

What I think I have discovered is about the use of GetForceVector

1) If I call GetForceVector from within the vessel code I get the correct results. What I mean for correct: the force vector that comes out from the functions is basically the expected sum of all the forces. This works from both clbkprestep and clbkpoststep, with different value of course but consistent.

2) If I call the function outside (for example from a plugin or from another vessel) the result seems much different. When I say "from outside" I mean to do:
Code:
VECTOR3 f_v;
OBJHANDLE h_ves = oapiGetVesselByName("MyShip"); //"handle to the desired vessel"
VESSEL* v = oapiGetVesselInterface(h_ves);
v->GetForceVector(f_v);
It seems that if I call this in clbkPreStep of my other vessel or from the clbkPresStep of a plugin I get as a result just the weight vector from that vessel, while if I call this in clbkPostStep I get the expected sum or something around that.
On the other hand if I use GetLinearMoment it seems that the result could be correct also in clbkPreStep.

I logged this, here below you can find the result of a single timestep.

The vessel from which I am calling the code is "SLS", and is calling the code for itself and for other 3 vessels "SLS_stage_1", "SLS_Booster_11" and "SLS_Booster_12".
The vectors are
Force Vector f_v
Weight Vector w_v
Drag Vector d_v
Thrust Vector t_v
Linear Moment l_m

4.414 is the time of the timestep.

Code:
Prestep
4.414 SLS f_v: -477.195 -671.926 1629212.206 length: 1629212.415
4.414 SLS w_v: -481.187 -671.930 -2820055.476 length: 2820055.597
4.414 SLS d_v: -0.564 1.509 -593.449 length: 593.452
4.414 SLS t_v: 0.000 0.000 0.000 length: 0.000
4.414 SLS l_m: -0.012 0.009 4449267.311 length: 4449267.311
4.414 SLS_stage_1 f_v: -1901.401 -2677.489 -11237349.327 length: 11237349.807
4.414 SLS_stage_1 w_v: -1917.356 -2677.470 -11237350.804 length: 11237351.287
4.414 SLS_stage_1 d_v: -0.508 1.610 -633.285 length: 633.288
4.414 SLS_stage_1 t_v: 0.000 0.000 10898383.375 length: 10898383.375
4.414 SLS_stage_1 l_m: -0.509 1.610 10897750.090 length: 10897750.090
4.414 SLS_Booster_11 f_v: -1477.182 1055.605 -6199702.330 length: 6199702.596
4.414 SLS_Booster_11 w_v: -1477.172 1064.408 -6199703.145 length: 6199703.412
4.414 SLS_Booster_11 d_v: 0.533 0.166 -210.503 length: 210.504
4.414 SLS_Booster_11 t_v: 0.000 0.000 15423320.910 length: 15423320.910
4.414 SLS_Booster_11 l_m: 0.533 0.166 15423110.407 length: 15423110.407
4.414 SLS_Booster_12 f_v: 1477.182 -1042.410 -6199702.321 length: 6199702.585
4.414 SLS_Booster_12 w_v: 1477.172 -1051.213 -6199703.136 length: 6199703.401
4.414 SLS_Booster_12 d_v: -0.538 -0.166 -210.538 length: 210.539
4.414 SLS_Booster_12 t_v: 0.000 0.000 15423320.910 length: 15423320.910
4.414 SLS_Booster_12 l_m: -0.538 -0.166 15423110.372 length: 15423110.372
Prestep COMPLETED
Poststep
4.414 SLS f_v: -473.035 -671.933 1629638.216 length: 1629638.424
4.414 SLS w_v: -477.183 -671.935 -2820055.105 length: 2820055.225
4.414 SLS d_v: -0.570 1.529 -601.572 length: 601.574
4.414 SLS t_v: 0.000 0.000 0.000 length: 0.000
4.414 SLS l_m: -0.012 0.010 4449692.931 length: 4449692.931
4.414 SLS_stage_1 f_v: -1885.149 -2675.742 -339589.338 length: 339605.112
4.414 SLS_stage_1 w_v: -1901.305 -2677.355 -11236786.360 length: 11236786.839
4.414 SLS_stage_1 d_v: -0.518 1.644 -641.939 length: 641.942
4.414 SLS_stage_1 t_v: 0.000 0.000 10898383.375 length: 10898383.375
4.414 SLS_stage_1 l_m: -0.515 1.632 10897741.436 length: 10897741.436
4.414 SLS_Booster_11 f_v: -1476.609 1046.287 9221857.411 length: 9221857.589
4.414 SLS_Booster_11 w_v: -1476.934 1055.428 -6198661.386 length: 6198661.652
4.414 SLS_Booster_11 d_v: 0.534 0.166 -213.389 length: 213.389
4.414 SLS_Booster_11 t_v: 0.000 0.000 15423320.910 length: 15423320.910
4.414 SLS_Booster_11 l_m: 0.540 0.168 15423107.521 length: 15423107.521
4.414 SLS_Booster_12 f_v: 1476.174 -1033.150 9221857.384 length: 9221857.560
4.414 SLS_Booster_12 w_v: 1476.934 -1042.235 -6198661.378 length: 6198661.641
4.414 SLS_Booster_12 d_v: -0.539 -0.166 -213.424 length: 213.425
4.414 SLS_Booster_12 t_v: 0.000 0.000 15423320.910 length: 15423320.910
4.414 SLS_Booster_12 l_m: -0.545 -0.168 15423107.486 length: 15423107.486
Poststep COMPLETED
The only explanation that comes to my mind is that when you call GetForceVector from "outside" it is not certain that the other vessel has already processed all the forces, so you cannot be so sure that everything will be included (from my experiments it seems that only weight is included).

Is that right? can anyone help here?

Thanks in advance
Fred


---------- Post added at 11:52 ---------- Previous post was at 00:38 ----------

Another weird thing I found out:

It seems that GetTorqueVector returns a mass normalised vector instead that the proper force vector, while GetAngularMoment returns the actual Torque... I think that by trial and error (and a lot of oapiWriteLogV...) I am slowly getting to the end of it, but a bit of clarification would be really needed.
fred18 is online now   Reply With Quote
Reply

  Orbiter-Forum > Orbiter Space Flight Simulator > Orbiter SDK


Thread Tools

Posting Rules
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Jump


All times are GMT. The time now is 10:38 PM.

Quick Links Need Help?


About Us | Rules & Guidelines | TOS Policy | Privacy Policy

Orbiter-Forum is hosted at Orbithangar.com
Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
Copyright 2007 - 2017, Orbiter-Forum.com. All rights reserved.