System State API
Related C++ Header in the Auterion SDK:<auterion_sdk/system_state/system_state.hpp>
Auterion SDK provides an interface for subscribing to various states of the vehicle, such as the current position, attitude or battery status. These states can be queried by polling or by registering callbacks.
Available data
The following states are available through the system state API:
State | Data type |
---|---|
Local Position |
|
Global Position |
|
Attitude |
|
Angular Rates |
|
Armed |
|
Home Position |
|
Battery |
|
VTOL State |
|
Manual Input |
|
Subscribing to system states
Instantiate an auterion::SystemState
object, then specify the states to subscribe to.
Each subscribed state will have an auterion::Subcription
object associated with it. The SystemState
class has accessor functions for each of the supported states, for example: system_state.localPosition()
. These will be used to query the states and register callbacks.
Querying the latest state
Poll the latest state value by calling the last()
function of the corresponding Subscription
. The return type will depend on what state is being queried.
Note that last()
will throw an exception if the state has not been subscribed to or if no data has been received for 500ms. To check that data is available and valid, use the isLastValid()
function.
Registering callbacks
When subscribing to a state, a callback can be provided that will run whenever new data is available.
It is possible to register one or more callbacks after subscribing to a state with the onUpdate()
method of the appropriate Subscription
.
Last updated