libkovan  1
The kovan standard library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ardrone.hpp
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright 2013 KISS Institute for Practical Robotics *
3  * *
4  * This file is part of libkovan. *
5  * *
6  * libkovan 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  * *
11  * libkovan is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14  * GNU General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU General Public License *
17  * along with libkovan. Check the LICENSE file in the project root. *
18  * If not, see <http://www.gnu.org/licenses/>. *
19  **************************************************************************/
20 
21 #ifndef _ARDRONE_HPP_
22 #define _ARDRONE_HPP_
23 
24 #include <opencv2/core/core.hpp>
25 #include <map>
26 #include <string>
27 
28 #include "kovan/camera.hpp"
29 #include "kovan/types.hpp"
30 
31 class DroneController;
32 
33 namespace Private
34 {
35  class ARDroneEmergencyStop;
36 }
37 
39 {
40 public:
41  enum State
42  {
43  Disconnected = 0,
45  Flying
46  };
47 
48  enum Camera
49  {
50  None = 0,
52  Bottom
53  };
54 
55  enum Version
56  {
57  Unknown = 0,
58  V1,
59  V2
60  };
61 
63  {
64  uint32_t battery;
65 
66  float pitch;
67  float roll;
68  float yaw;
69 
70  float altitude;
71 
74  };
75 
76  ~ARDrone();
77 
78 
79  bool connect(const char *const ip = "192.168.1.1", const double timeout = 3.0);
80 
84  void disconnect();
85 
89  Version version() const;
90 
91  NavigationData navigationData() const;
92 
93  void clearPosition();
94 
100  void setSsid(const char *const ssid);
101 
102  void setActiveCamera(const Camera activeCamera);
103  Camera activeCamera() const;
104 
105  void flatTrim();
106  void takeoff();
107  void land();
108 
109  void setEmergencyStopEnabled(const bool emergencyStopEnabled);
110  bool isEmergencyStopEnabled() const;
111 
112  void setOwnerAddress(const char *const address);
113  void pair();
114 
119  void hover();
120 
121  void move(const float x, const float y, const float z, const float yaw);
122 
123  std::map<std::string, std::string> configuration() const;
124 
125  void rawImage(cv::Mat &image) const;
126 
127  ARDrone::State state() const;
128 
129  static ARDrone *instance();
130 
131 private:
132  ARDrone();
133  ARDrone(const ARDrone &);
134 
135  ARDrone &operator =(const ARDrone &rhs);
136 
137  DroneController *m_controller;
138  Private::ARDroneEmergencyStop *m_emergencyStop;
139  Camera m_activeCamera;
140 };
141 
142 namespace Camera
143 {
145  {
146  public:
148  virtual bool open(const int number);
149  virtual bool isOpen() const;
150  virtual void setWidth(const unsigned width);
151  virtual void setHeight(const unsigned height);
152  virtual bool next(cv::Mat &image);
153  virtual bool close();
154 
155  private:
156  bool m_opened;
157  };
158 }
159 
160 #endif