The diagram below demonstrates what would typically be included in an application that uses the Onboard SDK.
In addition to the OSDK Core Library, and any application specific third party libraries, the application will also need to include a platform specific threading library. OSDK uses threading handle user requests, callbacks and UART communication simultaneously.
The application links to OSDK Core and the platform threading library at run-time.
The hierarchy diagram in the SDK Architectural Overview shows that the Vehicle class contains references to all components available through the OSDK.
Vehicle acts as an entry point for user code.
Let's take an example -
mission_sample provided as part of the Linux samples. Here is a snippet of
This section assumes you are using the CMake build system on Linux; the steps however are general enough to be conceptually reused with different platforms/build systems.
osdk-coreinclude files. If you install
osdk-coreto system, your includes will be in
/usr/local/include, so in this example you would set
ONBOARDSDK_SOURCEto be that directory.
Every API that communicates with the flight controller has two overloads in the OSDK:
Blocking APIs wait until the aircraft returns an acknowledgement. Blocking calls pass that acknowledgement, along with some metadata, to the caller as a return value for the API itself. Most blocking APIs return an ACK::ErrorCode; this allows querying of errors through the ACK::getError and ACK::getErrorCodeMessage APIs. Some blocking APIs have some additional information, and have specific return types.
One example of calling a blocking API and using the acknowledgement is shown in the image here, from the MFIO sample.
Non-blocking APIs will return immediately after the request is sent to the aircraft, and developers are expected to implement and supply a callback function to a non-blocking API to deal with the acknowledgement from the aircraft. Use these in an asynchronous program - where the handling of acknowledgements is not essential to the correct operation of the main flow of logic in the program.
The image shows a non-blocking API being called, and its associated callback implementation that executes the exact same functionality as the blocking call shown above:
On systems that support threading (all platforms except the STM32), the OSDK runs three threads:
Some things to note:
Before you run your application, see the Running your Application page.