MFD Parking Brake MFD

N_Molson

Addon Developer
Addon Developer
Donator
Joined
Mar 5, 2010
Messages
9,256
Reaction score
3,231
Points
203
Location
Toulouse
It's a native Orbiter feature.

I was not sure if it was native or coded through specific vessel modules, so good news there ?
 

N_Molson

Addon Developer
Addon Developer
Donator
Joined
Mar 5, 2010
Messages
9,256
Reaction score
3,231
Points
203
Location
Toulouse
@asbjos : I'd like to use it for the Proton launcher I'm developping (and then in other projects).

I know how to do it through .dll coding, but this can lead to some conflicts.

I'm working on "inline" launchers, with multiple stages docked together and strapon boosters for some of them.

Parking Brake in its current state works "too well" : it grounds all my rockets stages and bypasses the scenario docking information (overrides the DOCKINFO parameter). So my rocket stages dock but then are immediatly grounded by Parking Brake. As soon as I apply thrust, they all get back to their "normal" postion.

So what I need is a parameter in the scenario file that would disable parking brake for that vessel. Do you think it can be done ? That would help a lot. I'm sure a lot of people will use this great plugin and I want to make my stuff compatible with it.
 

asbjos

tuanibrO
Addon Developer
Joined
Jun 22, 2011
Messages
696
Reaction score
259
Points
78
Location
This place called "home".
@asbjos : I'd like to use it for the Proton launcher I'm developping (and then in other projects).

I know how to do it through .dll coding, but this can lead to some conflicts.

I'm working on "inline" launchers, with multiple stages docked together and strapon boosters for some of them.

Parking Brake in its current state works "too well" : it grounds all my rockets stages and bypasses the scenario docking information (overrides the DOCKINFO parameter). So my rocket stages dock but then are immediatly grounded by Parking Brake. As soon as I apply thrust, they all get back to their "normal" postion.

So what I need is a parameter in the scenario file that would disable parking brake for that vessel. Do you think it can be done ? That would help a lot. I'm sure a lot of people will use this great plugin and I want to make my stuff compatible with it.

What mode are you in? (Contact/low speed/launch control)

I'm not a fan of a scenario "ignore" flag, as it would require to retroactively add it to all previous add-ons, and all future add-ons to take mine into consideration.

Maybe better to add a condition so that I don't park vessels that are docked and/or that have a full propellant tank.

Could you send me a zip of a launcher for testing?
 

N_Molson

Addon Developer
Addon Developer
Donator
Joined
Mar 5, 2010
Messages
9,256
Reaction score
3,231
Points
203
Location
Toulouse
Yes I'll send you an alpha later today.

Yes I think that the "docked" condition check would work (y)
 

4throck

Enthusiast !
Joined
Jun 19, 2008
Messages
3,502
Reaction score
1,008
Points
153
Location
Lisbon
Website
orbiterspaceport.blogspot.com
Noticed one thing with SC4 vessels:
If lift-off and landing points are defined, ParkingBrake seems to only consider landing points. Lift-off are ignored.

I guess this might also affect non sc4 vessels that do similar changes.
 

N_Molson

Addon Developer
Addon Developer
Donator
Joined
Mar 5, 2010
Messages
9,256
Reaction score
3,231
Points
203
Location
Toulouse
Yes I'll send you an alpha later today.

@asbjos: still working on it !

Now it does not work with the Orbiter 2016 default "Space Shuttle Atlantis" scenarios, the whole stack ends in the flame trench. I think this is pretty much the same issue (but I'll send you the add-on pre-alpha before going to sleep). Testing the "docked" condition with Atlantis could be interesting, because Martins used docking ports instead of attachment points (that trend comes from there).
 

asbjos

tuanibrO
Addon Developer
Joined
Jun 22, 2011
Messages
696
Reaction score
259
Points
78
Location
This place called "home".
Noticed one thing with SC4 vessels:
If lift-off and landing points are defined, ParkingBrake seems to only consider landing points. Lift-off are ignored.

I guess this might also affect non sc4 vessels that do similar changes.
Do you have a link to such a vessel? But with a only-park-if-fuel-not-full rule, I assume that also this would be "fixed".

The parking is done in the same fashion as when using the scenario editor, so I don't do anything with touchdownpoints and their definitions in my code.
 

4throck

Enthusiast !
Joined
Jun 19, 2008
Messages
3,502
Reaction score
1,008
Points
153
Location
Lisbon
Website
orbiterspaceport.blogspot.com
Tested more and indeed it doesn't seem to be a parking break problem.
It's an Orbiter bug....

For the sake of discussion try:
Vinka's spacecraft » Vertical Take Off - Horizontal Landing

On KSC it works (vertical DG). Move to Brighton Beach using scenario editor, it works (vertical DG).
Move to Edwards or Kourou (bases with updated terrain) and the DG becomes horizontal...

Very strange :unsure:
 

asbjos

tuanibrO
Addon Developer
Joined
Jun 22, 2011
Messages
696
Reaction score
259
Points
78
Location
This place called "home".
Tested more and indeed it doesn't seem to be a parking break problem.
It's an Orbiter bug....

For the sake of discussion try:
Vinka's spacecraft » Vertical Take Off - Horizontal Landing

On KSC it works (vertical DG). Move to Brighton Beach using scenario editor, it works (vertical DG).
Move to Edwards or Kourou (bases with updated terrain) and the DG becomes horizontal...

Very strange :unsure:

The description of that scenario says "the landing position is switched when you reach an altitude of 100 m", so my guess is that Vinka uses mean-sea-level altitude, and not altitude over terrain.
Cape is at the coast, Brighton is -2.6 km, but Edwards is at 700 m.
 

Boxx

Mars Addict
Addon Developer
Donator
Joined
Nov 15, 2009
Messages
168
Reaction score
122
Points
58
Location
Paris Area
Hi, I re-used this piece of code in my OMX addon (fork of OMP), actually it was mandatory, otherwise the vessels landed at some time on Phobos or Mars slowly drift away after the user disconnects!!! Hence a bad surprise at reconnection :eek:

Thanks again for sharing the tip (that was duly credited).
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,563
Reaction score
2,526
Points
203
Location
Dallas, TX
@Boxx
Can you share that part. I think it would be nice for my EAgles that when on the surface they are landed.
 

Boxx

Mars Addict
Addon Developer
Donator
Joined
Nov 15, 2009
Messages
168
Reaction score
122
Points
58
Location
Paris Area
the criteria to make a vessel land are here (I think that's what you need), in my void STC_OwnVesselLanded(OBJHANDLE vHandle)
Code:
    // Only do extensive check if not already landed, but in contact with planet.
    if (v->GroundContact()) // ground contact, maybe not still.
    {
        if (v->GetThrusterGroupLevel(THGROUP_MAIN) < 0.01 && v->GetThrusterGroupLevel(THGROUP_HOVER) < 0.01 && v->GetThrusterGroupLevel(THGROUP_RETRO) < 0.01)
            // main thrusters near-to-Zero (RCS allowed, linear or rotation)
        {
            if (v->GetGroundspeed() < 0.5)
                // speed lower than 0.5m/s (docking requests 0.1m/s)
            {
                VECTOR3 vv = _V(0, 0, 0);
                v->GetAngularVel(vv);
                if (length(vv) < 30 * PI / 180)
                    // low-tumbling (<30deg/s, i.e. 30*pi/180 rad/s)
                {
                    if (v->GetPitch() < PI / 6 && v->GetBank() < PI / 6)
                        // the orientation must be close to horizontal (30deg max, we don't care the yaw angle)
                    {
                        if (!entry->Landed) {
                            // => force Landed status + notify the server
                            //tlogging(5, "STC_OwnVesselLanded > do we LandIt?");
                            ref = v->GetSurfaceRef();
                            v->GetEquPos(longitude, latitude, radius);
                            oapiGetHeading(vHandle, &heading);
                            STC_LandIt(v, ref, longitude, latitude, heading);

then, the function STC_LandIt itself is in the same .cpp here.
 

nbcfrosty

Active member
Joined
Jun 16, 2023
Messages
116
Reaction score
194
Points
43
Location
US
Code:
void ParkVessel(VESSEL* ves)
{
    // Thanks to "jarmonik": https://www.orbiter-forum.com/threads/mars-2020-rover-and-mars-helicopter-scout.37153/page-6#post-577597
    // Also honorably mention to "face": https://www.orbiter-forum.com/threads/orbiter-economic-simulation.39629/page-2#post-578205
    OBJHANDLE ref = ves->GetSurfaceRef();
    double longitude, latitude, radius;
    ves->GetEquPos(longitude, latitude, radius);
    double heading = 0.0;
    OBJHANDLE obj = ves->GetHandle();
    oapiGetHeading(obj, &heading);
    VESSELSTATUS2 vs;
    memset(&vs, 0, sizeof(vs));
    vs.version = 2;
    vs.rbody = ref;
    vs.status = 1; // Landed
    vs.arot.x = 10; // <----- Undocumented feature "magic value" to land on touchdown points !! IMPORTANT !! It has to be 10, no more, no less !
    vs.surf_lng = longitude;
    vs.surf_lat = latitude;
    vs.surf_hdg = heading;
    ves->DefSetStateEx(&vs);
}
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,563
Reaction score
2,526
Points
203
Location
Dallas, TX
Thanks. Do I need to call this some where?
I get a CTD now

I ran the debugger and breaks with no symbols loaded. I just added the code. It is not called any where?

So where is the void STC_LandIt called for?
 
Last edited:

Boxx

Mars Addict
Addon Developer
Donator
Joined
Nov 15, 2009
Messages
168
Reaction score
122
Points
58
Location
Paris Area
You need to call this piece of code at each frame (in ocpPreStep/opcPostStep or clbkPreStep/clbkPostStep). In OMX it's more complicated, but same concept, I do a loop on all vessels of the simulation, I simplified here below for you, removing all OMX specificities:
Code:
    OBJHANDLE handle;
    for(int i=0;(handle=oapiGetVesselByIndex(i))!=NULL;i++) { STC_OwnVesselLanded(handle); }

then, STC_OwnVesselLanded(handle) is the code above, with the criteria, here is how it starts:
Code:
void STC_OwnVesselLanded(OBJHANDLE vHandle)
{
    // here, we adapt Parking Brake MFD code to a permanent "Near-0 velocity mode"
    // => see STC_LandIt(...) for credits
    OBJHANDLE ref;
    IDload* pBody;
    double longitude, latitude, radius;
    double heading = 0.0;
    VESSELSTATUS2 vs;
    memset(&vs, 0, sizeof(vs));
    VESSEL* v = oapiGetVesselInterface(vHandle);
    // Only do extensive check if not already landed, but in contact with planet.
    if (v->GroundContact()) // ground contact, maybe not still.
======> (etc... see above)

then, if the criteria are met, STC_LandIt(v, ref, longitude, latitude, heading) is called. If you couldn't find it in the gitlab, here it is:
Code:
void STC_LandIt(VESSEL* v, OBJHANDLE rbody, double longitude, double latitude, double heading)
{
    // Thanks to "asbjos" (under GPLv2 for OMX): https://www.orbiter-forum.com/resources/parking-brake.3105/
    // Thanks to "jarmonik": https://www.orbiter-forum.com/threads/mars-2020-rover-and-mars-helicopter-scout.37153/page-6#post-577597
    // Also honorably mention to "Face": https://www.orbiter-forum.com/threads/orbiter-economic-simulation.39629/page-2#post-578205

    VESSELSTATUS2 vs;
    vs.version = 2;
    vs.flag = 0x0;
    v->GetStatusEx(&vs);
    vs.rbody = rbody;
    vs.status = 1; // Landed
    vs.rvel = _V(0, 0, 0);
    vs.arot = _V(0, 0, 0);
    vs.vrot = _V(0, 0, 0);
    vs.arot.x = 10; // <----- Undocumented feature "magic value" to land on touchdown points !! IMPORTANT !! It has to be 10, no more, no less !
    vs.surf_lng = longitude;
    vs.surf_lat = latitude;
    vs.surf_hdg = heading;
    // in order to "smooth" the anchoring on a small body surface and align with the local mesh, maybe consider:
    // VECTOR3 VESSEL::GetSurfaceNormal  (  ) const
    // ELEVHANDLE oapiElevationManager  ( OBJHANDLE  hPlanet ), then an access to the tiles would be needed (bool oapi::GraphicsClient::ElevationGrid?)
    // double oapiSurfaceElevation  ( OBJHANDLE  hPlanet,  double  lng,    double  lat    )
    // (or) double VESSEL::GetSurfaceElevation  (  ) const
    // BOOL oapiGetAltitude  ( OBJHANDLE  hVessel,  AltitudeMode  mode, double* alt)
    // + cancel totally all rotation, thrusts and auto-modes
    v->DefSetStateEx(&vs);
    return;
}
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,563
Reaction score
2,526
Points
203
Location
Dallas, TX
Thanks. I guess it is not as easy as just add those 3 parts to the vessel?
void EAGLE3::clbkPreStep(double simt, double simdt, double mjd) { OBJHANDLE handle; for (int i = 0; (handle = oapiGetVesselByIndex(i)) != NULL; i++) { STC_OwnVesselLanded(handle); }
void STC_OwnVesselLanded(OBJHANDLE vHandle)
and
void STC_LandIt(VESSEL * v, OBJHANDLE rbody, double longitude, double latitude, double heading)
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,563
Reaction score
2,526
Points
203
Location
Dallas, TX
So I used this on the eagle on the moon. And got it landed but it would not stay landed. from the mfd screen
 
Top