39 #ifndef _vpRobotBebop2_h_
40 #define _vpRobotBebop2_h_
42 #include <visp3/core/vpConfig.h>
44 #if defined(VISP_HAVE_ARSDK) && defined(VISP_HAVE_THREADS)
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>
76 vpRobotBebop2(
bool verbose =
false,
bool setDefaultSettings =
true, std::string ipAddress =
"192.168.42.1",
77 int discoveryPort = 44444);
82 std::string getIpAddress();
83 int getDiscoveryPort();
89 unsigned int getBatteryLevel();
90 void setVerbose(
bool verbose);
91 void resetAllSettings();
108 void setMaxTilt(
double maxTilt);
109 void setPitch(
int value);
110 void setPosition(
float dX,
float dY,
float dZ,
float dPsi,
bool blocking);
112 void setRoll(
int value);
113 void setVelocity(
const vpColVector &vel,
double delta_t);
114 void setVerticalSpeed(
int value);
115 void setYawSpeed(
int value);
117 void takeOff(
bool blocking =
true);
123 #ifdef VISP_HAVE_FFMPEG
128 int getVideoHeight();
130 void setExposure(
float expo);
131 void setStreamingMode(
int mode);
132 void setVideoResolution(
int mode);
133 void setVideoStabilisationMode(
int mode);
134 void startStreaming();
135 void stopStreaming();
143 double getCameraHorizontalFOV()
const;
144 double getCurrentCameraPan()
const;
145 double getMaxCameraPan()
const;
146 double getMinCameraPan()
const;
147 double getCurrentCameraTilt()
const;
148 double getMaxCameraTilt()
const;
149 double getMinCameraTilt()
const;
150 void setCameraOrientation(
double tilt,
double pan,
bool blocking =
false);
151 void setCameraPan(
double pan,
bool blocking =
false);
152 void setCameraTilt(
double tilt,
bool blocking =
false);
158 std::string m_ipAddress;
161 ARSAL_Sem_t m_stateSem;
162 struct sigaction m_sigAct;
164 #ifdef VISP_HAVE_FFMPEG
165 AVCodecContext *m_codecContext;
168 std::mutex m_bgr_picture_mutex;
169 AVFrame *m_bgr_picture;
170 SwsContext *m_img_convert_ctx;
173 bool m_videoDecodingStarted;
179 static bool m_running;
183 bool m_flatTrimFinished;
184 bool m_relativeMoveEnded;
185 bool m_videoResolutionSet;
186 bool m_streamingStarted;
187 bool m_streamingModeSet;
188 bool m_settingsReset;
190 bool m_update_codec_params;
191 std::vector<uint8_t> m_codec_params_data;
193 unsigned int m_batteryLevel;
196 double m_cameraHorizontalFOV;
198 double m_currentCameraTilt;
199 double m_minCameraTilt;
200 double m_maxCameraTilt;
202 double m_currentCameraPan;
203 double m_minCameraPan;
204 double m_maxCameraPan;
206 static ARCONTROLLER_Device_t *m_deviceController;
208 eARCONTROLLER_ERROR m_errorController;
209 eARCONTROLLER_DEVICE_STATE m_deviceState;
212 [[noreturn]]
static void sighandler(
int signo);
214 eARCOMMANDS_ARDRONE3_PILOTINGSTATE_FLYINGSTATECHANGED_STATE getFlyingState();
215 eARCOMMANDS_ARDRONE3_MEDIASTREAMINGSTATE_VIDEOENABLECHANGED_ENABLED getStreamingState();
219 ARDISCOVERY_Device_t *discoverDrone();
220 void createDroneController(ARDISCOVERY_Device_t *discoveredDrone);
221 void setupCallbacks();
222 void startController();
224 #ifdef VISP_HAVE_FFMPEG
229 void startVideoDecoding();
230 void stopVideoDecoding();
231 void computeFrame(ARCONTROLLER_Frame_t *frame);
236 static void stateChangedCallback(eARCONTROLLER_DEVICE_STATE newState, eARCONTROLLER_ERROR error,
void *customData);
237 #ifdef VISP_HAVE_FFMPEG
238 static eARCONTROLLER_ERROR decoderConfigCallback(ARCONTROLLER_Stream_Codec_t codec,
void *customData);
239 static eARCONTROLLER_ERROR didReceiveFrameCallback(ARCONTROLLER_Frame_t *frame,
void *customData);
242 static void cmdBatteryStateChangedRcv(ARCONTROLLER_DICTIONARY_ELEMENT_t *elementDictionary,
vpRobotBebop2 *drone);
243 static void cmdCameraOrientationChangedRcv(ARCONTROLLER_DICTIONARY_ELEMENT_t *elementDictionary,
245 static void cmdCameraSettingsRcv(ARCONTROLLER_DICTIONARY_ELEMENT_t *elementDictionary,
vpRobotBebop2 *drone);
246 static void cmdExposureSetRcv(ARCONTROLLER_DICTIONARY_ELEMENT_t *elementDictionary,
vpRobotBebop2 *drone);
247 static void cmdMaxPitchRollChangedRcv(ARCONTROLLER_DICTIONARY_ELEMENT_t *elementDictionary,
vpRobotBebop2 *drone);
248 static void cmdRelativeMoveEndedRcv(ARCONTROLLER_DICTIONARY_ELEMENT_t *elementDictionary,
vpRobotBebop2 *drone);
249 static void commandReceivedCallback(eARCONTROLLER_DICTIONARY_KEY commandKey,
250 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.