Programming Question Touchdown and eva

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
10,538
Reaction score
4,369
Points
203
Location
Dallas, TX
So I am confused.
On my mk2 I an recoding. I have this which will spawn and eva guy. but the Y value of the loaction does not seem to do anything? So I raised the mesh to be at ground level. Fixed that.
But then on the eva. He is above the ground. And the touchdown points do not seem to do anything:(

eva guy. The set TDVTXStuff is getting called here:
void LEVA::clbkSetClassCaps(FILEHANDLE cfg)
{

SetTDVTXStuff();
void LEVA::SetTDVTXStuff()
{
double x_target = -0.5;
double stiffness = (-1) * (ASTROMASS * G) / (3 * x_target);
double damping = 0.9 * (2 * sqrt(ASTROMASS * stiffness));
double ro = 0.3;
double Height_From_Ground = -.9;
for (int i = 0; i < ntdvtx; i++)
{
tdvtx.damping = damping;
tdvtx.mu = 3;
tdvtx.mu_lng = 3;
tdvtx.stiffness = stiffness;
}
tdvtx[0].pos.x = cos(30 * RAD) * ro;
tdvtx[0].pos.y = -Height_From_Ground;
tdvtx[0].pos.z = -sin(30 * RAD) * ro;
tdvtx[1].pos.x = 0;
tdvtx[1].pos.y = -Height_From_Ground;
tdvtx[1].pos.z = 1 * ro;
tdvtx[2].pos.x = -cos(30 * RAD) * ro;
tdvtx[2].pos.y = -Height_From_Ground;
tdvtx[2].pos.z = -sin(30 * RAD) * ro;

SetTouchdownPoints(tdvtx, ntdvtx);
}

and the mk2 spawn eva.
SpawnEVA(void)
{

{
VESSELSTATUS2 vs;
memset(&vs, 0, sizeof(vs));
vs.version = 2;
GetStatusEx(&vs);
OBJHANDLE EVAGUY;

vs2.vrot.x = 0.9;


vs.status = 1; // Landed

/* Calculate degrees / meter */
double planetRadius = oapiGetSize(GetSurfaceRef());
double metersPerDegree = (planetRadius * 2 * PI) / 360;

VECTOR3 rotatedPosition; // Holds the airlock position after being converted to horizon frame
HorizonRot(_V(-6.6,0, 0), rotatedPosition);

/* Update the position of the MMU vessel to be at the airlock */
vs.surf_lat += (rotatedPosition.z / metersPerDegree) * RAD;
vs.surf_lng += (rotatedPosition.x / metersPerDegree) * RAD;


// else {
// pParentVessel->Local2Rel(_V(4, 0, 1.5), vs.rpos); // Convert the airlock position to relative coords
// }
EVAGUY = oapiCreateVesselEx("Eva_1", "2016SEVASOLIDRED", &vs); // do we need apostrophes "" ?
VESSEL2* EVAGUY_vessel = (VESSEL2*)oapiGetVesselInterface(EVAGUY); // vessel interface if needed, delete line if not
eva1 = 1;
// SetMeshVisibilityMode(mesh_EVA1, MESHVIS_NEVER);


/* Create MMU Vessel - ensure vessel state changes are made *before* this point */
//auto mmuVessel = oapiCreateVesselEx(mmuName, "oMMU", &vesselStatus);
//oMMU_MMU* newMMU = static_cast<oMMU_MMU*>(oapiGetVesselInterface(mmuVessel)); // Instantiate the new MMU
// newMMU->setMMUData(mCrew[crewIndex]); // Pass crew data along
// RemoveCrew(crewIndex);

// Set camera / input focus on the new MMU vessel if requested
// if (setFocus) {
// oapiSetFocusObject(mmuVessel);
// }















}

}


I hope someone can see what is going on
 
I can't really see "whats going on", but you can try this little known Orbiter SDK "trick"....

After you set the vs.surf_lat & vs.surf_lng values, use:
Code:
vs.arot.x = 10;
This should tell Orbiter to set the vessel landed on its touchdown points.
Works for oapiDefSetStateEx( ) - it should work for oapiCreateVesselEx( ).

Good luck!
:cheers:
 
Thanks. I got them to exit now I need to figure out how to get them back in. Being using the LWLL for code source
 
So trying to place a created vessel in a certain location

SpawnCARGO1(void)
{

{

VESSELSTATUS2 vs2;
memset(&vs2, 0, sizeof(vs2));
vs2.version = 2;
GetStatusEx(&vs2);
vs2.status = 1;
vs2.vrot.x = 0.9;
OBJHANDLE CARGO1;
/* Calculate degrees / meter */
double planetRadius = oapiGetSize(GetSurfaceRef());
double metersPerDegree = (planetRadius * 2 * PI) / 360;

VECTOR3 rotatedPosition; // Holds the airlock position after being converted to horizon frame
HorizonRot(_V(-1, 0, 4), rotatedPosition);

/* Update the position of the MMU vessel to be at the airlock */
vs2.surf_lat += (rotatedPosition.z / metersPerDegree) * RAD;
vs2.surf_lng += (rotatedPosition.x / metersPerDegree) * RAD;


// else {
// pParentVessel->Local2Rel(_V(4, 0, 1.5), vs.rpos); // Convert the airlock position to relative coords
// }
CARGO1 = oapiCreateVesselEx("BUGGY", "ARTEMISEVATOOLS\\ARTEMISBUGGY", &vs2); // do we need apostrophes "" ?
VESSEL2* EVAGUY_vessel = (VESSEL2*)oapiGetVesselInterface(CARGO1); // vessel interface if needed, delete line if not

It creates the vessel but not where I thing it should be? it places it at the red dot
 

Attachments

  • cargolocation.jpg
    cargolocation.jpg
    41.7 KB · Views: 2
I got another question. For cargo,.... when released I want it to just drop and not bounce into orbit.

I am using this to determine TD points.
void LEVA::SetTDVTXStuff()
{
double x_target = -0.5;
double stiffness = (-1) * (ASTROMASS * G) / (3 * x_target);
double damping = 0.9 * (2 * sqrt(ASTROMASS * stiffness));
double ro = 0.3;
double Height_From_Ground = .3;
for (int i = 0; i < ntdvtx; i++)
{
tdvtx[i].damping = damping;
tdvtx[i].mu = 3;
tdvtx[i].mu_lng = 3;
tdvtx[i].stiffness = stiffness;
}
tdvtx[0].pos.x = cos(30 * RAD) * ro;
tdvtx[0].pos.y = -Height_From_Ground;
tdvtx[0].pos.z = -sin(30 * RAD) * ro;
tdvtx[1].pos.x = 0;
tdvtx[1].pos.y = -Height_From_Ground;
tdvtx[1].pos.z = 1 * ro;
tdvtx[2].pos.x = -cos(30 * RAD) * ro;
tdvtx[2].pos.y = -Height_From_Ground;
tdvtx[2].pos.z = -sin(30 * RAD) * ro;

SetTouchdownPoints(tdvtx, ntdvtx);
}
 
Weird. Another lander and the same code as the MK2.
But when I guy exits he is tilted. When He moves he straights up?
Mission1:2016SEVAwhite
STATUS Landed Moon
POS -33.4407176 41.1224070
HEADING 0.00
ALT 0.900
AROT 94.281 42.480 96.036
AFCMODE 7
NAVFREQ 0 0
EVA_TIME 329.761666
OXYGEN 99.427497
VISOR 0.000000
SVISOR 0.000000
FVISOR 0.000000
LIGHTS 0
TYPE 4
END

code for spawn
void FLEXUACS::SpawnEVA3(void)
{





VESSELSTATUS2 vs2;
memset(&vs2, 0, sizeof(vs2));
vs2.version = 2;
GetStatusEx(&vs2);
vs2.status = 1;
vs2.vrot.x = 0.9;//height off the ground

OBJHANDLE EVAGUY;
/* Calculate degrees / meter */
double planetRadius = oapiGetSize(GetSurfaceRef());
double metersPerDegree = (planetRadius * 2 * PI) / 360;

VECTOR3 rotatedPosition; // Holds the airlock position after being converted to horizon frame
HorizonRot(_V(-6.6, 0, 0), rotatedPosition);

/* Update the position of the MMU vessel to be at the airlock */
vs2.surf_lat += (rotatedPosition.z / metersPerDegree) * RAD;
vs2.surf_lng += (rotatedPosition.x / metersPerDegree) * RAD;


OBJHANDLE new_leva;
char cbuf[256];

new_leva = oapiCreateVesselEx(mis1_name, "2016SEVAwhite", &vs2);
sprintf(cbuf, "%lf %lf %lf", (float)(100), 0.0, 0.0);
crew4_on_board = 0;
oapiSetFocusObject(new_leva);
VESSEL4* v = (VESSEL4*)oapiGetVesselInterface(new_leva);
v->clbkConsumeBufferedKey(COMM_START_LEVA, false, cbuf);




}
 

Attachments

  • crewissue3.jpg
    crewissue3.jpg
    44.2 KB · Views: 4
So why is all vessel that I spawn at a slant?
As I understand it.
VESSELSTATUS2 vs2;
memset(&vs2, 0, sizeof(vs2));
vs2.version = 2;
GetStatusEx(&vs2);
vs2.status = 1;
vs2.vrot.x = 0.9;
OBJHANDLE EVAGUY;


vs2.status = 1; means the vessel is landed.
 

Attachments

  • slanteva2.jpg
    slanteva2.jpg
    49.8 KB · Views: 4
  • slanteva1.jpg
    slanteva1.jpg
    58.9 KB · Views: 4
not sure why these guys are slanted and then you move them they straighten up

17.62.2.3 int VESSELSTATUS2::statusflight status indicatorNote• 0=active (freeflight)• 1=inactive (landed
 
So I thought I had this fixed. Using the LWLL code. BUT when the craft is near the poles it doesn't work. I remember this same issue with driving. But that is fixed.
Any ideas?
@Max-Q

if (crew1_on_board == 1) {
double rt = oapiGetSize(GetSurfaceRef());
double moon_circ = rt * 2 * PI;
double each_deg = moon_circ / 360;
VESSELSTATUS2 vs2;
memset(&vs2, 0, sizeof(vs2));
vs2.version = 2;
GetStatusEx(&vs2);
vs2.status = 1;
vs2.vrot.x = 0.9;

double x_pos =-6.6;
double z_pos = 0;


double d_lat1 = (z_pos * cos(vs2.surf_hdg)) / each_deg;
double d_lng1 = (z_pos * sin(vs2.surf_hdg)) / each_deg;
double d_lat2 = (x_pos * -sin(vs2.surf_hdg)) / each_deg;
double d_lng2 = (x_pos * cos(vs2.surf_hdg)) / each_deg;
vs2.surf_lat += ((d_lat1 + d_lat2) * RAD);
vs2.surf_lng += ((d_lng1 + d_lng2) * RAD);

MATRIX3 rot1 = RotationMatrix(_V(0 * RAD, (90 * RAD - vs2.surf_lng), 0 * RAD), TRUE);
MATRIX3 rot2 = RotationMatrix(_V(-vs2.surf_lat + 0 * RAD, 0, 0 * RAD), TRUE);
MATRIX3 rot3 = RotationMatrix(_V(0, 0, 180 * RAD + vs2.surf_hdg), TRUE);
MATRIX3 rot4 = RotationMatrix(_V(90 * RAD, 0, 0), TRUE);
MATRIX3 RotMatrix_Def = mul(rot1, mul(rot2, mul(rot3, rot4)));
vs2.arot.x = atan2(RotMatrix_Def.m23, RotMatrix_Def.m33);
vs2.arot.y = -asin(RotMatrix_Def.m13);
vs2.arot.z = atan2(RotMatrix_Def.m12, RotMatrix_Def.m11);


char cbuf[256];

OBJHANDLE EVAGUY;

EVAGUY = oapiCreateVesselEx(cdr_name, "2016SEVASOLIDRED", &vs2);
sprintf(cbuf, "%lf %lf %lf", (float)(100), 0.0, 0.0);
crew1_on_board = 0;
VESSEL2* EVAGUY_vessel = (VESSEL2*)oapiGetVesselInterface(EVAGUY); // vessel interface if needed, delete line if not






oapiSetFocusObject(EVAGUY);
VESSEL4* v = (VESSEL4*)oapiGetVesselInterface(EVAGUY);
v->clbkConsumeBufferedKey(COMM_START_LEVA, false, cbuf);











}

}
 
si (crew1_on_board == 1)
{
double rt = oapiGetSize(GetSurfaceRef());
double moon_circ = rt * 2.0 * PI;
double each_deg = moon_circ / 360.0;

STATUT DU VAISSE2 vs2;
memset(&vs2, 0, sizeof(vs2));
vs2.version = 2;

ObtenirStatutEx(&vs2);
vs2.status = 1; // atterri

double x_pos = -6,6;
double z_pos = 0.0;

// projection locale vers planète
double hdg = vs2.surf_hdg;

double d_lat =
((z_pos * cos(hdg)) + (x_pos * -sin(hdg))) / chaque_deg;

double d_lng =
((z_pos * sin(hdg)) + (x_pos * cos(hdg))) / chaque_deg;

vs2.surf_lat += d_lat;
vs2.surf_lng += d_lng;

// IMPORTANT : éviter spawn instable
vs2.alt = 0.0;

// orientation simple (EVA stable)
vs2.arot.x = 0.0;
vs2.arot.y = 0.0;
vs2.arot.z = hdg;

OBJHANDLE EVAGUY =
oapiCreateVesselEx(cdr_name, "2016SEVASOLIDRED", &vs2);

crew1_on_board = 0;

si (EVAGUY)
{
oapiSetFocusObject(EVAGUY);

VESSEL2* ev =
(VESSEL2*)oapiGetVesselInterface(EVAGUY);

// option safe (évite le crash si EVA n'accepte pas la saisie)
char cbuf[] = "100 0 0";

si (ev)
{
ev->clbkConsumeBufferedKey(COMM_START_LEVA, false, cbuf);
}
}
}
 
Thanks. I think this is correct:
void FLEXUACS::SpawnEVA(void)
{
if (crew1_on_board == 1) {
double rt = oapiGetSize(GetSurfaceRef());
double moon_circ = rt * 2.0 * PI;
double each_deg = moon_circ / 360.0;
VESSELSTATUS2 vs2;
memset(&vs2, 0, sizeof(vs2));
vs2.version = 2;
GetStatusEx(&vs2);
// vs2.status = 1;
//vs2.vrot.x = 0.9;

double x_pos =-6.6;
double z_pos = 0;

// projection locale vers planète
double hdg = vs2.surf_hdg;

double d_lat =
((z_pos * cos(hdg)) + (x_pos * -sin(hdg))) / each_deg;

double d_lng =
((z_pos * sin(hdg)) + (x_pos * cos(hdg))) / each_deg;

vs2.surf_lat += d_lat;
vs2.surf_lng += d_lng;

//vs2.alt = 0.0;//not sure about this??
vs2.vrot.x = 0.9;
vs2.vrot.x = 0;
vs2.arot.z = hdg;


char cbuf[256];

OBJHANDLE EVAGUY;

EVAGUY = oapiCreateVesselEx(cdr_name, "2016SEVASOLIDRED", &vs2);
sprintf(cbuf, "%lf %lf %lf", (float)(100), 0.0, 0.0);
crew1_on_board = 0;
VESSEL2* EVAGUY_vessel = (VESSEL2*)oapiGetVesselInterface(EVAGUY); // vessel interface if needed, delete line if not






oapiSetFocusObject(EVAGUY);
VESSEL4* v = (VESSEL4*)oapiGetVesselInterface(EVAGUY);
v->clbkConsumeBufferedKey(COMM_START_LEVA, false, cbuf);











}

}
But when the is vessel is here:
STATUS Landed Moon
POS -125.7134310 -89.2545940
HEADING 2.54
ALT 7.511 the exit point is below the vessel center

but move it to Brighton and then the exit is closer to the ladder. I might need to adjust the double x_pos =-6.6;
 

Attachments

  • evabrighton.jpg
    evabrighton.jpg
    43.1 KB · Views: 3
  • evanearpole.jpg
    evanearpole.jpg
    37.7 KB · Views: 3
Hi,
// projection locale vers planète
double hdg = vs2.surf_hdg;

double d_lat =
((z_pos * cos(hdg)) + (x_pos * -sin(hdg))) / each_deg;

double d_lng =
((z_pos * sin(hdg)) + (x_pos * cos(hdg))) / each_deg;

vs2.surf_lat += d_lat;
vs2.surf_lng += d_lng;
this is only really valid for a flat plane - good enough if you're close to the equator.
But error will get worse closer to the pole (lines of longitude get closer together at the pole).

You could do it with vectors though (well, I like vectors 😁)......I wrote this code off the top of my head, not compiled or tested so you may need to adjust.......backup previous code just in case!......
Code:
OBJHANDLE hMoon = GetSurfaceRef();

VESSELSTATUS2 vs2;
memset(&vs2, 0, sizeof(vs2));
vs2.version = 2;
GetStatusEx(&vs2);

VECTOR3 eva_offset_local = _V(-6.6, 0, 0);    // eva pos relative to spacecraft
VECTOR3 eva_offset_global;
Local2Global(eva_offset_local , eva_offset_global); // eva global pos

VECTOR3 eva_pos_moon;
oapiGlobalToLocal(hMoon, &eva_offset_global, &eva_pos_moon); // eva pos moon frame

double eva_lat, eva_lng, eva_rad;
oapiLocalToEqu(hMoon, eva_pos_moon, &eva_lng, &eva_lat, &eva_rad); // eva equ coords

double eva_heading;
oapiGetHeading(GetHandle(),&eva_heading); // get heading just in case

vs2.status = 1;        // set landed just in case
vs2.surf_lat = eva_lat;
vs2.surf_lng = eva_lng;
vs2.surf_hdg = eva_heading;
vs2.arot.x = 10;     // SDK "trick" to put vessel on td points on surface

OBJHANDLE EVAGUY;
EVAGUY = oapiCreateVesselEx(cdr_name, "2016SEVASOLIDRED", &vs2);
Any good?

:cheers:
 
Last edited:
Thanks.
So I have this: I moved the exit point to -7.6
{
if (crew1_on_board == 1) {
OBJHANDLE hMoon = GetSurfaceRef();

VESSELSTATUS2 vs2;
memset(&vs2, 0, sizeof(vs2));
vs2.version = 2;
GetStatusEx(&vs2);

VECTOR3 eva_offset_local = _V(-7.6, 0, 0); // eva pos relative to spacecraft
VECTOR3 eva_offset_global;
Local2Global(eva_offset_local, eva_offset_global); // eva global pos

VECTOR3 eva_pos_moon;
oapiGlobalToLocal(hMoon, &eva_offset_global, &eva_pos_moon); // eva pos moon frame

double eva_lat, eva_lng, eva_rad;
oapiLocalToEqu(hMoon, eva_pos_moon, &eva_lng, &eva_lat, &eva_rad); // eva equ coords

double eva_heading;
oapiGetHeading(GetHandle(), &eva_heading); // get heading just in case

vs2.status = 1; // set landed just in case
vs2.surf_lat = eva_lat;
vs2.surf_lng = eva_lng;
vs2.surf_hdg = eva_heading;
vs2.arot.x = 10; // SDK "trick" to put vessel on td points on surface
char cbuf[256];
OBJHANDLE EVAGUY;
EVAGUY = oapiCreateVesselEx(cdr_name, "2016SEVASOLIDRED", &vs2);
sprintf(cbuf, "%lf %lf %lf", (float)(100), 0.0, 0.0);
crew1_on_board = 0;
VESSEL2* EVAGUY_vessel = (VESSEL2*)oapiGetVesselInterface(EVAGUY); // vessel interface if needed, delete line if not







oapiSetFocusObject(EVAGUY);
VESSEL4* v = (VESSEL4*)oapiGetVesselInterface(EVAGUY);
v->clbkConsumeBufferedKey(COMM_START_LEVA, false, cbuf);











}

}
Then exited and it put the guy under the rocket.
 
I am using 2016 also.
So it did not matter if you were at the poles or equator? the guy exited the same location?
 
I am using 2016 also.
So it did not matter if you were at the poles or equator? the guy exited the same location?
Tried it on Moon latitude -89.25 and +2.13 and it works fine.
I was spawning a "Carina" satellite, since I don't have an "EVAGUY".
One last thought:
Is the Spawn triggered in clbkPreStep(...)?
If so, move it to clbkPostStep(...)
...or vice versa..
Good luck!
 
Thanks
So I have this:
case IDC_EVA1:
if (sts->crew1_on_board == 1) {
sts->spawneva1 = 1;
sts->ConfigureCrewMeshes();
return 0;
}
so if the button for eva1 is pressed spawneva=1
and in
void FLEXUACS::clbkPostStep(double simt, double simdt, double mjd)
{


if (spawneva1 == 1) { SpawnEVA();
ConfigureCrewMeshes();
}

I wonder if that is wrong as the guy is in the wrong place.
what does your poststep look like?
 
Back
Top