Visual Servoing Platform  version 3.6.1 under development (2024-04-26)
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 
92 class VISP_EXPORT vpRobotMavsdk
93 {
94 public:
95  vpRobotMavsdk();
96  vpRobotMavsdk(const std::string &connection_info);
97  virtual ~vpRobotMavsdk();
98 
100 
101  void connect(const std::string &connection_info);
103 
105 
106  float getBatteryLevel() const;
107  void getPosition(float &ned_north, float &ned_east, float &ned_down, float &ned_yaw) const;
108  void getPosition(vpHomogeneousMatrix &ned_M_frd) const;
109  std::tuple<float, float> getHome() const;
110  std::string getAddress() const;
111  bool isRunning() const;
113 
115 
116  bool arm();
117  bool disarm();
118  void doFlatTrim();
119  bool hasFlyingCapability();
120  bool holdPosition();
121  bool kill();
122  bool land();
123  bool releaseControl();
124  bool sendMocapData(const vpHomogeneousMatrix &enu_M_flu, int display_fps = 1);
125  void setAutoLand(bool auto_land);
126  bool setForwardSpeed(double body_frd_vx);
127  bool setLateralSpeed(double body_frd_vy);
128  bool setGPSGlobalOrigin(double latitude, double longitude, double altitude);
129  void setPositioningIncertitude(float position_incertitude, float yaw_incertitude);
130  bool setPosition(float ned_north, float ned_east, float ned_down, float ned_yaw, bool blocking = true,
131  int timeout_sec = 10);
132  bool setPosition(const vpHomogeneousMatrix &ned_M_frd, bool blocking = true, int timeout_sec = 10);
133  bool setPositionRelative(float ned_delta_north, float ned_delta_east, float ned_delta_down, float ned_delta_yaw,
134  bool blocking = true, int timeout_sec = 10);
135  bool setPositionRelative(const vpHomogeneousMatrix &delta_frd_M_frd, bool blocking = true, int timeout_sec = 10);
136  bool setVelocity(const vpColVector &frd_vel_cmd);
137  bool setVerticalSpeed(double body_frd_vz);
138  bool setYawSpeed(double body_frd_wz);
139  void setTakeOffAlt(double altitude);
140  void setVerbose(bool verbose);
141  bool stopMoving();
142  bool takeControl();
143  bool takeOff(bool interactive = true, int timeout_sec = 10, bool use_gps = false);
144  bool takeOff(bool interactive, double takeoff_altitude, int timeout_sec = 10, bool use_gps = false);
146 
147 private:
148  //*** Setup functions ***//
149  void cleanUp();
150  void createDroneController();
151  void setupCallbacks();
152  void startController();
153 
154  vpRobotMavsdk(const vpRobotMavsdk &); // noncopyable
155  vpRobotMavsdk &operator=(const vpRobotMavsdk &); //
156 
157  class vpRobotMavsdkImpl;
158  vpRobotMavsdkImpl *m_impl;
159 };
160 
161 #endif // #ifdef VISP_HAVE_MAVSDK
162 #endif // #ifndef vpRobotMavsdk_h_
Implementation of column vector and the associated operations.
Definition: vpColVector.h:163
Implementation of an homogeneous matrix and operations on such kind of matrices.