Visual Servoing Platform  version 3.6.1 under development (2024-11-15)
vpRobotMavsdk.h
1 /****************************************************************************
2  *
3  * ViSP, open source Visual Servoing Platform software.
4  * Copyright (C) 2005 - 2023 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * See the file LICENSE.txt at the root directory of this source
11  * distribution for additional information about the GNU GPL.
12  *
13  * For using ViSP with software that can not be combined with the GNU
14  * GPL, please contact Inria about acquiring a ViSP Professional
15  * Edition License.
16  *
17  * See https://visp.inria.fr for more information.
18  *
19  * This software was developed at:
20  * Inria Rennes - Bretagne Atlantique
21  * Campus Universitaire de Beaulieu
22  * 35042 Rennes Cedex
23  * France
24  *
25  * If you have questions regarding the use of this file, please contact
26  * Inria at visp@inria.fr
27  *
28  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30  *
31  * Description:
32  * Interface to mavlink compatible controller using mavsdk 3rd party
33  *
34 *****************************************************************************/
35 
36 #ifndef vpRobotMavsdk_h_
37 #define vpRobotMavsdk_h_
38 
39 #include <visp3/core/vpConfig.h>
40 
41 // Check if std:c++17 or higher.
42 // Here we cannot use (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_17) in the declaration of the class
43 #if defined(VISP_HAVE_MAVSDK) && ((__cplusplus >= 201703L) || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201703L))) \
44  && defined(VISP_HAVE_THREADS)
45 
46 #include <future>
47 #include <mutex>
48 #include <signal.h>
49 #include <string>
50 #include <tuple>
51 
52 #include <visp3/core/vpHomogeneousMatrix.h>
53 
54 BEGIN_VISP_NAMESPACE
93 class VISP_EXPORT vpRobotMavsdk
94 {
95 public:
96  vpRobotMavsdk();
97  vpRobotMavsdk(const std::string &connection_info);
98  virtual ~vpRobotMavsdk();
99 
101 
102  void connect(const std::string &connection_info);
104 
106 
107  float getBatteryLevel() const;
108  void getPosition(float &ned_north, float &ned_east, float &ned_down, float &ned_yaw) const;
109  void getPosition(vpHomogeneousMatrix &ned_M_frd) const;
110  std::tuple<float, float> getHome() const;
111  std::string getAddress() const;
112  bool isRunning() const;
114 
116 
117  bool arm();
118  bool disarm();
119  void doFlatTrim();
120  bool hasFlyingCapability();
121  bool holdPosition();
122  bool kill();
123  bool land();
124  bool releaseControl();
125  bool sendMocapData(const vpHomogeneousMatrix &enu_M_flu, int display_fps = 1);
126  void setAutoLand(bool auto_land);
127  bool setForwardSpeed(double body_frd_vx);
128  bool setLateralSpeed(double body_frd_vy);
129  bool setGPSGlobalOrigin(double latitude, double longitude, double altitude);
130  void setPositioningIncertitude(float position_incertitude, float yaw_incertitude);
131  bool setPosition(float ned_north, float ned_east, float ned_down, float ned_yaw, bool blocking = true,
132  int timeout_sec = 10);
133  bool setPosition(const vpHomogeneousMatrix &ned_M_frd, bool blocking = true, int timeout_sec = 10);
134  bool setPositionRelative(float ned_delta_north, float ned_delta_east, float ned_delta_down, float ned_delta_yaw,
135  bool blocking = true, int timeout_sec = 10);
136  bool setPositionRelative(const vpHomogeneousMatrix &delta_frd_M_frd, bool blocking = true, int timeout_sec = 10);
137  bool setVelocity(const vpColVector &frd_vel_cmd);
138  bool setVerticalSpeed(double body_frd_vz);
139  bool setYawSpeed(double body_frd_wz);
140  void setTakeOffAlt(double altitude);
141  void setVerbose(bool verbose);
142  bool stopMoving();
143  bool takeControl();
144  bool takeOff(bool interactive = true, int timeout_sec = 10, bool use_gps = false);
145  bool takeOff(bool interactive, double takeoff_altitude, int timeout_sec = 10, bool use_gps = false);
147 
148 private:
149  //*** Setup functions ***//
150  void cleanUp();
151  void createDroneController();
152  void setupCallbacks();
153  void startController();
154 
155  vpRobotMavsdk(const vpRobotMavsdk &); // noncopyable
156  vpRobotMavsdk &operator=(const vpRobotMavsdk &); //
157 
158  class vpRobotMavsdkImpl;
159  vpRobotMavsdkImpl *m_impl;
160 };
161 END_VISP_NAMESPACE
162 #endif // #ifdef VISP_HAVE_MAVSDK
163 #endif // #ifndef vpRobotMavsdk_h_
Implementation of column vector and the associated operations.
Definition: vpColVector.h:191
Implementation of an homogeneous matrix and operations on such kind of matrices.