// Set up Tango Configuration handle, and connecting all callbacks. bool TangoData::SetConfig() { // Get the default TangoConfig. config_ = TangoService_getConfig(TANGO_CONFIG_DEFAULT); if (config_ == NULL) { LOGE("TangoService_getConfig(): Failed"); return false; } // Enable depth. if (TangoConfig_setBool(config_, "config_enable_depth", true) != TANGO_SUCCESS) { LOGE("config_enable_depth Failed"); return false; } // Enable color. if (TangoConfig_setBool(config_, "config_enable_color_camera", true) != TANGO_SUCCESS) { LOGE("config_enable_color_camera Failed"); return false; } // Get library version string from service. if (TangoConfig_getString( config_, "tango_service_library_version", const_cast<char*>( TangoData::GetInstance().lib_version_string.c_str()), kVersionStringLength) != TANGO_SUCCESS) { LOGE("Get tango_service_library_version Failed"); return false; } // Get max point cloud elements. The value is used for allocating // the depth buffer. int temp = 0; if (TangoConfig_getInt32(config_, "max_point_cloud_elements", &temp) != TANGO_SUCCESS) { LOGE("Get max_point_cloud_elements Failed"); return false; } max_vertex_count = static_cast<uint32_t>(temp); // Forward allocate the maximum size of depth buffer. // max_vertex_count is the vertices count, max_vertex_count*3 is // the actual float buffer size. depth_buffer = new float[3 * max_vertex_count]; return true; }
char* TangoData::GetVersonString() { TangoConfig_getString(config_, "tango_service_library_version", lib_version_, 26); return lib_version_; }
bool TangoData::SetConfig(bool is_auto_recovery) { // Get the default TangoConfig. // We get the default config first and change the config // flag as needed. config_ = TangoService_getConfig(TANGO_CONFIG_DEFAULT); if (config_ == NULL) { LOGE("TangoService_getConfig(): Failed"); return false; } // Turn on auto recovery for motion tracking. // Note that the auto-recovery is on by default. if (TangoConfig_setBool(config_, "config_enable_auto_recovery", is_auto_recovery) != TANGO_SUCCESS) { LOGE("config_enable_auto_recovery(): Failed"); return false; } // Get library version string from service. TangoConfig_getString(config_, "tango_service_library_version", const_cast<char*>(lib_version_string.c_str()), kVersionStringLength); // Setting up the start of service to ADF frame for the onPoseAvailable // callback, // it will check the localization status. TangoCoordinateFramePair pair; pair.base = TANGO_COORDINATE_FRAME_AREA_DESCRIPTION; pair.target = TANGO_COORDINATE_FRAME_START_OF_SERVICE; // Attach onPoseAvailable callback. // The callback will be called after the service is connected. if (TangoService_connectOnPoseAvailable(1, &pair, onPoseAvailable) != TANGO_SUCCESS) { LOGE("TangoService_connectOnPoseAvailable(): Failed"); return false; } // Attach onEventAvailable callback. // The callback will be called after the service is connected. if (TangoService_connectOnTangoEvent(onTangoEvent) != TANGO_SUCCESS) { LOGE("TangoService_connectOnTangoEvent(): Failed"); return false; } // Load the most recent ADF. char* uuid_list; // uuid_list will contain a comma separated list of UUIDs. if (TangoService_getAreaDescriptionUUIDList(&uuid_list) != TANGO_SUCCESS) { LOGI("TangoService_getAreaDescriptionUUIDList"); } // Parse the uuid_list to get the individual uuids. if (uuid_list != NULL && uuid_list[0] != '\0') { vector<string> adf_list; char* parsing_char; parsing_char = strtok(uuid_list, ","); while (parsing_char != NULL) { string s = string(parsing_char); adf_list.push_back(s); parsing_char = strtok(NULL, ","); } int list_size = adf_list.size(); if (list_size == 0) { LOGE("List size is 0"); return false; } cur_uuid = adf_list[list_size - 1]; if (TangoConfig_setString(config_, "config_load_area_description_UUID", adf_list[list_size - 1].c_str()) != TANGO_SUCCESS) { LOGE("config_load_area_description_uuid Failed"); return false; } else { LOGI("Load ADF: %s", adf_list[list_size - 1].c_str()); } } else { LOGE("No area description file available, no file loaded."); } is_localized = false; return true; }