ZEDLogMessage.cs 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. //======= Copyright (c) Stereolabs Corporation, All rights reserved. ===============
  2. /// <summary>
  3. /// Holds the ERROR enum returned by various high- and mid-level camera functions, and the Error2Str() method for
  4. /// converting the errors to human-readible versions for displaying for the user.
  5. /// </summary>
  6. public class ZEDLogMessage
  7. {
  8. /// <summary>
  9. /// Current version of the required SDK plugin as a string. Used to display errors
  10. /// relating to a missing or mismatched SDK version.
  11. /// </summary>
  12. static private string zed_sdk_version
  13. {
  14. get
  15. {
  16. int major = sl.ZEDCamera.PluginVersion.Major;
  17. int minor = sl.ZEDCamera.PluginVersion.Minor;
  18. return "v" + major + "." + minor;
  19. }
  20. }
  21. /// <summary>
  22. /// Error categories returned by various camera functions, most often in GUIMessage.
  23. /// See ZEDCommon.ERROR_CODE for errors straignt from the SDK.
  24. /// </summary>
  25. public enum ERROR
  26. {
  27. /// <summary>
  28. /// The screen resolution is not 16:9.
  29. /// </summary>
  30. SCREEN_RESOLUTION,
  31. /// <summary>
  32. /// The ZED tracking could not be initialized.
  33. /// </summary>
  34. TRACKING_NOT_INITIALIZED,
  35. /// <summary>
  36. /// The camera failed to initialize.
  37. /// </summary>
  38. CAMERA_NOT_INITIALIZED,
  39. /// <summary>
  40. /// The camera has not been initialized yet.
  41. /// </summary>
  42. CAMERA_LOADING,
  43. /// <summary>
  44. /// SDK module are loading (tracking, object detection...)
  45. /// </summary>
  46. SDK_MODULE_LOADING,
  47. /// <summary>
  48. /// Could not open the camera.
  49. /// </summary>
  50. UNABLE_TO_OPEN_CAMERA,
  51. /// <summary>
  52. /// Camera detection issue.
  53. /// </summary>
  54. CAMERA_DETECTION_ISSUE,
  55. /// <summary>
  56. /// Motion sensor not detected (ZED Mini only).
  57. /// </summary>
  58. SENSOR_NOT_DETECTED,
  59. /// <summary>
  60. /// Low USB bandwidth.
  61. /// </summary>
  62. LOW_USB_BANDWIDTH,
  63. /// <summary>
  64. /// SteamVR plugin Camera Rig prefab not found.
  65. /// </summary>
  66. VR_CAMERA_RIG_NOT_FOUND,
  67. /// <summary>
  68. /// SteamVR plugin Camera Rig controller not found.
  69. /// </summary>
  70. VR_CAMERA_RIG_CONTROLLER_NOT_FOUND,
  71. /// <summary>
  72. /// A calibration file has been found but no controller/Tracker exists of the file's listed serial number.
  73. /// </summary>
  74. PAD_CAMERA_CALIBRATION_MISMATCH,
  75. /// <summary>
  76. /// The serial number of the calibration tool does not match any of the current controllers.
  77. /// </summary>
  78. PAD_CAMERA_CALIBRATION_NOT_FOUND,
  79. /// <summary>
  80. /// At least one VR controller must be detected.
  81. /// </summary>
  82. NOT_ENOUGH_PAD_DETECTED,
  83. /// <summary>
  84. /// SteamVR Unity plugin hasn't been imported.
  85. /// </summary>
  86. STEAMVR_NOT_INSTALLED,
  87. /// <summary>
  88. /// Oculus Integration Unity plugin hasn't been imported.
  89. /// </summary>
  90. OVR_NOT_INSTALLED,
  91. /// <summary>
  92. /// The ZED has been disconnected. (It was connected previously)
  93. /// </summary>
  94. ZED_IS_DISCONNECETD,
  95. /// <summary>
  96. /// The ZED SDK is not installed or a dependency is missing.
  97. /// </summary>
  98. SDK_NOT_INSTALLED,
  99. /// <summary>
  100. /// The ZED SDK is installed but it's not the version the Unity plugin requires.
  101. /// </summary>
  102. INCORRECT_ZED_SDK_VERSION,
  103. /// <summary>
  104. /// The SDK has a missing dependency.
  105. /// </summary>
  106. SDK_DEPENDENCIES_ISSUE,
  107. /// <summary>
  108. /// Scanned mesh is too small to create a Nav Mesh.
  109. /// </summary>
  110. NAVMESH_NOT_GENERATED,
  111. /// <summary>
  112. /// The tracking system could not load the spatial memory area file.
  113. /// </summary>
  114. TRACKING_BASE_AREA_NOT_FOUND
  115. }
  116. /// <summary>
  117. /// Converts an ERROR enum to a string for displaying to the user. Called by various editor windows.
  118. /// </summary>
  119. /// <param name="error">Error type to be converted to a string.</param>
  120. /// <returns></returns>
  121. static public string Error2Str(ERROR error)
  122. {
  123. switch (error)
  124. {
  125. case ERROR.SCREEN_RESOLUTION:
  126. return "Warning: Screen size should be set to 16:9 aspect ratio";
  127. case ERROR.TRACKING_NOT_INITIALIZED:
  128. return "Error: Unable to initialize Tracking module";
  129. case ERROR.CAMERA_NOT_INITIALIZED:
  130. return "Unable to open camera";
  131. case ERROR.UNABLE_TO_OPEN_CAMERA:
  132. return "Camera not detected";
  133. case ERROR.CAMERA_DETECTION_ISSUE:
  134. return "Unable to open camera";
  135. case ERROR.SENSOR_NOT_DETECTED:
  136. return "Camera motion sensor not detected";
  137. case ERROR.LOW_USB_BANDWIDTH :
  138. return "Low USB bandwidth";
  139. case ERROR.CAMERA_LOADING:
  140. return "Loading camera...";
  141. case ERROR.SDK_MODULE_LOADING:
  142. return " Loading modules...";
  143. case ERROR.VR_CAMERA_RIG_NOT_FOUND:
  144. return "Warning: No SteamVR [Camera Rig] object found. Make sure you attach the CameraRig SteamVR Prefab in the project to be able to use a VR controller.\n " +
  145. "Otherwise, make sure the tracking is activated in the ZED Manager interface";
  146. case ERROR.VR_CAMERA_RIG_CONTROLLER_NOT_FOUND:
  147. return "Warning: At least one controller is recommended for the external camera";
  148. case ERROR.PAD_CAMERA_CALIBRATION_MISMATCH:
  149. return "Warning: VR Controller and ZED Camera must be calibrated before use with Stereolabs' GreenScreen Calibration tool). " +
  150. "\n The controller/Tracker in the calibration file is not present.";
  151. case ERROR.PAD_CAMERA_CALIBRATION_NOT_FOUND:
  152. return "Warning: VR Controller and ZED Camera must be calibrated before use with Stereolabs' GreenScreen Calibration tool). " +
  153. "\n No calibration file has been detected.";
  154. case ERROR.NOT_ENOUGH_PAD_DETECTED:
  155. return "Warning: At least one controller must be detected. Number of devices detected: ";
  156. case ERROR.STEAMVR_NOT_INSTALLED:
  157. return "Warning: SteamVR is not installed.";
  158. case ERROR.OVR_NOT_INSTALLED:
  159. return "Warning: OVR Plugin is not installed.";
  160. case ERROR.ZED_IS_DISCONNECETD:
  161. return "Camera disconnected";
  162. case ERROR.SDK_NOT_INSTALLED:
  163. return "ZED SDK not installed";
  164. case ERROR.SDK_DEPENDENCIES_ISSUE:
  165. return "The ZED plugin cannot be loaded. \n Please check that you have ZED SDK "+ zed_sdk_version +" installed" +
  166. "\n\n If the problem persists, please contact our support team at support@stereolabs.com\n";
  167. case ERROR.NAVMESH_NOT_GENERATED:
  168. return "The NavMesh cannot be generated. Please change the settings of the Navigation Agent, or scan a wider zone.";
  169. case ERROR.TRACKING_BASE_AREA_NOT_FOUND:
  170. return "The tracking could not load the spatial memory area file.";
  171. default:
  172. return "Unknown error";
  173. }
  174. }
  175. }