General Question Geostationary position definition code

satelliteGuy

New member
Joined
Feb 25, 2010
Messages
10
Reaction score
0
Points
0
I'm trying to directly position with keys a spacecraft in the earth's orbit on a geostationary position. Somehow all my attempts have failed.

My approach: use clbkPostStep:

void StationaryOrbit::clbkPostStep (double simt, double simdt, double mjd)

OBJHANDLE earthHandle = oapiGetGbodyByName ( "Earth" );

MATRIX3 earthRotInGlobal;
MATRIX3 earthAxisRotation;
VECTOR3 earthPos;
double earthRotation;

oapiGetPlanetObliquityMatrix ( earthHandle, &earthRotInGlobal );
oapiGetGlobalPos ( earthHandle, &earthPos );

earthRotation = oapiGetPlanetCurrentRotation ( earthHandle );
earthAxisRotation.m11 = cos ( earthRotation );
earthAxisRotation.m12 = 0;
earthAxisRotation.m13 = -sin ( earthRotation );
earthAxisRotation.m21 = 0;
earthAxisRotation.m22 = 1;
earthAxisRotation.m23 = 0;
earthAxisRotation.m31 = sin( earthRotation );
earthAxisRotation.m32 = 0;
earthAxisRotation.m33 = cos ( earthRotation );


VESSEL2STATUS status;
status.rbody = earthHandle;
status.arot = status.vrot = status.rvel = _V (0,0,0);
status.rpos = mul ( earthRotInGlobal, mul ( earthAxisRotation, targetPositionInEarthCoordinateSystem ) );
status.version = 2;
status.status = 0;

clbkSetStateEx ( &status );

}

Now, the earth sould NOT rotate underneath my satellite - but it still does. What am I doing wrong? I don't want Orbiter to simulate the orbit, I would like to control the position myself (like position that thing anywhere). I am fully aware that I'm trying to override Orbiter's simulation capabilities, but this is kind of a test to visualize trajectories provided from other sources.


Any help is appreciated.
 
Now, the earth should NOT rotate underneath my satellite - but it still does.

Wrong - it should rotate, because you just set the position, but not the velocity, the velocity is reset to zero by you. You should even fall back to Earth in an highly eccentric orbit. If you do it every time step, you should also make sure the math is correct - you rotate in a right handed coordinate system, not in a left-handed.
 
Last edited:
I set the speed to 0 on purpose. If I overwrite the position in every frame, Orbiter should not change the values anymore, as the simulation has been performed already. At least that's what I thought I did. Checking the documentation for clbkSetStateEx leads me to the assumption that this only has an effect on the vessel's state during initialization.

Is there any way to set position etc. of a vessel during a running simulation? According SetGlobalOrientation should at least do that for the rotation.

I start to believe that what I had in mind won't work.
 
I set the speed to 0 on purpose. If I overwrite the position in every frame, Orbiter should not change the values anymore, as the simulation has been performed already. At least that's what I thought I did. Checking the documentation for clbkSetStateEx leads me to the assumption that this only has an effect on the vessel's state during initialization.

Is there any way to set position etc. of a vessel during a running simulation? According SetGlobalOrientation should at least do that for the rotation.

I start to believe that what I had in mind won't work.
Velocity of a satellite in geostationary orbit isn't 0.
 
I know. The vessel still needs to match the Earth's rotation in order to stay above the same point and the centrifugal forces must neutralize the gravitation in order to maintain the height. But as I said: I do not want Orbiter to simulate the orbit, I want to position the vessel in every timestep myself - therefor I don't need the velocity to be know to Orbiter. It would work, if clbkSetStateEx in clbkPostStep would have done what I thought it would do (at least that's what I initially thouhgt it would do, looking at it's name, a closer look at the documentation after my first post revealed that I was wrong).

I was a little bit mislead because SetRotationMatrix seems to work (at least the vessel rotates), whereas there is no SetPosition, so I tried to use clbkSetStateEx - which failed. And setting these values in clbkPostStep I tried to overwrite what Orbiter calculated. I am trying to integrate a vessel that does not obey the laws of physics within Orbiter - doesn't seem to work. And I know that this is not really what Orbiter was meant for, but the graphics is one the best I've seen so far.
 
I know. The vessel still needs to match the Earth's rotation in order to stay above the same point and the centrifugal forces must neutralize the gravitation in order to maintain the height. But as I said: I do not want Orbiter to simulate the orbit, I want to position the vessel in every timestep myself - therefor I don't need the velocity to be know to Orbiter. It would work, if clbkSetStateEx in clbkPostStep would have done what I thought it would do (at least that's what I initially thouhgt it would do, looking at it's name, a closer look at the documentation after my first post revealed that I was wrong).

I was a little bit mislead because SetRotationMatrix seems to work (at least the vessel rotates), whereas there is no SetPosition, so I tried to use clbkSetStateEx - which failed. And setting these values in clbkPostStep I tried to overwrite what Orbiter calculated. I am trying to integrate a vessel that does not obey the laws of physics within Orbiter - doesn't seem to work. And I know that this is not really what Orbiter was meant for, but the graphics is one the best I've seen so far.
Interestingly enough, my first post on these forums might be useful to you:
http://www.orbiter-forum.com/showthread.php?p=21004&postcount=16

Short version: Move your code to clbkPreStep.
 
Last edited:
I do not want Orbiter to simulate the orbit, I want to position the vessel in every timestep myself - therefor I don't need the velocity to be know to Orbiter.
You may not need it to be known to Orbiter, but it might be considerate for other addons that care about the velocity of your vessel. Say for example someone wants to rendezvous with your vessel. The tools for doing so would not work because the trajectory your vessel is following is not predictable to them from its state vectors. Maybe that is not an issue for you :shrug:

It would work, if clbkSetStateEx in clbkPostStep would have done what I thought it would do (at least that's what I initially thouhgt it would do, looking at it's name, a closer look at the documentation after my first post revealed that I was wrong).
clbkSetStateEx is a callback that your class needs to provide for Orbiter to call when your vessel is created. Use DefSetStateEx instead, per Hielor's code. The other important thing to note from Hielor's code are these lines to ensure proper initialisation of the VESSELSTATUS2 structure:
Code:
VESSELSTATUS2 mystat;
memset(&mystat,0,sizeof(VESSELSTATUS2));
mystat.version = 2;
GetStatusEx(&mystat);
 
Back
Top