paparazzi/paparazzi — pull request #237 by flixr (2012-07-12 23:21:46+00:00)
Title: State interface with automatic coordinate transformations

A general state interface that holds all the most important vehicle states like position, speed, attitude, etc. for fixedwings and rotorcrafts alike. So any subsystem/module that needs to know any of these states should not get it directly from the ahrs, gps, airspeed sensors or whatever and just read it from the state interface. It will also do the appropriate coordinate and fixed/floating point conversions automatically and only when needed. This should decouple e.g. estimation and control more and also the "consumers" of vehicle states don't need to worry about where the data is actually coming from and in what format it was estimated or measured.

Current status:

* Most of the state interface and needed conversions are done
* You can set e.g. the position in any coordinate system you wish: ```stateSetPositionNed_i(pos_ned_i)``` to set the position in fixed-point NED coordinates
* If you need to read the position somewhere else in a different representation, simply call: ```stateGetPositionLla_f()``` and only then the LLA float position representation is calculated and returned on the fly. It's also only calculated once, until a new position is set.

There are however some open questions that need addressing before we go further:

* How to deal with the problem that a given representation can't be calculated or is not valid, e.g.
* something needed for conversion not initialized (e.g. LTP origin not initialized)
* simply no measurement of the state available (e.g. no airspeed sensor)
* state not valid (e.g. no 3d GPS fix, hence pos/speed not valid)
* Add extra functions to set multiple representations of the same state at once, or allow to set a state without marking the other representations as uncalculated?
* E.g. when the GPS already does the work and calculates several representations, why not use that instead of only setting one and doing the conversions again ourselves...