API Question create a vessel landed upright

fred18

Addon Developer
Addon Developer
Donator
Joined
Feb 2, 2012
Messages
1,667
Reaction score
115
Points
78
Hi there,

I'm trying to create via API a vessel that should be landed and upright as soon as it's created, but with the new touchdown points it seems I can't make it.

The vessel appears landed in place but randomly rotated, not upright. To turn it upright I need to create it up above the ground level, let it fall and wait for it to IDLE.

Since the vessel from which it gets the vessel status is upright I don't understand why this information is not passed.

The following code is what I'm using, it's in clbkPostCreation.

Thanks in advance
Code:
VESSELSTATUS2 vsramp;
memset(&vsramp,0,sizeof(vsramp));
vsramp.version=2;
GetStatusEx(&vsramp);
	
OBJHANDLE hramp= oapiCreateVesselEx("EmptyMod","EmptyModule",&vsramp);
	
VESSEL3 *vramp;
vramp = (VESSEL3*)oapiGetVesselInterface(hramp);		
vramp->SetEmptyMass(1000);

  TOUCHDOWNVTX td[3];
 for(int i=0;i<3;i++)
 {
	
	 td[i].damping=3e5;
	 td[i].mu=3;
	 td[i].mu_lng=3;
	 td[i].stiffness=3e5;
 }
 td[0].pos.x=-1;
 td[0].pos.y=-1;
 td[0].pos.z=0;
 td[1].pos.x=0;
 td[1].pos.y=1;
 td[1].pos.z=0;
 td[2].pos.x=1;
 td[2].pos.y=-1;
 td[2].pos.z=0;

 vsramp.status=1;
vramp->SetTouchdownPoints(td,3);
vramp->clbkSetStateEx(&vsramp);
 
Thanks, the point is that the vessel doesn't try to get the equilibrium, it simply stays in a randomly rotation until i force it to move somehow. Then it looks for the equilibrium. I tried also to redo the clkbSetStateEx after the touchdown were set, I tried to manually input the arot parameters, but still no luck. I don't know how orbiter set a vehicle upright from for example a scenario file. If I create a vessel simply landed with latitude, longitude and heading parameters for example, how can orbiter know the equilibrium position? or how can I force this position?

[EDIT]
it's like
Code:
vramp->clbkSetStateEx(&vsramp);
simply does not work.

I tried to log this:
Code:
GetStatusEx(&vsramp);
vsramp.status=1;

OBJHANDLE hramp= oapiCreateVesselEx("EmptyMod","EmptyModule",&vsramp);
VESSELSTATUS2 vstest;
	
VESSEL3 *vramp;
	
vramp = (VESSEL3*)oapiGetVesselInterface(hramp);
			  

vramp->clbkSetStateEx(&vsramp);
vramp->GetStatusEx(&vstest);

and while the log of vsramp is ok, the log of vstest status, arot etc is made of crazy numbers...

---------- Post added at 19:58 ---------- Previous post was at 17:59 ----------

In scenario file only "landed earth", latitude, longitude and heading are provided and the vessel is created upright and landed, I think only Dr Martin (:hailprobe:) knows how this works
 
Last edited:
OK, I'll look into this.

Can you try this:
In the scenario file, check if the the landed parent vessel has a line with tag AROT. If it doesn't, can you just launch the scenario, fire a small RCS thruster, wait until the vessel reenters idle state, and save the scenario. This should produce the AROT line.

Then, check whether the VESSELSTATUS2::arot values you get from GetStatusEx bear any resemblance to the values in the scenario file. If not, then maybe the vessel status is not completely defined yet at the point where you are using it (although it should be in clbkPostCreation).
 
Thank you very much!

Here are my results (and some of my thoughts):

1) if I give to my vessel into the scenario file just the lines:
- status landed earth
- latitude
- longitude
- heading

when I open the scenario I find my vessel exactly upright

2) In the other case I create it with a procedure placed in clbkPostCreation or also in the first frame called in postStep which first gets the VESSELSTATUS of my vessel and then calls oapiCreateVesselEx. With this the vessel is created with the correct latitude, longitude and heading, but the rotation is messed up, seems random, and if I save the scenario I get the two AROT values for the vessels which are completely different

3) If I alter the IDLE status of the created vessel somehow it then starts to move to look for the equilibrium and finally find it after some moments of moving around.

My thought was that in the orbiter core the process of creating a vessel was something like:
read the scenario with clbkLoadStateEx
create the vessel with oapiCreateVesselEx giving it the vesselstatus read before

But since this works even without providing the AROT parameter it means that the upright equilibrium processing was missing in my scheme, so somehow in between the above passages orbiter checks for the touchdown points and turns the vessel properly before placing it on the ground. That's what I'm missing here, that passage, When does orbiter checks the touchdown points and properly turns a landed vessel before placing it on the ground? Obviously I can get the direction through the AROT of my vessel, or thourgh vector calculation, but the issue is that if I create the vessel as landed (which is what I really really need) I can't modify its rotation.

Hope this was clear,

Thank you in advance for any help!! :hailprobe:
 
Could this be related to the alltime present "angular torque force", which I found during the XR2 troubleshooting ?
I.e. load a default Atlantis launch scenario and hit CTRL+F9.
Activate all options within the "forces-tab", and (at least in my case), I can see angular torque forces at the shuttle and all its attachments.
This was not the case in Orbiter 2010.
I tried it on the moon (yes....with the shuttle) and got similar forces displayed.
So it's not an atmosphere related issue.
Just an idea.....
 
Could this be related to the alltime present "angular torque force", which I found during the XR2 troubleshooting ?
I.e. load a default Atlantis launch scenario and hit CTRL+F9.
Activate all options within the "forces-tab", and (at least in my case), I can see angular torque forces at the shuttle and all its attachments.
This was not the case in Orbiter 2010.
I tried it on the moon (yes....with the shuttle) and got similar forces displayed.
So it's not an atmosphere related issue.
Just an idea.....

I doubt it's related. What I found out is basically that the oapiCreateVesselEx does not check for the rotation parameters if the vehicle created is landed, or something related to that.
 
This is a very important issue.. it's a fundamental problem to solve in order to allow retrocompatibility beetwen Multistage2 and the new Multistage module for Orbiter 2016... this thing can potentially save (and improve) hundreds of addons!
I'd like to repeat it and highlight the importance of this implementation by Fred!
 
Could this be related to the alltime present "angular torque force", which I found during the XR2 troubleshooting ?
I.e. load a default Atlantis launch scenario and hit CTRL+F9.
Activate all options within the "forces-tab", and (at least in my case), I can see angular torque forces at the shuttle and all its attachments.
This was not the case in Orbiter 2010.
I tried it on the moon (yes....with the shuttle) and got similar forces displayed.
So it's not an atmosphere related issue.
Just an idea.....

BTW the angular torque bug is fixed in the official Orbiter 2016 release.
 
I found a (crazy) workaround for this issue...

I create a hidden scenario file in which I save just the status items I need (position, heading and planet on which the vessel is landed), and then I let the created vessel load that scenario file and set its state as loaded. In this way the vessel appears upright as it was supposed to be. Of course if there is another way to do this that would be very helpful... :coffee:
 
BTW the angular torque bug is fixed in the official Orbiter 2016 release.
No..and I am not sure if this is a bug or just a new feature.
The XR2-related fix makes sure, that if vessel is at "landed(IDLE)", it does not have any lateral-velocity anymore (0.07 m/s vs. now 0.00 m/s in our case).
But the forces are still there, regardless wich vessel or planet/moon.
 
Back
Top