Visual Servoing Platform  version 3.5.1 under development (2023-03-14)
vpRobotMavsdk.h
1 /****************************************************************************
2  *
3  * ViSP, open source Visual Servoing Platform software.
4  * Copyright (C) 2005 - 2022 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 http://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 #if defined(VISP_HAVE_MAVSDK) && (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_17)
42 
43 #include <future>
44 #include <mutex>
45 #include <signal.h>
46 #include <string>
47 
48 #include <visp3/core/vpHomogeneousMatrix.h>
49 
68 class VISP_EXPORT vpRobotMavsdk
69 {
70 public:
71  vpRobotMavsdk();
72  vpRobotMavsdk(const std::string &connection_info);
73  virtual ~vpRobotMavsdk();
74 
76 
77  void connect(const std::string &connection_info);
79 
81 
82  float getBatteryLevel() const;
83  void getPose(vpHomogeneousMatrix &pose) const;
84  std::string getAddress() const;
86 
88 
89  // bool isFlying() const; // Not implemented yet
90  // bool isHovering() const; // Not implemented yet
91  // bool isLanded() const; // Not implemented yet
92  bool isRunning() const;
94 
96 
97  bool sendMocapData(const vpHomogeneousMatrix &M);
99 
101 
102  bool arm();
103  void doFlatTrim();
104  void holdPosition();
105  bool kill();
106  bool land();
107  void setForwardSpeed(double vx);
108  void setLateralSpeed(double vy);
109  void setPosition(float dX, float dY, float dZ, float dPsi);
110  void setPosition(const vpHomogeneousMatrix &M);
111  void setVelocity(const vpColVector &vel, double delta_t);
112  void setVelocity(const vpColVector &vel);
113  void setVerticalSpeed(double vz);
114  void setYawSpeed(double wz);
115  void stopMoving();
116  void setTakeOffAlt(double altitude);
117  bool takeOff(bool interactive = true);
119 
120 private:
121  [[noreturn]] static void sighandler(int signo);
122 
123  //*** Setup functions ***//
124  void cleanUp();
125  void createDroneController();
126  void setupCallbacks();
127  void startController();
128 
129  vpRobotMavsdk(const vpRobotMavsdk &); // noncopyable
130  vpRobotMavsdk &operator=(const vpRobotMavsdk &); //
131 
132  class vpRobotMavsdkImpl;
133  vpRobotMavsdkImpl *m_impl;
134 };
135 
136 #endif //#ifdef VISP_HAVE_MAVSDK
137 #endif //#ifndef vpRobotMavsdk_h_
Implementation of column vector and the associated operations.
Definition: vpColVector.h:131
Implementation of an homogeneous matrix and operations on such kind of matrices.