dronecode_sdk::Telemetry Class Reference

#include: telemetry.h


This class allows users to get vehicle telemetry and state information (e.g. battery, GPS, RC connection, flight mode etc.) and set telemetry update rates.

Data Structures

struct Battery

struct EulerAngle

struct GPSInfo

struct GroundSpeedNED

struct Health

struct Position

struct PositionNED

struct PositionVelocityNED

struct Quaternion

struct RCStatus

struct VelocityNED

Public Types

Type Description
enum FlightMode Flight modes.
enum Result Results enum for telemetry requests.
std::function< void(Result)> result_callback_t Callback type for telemetry requests.
std::function< void(PositionVelocityNED)> position_velocity_ned_callback_t Callback type for kinematic (position and velocity) updates.
std::function< void(Position)> position_callback_t Callback type for position updates.
std::function< void(bool in_air)> in_air_callback_t Callback type for in-air updates.
std::function< void(bool armed)> armed_callback_t Callback type for armed updates (asynchronous).
std::function< void(Quaternion quaternion)> attitude_quaternion_callback_t Callback type for attitude updates in quaternion.
std::function< void(EulerAngle euler_angle)> attitude_euler_angle_callback_t Callback type for attitude updates in Euler angles.
std::function< void(GroundSpeedNED ground_speed_ned)> ground_speed_ned_callback_t Callback type for ground speed (NED) updates.
std::function< void(GPSInfo gps_info)> gps_info_callback_t Callback type for GPS information updates.
std::function< void(Battery battery)> battery_callback_t Callback type for battery status updates.
std::function< void(FlightMode flight_mode)> flight_mode_callback_t Callback type for flight mode updates.
std::function< void(Health health)> health_callback_t Callback type for health status updates.
std::function< void(bool health_all_ok)> health_all_ok_callback_t Callback type for health status updates.
std::function< void(RCStatus rc_status)> rc_status_callback_t Callback type for RC status updates.

Public Member Functions

Type Name Description
  Telemetry (System & system) Constructor. Creates the plugin for a specific System.
  ~Telemetry () Destructor (internal use only).
  Telemetry (const Telemetry &)=delete Copy constructor (object is not copyable).
Result set_rate_position_velocity_ned (double rate_hz) Set rate of kinematic (position and velocity) updates (synchronous).
Result set_rate_position (double rate_hz) Set rate of position updates (synchronous).
Result set_rate_home_position (double rate_hz) Set rate of home position updates (synchronous).
Result set_rate_in_air (double rate_hz) Set rate of in-air status updates (synchronous).
Result set_rate_attitude (double rate_hz) Set rate of attitude updates (synchronous).
Result set_rate_camera_attitude (double rate_hz) Set rate of camera attitude updates (synchronous).
Result set_rate_ground_speed_ned (double rate_hz) Set rate of ground speed (NED) updates (synchronous).
Result set_rate_gps_info (double rate_hz) Set rate of GPS information updates (synchronous).
Result set_rate_battery (double rate_hz) Set rate of battery status updates (synchronous).
Result set_rate_rc_status (double rate_hz) Set rate of RC status updates (synchronous).
void set_rate_position_velocity_ned_async (double rate_hz, result_callback_t callback) Set rate of kinematic (position and velocity) updates (asynchronous).
void set_rate_position_async (double rate_hz, result_callback_t callback) Set rate of position updates (asynchronous).
void set_rate_home_position_async (double rate_hz, result_callback_t callback) Set rate of home position updates (asynchronous).
void set_rate_in_air_async (double rate_hz, result_callback_t callback) Set rate of in-air status updates (asynchronous).
void set_rate_attitude_async (double rate_hz, result_callback_t callback) Set rate of attitude updates (asynchronous).
void set_rate_camera_attitude_async (double rate_hz, result_callback_t callback) Set rate of camera attitude updates (asynchronous).
void set_rate_ground_speed_ned_async (double rate_hz, result_callback_t callback) Set rate of ground speed (NED) updates (asynchronous).
void set_rate_gps_info_async (double rate_hz, result_callback_t callback) Set rate of GPS information updates (asynchronous).
void set_rate_battery_async (double rate_hz, result_callback_t callback) Set rate of battery status updates (asynchronous).
void set_rate_rc_status_async (double rate_hz, result_callback_t callback) Set rate of RC status updates (asynchronous).
PositionVelocityNED position_velocity_ned () const Get the current kinematic (position and velocity) in NED frame (synchronous).
Position position () const Get the current position (synchronous).
Position home_position () const Get the home position (synchronous).
bool in_air () const Get the in-air status (synchronous).
bool armed () const Get the arming status (synchronous).
Quaternion attitude_quaternion () const Get the current attitude in quaternions (synchronous).
EulerAngle attitude_euler_angle () const Get the current attitude in Euler angles (synchronous).
Quaternion camera_attitude_quaternion () const Get the camera's attitude in quaternions (synchronous).
EulerAngle camera_attitude_euler_angle () const Get the camera's attitude in Euler angles (synchronous).
GroundSpeedNED ground_speed_ned () const Get the current ground speed (NED) (synchronous).
GPSInfo gps_info () const Get the current GPS information (synchronous).
Battery battery () const Get the current battery status (synchronous).
FlightMode flight_mode () const Get the current flight mode (synchronous).
Health health () const Get the current health status (synchronous).
bool health_all_ok () const Returns true if the overall health is ok (synchronous).
RCStatus rc_status () const Get the RC status (synchronous).
void position_velocity_ned_async (position_velocity_ned_callback_t callback) Subscribe to kinematic (position and velocity) updates (asynchronous).
void position_async (position_callback_t callback) Subscribe to position updates (asynchronous).
void home_position_async (position_callback_t callback) Subscribe to home position updates (asynchronous).
void in_air_async (in_air_callback_t callback) Subscribe to in-air updates (asynchronous).
void armed_async (armed_callback_t callback) Subscribe to armed updates (asynchronous).
void attitude_quaternion_async (attitude_quaternion_callback_t callback) Subscribe to attitude updates in quaternion (asynchronous).
void attitude_euler_angle_async (attitude_euler_angle_callback_t callback) Subscribe to attitude updates in Euler angles (asynchronous).
void camera_attitude_quaternion_async (attitude_quaternion_callback_t callback) Subscribe to camera attitude updates in quaternion (asynchronous).
void camera_attitude_euler_angle_async (attitude_euler_angle_callback_t callback) Subscribe to camera attitude updates in Euler angles (asynchronous).
void ground_speed_ned_async (ground_speed_ned_callback_t callback) Subscribe to ground speed (NED) updates (asynchronous).
void gps_info_async (gps_info_callback_t callback) Subscribe to GPS information updates (asynchronous).
void battery_async (battery_callback_t callback) Subscribe to battery status updates (asynchronous).
void flight_mode_async (flight_mode_callback_t callback) Subscribe to flight mode updates (asynchronous).
void health_async (health_callback_t callback) Subscribe to health status updates (asynchronous).
void health_all_ok_async (health_all_ok_callback_t callback) Subscribe to overall health status updates (asynchronous).
void rc_status_async (rc_status_callback_t callback) Subscribe to RC status updates (asynchronous).
const Telemetry & operator= (const Telemetry &)=delete Equality operator (object is not copyable).

Static Public Member Functions

Type Name Description
std::string flight_mode_str (FlightMode flight_mode) Get a human readable English string for a flight mode.
const char * result_str (Result result) Get human-readable English string for Telemetry::Result.

Constructor & Destructor Documentation

Telemetry()

dronecode_sdk::Telemetry::Telemetry(System &system)

Constructor. Creates the plugin for a specific System.

The plugin is typically created as shown below:

auto telemetry = std::make_shared<Telemetry>(system);

Parameters

  • System& system - The specific system associated with this plugin.

~Telemetry()

dronecode_sdk::Telemetry::~Telemetry()

Destructor (internal use only).

Telemetry()

dronecode_sdk::Telemetry::Telemetry(const Telemetry &)=delete

Copy constructor (object is not copyable).

Parameters

Member Typdef Documentation

typedef result_callback_t

typedef std::function<void(Result)> dronecode_sdk::Telemetry::result_callback_t

Callback type for telemetry requests.

typedef position_velocity_ned_callback_t

typedef std::function<void(PositionVelocityNED)> dronecode_sdk::Telemetry::position_velocity_ned_callback_t

Callback type for kinematic (position and velocity) updates.

typedef position_callback_t

typedef std::function<void(Position)> dronecode_sdk::Telemetry::position_callback_t

Callback type for position updates.

typedef in_air_callback_t

typedef std::function<void(bool in_air)> dronecode_sdk::Telemetry::in_air_callback_t

Callback type for in-air updates.

Parameters

  • in_air - true if in-air (flying) and not on-ground (landed).

typedef armed_callback_t

typedef std::function<void(bool armed)> dronecode_sdk::Telemetry::armed_callback_t

Callback type for armed updates (asynchronous).

Parameters

  • armed - true if armed (motors spinning).

typedef attitude_quaternion_callback_t

typedef std::function<void(Quaternion quaternion)> dronecode_sdk::Telemetry::attitude_quaternion_callback_t

Callback type for attitude updates in quaternion.

Parameters

  • quaternion - Attitude quaternion.

typedef attitude_euler_angle_callback_t

typedef std::function<void(EulerAngle euler_angle)> dronecode_sdk::Telemetry::attitude_euler_angle_callback_t

Callback type for attitude updates in Euler angles.

Parameters

  • euler_angle - Attitude Euler angle.

typedef ground_speed_ned_callback_t

typedef std::function<void(GroundSpeedNED ground_speed_ned)> dronecode_sdk::Telemetry::ground_speed_ned_callback_t

Callback type for ground speed (NED) updates.

Parameters

  • ground_speed_ned - Ground speed (NED).

typedef gps_info_callback_t

typedef std::function<void(GPSInfo gps_info)> dronecode_sdk::Telemetry::gps_info_callback_t

Callback type for GPS information updates.

Parameters

  • gps_info - GPS information.

typedef battery_callback_t

typedef std::function<void(Battery battery)> dronecode_sdk::Telemetry::battery_callback_t

Callback type for battery status updates.

Parameters

typedef flight_mode_callback_t

typedef std::function<void(FlightMode flight_mode)> dronecode_sdk::Telemetry::flight_mode_callback_t

Callback type for flight mode updates.

Parameters

  • flight_mode - Flight mode.

typedef health_callback_t

typedef std::function<void(Health health)> dronecode_sdk::Telemetry::health_callback_t

Callback type for health status updates.

Parameters

  • health - health flags.

typedef health_all_ok_callback_t

typedef std::function<void(bool health_all_ok)> dronecode_sdk::Telemetry::health_all_ok_callback_t

Callback type for health status updates.

Parameters

  • health_all_ok - If all health flags are ok.

typedef rc_status_callback_t

typedef std::function<void(RCStatus rc_status)> dronecode_sdk::Telemetry::rc_status_callback_t

Callback type for RC status updates.

Parameters

  • rc_status - RC status.

Member Enumeration Documentation

enum FlightMode

Flight modes.

For more information about flight modes, check out https://docs.px4.io/en/config/flight_mode.html.

Value Description
READY Armed and ready to take off.
TAKEOFF Taking off.
HOLD Hold mode (hovering in place (or circling for fixed-wing vehicles).
MISSION Mission mode.
RETURN_TO_LAUNCH Returning to launch position (then landing).
LAND Landing.
OFFBOARD Offboard mode.
FOLLOW_ME FollowMe mode.
UNKNOWN Mode not known.

enum Result

Results enum for telemetry requests.

Value Description
SUCCESS Request succeeded.
NO_SYSTEM No system connected.
CONNECTION_ERROR Connection error.
BUSY System busy.
COMMAND_DENIED Command denied.
TIMEOUT Request timeout.
UNKNOWN Unknown error.

Member Function Documentation

set_rate_position_velocity_ned()

Result dronecode_sdk::Telemetry::set_rate_position_velocity_ned(double rate_hz)

Set rate of kinematic (position and velocity) updates (synchronous).

Parameters

  • double rate_hz - Rate in Hz.

Returns

Result - Result of request.

See Also:

set_rate_position()

Result dronecode_sdk::Telemetry::set_rate_position(double rate_hz)

Set rate of position updates (synchronous).

Parameters

  • double rate_hz - Rate in Hz.

Returns

Result - Result of request.

set_rate_home_position()

Result dronecode_sdk::Telemetry::set_rate_home_position(double rate_hz)

Set rate of home position updates (synchronous).

Parameters

  • double rate_hz - Rate in Hz.

Returns

Result - Result of request.

set_rate_in_air()

Result dronecode_sdk::Telemetry::set_rate_in_air(double rate_hz)

Set rate of in-air status updates (synchronous).

Parameters

  • double rate_hz - Rate in Hz.

Returns

Result - Result of request.

set_rate_attitude()

Result dronecode_sdk::Telemetry::set_rate_attitude(double rate_hz)

Set rate of attitude updates (synchronous).

Parameters

  • double rate_hz - Rate in Hz.

Returns

Result - Result of request.

set_rate_camera_attitude()

Result dronecode_sdk::Telemetry::set_rate_camera_attitude(double rate_hz)

Set rate of camera attitude updates (synchronous).

Parameters

  • double rate_hz - Rate in Hz.

Returns

Result - Result of request.

set_rate_ground_speed_ned()

Result dronecode_sdk::Telemetry::set_rate_ground_speed_ned(double rate_hz)

Set rate of ground speed (NED) updates (synchronous).

Parameters

  • double rate_hz - Rate in Hz.

Returns

Result - Result of request.

set_rate_gps_info()

Result dronecode_sdk::Telemetry::set_rate_gps_info(double rate_hz)

Set rate of GPS information updates (synchronous).

Parameters

  • double rate_hz - Rate in Hz.

Returns

Result - Result of request.

set_rate_battery()

Result dronecode_sdk::Telemetry::set_rate_battery(double rate_hz)

Set rate of battery status updates (synchronous).

Parameters

  • double rate_hz - Rate in Hz.

Returns

Result - Result of request.

set_rate_rc_status()

Result dronecode_sdk::Telemetry::set_rate_rc_status(double rate_hz)

Set rate of RC status updates (synchronous).

Parameters

  • double rate_hz - Rate in Hz.

Returns

Result - Result of request.

set_rate_position_velocity_ned_async()

void dronecode_sdk::Telemetry::set_rate_position_velocity_ned_async(double rate_hz, result_callback_t callback)

Set rate of kinematic (position and velocity) updates (asynchronous).

Parameters

  • double rate_hz - Rate in Hz.
  • result_callback_t callback - Callback to receive request result.

See Also:

set_rate_position_async()

void dronecode_sdk::Telemetry::set_rate_position_async(double rate_hz, result_callback_t callback)

Set rate of position updates (asynchronous).

Parameters

  • double rate_hz - Rate in Hz.
  • result_callback_t callback - Callback to receive request result.

set_rate_home_position_async()

void dronecode_sdk::Telemetry::set_rate_home_position_async(double rate_hz, result_callback_t callback)

Set rate of home position updates (asynchronous).

Parameters

  • double rate_hz - Rate in Hz.
  • result_callback_t callback - Callback to receive request result.

set_rate_in_air_async()

void dronecode_sdk::Telemetry::set_rate_in_air_async(double rate_hz, result_callback_t callback)

Set rate of in-air status updates (asynchronous).

Parameters

  • double rate_hz - Rate in Hz.
  • result_callback_t callback - Callback to receive request result.

set_rate_attitude_async()

void dronecode_sdk::Telemetry::set_rate_attitude_async(double rate_hz, result_callback_t callback)

Set rate of attitude updates (asynchronous).

Parameters

  • double rate_hz - Rate in Hz.
  • result_callback_t callback - Callback to receive request result.

set_rate_camera_attitude_async()

void dronecode_sdk::Telemetry::set_rate_camera_attitude_async(double rate_hz, result_callback_t callback)

Set rate of camera attitude updates (asynchronous).

Parameters

  • double rate_hz - Rate in Hz.
  • result_callback_t callback - Callback to receive request result.

set_rate_ground_speed_ned_async()

void dronecode_sdk::Telemetry::set_rate_ground_speed_ned_async(double rate_hz, result_callback_t callback)

Set rate of ground speed (NED) updates (asynchronous).

Parameters

  • double rate_hz - Rate in Hz.
  • result_callback_t callback - Callback to receive request result.

set_rate_gps_info_async()

void dronecode_sdk::Telemetry::set_rate_gps_info_async(double rate_hz, result_callback_t callback)

Set rate of GPS information updates (asynchronous).

Parameters

  • double rate_hz - Rate in Hz.
  • result_callback_t callback - Callback to receive request result.

set_rate_battery_async()

void dronecode_sdk::Telemetry::set_rate_battery_async(double rate_hz, result_callback_t callback)

Set rate of battery status updates (asynchronous).

Parameters

  • double rate_hz - Rate in Hz.
  • result_callback_t callback - Callback to receive request result.

set_rate_rc_status_async()

void dronecode_sdk::Telemetry::set_rate_rc_status_async(double rate_hz, result_callback_t callback)

Set rate of RC status updates (asynchronous).

Parameters

  • double rate_hz - Rate in Hz.
  • result_callback_t callback - Callback to receive request result.

position_velocity_ned()

PositionVelocityNED dronecode_sdk::Telemetry::position_velocity_ned() const

Get the current kinematic (position and velocity) in NED frame (synchronous).

Returns

PositionVelocityNED - PositionVelocityNED.

position()

Position dronecode_sdk::Telemetry::position() const

Get the current position (synchronous).

Returns

Position - Position.

home_position()

Position dronecode_sdk::Telemetry::home_position() const

Get the home position (synchronous).

Returns

Position - Home position.

in_air()

bool dronecode_sdk::Telemetry::in_air() const

Get the in-air status (synchronous).

Returns

 bool - true if in-air (flying) and not on-ground (landed).

armed()

bool dronecode_sdk::Telemetry::armed() const

Get the arming status (synchronous).

Returns

 bool - true if armed (propellers spinning).

attitude_quaternion()

Quaternion dronecode_sdk::Telemetry::attitude_quaternion() const

Get the current attitude in quaternions (synchronous).

Returns

Quaternion - Attitude as quaternion.

attitude_euler_angle()

EulerAngle dronecode_sdk::Telemetry::attitude_euler_angle() const

Get the current attitude in Euler angles (synchronous).

Returns

EulerAngle - Attitude as Euler angle.

camera_attitude_quaternion()

Quaternion dronecode_sdk::Telemetry::camera_attitude_quaternion() const

Get the camera's attitude in quaternions (synchronous).

Note that the yaw component of attitude is relative to North (absolute frame).

Returns

Quaternion - Camera's attitude as quaternion.

camera_attitude_euler_angle()

EulerAngle dronecode_sdk::Telemetry::camera_attitude_euler_angle() const

Get the camera's attitude in Euler angles (synchronous).

Note that the yaw component of attitude is relative to North (absolute frame).

Returns

EulerAngle - Camera's attitude as Euler angle.

ground_speed_ned()

GroundSpeedNED dronecode_sdk::Telemetry::ground_speed_ned() const

Get the current ground speed (NED) (synchronous).

Returns

GroundSpeedNED - Ground speed in NED.

gps_info()

GPSInfo dronecode_sdk::Telemetry::gps_info() const

Get the current GPS information (synchronous).

Returns

GPSInfo - GPS information.

battery()

Battery dronecode_sdk::Telemetry::battery() const

Get the current battery status (synchronous).

Returns

Battery -

flight_mode()

FlightMode dronecode_sdk::Telemetry::flight_mode() const

Get the current flight mode (synchronous).

Returns

FlightMode - Flight mode.

health()

Health dronecode_sdk::Telemetry::health() const

Get the current health status (synchronous).

Returns

Health - Health status.

health_all_ok()

bool dronecode_sdk::Telemetry::health_all_ok() const

Returns true if the overall health is ok (synchronous).

Returns

 bool - True if all health flags are OK.

rc_status()

RCStatus dronecode_sdk::Telemetry::rc_status() const

Get the RC status (synchronous).

Returns

RCStatus - RC status.

position_velocity_ned_async()

void dronecode_sdk::Telemetry::position_velocity_ned_async(position_velocity_ned_callback_t callback)

Subscribe to kinematic (position and velocity) updates (asynchronous).

Parameters

position_async()

void dronecode_sdk::Telemetry::position_async(position_callback_t callback)

Subscribe to position updates (asynchronous).

Parameters

home_position_async()

void dronecode_sdk::Telemetry::home_position_async(position_callback_t callback)

Subscribe to home position updates (asynchronous).

Parameters

in_air_async()

void dronecode_sdk::Telemetry::in_air_async(in_air_callback_t callback)

Subscribe to in-air updates (asynchronous).

Parameters

armed_async()

void dronecode_sdk::Telemetry::armed_async(armed_callback_t callback)

Subscribe to armed updates (asynchronous).

Note that armed updates are limited to 1Hz.

Parameters

attitude_quaternion_async()

void dronecode_sdk::Telemetry::attitude_quaternion_async(attitude_quaternion_callback_t callback)

Subscribe to attitude updates in quaternion (asynchronous).

Parameters

attitude_euler_angle_async()

void dronecode_sdk::Telemetry::attitude_euler_angle_async(attitude_euler_angle_callback_t callback)

Subscribe to attitude updates in Euler angles (asynchronous).

Parameters

camera_attitude_quaternion_async()

void dronecode_sdk::Telemetry::camera_attitude_quaternion_async(attitude_quaternion_callback_t callback)

Subscribe to camera attitude updates in quaternion (asynchronous).

Parameters

camera_attitude_euler_angle_async()

void dronecode_sdk::Telemetry::camera_attitude_euler_angle_async(attitude_euler_angle_callback_t callback)

Subscribe to camera attitude updates in Euler angles (asynchronous).

Parameters

ground_speed_ned_async()

void dronecode_sdk::Telemetry::ground_speed_ned_async(ground_speed_ned_callback_t callback)

Subscribe to ground speed (NED) updates (asynchronous).

Parameters

gps_info_async()

void dronecode_sdk::Telemetry::gps_info_async(gps_info_callback_t callback)

Subscribe to GPS information updates (asynchronous).

Parameters

battery_async()

void dronecode_sdk::Telemetry::battery_async(battery_callback_t callback)

Subscribe to battery status updates (asynchronous).

Parameters

flight_mode_async()

void dronecode_sdk::Telemetry::flight_mode_async(flight_mode_callback_t callback)

Subscribe to flight mode updates (asynchronous).

Note that flight mode updates are limited to 1Hz.

Parameters

health_async()

void dronecode_sdk::Telemetry::health_async(health_callback_t callback)

Subscribe to health status updates (asynchronous).

Note that health status updates are limited to 1Hz.

Parameters

health_all_ok_async()

void dronecode_sdk::Telemetry::health_all_ok_async(health_all_ok_callback_t callback)

Subscribe to overall health status updates (asynchronous).

Note that overall health status updates are limited to 1Hz.

Parameters

rc_status_async()

void dronecode_sdk::Telemetry::rc_status_async(rc_status_callback_t callback)

Subscribe to RC status updates (asynchronous).

Parameters

operator=()

const Telemetry& dronecode_sdk::Telemetry::operator=(const Telemetry &)=delete

Equality operator (object is not copyable).

Parameters

Returns

 const Telemetry & -

flight_mode_str()

static std::string dronecode_sdk::Telemetry::flight_mode_str(FlightMode flight_mode)

Get a human readable English string for a flight mode.

Parameters

Returns

 std::string -

result_str()

static const char* dronecode_sdk::Telemetry::result_str(Result result)

Get human-readable English string for Telemetry::Result.

Parameters

  • Result result - The enum value for which string is needed.

Returns

 const char * - Human readable string for the Telemetry::Result.

© Dronecode 2017. License: CC BY 4.0            Updated: 2018-11-07 01:25:57

results matching ""

    No results matching ""