Auterion App SDK
Auterion SDK is a library that can be used by AuterionOS apps to communicate with the system.
Loading...
Searching...
No Matches
auterion::SDK Class Reference

SDK execution class. All callbacks are called on the same thread. More...

#include <auterion_sdk/auterion.hpp>

Public Types

using ShutdownCallbackHandle = rclcpp::PreShutdownCallbackHandle
 

Public Member Functions

 SDK (int argc, char **argv, const std::string &node_name)
 
void setSkipFlightControllerConnectionCheck (bool skip)
 
void run (RunOptions options=RunOptions())
 
rclcpp::Node::SharedPtr defaultRosHandle () const
 
bool canWaitForData () const
 Whether the calling thread can wait for data the SDK receives.
 
rclcpp::Time now () const
 
void addNode (rclcpp::Node::SharedPtr node)
 
void removeNode (rclcpp::Node::SharedPtr node)
 
ShutdownCallbackHandle addShutdownCallback (std::function< void()> callback)
 Register a callback for the app's shutdown (a signal, or requestShutdown())
 
void removeShutdownCallback (const ShutdownCallbackHandle &handle)
 
void requestShutdown (const std::string &reason)
 Shut the app down: the shutdown callbacks run, and run() returns.
 
const rclcpp::executors::SingleThreadedExecutor::UniquePtr & executor () const
 
template<typename T >
T getParameter (const std::string &name, std::function< void(const T &)> on_change_callback=nullptr)
 Get a parameter value and optionally register a callback for changes.
 
template<typename T >
void setParameter (const std::string &name, const T &value)
 Set a parameter.
 
template<typename T >
void setSystemParameter (const std::string &full_name, const T &value)
 Set a parameter of another app or service.
 
template<>
bool getParameter (const std::string &name, std::function< void(const bool &)> on_change_callback)
 
template<>
int64_t getParameter (const std::string &name, std::function< void(const int64_t &)> on_change_callback)
 
template<>
int getParameter (const std::string &name, std::function< void(const int &)> on_change_callback)
 
template<>
float getParameter (const std::string &name, std::function< void(const float &)> on_change_callback)
 
template<>
double getParameter (const std::string &name, std::function< void(const double &)> on_change_callback)
 
template<>
std::string getParameter (const std::string &name, std::function< void(const std::string &)> on_change_callback)
 
template<>
std::vector< bool > getParameter (const std::string &name, std::function< void(const std::vector< bool > &)> on_change_callback)
 
template<>
std::vector< int64_t > getParameter (const std::string &name, std::function< void(const std::vector< int64_t > &)> on_change_callback)
 
template<>
std::vector< int > getParameter (const std::string &name, std::function< void(const std::vector< int > &)> on_change_callback)
 
template<>
std::vector< float > getParameter (const std::string &name, std::function< void(const std::vector< float > &)> on_change_callback)
 
template<>
std::vector< double > getParameter (const std::string &name, std::function< void(const std::vector< double > &)> on_change_callback)
 
template<>
std::vector< std::string > getParameter (const std::string &name, std::function< void(const std::vector< std::string > &)> on_change_callback)
 

Static Public Member Functions

template<typename T >
static constexpr void verify_param ()
 

Detailed Description

SDK execution class. All callbacks are called on the same thread.

The SDK receives data (vehicle state, camera info and status, images, detections, parameter changes, ...) only for the API calls that ask for it: it subscribes on the first use of the API that needs the data, which saves the CPU of messages the app never uses. A first query that has to wait for its data says so in its documentation. What rclcpp creates on every node is left as rclcpp creates it.

Member Function Documentation

◆ addShutdownCallback()

ShutdownCallbackHandle auterion::SDK::addShutdownCallback ( std::function< void()>  callback)

Register a callback for the app's shutdown (a signal, or requestShutdown())

It runs before ROS shuts down, so it can still publish and send asynchronous requests, e.g. to hand a camera's controls back. Not necessarily on the SDK executor's thread. Remove it before the objects it captures die: the SDK's destructor shuts ROS down too, which runs the callbacks still registered.

Returns
a handle to remove the callback with

◆ canWaitForData()

bool auterion::SDK::canWaitForData ( ) const
inline

Whether the calling thread can wait for data the SDK receives.

True while run() spins the SDK executor on another thread, which delivers the data. On the executor's own thread, or before run(), a wait could only time out.

◆ getParameter()

template<typename T >
T auterion::SDK::getParameter ( const std::string &  name,
std::function< void(const T &)>  on_change_callback = nullptr 
)
inline

Get a parameter value and optionally register a callback for changes.

The parameter name must be defined in auterion-app.yml. The type must match (or be convertible from) the parameter type in the yaml definition.

Parameters
nameparameter name
on_change_callbackoptional callback for dynamic parameter changes
Exceptions
ParameterExceptionon error

◆ requestShutdown()

void auterion::SDK::requestShutdown ( const std::string &  reason)

Shut the app down: the shutdown callbacks run, and run() returns.

Parameters
reasonlogged

◆ setParameter()

template<typename T >
void auterion::SDK::setParameter ( const std::string &  name,
const T &  value 
)
inline

Set a parameter.

The parameter name must be defined in auterion-app.yml. The type must match (or be convertible from) the parameter type in the yaml definition.

Parameters
nameparameter name
valuevalue to set the parameter to
Exceptions
ParameterExceptionon error

◆ setSkipFlightControllerConnectionCheck()

void auterion::SDK::setSkipFlightControllerConnectionCheck ( bool  skip)
inline

By default, run() will first check if the flight controller is connected and ensure message format compatibility. This method can be used to disable that check.

Parameters
skip

◆ setSystemParameter()

template<typename T >
void auterion::SDK::setSystemParameter ( const std::string &  full_name,
const T &  value 
)
inline

Set a parameter of another app or service.

Parameters
full_namethe parameter's full name: the author, the app and the parameter's name, separated by dots
valuevalue to set the parameter to
Exceptions
ParameterExceptionon error

The documentation for this class was generated from the following file: