From 0f624089f87aac29792b9764cf31a8952276b5e8 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 9 Aug 2023 10:28:00 +1000 Subject: [PATCH] AP_ExternalControl: external control library for MAVLink,lua and DDS Signed-off-by: Ryan Friedman Co-authored-by: Andrew Tridgell --- .../AP_ExternalControl/AP_ExternalControl.cpp | 24 +++++++++++ .../AP_ExternalControl/AP_ExternalControl.h | 43 +++++++++++++++++++ .../AP_ExternalControl_config.h | 10 +++++ 3 files changed, 77 insertions(+) create mode 100644 libraries/AP_ExternalControl/AP_ExternalControl.cpp create mode 100644 libraries/AP_ExternalControl/AP_ExternalControl.h create mode 100644 libraries/AP_ExternalControl/AP_ExternalControl_config.h diff --git a/libraries/AP_ExternalControl/AP_ExternalControl.cpp b/libraries/AP_ExternalControl/AP_ExternalControl.cpp new file mode 100644 index 0000000000..e0e92f0a29 --- /dev/null +++ b/libraries/AP_ExternalControl/AP_ExternalControl.cpp @@ -0,0 +1,24 @@ +#include "AP_ExternalControl.h" + +#if AP_EXTERNAL_CONTROL_ENABLED + +// singleton instance +AP_ExternalControl *AP_ExternalControl::singleton; + +AP_ExternalControl::AP_ExternalControl() +{ + singleton = this; +} + + +namespace AP +{ + +AP_ExternalControl *externalcontrol() +{ + return AP_ExternalControl::get_singleton(); +} + +}; + +#endif // AP_EXTERNAL_CONTROL_ENABLED diff --git a/libraries/AP_ExternalControl/AP_ExternalControl.h b/libraries/AP_ExternalControl/AP_ExternalControl.h new file mode 100644 index 0000000000..7c3d7b7e35 --- /dev/null +++ b/libraries/AP_ExternalControl/AP_ExternalControl.h @@ -0,0 +1,43 @@ +/* + external control library for MAVLink, DDS and scripting + */ + +#pragma once + +#include "AP_ExternalControl_config.h" + +#if AP_EXTERNAL_CONTROL_ENABLED + +#include + +class AP_ExternalControl +{ +public: + + AP_ExternalControl(); + /* + Set linear velocity and yaw rate. Pass NaN for yaw_rate_rads to not control yaw. + Velocity is in earth frame, NED [m/s]. + Yaw is in earth frame, NED [rad/s]. + */ + virtual bool set_linear_velocity_and_yaw_rate(const Vector3f &linear_velocity, float yaw_rate_rads) + { + return false; + } + + static AP_ExternalControl *get_singleton(void) + { + return singleton; + } + +private: + static AP_ExternalControl *singleton; +}; + + +namespace AP +{ +AP_ExternalControl *externalcontrol(); +}; + +#endif // AP_EXTERNAL_CONTROL_ENABLED diff --git a/libraries/AP_ExternalControl/AP_ExternalControl_config.h b/libraries/AP_ExternalControl/AP_ExternalControl_config.h new file mode 100644 index 0000000000..1192bac867 --- /dev/null +++ b/libraries/AP_ExternalControl/AP_ExternalControl_config.h @@ -0,0 +1,10 @@ +#pragma once + +#include +#include + +#ifndef AP_EXTERNAL_CONTROL_ENABLED +#define AP_EXTERNAL_CONTROL_ENABLED 1 +#endif + +