Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

State interface with automatic coordinate transformations #237

Merged
merged 65 commits into from Sep 5, 2012

Conversation

flixr
Copy link
Member

@flixr flixr commented Jul 12, 2012

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...

See feature request #101

@gautierhattenberger
Copy link
Member

How to deal with the problem that a given representation can't be calculated or is not valid

Providing test function (e.g. isPosValid(),...) should be enough for the critical parts to test themselves if they should start or go to some critical/safety mode

  • ex: if the ahrs is not yet aligned, the attitude state is not valid and the control cannot run (or the motors can't start at all ?)

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?

add a set(*format1, *format2, ...) function that can set all formats and only set the one that are not pointers to NULL ?

  • ex: setPos(&ltp, &ecef, NULL, NULL) set the ltp and ecef representation but not utm or lla.

I think it would be good to merge this as soon as possible. It looks that the major parts needed to use it on rotorcraft are done and must be tested by as much people as possible (eg: merge into master)

@flixr
Copy link
Member Author

flixr commented Jul 16, 2012

Since this is supposed to become a very stable API, we should make sure we choose the name wisely.
Any comments on the names of the get/set functions? CamelCasing ok?
Maybe rename speed to velocity where appropriate?
So stateGetVelocityNed_i() instead of stateGetSpeedNed_i()
Since speed normally refers to the scalar quantity and velocity to the vector.

@gautierhattenberger
Copy link
Member

I'm fine with replacing speed by velocity and use speed only for the norm of the speed vector.

I think we can keep the current casing. Maybe the question is do we keep state in front of all functions. It could make the code lighter but more ambiguous.

@flixr
Copy link
Member Author

flixr commented Jul 17, 2012

I think I would keep the state prefix for clarity at the expense of slightly longer names.
Feel free to change stuff (like speed to velocity, the valid functions, set functions for multiple ones, etc), as I don't have time to work on this right now....

- INS interface build for FW and Rotorcraft on the same basis as AHRS
- For FW, most of the old estimator (vertical kalman filter) as been moved
  to the new ins_float. Some triggers are missing for main_ap, especially
  the baro_event since the Baro interface is not done here.
- Some more integration is needed to remove old estimator.c
- INS modules should follow the general interface
- FW main_ap is not very clear concerning the INS (nor the AHRS) because
  of the freq scaling part from CDW
So we can trigger ins_baro_update.
Start to solve issue #106
need to handle baro measures coming from modules
Some modules can be used directly, some needs some more changes or
adaptation
gautierhattenberger added a commit that referenced this pull request Sep 5, 2012
State interface with automatic coordinate transformations
@gautierhattenberger gautierhattenberger merged commit dbdbbaf into master Sep 5, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants