Tudat / tudat

NOTE: This Tudat version is no longer supported. See https://docs.tudat.space/en/stable/ and https://github.com/tudat-team/tudat-bundle for the new version
BSD 3-Clause "New" or "Revised" License
87 stars 143 forks source link

Using observations without orbit determination #566

Closed Casperbru closed 5 years ago

Casperbru commented 5 years ago

Hi,

I would like to use code from the observation model packages, but without performing orbit determination / parameter estimation. For my application I only need the range observation/ relative distance between two link ends and I would like to use the observation viability calculator, since my problem for now is purely a geometry problem. When I am looking at the earthOrbiterBasicStateEstimation it actually does require of the orbitDeterminationManager. According to Dominic this is probably not necessary. How can I use a basic form of the code?

DominicDirkx commented 5 years ago

Hi Casper,

The lines you are referring to are, I think:

https://github.com/Tudat/tudatExampleApplications/blob/master/satellitePropagatorExamples/SatellitePropagatorExamples/earthOrbiterBasicStateEstimation.cpp#L307-L309

where the observations are simulated. Since this uses orbitDeterminationManager.getObservationSimulators( ) as input, you have an unwanted dependency on the OrbitDeterminationManager class. This can be circumvented by using:

std::map< ObservableType, std::shared_ptr< ObservationSimulatorBase< double, double > > > observationSimulators = createObservationSimulators( observationSettingsMap , bodyMap );

to manually create the observation simulators. You can then replace orbitDeterminationManager.getObservationSimulators( ) by observationSimulators to remove your dependency on the OrbitDeterminationManager class.

Let me know if this answers your question,

Best,

Dominic

Casperbru commented 5 years ago

Hi Dominic,

Thanks for the answer. I tried to include parts of the code with some adjustments in my own code, but I still get a lot of errors. First the type ObservationSettingsMap wouldn't load, after a while I figured I could fix this by including #include <Tudat/SimulationSetup/tudatEstimationHeader.h>. Why is this necessary and can't the object be loaded by using namespaces? I figured I didn't really need the parameter perturb part of the code, so I commented this out (this part of the code also included another instance of the orbitDeterminationManager problem). This lead to the problem of how to write the results to a file, since in the example they're using code in the perturb part to get writeable data. So my second question is how to convert observationsAndTimes (eg) to something that I can write to a file? But even if I skip the writing to file part the program won't run and I get many issues, mostly in the form of "undefined reference to" something in the observation model. It doesn't give a more detailed explanation than that and it doesn't show in the code where errors originate.

I attached the compilation output and the code can be found on my github: https://github.com/Casperbru/firstProg Within the application myConstellationSimulator.cpp errorLog_woPerturb.txt

DominicDirkx commented 5 years ago

Hi Casper,

The include statement is needed to make the code for the estimation models (including observation models) visible.

I think that your undefined reference .... errors are due to this line:

https://github.com/Casperbru/firstProg/blob/master/CMakeLists.txt#L181

change TUDAT_PROPAGATION_LIBRARIES into TUDAT_ESTIMATION_LIBRARIES and I think they'll go away.

Could you put a link to the file and line (see example for above CMakeLists) where you generate the observationsAndTimes? Depending on the data type, and I'll point you in the right direction to write it to a file,

Dominic

Casperbru commented 5 years ago

Hi, The first solution does work! Still not running though. I get a pop up that the .exe has stopped working and This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. in the Application output. After some testing I figured out it happens within https://github.com/Casperbru/firstProg/blob/master/myConstellationSimulator.cpp#L353-L355 I think it might have to do with the size of the initial state.

observationAndTimes is created in https://github.com/Casperbru/firstProg/blob/master/myConstellationSimulator.cpp#L411-L412

Casper

Casperbru commented 5 years ago

My system initial state includes multiple satellites, while the example only uses 1 satellite and thus a vector with size 6, probable this causes the error

Casperbru commented 5 years ago

Okay, I realised I don't really need the parameter determination part, so I could remove the part where the problem appeared. Now I get a similar pop up and 10:00:31: The program has unexpectedly finished.. This is because of lines https://github.com/Casperbru/firstProg/blob/master/myConstellationSimulator.cpp#L411-L412. The lines where observationAndTimes are created...

DominicDirkx commented 5 years ago

Hi Casper,

I don't see an issue with the code, so here are a few ways to try to hunt down what's going on:

http://tudat.tudelft.nl/tutorials/troubleshooting/debuggers.html

https://github.com/Casperbru/firstProg/blob/master/myConstellationSimulator.cpp#L411-L412

If the error persists, you know the offending lines of code are earlier in the program. You can try to comment out more and more of the program to see where the issue lies. Note that the code giving the problem may lie at any point before the crash, not necesarilly at the point of the crash.

https://github.com/Casperbru/firstProg/blob/master/myConstellationSimulator.cpp#L385-L398

If this makes the program run, the problem is some sort of incompatibility between the observatin settings and the observation models/environment

Let me know if this helps you pin down where/what is going wrong

Dominic

Casperbru commented 5 years ago

Hi, Your second point indeed appears to be the problem. What do you propose to fix this?

DominicDirkx commented 5 years ago

Have you tried to get a stack trace (first point)? This should give more insight into the location of the crash

Casperbru commented 5 years ago

So after a lot trial and error, we figured out that the problem could be fixed by not using the provided work-around with the OrbitDeterminationManager class. So implementing the class again and letting the program estimate one parameter is a (temporary) fix to the problem. However the program takes very long to run now and there is a lot of stuff I don't necessarily need in my application, but for now I got something running. The observationsAndTimes are now created in https://github.com/Casperbru/firstProg/blob/master/myConstellationSimulator.cpp#L436-L437 btw

SamFayolle commented 5 years ago

Small precision on the plausible error source: I think using the createObservationSimulators function to avoid creating the OrbitDeterminationManager object only works when the linkEnds involve celestial bodies whose ephemerides are already defined by default. But when trying to do so with linkEnds defined from bodies that need to be propagated, the program crashes because their ephemerides are undefined.

DominicDirkx commented 5 years ago

Yes, that is also by design (although an error message should be printed). If a link end does not have a state function associated with it, it is not possible to generate and state-based observations of it.

Since I don't see any unresolved questions in this thread (?) I'm closing the issue.

Casperbru commented 5 years ago

Well even when I give the satellites an ephemeris (and they all have states over the simulation time of course, and the observations are done within the simulation period on epochs where there is a state), it is still not possible to avoid the OrbitDeterminationManager. So right now I have to use the manager and because of that I also have to give parameter to be estimated. This requires significant computation time (especially when I am increasing the simulation time and the number of satellites). The question remains, how to avoid using the OrbitDeterminationManager and the parameter estimation.

DominicDirkx commented 5 years ago

Hi Casper,

Ok, when you say it's not possble to avoid the OrbitDeterminationManager, why is this? Because of a compile/run error when you try to do so? If so, please post a link to the corresponding code, and teh error output,

Dominic

Casperbru commented 5 years ago

Hi Dominic, Yes that is correct. When I try to use your work around to avoid using OrbitDeterminationManager, I can compile, but it doesn't run. It is finished unexpectedly. THe code can be found at https://github.com/Casperbru/firstProg/blob/master/myConstellationSimulator.cpp#L389-L406 the lines here are the lines for the parameter estimation and the orbitdetermination manager. right now they are commented out and the code is not working. When I uncomment the lines the code does work. The weird thing is that I am not using the orbit determination manager later in my code (because I use the lines you suggested in your first answer, see https://github.com/Casperbru/firstProg/blob/master/myConstellationSimulator.cpp#L450-L451). I looked at this with Marie, see her reply to this issue.

DominicDirkx commented 5 years ago

Hi Casper,

In that case, did you manage to get the debugger output? That should help us figuring out where things go wrong,

Dominic

Casperbru commented 5 years ago

stackTrace.txt

Casperbru commented 5 years ago

The suggested action of not clearing the ephemeris info in the SingleArcDynamicsSimulator does not solve the problem unfortunately. stackTrace2.txt

DominicDirkx commented 5 years ago

Short answer; in a meeting. I think you are toggling the wrong boolean, please read the associated documentation in more detail

Casperbru commented 5 years ago

You are correct. Thank you so much!