39 #include <visp3/core/vpConfig.h>
41 #ifdef VISP_HAVE_ARSDK
43 #include <visp3/robot/vpRobotBebop2.h>
45 #include <visp3/core/vpExponentialMap.h>
47 #ifdef VISP_HAVE_FFMPEG
49 #include <libavcodec/avcodec.h>
50 #include <libavformat/avformat.h>
51 #include <libavutil/imgutils.h>
53 #include <visp3/core/vpImageConvert.h>
59 #define TAG "vpRobotBebop2"
76 bool vpRobotBebop2::m_running =
false;
77 ARCONTROLLER_Device_t *vpRobotBebop2::m_deviceController =
nullptr;
115 : m_ipAddress(ipAddress), m_discoveryPort(discoveryPort)
118 memset(&m_sigAct, 0,
sizeof(m_sigAct));
119 m_sigAct.sa_handler = vpRobotBebop2::sighandler;
120 sigaction(SIGINT, &m_sigAct, 0);
121 sigaction(SIGBUS, &m_sigAct, 0);
122 sigaction(SIGSEGV, &m_sigAct, 0);
123 sigaction(SIGKILL, &m_sigAct, 0);
124 sigaction(SIGQUIT, &m_sigAct, 0);
126 #ifdef VISP_HAVE_FFMPEG
127 m_codecContext =
nullptr;
128 m_packet = AVPacket();
130 m_bgr_picture =
nullptr;
131 m_img_convert_ctx =
nullptr;
133 m_videoDecodingStarted =
false;
136 m_batteryLevel = 100;
138 m_exposureSet =
true;
139 m_flatTrimFinished =
true;
140 m_relativeMoveEnded =
true;
141 m_videoResolutionSet =
true;
142 m_streamingStarted =
false;
143 m_streamingModeSet =
false;
144 m_settingsReset =
false;
146 m_update_codec_params =
false;
147 m_codec_params_data = std::vector<uint8_t>();
151 m_cameraHorizontalFOV = -1;
152 m_currentCameraTilt = -1;
153 m_minCameraTilt = -1;
154 m_maxCameraTilt = -1;
155 m_currentCameraPan = -1;
161 m_errorController = ARCONTROLLER_OK;
162 m_deviceState = ARCONTROLLER_DEVICE_STATE_MAX;
165 ARSAL_Sem_Init(&(m_stateSem), 0, 0);
168 ARDISCOVERY_Device_t *discoverDevice = discoverDrone();
171 createDroneController(discoverDevice);
180 if ((m_errorController != ARCONTROLLER_OK) || (m_deviceState != ARCONTROLLER_DEVICE_STATE_RUNNING)) {
185 "Failed to connect to bebop2 with ip %s and port %d. Make sure that the ip address is correct "
186 "and that your computer is connected to the drone Wifi spot before starting",
187 ipAddress.c_str(), discoveryPort));
192 #ifdef VISP_HAVE_FFMPEG
195 if (setDefaultSettings) {
200 #ifdef VISP_HAVE_FFMPEG
227 m_flatTrimFinished =
false;
229 m_deviceController->aRDrone3->sendPilotingFlatTrim(m_deviceController->aRDrone3);
232 while (!m_flatTrimFinished) {
237 ARSAL_PRINT(ARSAL_PRINT_ERROR,
"ERROR",
"Can't do a flat trim : drone isn't landed.");
323 if (
isRunning() && m_deviceController !=
nullptr) {
325 m_deviceController->aRDrone3->sendCameraOrientationV2(m_deviceController->aRDrone3,
static_cast<float>(tilt),
326 static_cast<float>(pan));
329 while (std::abs(tilt - m_currentCameraTilt) > 0.01 || std::abs(pan - m_currentCameraPan) > 0.01) {
336 ARSAL_PRINT(ARSAL_PRINT_ERROR,
"ERROR",
"Can't set camera orientation : drone isn't running.");
353 if (
isRunning() && m_deviceController !=
nullptr) {
355 m_deviceController->aRDrone3->sendCameraOrientationV2(m_deviceController->aRDrone3,
static_cast<float>(tilt),
359 while (std::abs(tilt - m_currentCameraTilt) > 0.01) {
366 ARSAL_PRINT(ARSAL_PRINT_ERROR,
"ERROR",
"Can't set camera tilt value : drone isn't running.");
383 if (
isRunning() && m_deviceController !=
nullptr) {
385 m_deviceController->aRDrone3->sendCameraOrientationV2(
386 m_deviceController->aRDrone3,
static_cast<float>(
getCurrentCameraTilt()),
static_cast<float>(pan));
389 while (std::abs(pan - m_currentCameraPan) > 0.01) {
396 ARSAL_PRINT(ARSAL_PRINT_ERROR,
"ERROR",
"Can't set camera pan value : drone isn't running.");
406 if (m_deviceController ==
nullptr) {
420 #ifdef VISP_HAVE_FFMPEG
421 return m_videoDecodingStarted;
433 return getFlyingState() == ARCOMMANDS_ARDRONE3_PILOTINGSTATE_FLYINGSTATECHANGED_STATE_HOVERING;
442 return getFlyingState() == ARCOMMANDS_ARDRONE3_PILOTINGSTATE_FLYINGSTATECHANGED_STATE_FLYING;
451 return getFlyingState() == ARCOMMANDS_ARDRONE3_PILOTINGSTATE_FLYINGSTATECHANGED_STATE_LANDED;
465 m_deviceController->aRDrone3->sendPilotingTakeOff(m_deviceController->aRDrone3);
475 ARSAL_PRINT(ARSAL_PRINT_ERROR,
"ERROR",
"Can't take off : drone isn't landed.");
487 if (m_deviceController !=
nullptr) {
488 m_deviceController->aRDrone3->sendPilotingLanding(m_deviceController->aRDrone3);
506 m_deviceController->aRDrone3->setPilotingPCMDGaz(m_deviceController->aRDrone3,
static_cast<char>(value));
508 if (m_errorController != ARCONTROLLER_OK) {
509 ARSAL_PRINT(ARSAL_PRINT_ERROR, TAG,
"- error when sending move command : %s",
510 ARCONTROLLER_Error_ToString(m_errorController));
515 ARSAL_PRINT(ARSAL_PRINT_ERROR,
"ERROR",
"Can't set vertical speed : drone isn't flying or hovering.");
534 m_deviceController->aRDrone3->setPilotingPCMDYaw(m_deviceController->aRDrone3,
static_cast<char>(value));
536 if (m_errorController != ARCONTROLLER_OK) {
537 ARSAL_PRINT(ARSAL_PRINT_ERROR, TAG,
"- error when sending move command : %s",
538 ARCONTROLLER_Error_ToString(m_errorController));
543 ARSAL_PRINT(ARSAL_PRINT_ERROR,
"ERROR",
"Can't set yaw speed : drone isn't flying or hovering.");
562 m_deviceController->aRDrone3->setPilotingPCMDPitch(m_deviceController->aRDrone3,
static_cast<char>(value));
563 m_errorController = m_deviceController->aRDrone3->setPilotingPCMDFlag(m_deviceController->aRDrone3, 1);
565 if (m_errorController != ARCONTROLLER_OK) {
566 ARSAL_PRINT(ARSAL_PRINT_ERROR, TAG,
"- error when sending move command : %s",
567 ARCONTROLLER_Error_ToString(m_errorController));
572 ARSAL_PRINT(ARSAL_PRINT_ERROR,
"ERROR",
"Can't set pitch value : drone isn't flying or hovering.");
591 m_deviceController->aRDrone3->setPilotingPCMDRoll(m_deviceController->aRDrone3,
static_cast<char>(value));
592 m_errorController = m_deviceController->aRDrone3->setPilotingPCMDFlag(m_deviceController->aRDrone3, 1);
594 if (m_errorController != ARCONTROLLER_OK) {
595 ARSAL_PRINT(ARSAL_PRINT_ERROR, TAG,
"- error when sending move command : %s",
596 ARCONTROLLER_Error_ToString(m_errorController));
601 ARSAL_PRINT(ARSAL_PRINT_ERROR,
"ERROR",
"Can't set roll value : drone isn't flying or hovering.");
613 if (m_deviceController !=
nullptr) {
614 m_errorController = m_deviceController->aRDrone3->sendPilotingEmergency(m_deviceController->aRDrone3);
637 m_relativeMoveEnded =
false;
638 m_deviceController->aRDrone3->sendPilotingMoveBy(m_deviceController->aRDrone3, dX, dY, dZ, dPsi);
643 while (!m_relativeMoveEnded) {
649 ARSAL_PRINT(ARSAL_PRINT_ERROR,
"ERROR",
"Can't move : drone isn't flying or hovering.");
668 double epsilon = (std::numeric_limits<double>::epsilon());
670 ARSAL_PRINT(ARSAL_PRINT_ERROR,
"ERROR",
"Can't move : rotation around X axis should be 0.");
674 ARSAL_PRINT(ARSAL_PRINT_ERROR,
"ERROR",
"Can't move : rotation around Y axis should be 0.");
679 setPosition(
static_cast<float>(t[0]),
static_cast<float>(t[1]),
static_cast<float>(t[2]), dThetaZ, blocking);
696 if (vel_cmd.
size() != 4) {
697 ARSAL_PRINT(ARSAL_PRINT_ERROR,
"ERROR",
698 "Can't set velocity : dimension of the velocity vector should be equal to 4.");
725 ARSAL_Print_SetMinimumLevel(ARSAL_PRINT_INFO);
728 ARSAL_Print_SetMinimumLevel(ARSAL_PRINT_WARNING);
738 if (
isRunning() && m_deviceController !=
nullptr) {
740 m_settingsReset =
false;
741 m_deviceController->common->sendSettingsReset(m_deviceController->common);
743 while (!m_settingsReset) {
749 ARSAL_PRINT(ARSAL_PRINT_ERROR,
"ERROR",
"Can't reset drone settings : drone isn't running.");
766 if (
isRunning() && m_deviceController !=
nullptr) {
767 m_deviceController->aRDrone3->sendPilotingSettingsMaxTilt(m_deviceController->aRDrone3,
768 static_cast<float>(maxTilt));
771 ARSAL_PRINT(ARSAL_PRINT_ERROR,
"ERROR",
"Can't set tilt value : drone isn't running.");
785 m_errorController = m_deviceController->aRDrone3->setPilotingPCMD(m_deviceController->aRDrone3, 0, 0, 0, 0, 0, 0);
793 #ifdef VISP_HAVE_FFMPEG
805 if (m_videoDecodingStarted) {
807 if (m_bgr_picture->data[0] !=
nullptr) {
808 I.
resize(
static_cast<unsigned int>(m_videoHeight),
static_cast<unsigned int>(m_videoWidth));
810 m_bgr_picture_mutex.lock();
813 m_bgr_picture_mutex.unlock();
816 ARSAL_PRINT(ARSAL_PRINT_ERROR,
"ERROR",
"Error while getting current grayscale image : image data is nullptr");
821 ARSAL_PRINT(ARSAL_PRINT_ERROR,
"ERROR",
"Can't get current image : video streaming isn't started.");
835 if (m_videoDecodingStarted) {
837 if (m_bgr_picture->data[0] !=
nullptr) {
838 I.
resize(
static_cast<unsigned int>(m_videoHeight),
static_cast<unsigned int>(m_videoWidth));
840 m_bgr_picture_mutex.lock();
843 m_bgr_picture_mutex.unlock();
846 ARSAL_PRINT(ARSAL_PRINT_ERROR,
"ERROR",
"Error while getting current RGBa image : image data is nullptr");
851 ARSAL_PRINT(ARSAL_PRINT_ERROR,
"ERROR",
"Can't get current image : video streaming isn't started.");
878 if (
isRunning() && m_deviceController !=
nullptr) {
879 expo = std::min<float>(1.5f, std::max<float>(-1.5f, expo));
881 m_exposureSet =
false;
882 m_deviceController->aRDrone3->sendPictureSettingsExpositionSelection(m_deviceController->aRDrone3, expo);
885 while (!m_exposureSet) {
890 ARSAL_PRINT(ARSAL_PRINT_ERROR,
"ERROR",
"Can't set exposure : drone isn't running.");
910 if (
isRunning() && m_deviceController !=
nullptr) {
913 eARCOMMANDS_ARDRONE3_MEDIASTREAMING_VIDEOSTREAMMODE_MODE cmd_mode =
914 ARCOMMANDS_ARDRONE3_MEDIASTREAMING_VIDEOSTREAMMODE_MODE_LOW_LATENCY;
917 cmd_mode = ARCOMMANDS_ARDRONE3_MEDIASTREAMING_VIDEOSTREAMMODE_MODE_LOW_LATENCY;
920 cmd_mode = ARCOMMANDS_ARDRONE3_MEDIASTREAMING_VIDEOSTREAMMODE_MODE_HIGH_RELIABILITY;
923 cmd_mode = ARCOMMANDS_ARDRONE3_MEDIASTREAMING_VIDEOSTREAMMODE_MODE_HIGH_RELIABILITY_LOW_FRAMERATE;
928 m_streamingModeSet =
false;
929 m_deviceController->aRDrone3->sendMediaStreamingVideoStreamMode(m_deviceController->aRDrone3, cmd_mode);
932 while (!m_streamingModeSet) {
939 ARSAL_PRINT_ERROR,
"ERROR",
940 "Can't set streaming mode : drone has to be landed and not streaming in order to set streaming mode.");
944 ARSAL_PRINT(ARSAL_PRINT_ERROR,
"ERROR",
"Can't set streaming mode : drone isn't running.");
961 if (
isRunning() && m_deviceController !=
nullptr) {
965 eARCOMMANDS_ARDRONE3_PICTURESETTINGS_VIDEORESOLUTIONS_TYPE cmd_mode;
971 cmd_mode = ARCOMMANDS_ARDRONE3_PICTURESETTINGS_VIDEORESOLUTIONS_TYPE_REC1080_STREAM480;
977 cmd_mode = ARCOMMANDS_ARDRONE3_PICTURESETTINGS_VIDEORESOLUTIONS_TYPE_REC720_STREAM720;
983 m_videoResolutionSet =
false;
984 m_deviceController->aRDrone3->sendPictureSettingsVideoResolutions(m_deviceController->aRDrone3, cmd_mode);
987 while (!m_videoResolutionSet) {
993 ARSAL_PRINT(ARSAL_PRINT_ERROR,
"ERROR",
994 "Can't set video resolution : drone has to be landed and not streaming in order to set streaming "
999 ARSAL_PRINT(ARSAL_PRINT_ERROR,
"ERROR",
"Can't set video resolution : drone isn't running.");
1016 if (
isRunning() && m_deviceController !=
nullptr) {
1018 eARCOMMANDS_ARDRONE3_PICTURESETTINGS_VIDEOSTABILIZATIONMODE_MODE cmd_mode =
1019 ARCOMMANDS_ARDRONE3_PICTURESETTINGS_VIDEOSTABILIZATIONMODE_MODE_NONE;
1023 cmd_mode = ARCOMMANDS_ARDRONE3_PICTURESETTINGS_VIDEOSTABILIZATIONMODE_MODE_NONE;
1026 cmd_mode = ARCOMMANDS_ARDRONE3_PICTURESETTINGS_VIDEOSTABILIZATIONMODE_MODE_ROLL;
1029 cmd_mode = ARCOMMANDS_ARDRONE3_PICTURESETTINGS_VIDEOSTABILIZATIONMODE_MODE_PITCH;
1032 cmd_mode = ARCOMMANDS_ARDRONE3_PICTURESETTINGS_VIDEOSTABILIZATIONMODE_MODE_ROLL_PITCH;
1038 m_deviceController->aRDrone3->sendPictureSettingsVideoStabilizationMode(m_deviceController->aRDrone3, cmd_mode);
1042 ARSAL_PRINT(ARSAL_PRINT_ERROR,
"ERROR",
"Can't set video stabilisation mode : drone isn't running.");
1056 if (
isRunning() && m_deviceController !=
nullptr) {
1057 ARSAL_PRINT(ARSAL_PRINT_INFO, TAG,
"- Starting video streaming ... ");
1060 m_errorController = m_deviceController->aRDrone3->sendMediaStreamingVideoEnable(m_deviceController->aRDrone3, 1);
1062 if (m_errorController == ARCONTROLLER_OK) {
1063 m_streamingStarted =
false;
1065 while (!m_streamingStarted) {
1068 startVideoDecoding();
1077 ARSAL_PRINT(ARSAL_PRINT_ERROR, TAG,
"- error :%s", ARCONTROLLER_Error_ToString(m_errorController));
1082 ARSAL_PRINT(ARSAL_PRINT_ERROR,
"ERROR",
"Can't start streaming : drone isn't running.");
1093 if (m_videoDecodingStarted && m_deviceController !=
nullptr) {
1094 ARSAL_PRINT(ARSAL_PRINT_INFO, TAG,
"- Stopping video streaming ... ");
1097 m_errorController = m_deviceController->aRDrone3->sendMediaStreamingVideoEnable(m_deviceController->aRDrone3, 0);
1099 if (m_errorController == ARCONTROLLER_OK) {
1102 while (getStreamingState() != ARCOMMANDS_ARDRONE3_MEDIASTREAMINGSTATE_VIDEOENABLECHANGED_ENABLED_DISABLED) {
1106 stopVideoDecoding();
1110 ARSAL_PRINT(ARSAL_PRINT_ERROR, TAG,
"- error :%s", ARCONTROLLER_Error_ToString(m_errorController));
1115 ARSAL_PRINT(ARSAL_PRINT_ERROR,
"ERROR",
"Can't stop streaming : streaming already stopped.");
1129 void vpRobotBebop2::sighandler(
int signo)
1131 std::cout <<
"Stopping Bebop2 because of detected signal (" << signo <<
"): " <<
static_cast<char>(7);
1134 std::cout <<
"SIGINT (stopped by ^C) " << std::endl;
1137 std::cout <<
"SIGBUS (stopped due to a bus error) " << std::endl;
1140 std::cout <<
"SIGSEGV (stopped due to a segmentation fault) " << std::endl;
1143 std::cout <<
"SIGKILL (stopped by CTRL \\) " << std::endl;
1146 std::cout <<
"SIGQUIT " << std::endl;
1149 std::cout << signo << std::endl;
1152 vpRobotBebop2::m_running =
false;
1155 if (m_deviceController !=
nullptr) {
1156 m_deviceController->aRDrone3->sendPilotingLanding(m_deviceController->aRDrone3);
1158 std::exit(EXIT_FAILURE);
1165 eARCOMMANDS_ARDRONE3_PILOTINGSTATE_FLYINGSTATECHANGED_STATE vpRobotBebop2::getFlyingState()
1167 if (m_deviceController !=
nullptr) {
1168 eARCOMMANDS_ARDRONE3_PILOTINGSTATE_FLYINGSTATECHANGED_STATE flyingState =
1169 ARCOMMANDS_ARDRONE3_PILOTINGSTATE_FLYINGSTATECHANGED_STATE_MAX;
1170 eARCONTROLLER_ERROR error;
1172 ARCONTROLLER_DICTIONARY_ELEMENT_t *elementDictionary = ARCONTROLLER_ARDrone3_GetCommandElements(
1173 m_deviceController->aRDrone3, ARCONTROLLER_DICTIONARY_KEY_ARDRONE3_PILOTINGSTATE_FLYINGSTATECHANGED, &error);
1175 if (error == ARCONTROLLER_OK && elementDictionary !=
nullptr) {
1176 ARCONTROLLER_DICTIONARY_ARG_t *arg =
nullptr;
1177 ARCONTROLLER_DICTIONARY_ELEMENT_t *element =
nullptr;
1179 HASH_FIND_STR(elementDictionary, ARCONTROLLER_DICTIONARY_SINGLE_KEY, element);
1181 if (element !=
nullptr) {
1184 HASH_FIND_STR(element->arguments, ARCONTROLLER_DICTIONARY_KEY_ARDRONE3_PILOTINGSTATE_FLYINGSTATECHANGED_STATE,
1187 if (arg !=
nullptr) {
1189 flyingState =
static_cast<eARCOMMANDS_ARDRONE3_PILOTINGSTATE_FLYINGSTATECHANGED_STATE
>(arg->value.I32);
1196 ARSAL_PRINT(ARSAL_PRINT_ERROR, TAG,
"Error when checking flying state : drone isn't connected.");
1197 return ARCOMMANDS_ARDRONE3_PILOTINGSTATE_FLYINGSTATECHANGED_STATE_MAX;
1205 eARCOMMANDS_ARDRONE3_MEDIASTREAMINGSTATE_VIDEOENABLECHANGED_ENABLED vpRobotBebop2::getStreamingState()
1207 if (m_deviceController !=
nullptr) {
1208 eARCOMMANDS_ARDRONE3_MEDIASTREAMINGSTATE_VIDEOENABLECHANGED_ENABLED streamingState =
1209 ARCOMMANDS_ARDRONE3_MEDIASTREAMINGSTATE_VIDEOENABLECHANGED_ENABLED_MAX;
1210 eARCONTROLLER_ERROR error;
1212 ARCONTROLLER_DICTIONARY_ELEMENT_t *elementDictionary = ARCONTROLLER_ARDrone3_GetCommandElements(
1213 m_deviceController->aRDrone3, ARCONTROLLER_DICTIONARY_KEY_ARDRONE3_MEDIASTREAMINGSTATE_VIDEOENABLECHANGED,
1216 if (error == ARCONTROLLER_OK && elementDictionary !=
nullptr) {
1217 ARCONTROLLER_DICTIONARY_ARG_t *arg =
nullptr;
1218 ARCONTROLLER_DICTIONARY_ELEMENT_t *element =
nullptr;
1220 HASH_FIND_STR(elementDictionary, ARCONTROLLER_DICTIONARY_SINGLE_KEY, element);
1222 if (element !=
nullptr) {
1224 HASH_FIND_STR(element->arguments,
1225 ARCONTROLLER_DICTIONARY_KEY_ARDRONE3_MEDIASTREAMINGSTATE_VIDEOENABLECHANGED_ENABLED, arg);
1227 if (arg !=
nullptr) {
1230 static_cast<eARCOMMANDS_ARDRONE3_MEDIASTREAMINGSTATE_VIDEOENABLECHANGED_ENABLED
>(arg->value.I32);
1234 return streamingState;
1237 ARSAL_PRINT(ARSAL_PRINT_ERROR, TAG,
"Error when checking streaming state : drone isn't connected.");
1238 return ARCOMMANDS_ARDRONE3_MEDIASTREAMINGSTATE_VIDEOENABLECHANGED_ENABLED_MAX;
1246 ARDISCOVERY_Device_t *vpRobotBebop2::discoverDrone()
1248 eARDISCOVERY_ERROR errorDiscovery = ARDISCOVERY_OK;
1250 ARDISCOVERY_Device_t *device = ARDISCOVERY_Device_New(&errorDiscovery);
1252 ARSAL_PRINT(ARSAL_PRINT_INFO, TAG,
" - Starting drone Wifi discovery ...");
1253 const char *charIpAddress = m_ipAddress.c_str();
1255 ARDISCOVERY_Device_InitWifi(device, ARDISCOVERY_PRODUCT_BEBOP_2,
"bebop2", charIpAddress, m_discoveryPort);
1257 if (errorDiscovery != ARDISCOVERY_OK) {
1258 ARSAL_PRINT(ARSAL_PRINT_ERROR, TAG,
"Discovery error :%s", ARDISCOVERY_Error_ToString(errorDiscovery));
1260 ARSAL_PRINT(ARSAL_PRINT_INFO, TAG,
"- Drone controller created.");
1270 void vpRobotBebop2::createDroneController(ARDISCOVERY_Device_t *discoveredDrone)
1272 m_deviceController = ARCONTROLLER_Device_New(discoveredDrone, &m_errorController);
1273 if (m_errorController != ARCONTROLLER_OK) {
1274 ARSAL_PRINT(ARSAL_PRINT_ERROR, TAG,
"Creation of deviceController failed.");
1276 ARDISCOVERY_Device_Delete(&discoveredDrone);
1277 ARSAL_PRINT(ARSAL_PRINT_INFO, TAG,
"- Device created.");
1284 void vpRobotBebop2::setupCallbacks()
1287 m_errorController = ARCONTROLLER_Device_AddStateChangedCallback(m_deviceController, stateChangedCallback,
this);
1288 if (m_errorController != ARCONTROLLER_OK) {
1289 ARSAL_PRINT(ARSAL_PRINT_ERROR, TAG,
"add State callback failed.");
1293 m_errorController = ARCONTROLLER_Device_AddCommandReceivedCallback(m_deviceController, commandReceivedCallback,
this);
1295 if (m_errorController != ARCONTROLLER_OK) {
1296 ARSAL_PRINT(ARSAL_PRINT_ERROR, TAG,
"add Command callback failed.");
1299 #ifdef VISP_HAVE_FFMPEG
1301 m_errorController = ARCONTROLLER_Device_SetVideoStreamCallbacks(m_deviceController, decoderConfigCallback,
1302 didReceiveFrameCallback,
nullptr,
this);
1304 if (m_errorController != ARCONTROLLER_OK) {
1305 ARSAL_PRINT(ARSAL_PRINT_ERROR, TAG,
"- error: %s", ARCONTROLLER_Error_ToString(m_errorController));
1308 ARSAL_PRINT(ARSAL_PRINT_INFO, TAG,
"- Callbacks set up.");
1315 void vpRobotBebop2::startController()
1318 ARSAL_PRINT(ARSAL_PRINT_INFO, TAG,
"Connecting ...");
1319 m_errorController = ARCONTROLLER_Device_Start(m_deviceController);
1321 if (m_errorController != ARCONTROLLER_OK) {
1322 ARSAL_PRINT(ARSAL_PRINT_ERROR, TAG,
"- error :%s", ARCONTROLLER_Error_ToString(m_errorController));
1326 ARSAL_Sem_Wait(&(m_stateSem));
1329 m_deviceState = ARCONTROLLER_Device_GetState(m_deviceController, &m_errorController);
1331 if ((m_errorController != ARCONTROLLER_OK) || (m_deviceState != ARCONTROLLER_DEVICE_STATE_RUNNING)) {
1332 ARSAL_PRINT(ARSAL_PRINT_ERROR, TAG,
"- deviceState :%d", m_deviceState);
1333 ARSAL_PRINT(ARSAL_PRINT_ERROR, TAG,
"- error :%s", ARCONTROLLER_Error_ToString(m_errorController));
1335 ARSAL_PRINT(ARSAL_PRINT_INFO, TAG,
"- Controller started.");
1338 #ifdef VISP_HAVE_FFMPEG
1344 void vpRobotBebop2::initCodec()
1347 avcodec_register_all();
1348 avformat_network_init();
1351 AVCodec *codec = avcodec_find_decoder(AV_CODEC_ID_H264);
1353 ARSAL_PRINT(ARSAL_PRINT_ERROR, TAG,
"Codec not found.");
1358 m_codecContext = avcodec_alloc_context3(codec);
1360 if (!m_codecContext) {
1361 ARSAL_PRINT(ARSAL_PRINT_ERROR, TAG,
"Failed to allocate codec context.");
1366 m_codecContext->pix_fmt = AV_PIX_FMT_YUV420P;
1367 m_codecContext->skip_frame = AVDISCARD_DEFAULT;
1368 m_codecContext->error_concealment = FF_EC_GUESS_MVS | FF_EC_DEBLOCK;
1369 m_codecContext->skip_loop_filter = AVDISCARD_DEFAULT;
1370 m_codecContext->workaround_bugs = AVMEDIA_TYPE_VIDEO;
1371 m_codecContext->codec_id = AV_CODEC_ID_H264;
1372 m_codecContext->skip_idct = AVDISCARD_DEFAULT;
1374 m_codecContext->width = m_videoWidth;
1375 m_codecContext->height = m_videoHeight;
1377 if (codec->capabilities & AV_CODEC_CAP_TRUNCATED) {
1378 m_codecContext->flags |= AV_CODEC_FLAG_TRUNCATED;
1380 m_codecContext->flags2 |= AV_CODEC_FLAG2_CHUNKS;
1383 if (avcodec_open2(m_codecContext, codec,
nullptr) < 0) {
1384 ARSAL_PRINT(ARSAL_PRINT_ERROR, TAG,
"Failed to open codec.");
1388 AVPixelFormat pFormat = AV_PIX_FMT_BGR24;
1389 int numBytes = av_image_get_buffer_size(pFormat, m_codecContext->width, m_codecContext->height, 1);
1390 m_buffer =
static_cast<uint8_t *
>(av_malloc(
static_cast<unsigned long>(numBytes) *
sizeof(uint8_t)));
1392 av_init_packet(&m_packet);
1393 m_picture = av_frame_alloc();
1395 m_bgr_picture_mutex.lock();
1396 m_bgr_picture = av_frame_alloc();
1397 m_bgr_picture_mutex.unlock();
1399 m_img_convert_ctx = sws_getContext(m_codecContext->width, m_codecContext->height, m_codecContext->pix_fmt,
1400 m_codecContext->width, m_codecContext->height, pFormat, SWS_BICUBIC,
nullptr,
nullptr,
1409 void vpRobotBebop2::cleanUpCodec()
1411 m_videoDecodingStarted =
false;
1412 av_packet_unref(&m_packet);
1414 if (m_codecContext) {
1415 avcodec_flush_buffers(m_codecContext);
1416 avcodec_free_context(&m_codecContext);
1420 av_frame_free(&m_picture);
1423 if (m_bgr_picture) {
1424 m_bgr_picture_mutex.lock();
1425 av_frame_free(&m_bgr_picture);
1426 m_bgr_picture_mutex.unlock();
1429 if (m_img_convert_ctx) {
1430 sws_freeContext(m_img_convert_ctx);
1442 void vpRobotBebop2::startVideoDecoding()
1444 if (!m_videoDecodingStarted) {
1446 m_videoDecodingStarted =
true;
1449 ARSAL_PRINT(ARSAL_PRINT_ERROR,
"ERROR",
"Video decoding is already started.");
1458 void vpRobotBebop2::stopVideoDecoding()
1460 if (m_videoDecodingStarted) {
1464 ARSAL_PRINT(ARSAL_PRINT_ERROR,
"ERROR",
"Video decoding is already stopped.");
1475 void vpRobotBebop2::computeFrame(ARCONTROLLER_Frame_t *frame)
1479 if (m_update_codec_params && m_codec_params_data.size()) {
1480 ARSAL_PRINT(ARSAL_PRINT_INFO, TAG,
"Updating H264 codec parameters (Buffer Size: %lu) ...",
1481 m_codec_params_data.size());
1483 m_packet.data = &m_codec_params_data[0];
1484 m_packet.size =
static_cast<int>(m_codec_params_data.size());
1486 int ret = avcodec_send_packet(m_codecContext, &m_packet);
1490 ret = avcodec_receive_frame(m_codecContext, m_picture);
1492 if (ret == 0 || ret == AVERROR(EAGAIN)) {
1493 ARSAL_PRINT(ARSAL_PRINT_INFO, TAG,
"H264 codec parameters updated.");
1496 ARSAL_PRINT(ARSAL_PRINT_ERROR, TAG,
"Unexpected error while updating H264 parameters.");
1500 ARSAL_PRINT(ARSAL_PRINT_ERROR, TAG,
"Unexpected error while sending H264 parameters.");
1502 m_update_codec_params =
false;
1503 av_packet_unref(&m_packet);
1504 av_frame_unref(m_picture);
1508 m_packet.data = frame->data;
1509 m_packet.size =
static_cast<int>(frame->used);
1511 int ret = avcodec_send_packet(m_codecContext, &m_packet);
1514 char *errbuff =
new char[AV_ERROR_MAX_STRING_SIZE];
1515 av_strerror(ret, errbuff, AV_ERROR_MAX_STRING_SIZE);
1516 std::string err(errbuff);
1518 ARSAL_PRINT(ARSAL_PRINT_ERROR, TAG,
"Error sending a packet for decoding : %d, %s", ret, err.c_str());
1523 ret = avcodec_receive_frame(m_codecContext, m_picture);
1527 if (ret == AVERROR(EAGAIN)) {
1528 ARSAL_PRINT(ARSAL_PRINT_INFO, TAG,
"AVERROR(EAGAIN)");
1530 else if (ret == AVERROR_EOF) {
1531 ARSAL_PRINT(ARSAL_PRINT_INFO, TAG,
"AVERROR_EOF");
1535 char *errbuff =
new char[AV_ERROR_MAX_STRING_SIZE];
1536 av_strerror(ret, errbuff, AV_ERROR_MAX_STRING_SIZE);
1537 std::string err(errbuff);
1539 ARSAL_PRINT(ARSAL_PRINT_ERROR, TAG,
"Error receiving a decoded frame : %d, %s", ret, err.c_str());
1543 m_bgr_picture_mutex.lock();
1544 av_frame_unref(m_bgr_picture);
1545 av_image_fill_arrays(m_bgr_picture->data, m_bgr_picture->linesize, m_buffer, AV_PIX_FMT_BGR24,
1546 m_codecContext->width, m_codecContext->height, 1);
1548 sws_scale(m_img_convert_ctx, (m_picture)->data, (m_picture)->linesize, 0, m_codecContext->height,
1549 (m_bgr_picture)->data, (m_bgr_picture)->linesize);
1551 m_bgr_picture_mutex.unlock();
1555 av_packet_unref(&m_packet);
1557 av_frame_unref(m_picture);
1565 void vpRobotBebop2::cleanUp()
1567 if (m_deviceController !=
nullptr) {
1571 #ifdef VISP_HAVE_FFMPEG
1577 m_deviceState = ARCONTROLLER_Device_GetState(m_deviceController, &m_errorController);
1578 if ((m_errorController == ARCONTROLLER_OK) && (m_deviceState != ARCONTROLLER_DEVICE_STATE_STOPPED)) {
1580 ARSAL_PRINT(ARSAL_PRINT_INFO, TAG,
"Disconnecting ...");
1581 m_errorController = ARCONTROLLER_Device_Stop(m_deviceController);
1583 if (m_errorController == ARCONTROLLER_OK) {
1585 ARSAL_Sem_Wait(&(m_stateSem));
1588 ARSAL_PRINT(ARSAL_PRINT_INFO, TAG,
"Deleting device controller ...");
1589 ARCONTROLLER_Device_Delete(&m_deviceController);
1592 ARSAL_Sem_Destroy(&(m_stateSem));
1594 ARSAL_PRINT(ARSAL_PRINT_INFO, TAG,
"- Cleanup done.");
1598 ARSAL_PRINT(ARSAL_PRINT_ERROR, TAG,
"Error while cleaning up memory.");
1615 void vpRobotBebop2::stateChangedCallback(eARCONTROLLER_DEVICE_STATE newState, eARCONTROLLER_ERROR error,
1618 ARSAL_PRINT(ARSAL_PRINT_INFO, TAG,
" - Controller state changed, new state: %d.", newState);
1623 case ARCONTROLLER_DEVICE_STATE_STOPPED:
1625 drone->m_running =
false;
1627 ARSAL_Sem_Post(&(drone->m_stateSem));
1630 case ARCONTROLLER_DEVICE_STATE_RUNNING:
1632 ARSAL_Sem_Post(&(drone->m_stateSem));
1640 #ifdef VISP_HAVE_FFMPEG
1650 eARCONTROLLER_ERROR vpRobotBebop2::decoderConfigCallback(ARCONTROLLER_Stream_Codec_t codec,
void *customData)
1654 uint8_t *sps_buffer_ptr = codec.parameters.h264parameters.spsBuffer;
1655 uint32_t sps_buffer_size =
static_cast<uint32_t
>(codec.parameters.h264parameters.spsSize);
1656 uint8_t *pps_buffer_ptr = codec.parameters.h264parameters.ppsBuffer;
1657 uint32_t pps_buffer_size =
static_cast<uint32_t
>(codec.parameters.h264parameters.ppsSize);
1659 ARSAL_PRINT(ARSAL_PRINT_INFO, TAG,
"H264 configuration packet received: #SPS: %d #PPS: %d", sps_buffer_size,
1662 drone->m_update_codec_params = (sps_buffer_ptr && pps_buffer_ptr && sps_buffer_size && pps_buffer_size &&
1663 (pps_buffer_size < 32) && (sps_buffer_size < 32));
1665 if (drone->m_update_codec_params) {
1668 drone->m_codec_params_data.resize(sps_buffer_size + pps_buffer_size);
1669 std::copy(sps_buffer_ptr, sps_buffer_ptr + sps_buffer_size, drone->m_codec_params_data.begin());
1670 std::copy(pps_buffer_ptr, pps_buffer_ptr + pps_buffer_size, drone->m_codec_params_data.begin() + sps_buffer_size);
1674 drone->m_codec_params_data.clear();
1676 return ARCONTROLLER_OK;
1687 eARCONTROLLER_ERROR vpRobotBebop2::didReceiveFrameCallback(ARCONTROLLER_Frame_t *frame,
void *customData)
1691 if (frame !=
nullptr) {
1693 if (drone->m_videoDecodingStarted) {
1694 drone->computeFrame(frame);
1699 ARSAL_PRINT(ARSAL_PRINT_WARNING, TAG,
"frame is nullptr.");
1702 return ARCONTROLLER_OK;
1715 void vpRobotBebop2::cmdBatteryStateChangedRcv(ARCONTROLLER_DICTIONARY_ELEMENT_t *elementDictionary,
1718 ARCONTROLLER_DICTIONARY_ARG_t *arg =
nullptr;
1719 ARCONTROLLER_DICTIONARY_ELEMENT_t *singleElement =
nullptr;
1721 if (elementDictionary ==
nullptr) {
1722 ARSAL_PRINT(ARSAL_PRINT_ERROR, TAG,
"elements is nullptr");
1727 HASH_FIND_STR(elementDictionary, ARCONTROLLER_DICTIONARY_SINGLE_KEY, singleElement);
1729 if (singleElement ==
nullptr) {
1730 ARSAL_PRINT(ARSAL_PRINT_ERROR, TAG,
"singleElement is nullptr");
1735 HASH_FIND_STR(singleElement->arguments, ARCONTROLLER_DICTIONARY_KEY_COMMON_COMMONSTATE_BATTERYSTATECHANGED_PERCENT,
1738 if (arg ==
nullptr) {
1739 ARSAL_PRINT(ARSAL_PRINT_ERROR, TAG,
"arg is nullptr");
1742 drone->m_batteryLevel = arg->value.U8;
1743 ARSAL_PRINT(ARSAL_PRINT_INFO, TAG,
" - Battery level changed : %u percent remaining.", drone->m_batteryLevel);
1745 if (drone->m_batteryLevel <= 5) {
1746 ARSAL_PRINT(ARSAL_PRINT_WARNING, TAG,
" - WARNING, very low battery level, drone will stop soon !");
1748 else if (drone->m_batteryLevel <= 10) {
1749 ARSAL_PRINT(ARSAL_PRINT_WARNING, TAG,
" - Warning, low battery level !");
1763 void vpRobotBebop2::cmdCameraOrientationChangedRcv(ARCONTROLLER_DICTIONARY_ELEMENT_t *elementDictionary,
1766 ARCONTROLLER_DICTIONARY_ARG_t *arg =
nullptr;
1767 ARCONTROLLER_DICTIONARY_ELEMENT_t *element =
nullptr;
1768 HASH_FIND_STR(elementDictionary, ARCONTROLLER_DICTIONARY_SINGLE_KEY, element);
1769 if (element !=
nullptr) {
1770 HASH_FIND_STR(element->arguments, ARCONTROLLER_DICTIONARY_KEY_ARDRONE3_CAMERASTATE_ORIENTATIONV2_TILT, arg);
1772 if (arg !=
nullptr) {
1773 drone->m_currentCameraTilt =
static_cast<double>(arg->value.Float);
1776 HASH_FIND_STR(element->arguments, ARCONTROLLER_DICTIONARY_KEY_ARDRONE3_CAMERASTATE_ORIENTATIONV2_PAN, arg);
1777 if (arg !=
nullptr) {
1778 drone->m_currentCameraPan =
static_cast<double>(arg->value.Float);
1794 void vpRobotBebop2::cmdCameraSettingsRcv(ARCONTROLLER_DICTIONARY_ELEMENT_t *elementDictionary,
vpRobotBebop2 *drone)
1796 ARCONTROLLER_DICTIONARY_ARG_t *arg =
nullptr;
1797 ARCONTROLLER_DICTIONARY_ELEMENT_t *element =
nullptr;
1798 HASH_FIND_STR(elementDictionary, ARCONTROLLER_DICTIONARY_SINGLE_KEY, element);
1799 if (element !=
nullptr) {
1800 HASH_FIND_STR(element->arguments, ARCONTROLLER_DICTIONARY_KEY_COMMON_CAMERASETTINGSSTATE_CAMERASETTINGSCHANGED_FOV,
1802 if (arg !=
nullptr) {
1803 drone->m_cameraHorizontalFOV =
static_cast<double>(arg->value.Float);
1804 ARSAL_PRINT(ARSAL_PRINT_INFO, TAG,
" - Camera horizontal FOV : %f degrees.",
1805 static_cast<double>(drone->m_cameraHorizontalFOV));
1807 HASH_FIND_STR(element->arguments,
1808 ARCONTROLLER_DICTIONARY_KEY_COMMON_CAMERASETTINGSSTATE_CAMERASETTINGSCHANGED_PANMAX, arg);
1809 if (arg !=
nullptr) {
1810 drone->m_maxCameraPan =
static_cast<double>(arg->value.Float);
1811 ARSAL_PRINT(ARSAL_PRINT_INFO, TAG,
" - Max camera pan : %f degrees.",
1812 static_cast<double>(drone->m_maxCameraPan));
1814 HASH_FIND_STR(element->arguments,
1815 ARCONTROLLER_DICTIONARY_KEY_COMMON_CAMERASETTINGSSTATE_CAMERASETTINGSCHANGED_PANMIN, arg);
1816 if (arg !=
nullptr) {
1817 drone->m_minCameraPan =
static_cast<double>(arg->value.Float);
1818 ARSAL_PRINT(ARSAL_PRINT_INFO, TAG,
" - Min camera pan : %f degrees.",
1819 static_cast<double>(drone->m_minCameraPan));
1821 HASH_FIND_STR(element->arguments,
1822 ARCONTROLLER_DICTIONARY_KEY_COMMON_CAMERASETTINGSSTATE_CAMERASETTINGSCHANGED_TILTMAX, arg);
1823 if (arg !=
nullptr) {
1824 drone->m_maxCameraTilt =
static_cast<double>(arg->value.Float);
1825 ARSAL_PRINT(ARSAL_PRINT_INFO, TAG,
" - Max camera tilt : %f degrees.",
1826 static_cast<double>(drone->m_maxCameraTilt));
1828 HASH_FIND_STR(element->arguments,
1829 ARCONTROLLER_DICTIONARY_KEY_COMMON_CAMERASETTINGSSTATE_CAMERASETTINGSCHANGED_TILTMIN, arg);
1830 if (arg !=
nullptr) {
1831 drone->m_minCameraTilt =
static_cast<double>(arg->value.Float);
1832 ARSAL_PRINT(ARSAL_PRINT_INFO, TAG,
" - Min camera tilt : %f degrees.",
1833 static_cast<double>(drone->m_minCameraTilt));
1848 void vpRobotBebop2::cmdMaxPitchRollChangedRcv(ARCONTROLLER_DICTIONARY_ELEMENT_t *elementDictionary,
1851 ARCONTROLLER_DICTIONARY_ARG_t *arg =
nullptr;
1852 ARCONTROLLER_DICTIONARY_ELEMENT_t *element =
nullptr;
1854 HASH_FIND_STR(elementDictionary, ARCONTROLLER_DICTIONARY_SINGLE_KEY, element);
1855 if (element !=
nullptr) {
1856 HASH_FIND_STR(element->arguments, ARCONTROLLER_DICTIONARY_KEY_ARDRONE3_PILOTINGSETTINGSSTATE_MAXTILTCHANGED_CURRENT,
1858 if (arg !=
nullptr) {
1859 drone->m_maxTilt =
static_cast<double>(arg->value.Float);
1874 void vpRobotBebop2::cmdRelativeMoveEndedRcv(ARCONTROLLER_DICTIONARY_ELEMENT_t *elementDictionary,
vpRobotBebop2 *drone)
1876 ARCONTROLLER_DICTIONARY_ARG_t *arg =
nullptr;
1877 ARCONTROLLER_DICTIONARY_ELEMENT_t *element =
nullptr;
1879 HASH_FIND_STR(elementDictionary, ARCONTROLLER_DICTIONARY_SINGLE_KEY, element);
1881 if (element !=
nullptr) {
1882 HASH_FIND_STR(element->arguments, ARCONTROLLER_DICTIONARY_KEY_ARDRONE3_PILOTINGEVENT_MOVEBYEND_ERROR, arg);
1884 if (arg !=
nullptr) {
1885 eARCOMMANDS_ARDRONE3_PILOTINGEVENT_MOVEBYEND_ERROR error =
1886 static_cast<eARCOMMANDS_ARDRONE3_PILOTINGEVENT_MOVEBYEND_ERROR
>(arg->value.I32);
1887 if ((error != ARCOMMANDS_ARDRONE3_PILOTINGEVENT_MOVEBYEND_ERROR_OK) &&
1888 (error != ARCOMMANDS_ARDRONE3_PILOTINGEVENT_MOVEBYEND_ERROR_INTERRUPTED)) {
1889 ARSAL_PRINT(ARSAL_PRINT_ERROR, TAG,
"Relative move ended with error %d", error);
1891 drone->m_relativeMoveEnded =
true;
1906 void vpRobotBebop2::cmdExposureSetRcv(ARCONTROLLER_DICTIONARY_ELEMENT_t *elementDictionary,
vpRobotBebop2 *drone)
1908 ARCONTROLLER_DICTIONARY_ARG_t *arg =
nullptr;
1909 ARCONTROLLER_DICTIONARY_ELEMENT_t *element =
nullptr;
1911 HASH_FIND_STR(elementDictionary, ARCONTROLLER_DICTIONARY_SINGLE_KEY, element);
1913 if (element !=
nullptr) {
1915 HASH_FIND_STR(element->arguments, ARCONTROLLER_DICTIONARY_KEY_ARDRONE3_PICTURESETTINGSSTATE_EXPOSITIONCHANGED_VALUE,
1918 if (arg !=
nullptr) {
1919 drone->m_exposureSet =
true;
1933 void vpRobotBebop2::commandReceivedCallback(eARCONTROLLER_DICTIONARY_KEY commandKey,
1934 ARCONTROLLER_DICTIONARY_ELEMENT_t *elementDictionary,
void *customData)
1938 if (drone ==
nullptr)
1941 switch (commandKey) {
1942 case ARCONTROLLER_DICTIONARY_KEY_COMMON_COMMONSTATE_BATTERYSTATECHANGED:
1944 cmdBatteryStateChangedRcv(elementDictionary, drone);
1947 case ARCONTROLLER_DICTIONARY_KEY_ARDRONE3_PILOTINGSETTINGSSTATE_MAXTILTCHANGED:
1949 cmdMaxPitchRollChangedRcv(elementDictionary, drone);
1952 case ARCONTROLLER_DICTIONARY_KEY_ARDRONE3_PILOTINGEVENT_MOVEBYEND:
1954 cmdRelativeMoveEndedRcv(elementDictionary, drone);
1957 case ARCONTROLLER_DICTIONARY_KEY_ARDRONE3_PILOTINGSTATE_FLATTRIMCHANGED:
1959 ARSAL_PRINT(ARSAL_PRINT_INFO, TAG,
"Flat trim finished ...");
1960 drone->m_flatTrimFinished =
true;
1963 case ARCONTROLLER_DICTIONARY_KEY_ARDRONE3_PICTURESETTINGSSTATE_EXPOSITIONCHANGED:
1965 cmdExposureSetRcv(elementDictionary, drone);
1968 case ARCONTROLLER_DICTIONARY_KEY_ARDRONE3_PICTURESETTINGSSTATE_VIDEORESOLUTIONSCHANGED:
1970 ARSAL_PRINT(ARSAL_PRINT_INFO, TAG,
"Video resolution set ...");
1971 drone->m_videoResolutionSet =
true;
1974 case ARCONTROLLER_DICTIONARY_KEY_ARDRONE3_MEDIASTREAMINGSTATE_VIDEOENABLECHANGED:
1976 drone->m_streamingStarted =
true;
1979 case ARCONTROLLER_DICTIONARY_KEY_ARDRONE3_MEDIASTREAMINGSTATE_VIDEOSTREAMMODECHANGED:
1981 drone->m_streamingModeSet =
true;
1984 case ARCONTROLLER_DICTIONARY_KEY_COMMON_SETTINGSSTATE_RESETCHANGED:
1986 ARSAL_PRINT(ARSAL_PRINT_INFO, TAG,
"Settings reset ...");
1987 drone->m_settingsReset =
true;
1990 case ARCONTROLLER_DICTIONARY_KEY_ARDRONE3_CAMERASTATE_ORIENTATIONV2:
1992 cmdCameraOrientationChangedRcv(elementDictionary, drone);
1995 case ARCONTROLLER_DICTIONARY_KEY_COMMON_CAMERASETTINGSSTATE_CAMERASETTINGSCHANGED:
1997 cmdCameraSettingsRcv(elementDictionary, drone);
2007 #elif !defined(VISP_BUILD_SHARED_LIBS)
2010 void dummy_vpRobotBebop2() { };
unsigned int size() const
Return the number of elements of the 2D array.
Implementation of column vector and the associated operations.
error that can be emitted by ViSP classes.
static vpHomogeneousMatrix direct(const vpColVector &v)
Implementation of an homogeneous matrix and operations on such kind of matrices.
vpRotationMatrix getRotationMatrix() const
vpTranslationVector getTranslationVector() const
static void BGRToGrey(unsigned char *bgr, unsigned char *grey, unsigned int width, unsigned int height, bool flip=false, unsigned int nThreads=0)
static void BGRToRGBa(unsigned char *bgr, unsigned char *rgba, unsigned int width, unsigned int height, bool flip=false)
unsigned int getWidth() const
void resize(unsigned int h, unsigned int w)
resize the image : Image initialization
Type * bitmap
points toward the bitmap
unsigned int getHeight() const
std::string getIpAddress()
double getMinCameraPan() const
void setMaxTilt(double maxTilt)
void setPosition(float dX, float dY, float dZ, float dPsi, bool blocking)
void setVelocity(const vpColVector &vel, double delta_t)
void setExposure(float expo)
double getCurrentCameraPan() const
void setVideoStabilisationMode(int mode)
double getMinCameraTilt() const
double getMaxCameraTilt() const
void setVerbose(bool verbose)
void setVerticalSpeed(int value)
void getGrayscaleImage(vpImage< unsigned char > &I)
void setStreamingMode(int mode)
unsigned int getBatteryLevel()
void getRGBaImage(vpImage< vpRGBa > &I)
void setYawSpeed(int value)
void setCameraPan(double pan, bool blocking=false)
void takeOff(bool blocking=true)
double getCurrentCameraTilt() const
double getCameraHorizontalFOV() const
void setVideoResolution(int mode)
void setCameraTilt(double tilt, bool blocking=false)
vpRobotBebop2(bool verbose=false, bool setDefaultSettings=true, std::string ipAddress="192.168.42.1", int discoveryPort=44444)
void setCameraOrientation(double tilt, double pan, bool blocking=false)
double getMaxCameraPan() const
vpThetaUVector getThetaUVector()
Class that consider the case of a translation vector.
VISP_EXPORT void sleepMs(double t)