39 #ifndef _vpRobotBebop2_h_
40 #define _vpRobotBebop2_h_
42 #include <visp3/core/vpConfig.h>
44 #ifdef VISP_HAVE_ARSDK
46 #include <visp3/core/vpImage.h>
49 #include <libARController/ARController.h>
50 #include <libARSAL/ARSAL.h>
52 #ifdef VISP_HAVE_FFMPEG
53 #include <libavcodec/avcodec.h>
54 #include <libswscale/swscale.h>
75 vpRobotBebop2(
bool verbose =
false,
bool setDefaultSettings =
true, std::string ipAddress =
"192.168.42.1",
76 int discoveryPort = 44444);
81 std::string getIpAddress();
82 int getDiscoveryPort();
88 unsigned int getBatteryLevel();
89 void setVerbose(
bool verbose);
90 void resetAllSettings();
107 void setMaxTilt(
double maxTilt);
108 void setPitch(
int value);
109 void setPosition(
float dX,
float dY,
float dZ,
float dPsi,
bool blocking);
111 void setRoll(
int value);
112 void setVelocity(
const vpColVector &vel,
double delta_t);
113 void setVerticalSpeed(
int value);
114 void setYawSpeed(
int value);
116 void takeOff(
bool blocking =
true);
122 #ifdef VISP_HAVE_FFMPEG
127 int getVideoHeight();
129 void setExposure(
float expo);
130 void setStreamingMode(
int mode);
131 void setVideoResolution(
int mode);
132 void setVideoStabilisationMode(
int mode);
133 void startStreaming();
134 void stopStreaming();
142 double getCameraHorizontalFOV()
const;
143 double getCurrentCameraPan()
const;
144 double getMaxCameraPan()
const;
145 double getMinCameraPan()
const;
146 double getCurrentCameraTilt()
const;
147 double getMaxCameraTilt()
const;
148 double getMinCameraTilt()
const;
149 void setCameraOrientation(
double tilt,
double pan,
bool blocking =
false);
150 void setCameraPan(
double pan,
bool blocking =
false);
151 void setCameraTilt(
double tilt,
bool blocking =
false);
157 std::string m_ipAddress;
160 ARSAL_Sem_t m_stateSem;
161 struct sigaction m_sigAct;
163 #ifdef VISP_HAVE_FFMPEG
164 AVCodecContext *m_codecContext;
167 std::mutex m_bgr_picture_mutex;
168 AVFrame *m_bgr_picture;
169 SwsContext *m_img_convert_ctx;
172 bool m_videoDecodingStarted;
178 static bool m_running;
182 bool m_flatTrimFinished;
183 bool m_relativeMoveEnded;
184 bool m_videoResolutionSet;
185 bool m_streamingStarted;
186 bool m_streamingModeSet;
187 bool m_settingsReset;
189 bool m_update_codec_params;
190 std::vector<uint8_t> m_codec_params_data;
192 unsigned int m_batteryLevel;
195 double m_cameraHorizontalFOV;
197 double m_currentCameraTilt;
198 double m_minCameraTilt;
199 double m_maxCameraTilt;
201 double m_currentCameraPan;
202 double m_minCameraPan;
203 double m_maxCameraPan;
205 static ARCONTROLLER_Device_t *m_deviceController;
207 eARCONTROLLER_ERROR m_errorController;
208 eARCONTROLLER_DEVICE_STATE m_deviceState;
211 [[noreturn]]
static void sighandler(
int signo);
213 eARCOMMANDS_ARDRONE3_PILOTINGSTATE_FLYINGSTATECHANGED_STATE getFlyingState();
214 eARCOMMANDS_ARDRONE3_MEDIASTREAMINGSTATE_VIDEOENABLECHANGED_ENABLED getStreamingState();
218 ARDISCOVERY_Device_t *discoverDrone();
219 void createDroneController(ARDISCOVERY_Device_t *discoveredDrone);
220 void setupCallbacks();
221 void startController();
223 #ifdef VISP_HAVE_FFMPEG
228 void startVideoDecoding();
229 void stopVideoDecoding();
230 void computeFrame(ARCONTROLLER_Frame_t *frame);
235 static void stateChangedCallback(eARCONTROLLER_DEVICE_STATE newState, eARCONTROLLER_ERROR error,
void *customData);
236 #ifdef VISP_HAVE_FFMPEG
237 static eARCONTROLLER_ERROR decoderConfigCallback(ARCONTROLLER_Stream_Codec_t codec,
void *customData);
238 static eARCONTROLLER_ERROR didReceiveFrameCallback(ARCONTROLLER_Frame_t *frame,
void *customData);
241 static void cmdBatteryStateChangedRcv(ARCONTROLLER_DICTIONARY_ELEMENT_t *elementDictionary,
vpRobotBebop2 *drone);
242 static void cmdCameraOrientationChangedRcv(ARCONTROLLER_DICTIONARY_ELEMENT_t *elementDictionary,
244 static void cmdCameraSettingsRcv(ARCONTROLLER_DICTIONARY_ELEMENT_t *elementDictionary,
vpRobotBebop2 *drone);
245 static void cmdExposureSetRcv(ARCONTROLLER_DICTIONARY_ELEMENT_t *elementDictionary,
vpRobotBebop2 *drone);
246 static void cmdMaxPitchRollChangedRcv(ARCONTROLLER_DICTIONARY_ELEMENT_t *elementDictionary,
vpRobotBebop2 *drone);
247 static void cmdRelativeMoveEndedRcv(ARCONTROLLER_DICTIONARY_ELEMENT_t *elementDictionary,
vpRobotBebop2 *drone);
248 static void commandReceivedCallback(eARCONTROLLER_DICTIONARY_KEY commandKey,
249 ARCONTROLLER_DICTIONARY_ELEMENT_t *elementDictionary,
void *customData);
Implementation of column vector and the associated operations.
Implementation of an homogeneous matrix and operations on such kind of matrices.