├── .clang-format ├── .gitignore ├── .make_deb.sh ├── 56-orbbec-usb.rules ├── CHANGELOG.rst ├── CMakeLists.txt ├── LICENSE ├── README.md ├── cfg └── Astra.cfg ├── dependencies └── libuvc_master_d3318ae72.zip ├── include ├── astra_camera │ ├── constants.h │ ├── d2c_viewer.h │ ├── json.hpp │ ├── ob_camera_node.h │ ├── ob_camera_node_factory.h │ ├── ob_context.h │ ├── point_cloud_proc │ │ ├── depth_conversions.h │ │ ├── depth_traits.h │ │ ├── point_cloud_proc.h │ │ ├── point_cloud_xyz.h │ │ └── point_cloud_xyzrgb.h │ ├── types.h │ ├── utils.h │ └── uvc_camera_driver.h ├── openni2 │ ├── Android-Arm │ │ └── OniPlatformAndroid-Arm.h │ ├── Driver │ │ ├── OniDriverAPI.h │ │ └── OniDriverTypes.h │ ├── KinectProperties.h │ ├── Linux-Arm │ │ └── OniPlatformLinux-Arm.h │ ├── Linux-x86 │ │ └── OniPlatformLinux-x86.h │ ├── MacOSX │ │ └── OniPlatformMacOSX.h │ ├── OniCAPI.h │ ├── OniCEnums.h │ ├── OniCProperties.h │ ├── OniCTypes.h │ ├── OniEnums.h │ ├── OniPlatform.h │ ├── OniProperties.h │ ├── OniTest.h │ ├── OniVersion.h │ ├── OpenNI.h │ ├── PS1080.h │ ├── PSLink.h │ ├── PrimeSense.h │ ├── SonixCamera.h │ ├── Win32 │ │ └── OniPlatformWin32.h │ └── util.h └── openni2_redist │ ├── arm │ ├── OpenNI.ini │ ├── OpenNI2 │ │ └── Drivers │ │ │ ├── OniFile.ini │ │ │ ├── libOniFile.so │ │ │ ├── liborbbec.so │ │ │ └── orbbec.ini │ ├── PS1080Console │ ├── SimpleRead │ └── libOpenNI2.so │ ├── arm64 │ ├── NiViewer │ ├── OpenNI.ini │ ├── OpenNI2 │ │ └── Drivers │ │ │ ├── OniFile.ini │ │ │ ├── libOniFile.so │ │ │ ├── liborbbec.so │ │ │ └── orbbec.ini │ ├── PS1080Console │ ├── SimpleRead │ └── libOpenNI2.so │ └── x64 │ ├── NiViewer │ ├── OpenNI.ini │ ├── OpenNI2 │ └── Drivers │ │ ├── OniFile.ini │ │ ├── libOniFile.so │ │ ├── liborbbec.so │ │ └── orbbec.ini │ ├── PS1080Console │ ├── SimpleRead │ └── libOpenNI2.so ├── launch ├── astra.launch ├── astra_pro.launch ├── astra_pro_plus.launch ├── dabai.launch ├── dabai_dc1.launch ├── dabai_dcw.launch ├── dabai_dcw2.launch ├── dabai_dw.launch ├── dabai_dw2.launch ├── dabai_max.launch ├── dabai_max_pro.launch ├── dabai_pro.launch ├── dabai_u3.launch ├── deeyea.launch ├── embedded_s.launch ├── embedded_u3.launch ├── gemini.launch ├── gemini_e.launch ├── gemini_e_lite.launch ├── gemini_uw.launch ├── list_devices.launch ├── multi_astra.launch ├── multi_dabai.launch ├── multi_dabai_dcw.launch ├── multi_dabai_dcw2.launch ├── multi_dabai_pro.launch ├── multi_deeyea.launch ├── multi_device.launch ├── multi_gemini.launch ├── stereo_s.launch └── stereo_s_u3.launch ├── msg ├── DeviceInfo.msg ├── Extrinsics.msg └── Metadata.msg ├── package.xml ├── scripts ├── create_udev_rules ├── depth_to_color.py ├── get_point_cloud_dist.py ├── get_supported_video_modes.py ├── sync.py └── test_open_close_stream.py ├── src ├── d2c_viewer.cpp ├── list_devices_node.cpp ├── main.cpp ├── ob_camera_info.cpp ├── ob_camera_node.cpp ├── ob_camera_node_factory.cpp ├── ob_context.cpp ├── point_cloud_proc │ ├── point_cloud_xyz.cpp │ └── point_cloud_xyzrgb.cpp ├── ros_service.cpp ├── utils.cpp └── uvc_camera_driver.cpp ├── srv ├── GetBool.srv ├── GetCameraInfo.srv ├── GetCameraParams.srv ├── GetDeviceInfo.srv ├── GetDouble.srv ├── GetInt32.srv ├── GetString.srv ├── SetInt32.srv └── SetString.srv └── test └── .gitkeep /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Cpp 3 | BasedOnStyle: Google 4 | AccessModifierOffset: -1 5 | AlignAfterOpenBracket: Align 6 | AlignConsecutiveMacros: false 7 | AlignConsecutiveAssignments: false 8 | AlignConsecutiveDeclarations: false 9 | AlignEscapedNewlines: Left 10 | AlignOperands: true 11 | AlignTrailingComments: true 12 | AllowAllArgumentsOnNextLine: true 13 | AllowAllConstructorInitializersOnNextLine: true 14 | AllowAllParametersOfDeclarationOnNextLine: true 15 | AllowShortBlocksOnASingleLine: Never 16 | AllowShortCaseLabelsOnASingleLine: false 17 | AllowShortFunctionsOnASingleLine: All 18 | AllowShortLambdasOnASingleLine: All 19 | AllowShortIfStatementsOnASingleLine: WithoutElse 20 | AllowShortLoopsOnASingleLine: true 21 | AlwaysBreakAfterDefinitionReturnType: None 22 | AlwaysBreakAfterReturnType: None 23 | AlwaysBreakBeforeMultilineStrings: true 24 | AlwaysBreakTemplateDeclarations: Yes 25 | BinPackArguments: true 26 | BinPackParameters: true 27 | BraceWrapping: 28 | AfterCaseLabel: false 29 | AfterClass: false 30 | AfterControlStatement: false 31 | AfterEnum: false 32 | AfterFunction: false 33 | AfterNamespace: false 34 | AfterObjCDeclaration: false 35 | AfterStruct: false 36 | AfterUnion: false 37 | AfterExternBlock: false 38 | BeforeCatch: false 39 | BeforeElse: false 40 | IndentBraces: false 41 | SplitEmptyFunction: true 42 | SplitEmptyRecord: true 43 | SplitEmptyNamespace: true 44 | BreakBeforeBinaryOperators: None 45 | BreakBeforeBraces: Attach 46 | BreakBeforeInheritanceComma: false 47 | BreakInheritanceList: BeforeColon 48 | BreakBeforeTernaryOperators: true 49 | BreakConstructorInitializersBeforeComma: false 50 | BreakConstructorInitializers: BeforeColon 51 | BreakAfterJavaFieldAnnotations: false 52 | BreakStringLiterals: true 53 | ColumnLimit: 100 54 | CommentPragmas: '^ IWYU pragma:' 55 | CompactNamespaces: false 56 | ConstructorInitializerAllOnOneLineOrOnePerLine: true 57 | ConstructorInitializerIndentWidth: 4 58 | ContinuationIndentWidth: 4 59 | Cpp11BracedListStyle: true 60 | DeriveLineEnding: true 61 | DerivePointerAlignment: true 62 | DisableFormat: false 63 | ExperimentalAutoDetectBinPacking: false 64 | FixNamespaceComments: true 65 | ForEachMacros: 66 | - foreach 67 | - Q_FOREACH 68 | - BOOST_FOREACH 69 | IncludeBlocks: Regroup 70 | IncludeCategories: 71 | - Regex: '^' 72 | Priority: 2 73 | SortPriority: 0 74 | - Regex: '^<.*\.h>' 75 | Priority: 1 76 | SortPriority: 0 77 | - Regex: '^<.*' 78 | Priority: 2 79 | SortPriority: 0 80 | - Regex: '.*' 81 | Priority: 3 82 | SortPriority: 0 83 | IncludeIsMainRegex: '([-_](test|unittest))?$' 84 | IncludeIsMainSourceRegex: '' 85 | IndentCaseLabels: true 86 | IndentGotoLabels: true 87 | IndentPPDirectives: None 88 | IndentWidth: 2 89 | IndentWrappedFunctionNames: false 90 | JavaScriptQuotes: Leave 91 | JavaScriptWrapImports: true 92 | KeepEmptyLinesAtTheStartOfBlocks: false 93 | MacroBlockBegin: '' 94 | MacroBlockEnd: '' 95 | MaxEmptyLinesToKeep: 1 96 | NamespaceIndentation: None 97 | ObjCBinPackProtocolList: Never 98 | ObjCBlockIndentWidth: 2 99 | ObjCSpaceAfterProperty: false 100 | ObjCSpaceBeforeProtocolList: true 101 | PenaltyBreakAssignment: 2 102 | PenaltyBreakBeforeFirstCallParameter: 1 103 | PenaltyBreakComment: 300 104 | PenaltyBreakFirstLessLess: 120 105 | PenaltyBreakString: 1000 106 | PenaltyBreakTemplateDeclaration: 10 107 | PenaltyExcessCharacter: 1000000 108 | PenaltyReturnTypeOnItsOwnLine: 200 109 | PointerAlignment: Left 110 | RawStringFormats: 111 | - Language: Cpp 112 | Delimiters: 113 | - cc 114 | - CC 115 | - cpp 116 | - Cpp 117 | - CPP 118 | - 'c++' 119 | - 'C++' 120 | CanonicalDelimiter: '' 121 | BasedOnStyle: google 122 | - Language: TextProto 123 | Delimiters: 124 | - pb 125 | - PB 126 | - proto 127 | - PROTO 128 | EnclosingFunctions: 129 | - EqualsProto 130 | - EquivToProto 131 | - PARSE_PARTIAL_TEXT_PROTO 132 | - PARSE_TEST_PROTO 133 | - PARSE_TEXT_PROTO 134 | - ParseTextOrDie 135 | - ParseTextProtoOrDie 136 | CanonicalDelimiter: '' 137 | BasedOnStyle: google 138 | ReflowComments: true 139 | SortIncludes: true 140 | SortUsingDeclarations: true 141 | SpaceAfterCStyleCast: false 142 | SpaceAfterLogicalNot: false 143 | SpaceAfterTemplateKeyword: true 144 | SpaceBeforeAssignmentOperators: true 145 | SpaceBeforeCpp11BracedList: false 146 | SpaceBeforeCtorInitializerColon: true 147 | SpaceBeforeInheritanceColon: true 148 | SpaceBeforeParens: ControlStatements 149 | SpaceBeforeRangeBasedForLoopColon: true 150 | SpaceInEmptyBlock: false 151 | SpaceInEmptyParentheses: false 152 | SpacesBeforeTrailingComments: 2 153 | SpacesInAngles: false 154 | SpacesInConditionalStatement: false 155 | SpacesInContainerLiterals: true 156 | SpacesInCStyleCastParentheses: false 157 | SpacesInParentheses: false 158 | SpacesInSquareBrackets: false 159 | SpaceBeforeSquareBrackets: false 160 | Standard: Auto 161 | StatementMacros: 162 | - Q_UNUSED 163 | - QT_REQUIRE_VERSION 164 | TabWidth: 8 165 | UseCRLF: false 166 | UseTab: Never 167 | ... 168 | 169 | -------------------------------------------------------------------------------- /.make_deb.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | set -e 3 | CURR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" 4 | rm -fr debian obj-x86_64-linux-gnu 5 | export DEBIAN_INC=1 6 | bloom-generate rosdebian --os-name ubuntu --ros-distro $ROS_DISTRO -i ${DEBIAN_INC}.$(date +%Y%m%d.%H%M%S) 7 | export DEB_BUILD_OPTIONS="parallel=$(($(nproc) - 1))" 8 | fakeroot debian/rules binary 9 | 10 | -------------------------------------------------------------------------------- /CHANGELOG.rst: -------------------------------------------------------------------------------- 1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2 | Changelog for package astra_camera 3 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 4 | 1.2.6 (2023-11-16) 5 | ------------ 6 | * Add device Astra mini pro. 7 | * Add device Dabai Max 8 | 9 | 1.2.1 (2023-01-12) 10 | ------------ 11 | 12 | * Migration of all parameters to the launch file. 13 | * Optimized multi-camera. 14 | * Fixed reading calibration parameters. 15 | * Fix the deadlock bug of the subscription when disconnected 16 | 17 | 1.0.9(2022-07-25) 18 | ------------ 19 | * Support Dabai DCW/Dabai DW 20 | * Removed a lot of unnecessary commented code 21 | * Add support for hotplug 22 | * Fix point cloud alignment problem (depth alignment) 23 | * Update README 24 | 25 | 0.3.0 (2019-08-08) 26 | ------------ 27 | * Add UVC support 28 | * Add OPENNI2 include files under include folder 29 | * Add more video modes 30 | * Add useful services to control cameras 31 | * Support Stereo S, Embedded S, and Stereo S U3 32 | * Merge astra_launch package 33 | * 56-orbbec-usb.rules now includes uvc support 34 | * CMakeLists.txt changes accordingly 35 | * Update README 36 | * Contributors: Chi-Ju Wu, Nan Xu, dandedrick, coxep 37 | 38 | 0.2.2 (2018-03-22) 39 | ----------- 40 | * Add launchfile info and reformat nicely 41 | * Publish projector/camera_info (fixes disparity img) 42 | * modify gcc optimizate problem 43 | * Contributors: Chan Jun Shern, Martin Günther, Mikael Arguedas, Tim 44 | 45 | 0.2.1 (2018-02-12) 46 | ----------- 47 | * 1,patch for catkin_make -j1 in docker 2,patch for x64 use x86 in docker 3,arm/arm64 use no-filter library 48 | * Contributors: Tim 49 | 50 | 0.2.0 (2018-01-25) 51 | ------------------ 52 | * add support for astra mini s 53 | * Contributors: Tim Liu 54 | 55 | 0.1.5 (2016-05-27) 56 | ------------------ 57 | * add dependency on generated messages to avoid race condition at build time 58 | * switching to libusb-1.0 59 | * Contributors: Tully Foote 60 | 61 | 0.1.4 (2016-05-27) 62 | ------------------ 63 | * add libusb-dev as a build dependency 64 | * Contributors: Tully Foote 65 | 66 | 0.1.3 (2016-05-26) 67 | ------------------ 68 | * Adding build dependency on libudev-dev 69 | * Contributors: Tully Foote 70 | 71 | 0.1.2 (2016-05-26) 72 | ------------------ 73 | * add git as a dependency 74 | * Contributors: Tully Foote 75 | 76 | 0.1.1 (2016-05-26) 77 | ------------------ 78 | * removing dependency which was internalilzed 79 | * Contributors: Tully Foote 80 | 81 | 0.1.0 (2016-05-26) 82 | ------------------ 83 | * Initial release of ROS driver for Astra camera 84 | * Contributors: Ernesto Corbellini, Len Zhong, Tim, Tully Foote, ob-tim-liu 85 | -------------------------------------------------------------------------------- /dependencies/libuvc_master_d3318ae72.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orbbec/ros_astra_camera/affcfae0bc4786b5f64177ba852577742cdefa90/dependencies/libuvc_master_d3318ae72.zip -------------------------------------------------------------------------------- /include/astra_camera/constants.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************/ 2 | /* */ 3 | /* Copyright (c) 2013-2022 Orbbec 3D Technology, Inc */ 4 | /* */ 5 | /* PROPRIETARY RIGHTS of Orbbec 3D Technology are involved in the */ 6 | /* subject matter of this material. All manufacturing, reproduction, use, */ 7 | /* and sales rights pertaining to this subject matter are governed by the */ 8 | /* license agreement. The recipient of this software implicitly accepts */ 9 | /* the terms of the license. */ 10 | /* */ 11 | /**************************************************************************/ 12 | 13 | #pragma once 14 | 15 | #include 16 | #include 17 | 18 | #define OB_ROS_MAJOR_VERSION 1 19 | #define OB_ROS_MINOR_VERSION 2 20 | #define OB_ROS_PATCH_VERSION 7 21 | 22 | #ifndef STRINGIFY 23 | #define STRINGIFY(arg) #arg 24 | #endif 25 | #ifndef VAR_ARG_STRING 26 | #define VAR_ARG_STRING(arg) STRINGIFY(arg) 27 | #endif 28 | 29 | #define STRINGIFY(arg) #arg 30 | #define VAR_ARG_STRING(arg) STRINGIFY(arg) 31 | /* Return version in "X.Y.Z" format */ 32 | #define OB_ROS_VERSION_STR \ 33 | (VAR_ARG_STRING(OB_ROS_MAJOR_VERSION.OB_ROS_MINOR_VERSION.OB_ROS_PATCH_VERSION)) 34 | 35 | namespace astra_camera { 36 | 37 | const bool ALIGN_DEPTH = false; 38 | const bool POINTCLOUD = false; 39 | const bool ALLOW_NO_TEXTURE_POINTS = false; 40 | const bool SYNC_FRAMES = false; 41 | const bool ORDERED_POINTCLOUD = false; 42 | 43 | const bool PUBLISH_TF = true; 44 | const double TF_PUBLISH_RATE = 0; // Static transform 45 | const double DIAGNOSTICS_PERIOD = 0; // Static transform 46 | 47 | const int IMAGE_WIDTH = 640; 48 | const int IMAGE_HEIGHT = 480; 49 | const int IMAGE_FPS = 30; 50 | 51 | const std::string IMAGE_QOS = "SYSTEM_DEFAULT"; 52 | const std::string DEFAULT_QOS = "DEFAULT"; 53 | const std::string HID_QOS = "HID_DEFAULT"; 54 | const std::string EXTRINSICS_QOS = "EXTRINSICS_DEFAULT"; 55 | 56 | const double IMU_FPS = 0; 57 | 58 | const bool ENABLE_DEPTH = true; 59 | const bool ENABLE_INFRA1 = true; 60 | const bool ENABLE_INFRA2 = true; 61 | const bool ENABLE_COLOR = true; 62 | const bool ENABLE_FISHEYE = true; 63 | const bool ENABLE_IMU = true; 64 | const bool HOLD_BACK_IMU_FOR_FRAMES = false; 65 | const bool PUBLISH_ODOM_TF = true; 66 | 67 | const std::string DEFAULT_BASE_FRAME_ID = "camera_link"; 68 | const std::string DEFAULT_ODOM_FRAME_ID = "odom_frame"; 69 | const std::string DEFAULT_DEPTH_FRAME_ID = "camera_depth_frame"; 70 | const std::string DEFAULT_INFRA1_FRAME_ID = "camera_infra1_frame"; 71 | const std::string DEFAULT_INFRA2_FRAME_ID = "camera_infra2_frame"; 72 | const std::string DEFAULT_COLOR_FRAME_ID = "camera_color_frame"; 73 | const std::string DEFAULT_FISHEYE_FRAME_ID = "camera_fisheye_frame"; 74 | const std::string DEFAULT_IMU_FRAME_ID = "camera_imu_frame"; 75 | 76 | const std::string DEFAULT_DEPTH_OPTICAL_FRAME_ID = "camera_depth_optical_frame"; 77 | const std::string DEFAULT_INFRA1_OPTICAL_FRAME_ID = "camera_infra1_optical_frame"; 78 | const std::string DEFAULT_INFRA2_OPTICAL_FRAME_ID = "camera_infra2_optical_frame"; 79 | const std::string DEFAULT_COLOR_OPTICAL_FRAME_ID = "camera_color_optical_frame"; 80 | const std::string DEFAULT_FISHEYE_OPTICAL_FRAME_ID = "camera_fisheye_optical_frame"; 81 | const std::string DEFAULT_ACCEL_OPTICAL_FRAME_ID = "camera_accel_optical_frame"; 82 | const std::string DEFAULT_GYRO_OPTICAL_FRAME_ID = "camera_gyro_optical_frame"; 83 | const std::string DEFAULT_IMU_OPTICAL_FRAME_ID = "camera_imu_optical_frame"; 84 | 85 | const std::string DEFAULT_ALIGNED_DEPTH_TO_COLOR_FRAME_ID = "camera_aligned_depth_to_color_frame"; 86 | const std::string DEFAULT_ALIGNED_DEPTH_TO_INFRA1_FRAME_ID = "camera_aligned_depth_to_infra1_frame"; 87 | const std::string DEFAULT_ALIGNED_DEPTH_TO_INFRA2_FRAME_ID = "camera_aligned_depth_to_infra2_frame"; 88 | const std::string DEFAULT_ALIGNED_DEPTH_TO_FISHEYE_FRAME_ID = 89 | "camera_aligned_depth_to_fisheye_frame"; 90 | 91 | const std::string DEFAULT_UNITE_IMU_METHOD = ""; 92 | const std::string DEFAULT_FILTERS = ""; 93 | const std::string DEFAULT_TOPIC_ODOM_IN = ""; 94 | const std::string DEFAULT_D2C_MODE = "sw"; // sw = software mode, hw=hardware mode, none, 95 | const float ROS_DEPTH_SCALE = 0.001; 96 | const int TIME_FILTER_LENGTH = 10; 97 | 98 | constexpr static uint32_t DABAI_DCW_RGB_PID = 0x0559; 99 | constexpr static uint32_t DABAI_PRO_PID = 0x0655; 100 | constexpr static uint32_t DABAI_MINI_PID = 0x0656; 101 | constexpr static uint32_t DABAI_DC1_PID = 0x0657; 102 | constexpr static uint32_t DABAI_D1_PID = 0x0658; 103 | constexpr static uint32_t DABAI_DCW_DEPTH_PID = 0x0659; 104 | constexpr static uint32_t DABAI_DW_PID = 0x065a; 105 | constexpr static uint32_t DEEYEA_UVC_PID = 0x050b; 106 | constexpr static uint32_t GEMIN_E_UVC_PID = 0x055c; 107 | constexpr static uint32_t GEMINI_E_DEPTH_PID = 0x065c; 108 | constexpr static uint32_t GEMINI_E_LITE_DEPTH_PID = 0x065d; 109 | constexpr static uint32_t DABAI_MAX_PID = 0x069a; 110 | constexpr static uint32_t DABAI_MAX_PRO_PID = 0x069e; 111 | constexpr static uint32_t GEMINI_UW_PID = 0x06aa; 112 | constexpr static uint32_t ASTRA_PRO_DEPTH_PID = 0x0403; 113 | constexpr static uint32_t DABAI_DCW2_DEPTH_PID = 0x06a0; 114 | constexpr static uint32_t DABAI_DW2_DEPTH_PID = 0x069f; 115 | const std::string OB_STEREO_S = "Orbbec Canglong"; 116 | const std::string OB_EMBEDDED_S = "Astra SL1000S_U3"; 117 | const std::string OB_STEREO_S_U3 = "Astra SV1301S_U3"; 118 | const std::string OB_ASTRA_PRO = "Orbbec Astra Pro"; 119 | const std::string OB_ASTRA_PRO_PLUS = "Orbbec Astra Pro Plus"; 120 | const std::string OB_DABAI = "Orbbec Dabai"; 121 | const std::string OB_ASTRA_PLUS = "Orbbec Astra+"; 122 | const std::string OB_ASTRA_PLUS_S = "Orbbec Astra+_S"; 123 | const std::string OB_DABAI_PRO = "Orbbec Astra DaBai Pro"; 124 | const std::string OB_DABAI_DCW = "Orbbec DaBai DCW"; 125 | const std::string OB_DABAI_DW = "Orbbec DaBai DW"; 126 | const std::string DEFAULT_LOCK_FILE = "astra_device.lock"; 127 | const key_t DEFAULT_SEM_KEY = 0x0401; 128 | 129 | } // namespace astra_camera 130 | -------------------------------------------------------------------------------- /include/astra_camera/d2c_viewer.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* Copyright (c) 2013-2022 Orbbec 3D Technology, Inc */ 4 | /* */ 5 | /* PROPRIETARY RIGHTS of Orbbec 3D Technology are involved in the */ 6 | /* subject matter of this material. All manufacturing, reproduction, use, */ 7 | /* and sales rights pertaining to this subject matter are governed by the */ 8 | /* license agreement. The recipient of this software implicitly accepts */ 9 | /* the terms of the license. */ 10 | /* */ 11 | /**************************************************************************/ 12 | 13 | #pragma once 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #include "types.h" 21 | #include "utils.h" 22 | 23 | namespace astra_camera { 24 | class D2CViewer { 25 | public: 26 | D2CViewer(ros::NodeHandle& nh, ros::NodeHandle& nh_private); 27 | ~D2CViewer(); 28 | 29 | void messageCallback(const sensor_msgs::ImageConstPtr& rgb_msg, 30 | const sensor_msgs::ImageConstPtr& depth_msg); 31 | private: 32 | ros::NodeHandle nh_; 33 | ros::NodeHandle nh_private_; 34 | message_filters::Subscriber rgb_sub_; 35 | message_filters::Subscriber depth_sub_; 36 | using MySyncPolicy = message_filters::sync_policies::ApproximateTime; 37 | std::unique_ptr> sync_; 38 | ros::Publisher d2c_pub_; 39 | }; 40 | } // namespace astra_camera 41 | -------------------------------------------------------------------------------- /include/astra_camera/ob_camera_node_factory.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************/ 2 | /* */ 3 | /* Copyright (c) 2013-2022 Orbbec 3D Technology, Inc */ 4 | /* */ 5 | /* PROPRIETARY RIGHTS of Orbbec 3D Technology are involved in the */ 6 | /* subject matter of this material. All manufacturing, reproduction, use, */ 7 | /* and sales rights pertaining to this subject matter are governed by the */ 8 | /* license agreement. The recipient of this software implicitly accepts */ 9 | /* the terms of the license. */ 10 | /* */ 11 | /**************************************************************************/ 12 | #pragma once 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include "ob_camera_node.h" 27 | #include "ob_context.h" 28 | #include "std_msgs/Empty.h" 29 | #include "uvc_camera_driver.h" 30 | #include 31 | namespace astra_camera { 32 | class OBCameraNodeFactory { 33 | public: 34 | explicit OBCameraNodeFactory(ros::NodeHandle& nh, ros::NodeHandle& nh_private); 35 | 36 | ~OBCameraNodeFactory(); 37 | 38 | private: 39 | void init(); 40 | 41 | void startDevice(const std::shared_ptr& device, 42 | const openni::DeviceInfo* device_info); 43 | 44 | void onDeviceConnected(const openni::DeviceInfo* device_info); 45 | 46 | void onDeviceDisconnected(const openni::DeviceInfo* device_info); 47 | 48 | void checkConnectionTimer(); 49 | 50 | static OniLogSeverity getLogLevelFromString(const std::string& level); 51 | 52 | void queryDevice(); 53 | 54 | private: 55 | ros::NodeHandle nh_; 56 | ros::NodeHandle nh_private_; 57 | std::atomic_bool is_alive_{false}; 58 | std::unique_ptr ob_camera_node_ = nullptr; 59 | std::shared_ptr device_ = nullptr; 60 | std::shared_ptr device_info_ = nullptr; 61 | std::unique_ptr reconfigure_ = nullptr; 62 | bool use_uvc_camera_ = false; 63 | UVCCameraConfig uvc_config_; 64 | std::unique_ptr context_ = nullptr; 65 | std::string serial_number_; 66 | std::string device_type_; 67 | std::string device_uri_; 68 | ros::WallTimer check_connection_timer_; 69 | std::atomic_bool device_connected_{false}; 70 | std::atomic_bool has_exception_{false}; 71 | size_t device_num_ = 1; 72 | long connection_delay_ = 100; 73 | std::string oni_log_level_str_ = "none"; 74 | bool oni_log_to_console_ = false; 75 | bool oni_log_to_file_ = false; 76 | std::recursive_mutex device_lock_; 77 | std::unique_ptr query_device_thread_ = nullptr; 78 | pthread_mutex_t* astra_device_lock_ = nullptr; 79 | pthread_mutexattr_t astra_device_lock_attr_; 80 | uint8_t* astra_device_lock_shm_ptr_ = nullptr; 81 | int astra_device_lock_shm_id_ = -1; 82 | static backward::SignalHandling sh; 83 | }; 84 | } // namespace astra_camera 85 | -------------------------------------------------------------------------------- /include/astra_camera/ob_context.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* Copyright (c) 2013-2022 Orbbec 3D Technology, Inc */ 4 | /* */ 5 | /* PROPRIETARY RIGHTS of Orbbec 3D Technology are involved in the */ 6 | /* subject matter of this material. All manufacturing, reproduction, use, */ 7 | /* and sales rights pertaining to this subject matter are governed by the */ 8 | /* license agreement. The recipient of this software implicitly accepts */ 9 | /* the terms of the license. */ 10 | /* */ 11 | /**************************************************************************/ 12 | #pragma once 13 | #include 14 | #include 15 | #include 16 | 17 | namespace astra_camera { 18 | 19 | using DeviceConnectedCb = std::function; 20 | 21 | using DeviceDisconnectedCb = std::function; 22 | 23 | class Context : public openni::OpenNI::DeviceConnectedListener, 24 | public openni::OpenNI::DeviceDisconnectedListener, 25 | public openni::OpenNI::DeviceStateChangedListener { 26 | public: 27 | explicit Context(DeviceDisconnectedCb device_disconnected_cb); 28 | 29 | ~Context() override; 30 | 31 | void onDeviceStateChanged(const openni::DeviceInfo* pInfo, openni::DeviceState state) override; 32 | 33 | void onDeviceConnected(const openni::DeviceInfo* pInfo) override; 34 | 35 | void onDeviceDisconnected(const openni::DeviceInfo* pInfo) override; 36 | 37 | std::vector queryDeviceList(); 38 | 39 | private: 40 | std::recursive_mutex mutex_; 41 | bool first_time_query_ = true; 42 | DeviceDisconnectedCb device_disconnected_cb_; 43 | std::map device_info_list_; 44 | }; 45 | 46 | } // namespace astra_camera 47 | -------------------------------------------------------------------------------- /include/astra_camera/point_cloud_proc/depth_conversions.h: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | * Software License Agreement (BSD License) 3 | * 4 | * Copyright (c) 2008, Willow Garage, Inc. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following 15 | * disclaimer in the documentation and/or other materials provided 16 | * with the distribution. 17 | * * Neither the name of the Willow Garage nor the names of its 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 31 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | * POSSIBILITY OF SUCH DAMAGE. 33 | *********************************************************************/ 34 | #pragma once 35 | #include 36 | #include 37 | #include 38 | 39 | #include 40 | 41 | #include "depth_traits.h" 42 | 43 | namespace astra_camera { 44 | using PointCloud2 = sensor_msgs::PointCloud2; 45 | 46 | // Handles float or uint16 depths 47 | template 48 | inline void convert(const sensor_msgs::ImageConstPtr& depth_msg, PointCloud2::Ptr& cloud_msg, 49 | const image_geometry::PinholeCameraModel& model, double range_max = 0.0) { 50 | // Use correct principal point from calibration 51 | float center_x = model.cx(); 52 | float center_y = model.cy(); 53 | 54 | // Combine unit conversion (if necessary) with scaling by focal length for computing (X,Y) 55 | double unit_scaling = DepthTraits::toMeters(T(1)); 56 | float constant_x = unit_scaling / model.fx(); 57 | float constant_y = unit_scaling / model.fy(); 58 | float bad_point = std::numeric_limits::quiet_NaN(); 59 | 60 | sensor_msgs::PointCloud2Iterator iter_x(*cloud_msg, "x"); 61 | sensor_msgs::PointCloud2Iterator iter_y(*cloud_msg, "y"); 62 | sensor_msgs::PointCloud2Iterator iter_z(*cloud_msg, "z"); 63 | const T* depth_row = reinterpret_cast(&depth_msg->data[0]); 64 | int row_step = depth_msg->step / sizeof(T); 65 | for (int v = 0; v < (int)cloud_msg->height; ++v, depth_row += row_step) { 66 | for (int u = 0; u < (int)cloud_msg->width; ++u, ++iter_x, ++iter_y, ++iter_z) { 67 | T depth = depth_row[u]; 68 | 69 | // Missing points denoted by NaNs 70 | if (!DepthTraits::valid(depth)) { 71 | if (range_max != 0.0) { 72 | depth = DepthTraits::fromMeters(range_max); 73 | } else { 74 | *iter_x = *iter_y = *iter_z = bad_point; 75 | continue; 76 | } 77 | } 78 | 79 | // Fill in XYZ 80 | *iter_x = (u - center_x) * depth * constant_x; 81 | *iter_y = (v - center_y) * depth * constant_y; 82 | *iter_z = DepthTraits::toMeters(depth); 83 | } 84 | } 85 | } 86 | } // namespace astra_camera 87 | -------------------------------------------------------------------------------- /include/astra_camera/point_cloud_proc/depth_traits.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2008, Willow Garage, Inc. 2 | // All rights reserved. 3 | // 4 | // Software License Agreement (BSD License 2.0) 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions 8 | // are met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following 14 | // disclaimer in the documentation and/or other materials provided 15 | // with the distribution. 16 | // * Neither the name of the Willow Garage nor the names of its 17 | // contributors may be used to endorse or promote products derived 18 | // from this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 30 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | // POSSIBILITY OF SUCH DAMAGE. 32 | #pragma once 33 | 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | 40 | namespace astra_camera { 41 | 42 | // Encapsulate differences between processing float and uint16_t depths 43 | template 44 | struct DepthTraits {}; 45 | 46 | template <> 47 | struct DepthTraits { 48 | static inline bool valid(uint16_t depth) { return depth != 0; } 49 | static inline float toMeters(uint16_t depth) { 50 | return static_cast(depth) * 0.001f; 51 | } // originally mm 52 | static inline uint16_t fromMeters(float depth) { return std::lround(depth * 1000.0f); } 53 | // Do nothing - already zero-filled 54 | static inline void initializeBuffer(std::vector &buffer) { (void)buffer; } 55 | }; 56 | 57 | template <> 58 | struct DepthTraits { 59 | static inline bool valid(float depth) { return std::isfinite(depth); } 60 | static inline float toMeters(float depth) { return depth; } 61 | static inline float fromMeters(float depth) { return depth; } 62 | 63 | static inline void initializeBuffer(std::vector &buffer) { 64 | auto start = reinterpret_cast(&buffer[0]); 65 | auto end = reinterpret_cast(&buffer[0] + buffer.size()); 66 | std::fill(start, end, std::numeric_limits::quiet_NaN()); 67 | } 68 | }; 69 | 70 | } // namespace astra_camera 71 | -------------------------------------------------------------------------------- /include/astra_camera/point_cloud_proc/point_cloud_proc.h: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | * Software License Agreement (BSD License) 3 | * 4 | * Copyright (c) 2008, Willow Garage, Inc. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following 15 | * disclaimer in the documentation and/or other materials provided 16 | * with the distribution. 17 | * * Neither the name of the Willow Garage nor the names of its 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 31 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | * POSSIBILITY OF SUCH DAMAGE. 33 | *********************************************************************/ 34 | 35 | #pragma once 36 | #include "point_cloud_xyz.h" 37 | #include "point_cloud_xyzrgb.h" 38 | -------------------------------------------------------------------------------- /include/astra_camera/point_cloud_proc/point_cloud_xyz.h: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | * Software License Agreement (BSD License) 3 | * 4 | * Copyright (c) 2008, Willow Garage, Inc. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following 15 | * disclaimer in the documentation and/or other materials provided 16 | * with the distribution. 17 | * * Neither the name of the Willow Garage nor the names of its 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 31 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | * POSSIBILITY OF SUCH DAMAGE. 33 | *********************************************************************/ 34 | #pragma once 35 | 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | 50 | #include 51 | 52 | #include "depth_conversions.h" 53 | #include "depth_traits.h" 54 | 55 | #include "astra_camera/utils.h" 56 | #include "astra_camera/types.h" 57 | 58 | namespace astra_camera { 59 | using namespace message_filters::sync_policies; 60 | namespace enc = sensor_msgs::image_encodings; 61 | using PointCloud2 = sensor_msgs::PointCloud2; 62 | 63 | class PointCloudXyzNode { 64 | public: 65 | PointCloudXyzNode(ros::NodeHandle& nh, ros::NodeHandle& nh_private); 66 | ~PointCloudXyzNode(); 67 | 68 | private: 69 | void connectCb(); 70 | void disconnectCb(); 71 | 72 | void depthCb(const sensor_msgs::ImageConstPtr& depth_msg, 73 | const sensor_msgs::CameraInfoConstPtr& info_msg); 74 | 75 | bool SavePointCloudXyzCallback(std_srvs::Empty::Request& request, 76 | std_srvs::Empty::Response& response); 77 | 78 | private: 79 | ros::NodeHandle nh_; 80 | ros::NodeHandle nh_private_; 81 | std::shared_ptr it_; 82 | image_transport::CameraSubscriber sub_depth_; 83 | ros::ServiceServer save_point_cloud_srv_; 84 | std::atomic_bool save_cloud_{false}; 85 | int queue_size_ = 5; 86 | 87 | // Publications 88 | std::mutex connect_mutex_; 89 | ros::Publisher pub_point_cloud_; 90 | 91 | image_geometry::PinholeCameraModel model_; 92 | }; 93 | } // namespace astra_camera 94 | -------------------------------------------------------------------------------- /include/astra_camera/point_cloud_proc/point_cloud_xyzrgb.h: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | * Software License Agreement (BSD License) 3 | * 4 | * Copyright (c) 2008, Willow Garage, Inc. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following 15 | * disclaimer in the documentation and/or other materials provided 16 | * with the distribution. 17 | * * Neither the name of the Willow Garage nor the names of its 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 31 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | * POSSIBILITY OF SUCH DAMAGE. 33 | *********************************************************************/ 34 | #pragma once 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | 49 | #include 50 | 51 | #include "depth_traits.h" 52 | #include "astra_camera/utils.h" 53 | #include "astra_camera/types.h" 54 | 55 | 56 | namespace astra_camera { 57 | using namespace message_filters::sync_policies; 58 | namespace enc = sensor_msgs::image_encodings; 59 | using PointCloud2 = sensor_msgs::PointCloud2; 60 | 61 | class PointCloudXyzrgbNode { 62 | public: 63 | PointCloudXyzrgbNode(ros::NodeHandle& nh, ros::NodeHandle& nh_private); 64 | 65 | ~PointCloudXyzrgbNode(); 66 | 67 | private: 68 | void connectCb(); 69 | 70 | void disconnectCb(); 71 | 72 | void imageCb(const sensor_msgs::ImageConstPtr& depth_msg, 73 | const sensor_msgs::ImageConstPtr& rgb_msg, 74 | const sensor_msgs::CameraInfoConstPtr& info_msg); 75 | bool SavePointCloudXyzrgbCallback(std_srvs::Empty::Request& request, 76 | std_srvs::Empty::Response& response); 77 | 78 | template 79 | void convert(const sensor_msgs::ImageConstPtr& depth_msg, 80 | const sensor_msgs::ImageConstPtr& rgb_msg, const PointCloud2::Ptr& cloud_msg, 81 | int red_offset, int green_offset, int blue_offset, int color_step); 82 | 83 | private: 84 | ros::NodeHandle nh_; 85 | ros::NodeHandle nh_private_; 86 | ros::NodeHandlePtr rgb_nh_; 87 | boost::shared_ptr rgb_it_, depth_it_; 88 | 89 | // Subscriptions 90 | image_transport::SubscriberFilter sub_depth_, sub_rgb_; 91 | message_filters::Subscriber sub_info_; 92 | typedef ApproximateTime 93 | SyncPolicy; 94 | typedef ExactTime 95 | ExactSyncPolicy; 96 | typedef message_filters::Synchronizer Synchronizer; 97 | typedef message_filters::Synchronizer ExactSynchronizer; 98 | std::shared_ptr sync_; 99 | std::shared_ptr exact_sync_; 100 | ros::ServiceServer save_point_cloud_srv_; 101 | std::atomic_bool save_cloud_{false}; 102 | 103 | // Publications 104 | std::mutex connect_mutex_; 105 | typedef sensor_msgs::PointCloud2 PointCloud; 106 | ros::Publisher pub_point_cloud_; 107 | 108 | image_geometry::PinholeCameraModel model_; 109 | }; 110 | } // namespace astra_camera 111 | -------------------------------------------------------------------------------- /include/astra_camera/types.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************/ 2 | /* Copyright (c) 2013-2022 Orbbec 3D Technology, Inc */ 3 | /* */ 4 | /* PROPRIETARY RIGHTS of Orbbec 3D Technology are involved in the */ 5 | /* subject matter of this material. All manufacturing, reproduction, use, */ 6 | /* and sales rights pertaining to this subject matter are governed by the */ 7 | /* license agreement. The recipient of this software implicitly accepts */ 8 | /* the terms of the license. */ 9 | /* */ 10 | /**************************************************************************/ 11 | #pragma once 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include "astra_camera/DeviceInfo.h" 25 | #include "astra_camera/Extrinsics.h" 26 | #include "astra_camera/GetBool.h" 27 | #include "astra_camera/GetCameraInfo.h" 28 | #include "astra_camera/GetDeviceInfo.h" 29 | #include "astra_camera/GetDouble.h" 30 | #include "astra_camera/GetInt32.h" 31 | #include "astra_camera/GetString.h" 32 | #include "astra_camera/Metadata.h" 33 | #include "astra_camera/SetInt32.h" 34 | #include "std_srvs/SetBool.h" 35 | #include "std_srvs/Empty.h" 36 | #include "astra_camera/SetString.h" 37 | #include "astra_camera/GetCameraParams.h" 38 | #include "std_msgs/Empty.h" 39 | #include "json.hpp" 40 | 41 | namespace astra_camera { 42 | using FrameCallbackFunction = std::function; 43 | using stream_index_pair = std::pair; 44 | 45 | const stream_index_pair COLOR{openni::SENSOR_COLOR, 0}; 46 | const stream_index_pair DEPTH{openni::SENSOR_DEPTH, 0}; 47 | const stream_index_pair INFRA1{openni::SENSOR_IR, 0}; 48 | const stream_index_pair INFRA2{openni::SENSOR_IR, 1}; 49 | 50 | const std::vector IMAGE_STREAMS = {DEPTH, INFRA1, COLOR}; 51 | 52 | typedef enum { 53 | RGBResolution4_3 = 0, // 4:3分辨率 如:640x480 54 | RGBResolution16_9 = 1, // 16:9分辨率 如:1920x1280 55 | } RgbResolution; 56 | 57 | struct ImageROI { 58 | int x = -1; 59 | int y = -1; 60 | int width = -1; 61 | int height = -1; 62 | }; 63 | 64 | enum class MultiDeviceSyncMode { 65 | None = 0, // 不同步 66 | Master = 1, 67 | Slave = 2, 68 | }; 69 | 70 | } // namespace astra_camera 71 | -------------------------------------------------------------------------------- /include/astra_camera/utils.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************/ 2 | /* */ 3 | /* Copyright (c) 2013-2022 Orbbec 3D Technology, Inc */ 4 | /* */ 5 | /* PROPRIETARY RIGHTS of Orbbec 3D Technology are involved in the */ 6 | /* subject matter of this material. All manufacturing, reproduction, use, */ 7 | /* and sales rights pertaining to this subject matter are governed by the */ 8 | /* license agreement. The recipient of this software implicitly accepts */ 9 | /* the terms of the license. */ 10 | /* */ 11 | /**************************************************************************/ 12 | #pragma once 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #include "astra_camera/Extrinsics.h" 25 | #include "constants.h" 26 | #include "types.h" 27 | 28 | 29 | namespace astra_camera { 30 | inline void LogFatal(const char *file, int line, const std::string &message) { 31 | std::cerr << "Check failed at " << file << ":" << line << ": " << message << std::endl; 32 | std::abort(); 33 | } 34 | } // namespace orbbec_camera 35 | 36 | // Macros for checking conditions and comparing values 37 | #define CHECK(condition) \ 38 | (!(condition) ? LogFatal(__FILE__, __LINE__, "Check failed: " #condition) : (void)0) 39 | 40 | template 41 | void CheckOp(const char *expr, const char *file, int line, T1 val1, T2 val2, bool result) { 42 | if (!result) { 43 | std::ostringstream os; 44 | os << "Check failed: " << expr << " (" << val1 << " vs. " << val2 << ")"; 45 | astra_camera::LogFatal(file, line, os.str()); 46 | } 47 | } 48 | 49 | #define CHECK_OP(opname, op, val1, val2) \ 50 | CheckOp(#val1 " " #op " " #val2, __FILE__, __LINE__, val1, val2, (val1)op(val2)) 51 | 52 | #define CHECK_EQ(val1, val2) CHECK_OP(_EQ, ==, val1, val2) 53 | #define CHECK_NE(val1, val2) CHECK_OP(_NE, !=, val1, val2) 54 | #define CHECK_LE(val1, val2) CHECK_OP(_LE, <=, val1, val2) 55 | #define CHECK_LT(val1, val2) CHECK_OP(_LT, <, val1, val2) 56 | #define CHECK_GE(val1, val2) CHECK_OP(_GE, >=, val1, val2) 57 | #define CHECK_GT(val1, val2) CHECK_OP(_GT, >, val1, val2) 58 | 59 | // Overload for raw pointers 60 | template 61 | T *CheckNotNull(T *ptr, const char *file, int line) { 62 | if (ptr == nullptr) { 63 | std::ostringstream os; 64 | os << "Null pointer passed to CheckNotNull at " << file << ":" << line; 65 | astra_camera::LogFatal(file, line, os.str()); 66 | } 67 | return ptr; 68 | } 69 | 70 | // Template for smart pointers like std::shared_ptr, std::unique_ptr 71 | template 72 | T &CheckNotNull(T &ptr, const char *file, int line) { 73 | if (ptr == nullptr) { 74 | std::ostringstream os; 75 | os << "Null pointer passed to CheckNotNull at " << file << ":" << line; 76 | astra_camera::LogFatal(file, line, os.str()); 77 | } 78 | return ptr; 79 | } 80 | 81 | #if defined(CHECK_NOTNULL) 82 | #undef CHECK_NOTNULL 83 | #endif 84 | #define CHECK_NOTNULL(val) CheckNotNull(val, __FILE__, __LINE__) 85 | 86 | namespace astra_camera { 87 | bool operator==(const openni::VideoMode &lhs, const openni::VideoMode &rhs); 88 | 89 | bool operator!=(const openni::VideoMode &lhs, const openni::VideoMode &rhs); 90 | 91 | std::ostream &operator<<(std::ostream &os, const openni::VideoMode &video_mode); 92 | 93 | tf2::Quaternion rotationMatrixToQuaternion(const std::vector &rotation); 94 | 95 | Extrinsics obExtrinsicsToMsg(const std::vector &rotation, const std::vector &transition, 96 | const std::string &frame_id); 97 | 98 | 99 | bool isValidCameraParams(const OBCameraParams ¶ms); 100 | 101 | void cameraParameterPrinter(const std::vector &rotation, 102 | const std::vector &transition); 103 | 104 | std::string PixelFormatToString(const openni::PixelFormat &format); 105 | 106 | void savePointToPly(sensor_msgs::PointCloud2::Ptr cloud, const std::string &filename); 107 | 108 | void saveRGBPointToPly(sensor_msgs::PointCloud2::Ptr cloud, const std::string &filename); 109 | 110 | MultiDeviceSyncMode getMultiDeviceSyncMode(const std::string &mode); 111 | 112 | 113 | } // namespace astra_camera 114 | -------------------------------------------------------------------------------- /include/openni2/Android-Arm/OniPlatformAndroid-Arm.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * * 3 | * OpenNI 2.x Alpha * 4 | * Copyright (C) 2012 PrimeSense Ltd. * 5 | * * 6 | * This file is part of OpenNI. * 7 | * * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); * 9 | * you may not use this file except in compliance with the License. * 10 | * You may obtain a copy of the License at * 11 | * * 12 | * http://www.apache.org/licenses/LICENSE-2.0 * 13 | * * 14 | * Unless required by applicable law or agreed to in writing, software * 15 | * distributed under the License is distributed on an "AS IS" BASIS, * 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 17 | * See the License for the specific language governing permissions and * 18 | * limitations under the License. * 19 | * * 20 | *****************************************************************************/ 21 | #ifndef ONIPLATFORMANDROID_ARM_H 22 | #define ONIPLATFORMANDROID_ARM_H 23 | 24 | // Start with Linux-x86, and override what's different 25 | #include "../Linux-x86/OniPlatformLinux-x86.h" 26 | 27 | //--------------------------------------------------------------------------- 28 | // Platform Basic Definition 29 | //--------------------------------------------------------------------------- 30 | #undef ONI_PLATFORM 31 | #undef ONI_PLATFORM_STRING 32 | 33 | #define ONI_PLATFORM ONI_PLATFORM_ANDROID_ARM 34 | #define ONI_PLATFORM_STRING "Android-Arm" 35 | 36 | #ifdef HAVE_ANDROID_OS 37 | #define ONI_PLATFORM_ANDROID_OS 38 | 39 | #undef ONI_PLATFORM_STRING 40 | #define ONI_PLATFORM_STRING "AndroidOS-Arm" 41 | #endif 42 | 43 | #endif // ONIPLATFORMANDROID_ARM_H 44 | -------------------------------------------------------------------------------- /include/openni2/Driver/OniDriverTypes.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * * 3 | * OpenNI 2.x Alpha * 4 | * Copyright (C) 2012 PrimeSense Ltd. * 5 | * * 6 | * This file is part of OpenNI. * 7 | * * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); * 9 | * you may not use this file except in compliance with the License. * 10 | * You may obtain a copy of the License at * 11 | * * 12 | * http://www.apache.org/licenses/LICENSE-2.0 * 13 | * * 14 | * Unless required by applicable law or agreed to in writing, software * 15 | * distributed under the License is distributed on an "AS IS" BASIS, * 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 17 | * See the License for the specific language governing permissions and * 18 | * limitations under the License. * 19 | * * 20 | *****************************************************************************/ 21 | #ifndef ONIDRIVERTYPES_H 22 | #define ONIDRIVERTYPES_H 23 | 24 | #include 25 | #include 26 | 27 | #define ONI_STREAM_PROPERTY_PRIVATE_BASE XN_MAX_UINT16 28 | 29 | typedef struct 30 | { 31 | int dataSize; 32 | void* data; 33 | } OniGeneralBuffer; 34 | 35 | /////// DriverServices 36 | struct OniDriverServices 37 | { 38 | void* driverServices; 39 | void (ONI_CALLBACK_TYPE* errorLoggerAppend)(void* driverServices, const char* format, va_list args); 40 | void (ONI_CALLBACK_TYPE* errorLoggerClear)(void* driverServices); 41 | void (ONI_CALLBACK_TYPE* log)(void* driverServices, int severity, const char* file, int line, const char* mask, const char* message); 42 | }; 43 | 44 | struct OniStreamServices 45 | { 46 | void* streamServices; 47 | int (ONI_CALLBACK_TYPE* getDefaultRequiredFrameSize)(void* streamServices); 48 | OniFrame* (ONI_CALLBACK_TYPE* acquireFrame)(void* streamServices); // returns a frame with size corresponding to getRequiredFrameSize() 49 | void (ONI_CALLBACK_TYPE* addFrameRef)(void* streamServices, OniFrame* pframe); 50 | void (ONI_CALLBACK_TYPE* releaseFrame)(void* streamServices, OniFrame* pframe); 51 | }; 52 | 53 | 54 | #endif // ONIDRIVERTYPES_H 55 | -------------------------------------------------------------------------------- /include/openni2/KinectProperties.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * * 3 | * OpenNI 2.x Alpha * 4 | * Copyright (C) 2012 PrimeSense Ltd. * 5 | * * 6 | * This file is part of OpenNI. * 7 | * * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); * 9 | * you may not use this file except in compliance with the License. * 10 | * You may obtain a copy of the License at * 11 | * * 12 | * http://www.apache.org/licenses/LICENSE-2.0 * 13 | * * 14 | * Unless required by applicable law or agreed to in writing, software * 15 | * distributed under the License is distributed on an "AS IS" BASIS, * 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 17 | * See the License for the specific language governing permissions and * 18 | * limitations under the License. * 19 | * * 20 | *****************************************************************************/ 21 | #ifndef KINECTPROPERTIES_H 22 | #define KINECTPROPERTIES_H 23 | 24 | #include 25 | 26 | /* 27 | * private properties of Microsoft Kinect devices. 28 | * 29 | * @remarks 30 | * properties structure is 0x045eXXYY (045e = Microsoft's USB vendor ID) 31 | * where XX is range and YY is code. 32 | * range values: 33 | * 00 - common stream properties 34 | * 10 - depth stream properties 35 | * 20 - color stream properties 36 | * E0 - device commands 37 | * F0 - device properties 38 | */ 39 | enum 40 | { 41 | KINECT_PROPERTY_BASE = 0x045e0000, 42 | 43 | /*******************************************************************/ 44 | /* Common stream properties (00-) */ 45 | /*******************************************************************/ 46 | 47 | /*******************************************************************/ 48 | /* Depth stream properties (10-) */ 49 | /*******************************************************************/ 50 | 51 | /** OniBool, set and get. 52 | * Maps to Near Mode in Kinect SDK. 53 | * Also maps to XN_STREAM_PROPERTY_CLOSE_RANGE in PS1080.h. 54 | */ 55 | KINECT_DEPTH_PROPERTY_CLOSE_RANGE = KINECT_PROPERTY_BASE + 0x1001, 56 | 57 | /*******************************************************************/ 58 | /* Color stream properties (20-) */ 59 | /*******************************************************************/ 60 | 61 | /*******************************************************************/ 62 | /* Device commands (E0-) */ 63 | /*******************************************************************/ 64 | 65 | /*******************************************************************/ 66 | /* Device properties (F0-) */ 67 | /*******************************************************************/ 68 | 69 | /* 3D sensing properties (F0-) */ 70 | 71 | /** OniBool, set and get. 72 | * Maps to !NuiGetForceInfraredEmitterOff in Kinect SDK. 73 | * Also maps to XN_MODULE_PROPERTY_EMITTER_STATE. 74 | */ 75 | KINECT_DEVICE_PROPERTY_EMITTER_STATE = KINECT_PROPERTY_BASE + 0xF001, 76 | 77 | /* Non- 3D sensing bonus properties (F8) */ 78 | 79 | /** long, set and get. 80 | * Maps to NuiCameraElevationGetAngle and NuiCameraElevationSetAngle in Kinect SDK. 81 | */ 82 | KINECT_DEVICE_PROPERTY_CAMERA_ELEVATION = KINECT_PROPERTY_BASE + 0xF801, 83 | 84 | /** KinectVector3f, get only. 85 | * Maps to NuiAccelerometerGetCurrentReading. 86 | */ 87 | KINECT_DEVICE_PROPERTY_ACCELEROMETER = KINECT_PROPERTY_BASE + 0xF802, 88 | 89 | /** String, get only. 90 | * Maps to NuiAudioArrayId. 91 | * Useful to find the mic array on the sensor when developing audio-enabled applications. 92 | */ 93 | KINECT_DEVICE_PROPERTY_AUDIO_ARRAY_ID = KINECT_PROPERTY_BASE + 0xF803, 94 | 95 | }; 96 | 97 | typedef struct 98 | { 99 | float x; 100 | float y; 101 | float z; 102 | } KinectVector3f; 103 | 104 | #endif // KINECTPROPERTIES_H 105 | -------------------------------------------------------------------------------- /include/openni2/Linux-Arm/OniPlatformLinux-Arm.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * * 3 | * OpenNI 2.x Alpha * 4 | * Copyright (C) 2012 PrimeSense Ltd. * 5 | * * 6 | * This file is part of OpenNI. * 7 | * * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); * 9 | * you may not use this file except in compliance with the License. * 10 | * You may obtain a copy of the License at * 11 | * * 12 | * http://www.apache.org/licenses/LICENSE-2.0 * 13 | * * 14 | * Unless required by applicable law or agreed to in writing, software * 15 | * distributed under the License is distributed on an "AS IS" BASIS, * 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 17 | * See the License for the specific language governing permissions and * 18 | * limitations under the License. * 19 | * * 20 | *****************************************************************************/ 21 | #ifndef ONIPLATFORMLINUX_ARM_H 22 | #define ONIPLATFORMLINUX_ARM_H 23 | 24 | // Start with Linux-x86, and override what's different 25 | #include "../Linux-x86/OniPlatformLinux-x86.h" 26 | 27 | //--------------------------------------------------------------------------- 28 | // Platform Basic Definition 29 | //--------------------------------------------------------------------------- 30 | #undef ONI_PLATFORM 31 | #undef ONI_PLATFORM_STRING 32 | #define ONI_PLATFORM ONI_PLATFORM_LINUX_ARM 33 | #define ONI_PLATFORM_STRING "Linux-Arm" 34 | 35 | #endif // ONIPLATFORMLINUX_ARM_H 36 | 37 | -------------------------------------------------------------------------------- /include/openni2/Linux-x86/OniPlatformLinux-x86.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * * 3 | * OpenNI 2.x Alpha * 4 | * Copyright (C) 2012 PrimeSense Ltd. * 5 | * * 6 | * This file is part of OpenNI. * 7 | * * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); * 9 | * you may not use this file except in compliance with the License. * 10 | * You may obtain a copy of the License at * 11 | * * 12 | * http://www.apache.org/licenses/LICENSE-2.0 * 13 | * * 14 | * Unless required by applicable law or agreed to in writing, software * 15 | * distributed under the License is distributed on an "AS IS" BASIS, * 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 17 | * See the License for the specific language governing permissions and * 18 | * limitations under the License. * 19 | * * 20 | *****************************************************************************/ 21 | #ifndef ONIPLATFORMLINUX_X86_H 22 | #define ONIPLATFORMLINUX_X86_H 23 | 24 | //--------------------------------------------------------------------------- 25 | // Prerequisites 26 | //--------------------------------------------------------------------------- 27 | 28 | //--------------------------------------------------------------------------- 29 | // Includes 30 | //--------------------------------------------------------------------------- 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | //--------------------------------------------------------------------------- 40 | // Platform Basic Definition 41 | //--------------------------------------------------------------------------- 42 | #define ONI_PLATFORM ONI_PLATFORM_LINUX_X86 43 | #define ONI_PLATFORM_STRING "Linux-x86" 44 | 45 | //--------------------------------------------------------------------------- 46 | // Platform Capabilities 47 | //--------------------------------------------------------------------------- 48 | #define ONI_PLATFORM_ENDIAN_TYPE ONI_PLATFORM_IS_LITTLE_ENDIAN 49 | 50 | #define ONI_PLATFORM_SUPPORTS_DYNAMIC_LIBS 1 51 | 52 | //--------------------------------------------------------------------------- 53 | // Memory 54 | //--------------------------------------------------------------------------- 55 | /** The default memory alignment. */ 56 | #define ONI_DEFAULT_MEM_ALIGN 16 57 | 58 | /** The thread static declarator (using TLS). */ 59 | #define ONI_THREAD_STATIC __thread 60 | 61 | //--------------------------------------------------------------------------- 62 | // Files 63 | //--------------------------------------------------------------------------- 64 | /** The maximum allowed file path size (in bytes). */ 65 | #define ONI_FILE_MAX_PATH 256 66 | 67 | //--------------------------------------------------------------------------- 68 | // Call back 69 | //--------------------------------------------------------------------------- 70 | /** The std call type. */ 71 | #define ONI_STDCALL __stdcall 72 | 73 | /** The call back calling convention. */ 74 | #define ONI_CALLBACK_TYPE 75 | 76 | /** The C and C++ calling convension. */ 77 | #define ONI_C_DECL 78 | 79 | //--------------------------------------------------------------------------- 80 | // Macros 81 | //--------------------------------------------------------------------------- 82 | /** Returns the date and time at compile time. */ 83 | #define ONI_TIMESTAMP __DATE__ " " __TIME__ 84 | 85 | /** Converts n into a pre-processor string. */ 86 | #define ONI_STRINGIFY(n) ONI_STRINGIFY_HELPER(n) 87 | #define ONI_STRINGIFY_HELPER(n) #n 88 | 89 | //--------------------------------------------------------------------------- 90 | // API Export/Import Macros 91 | //--------------------------------------------------------------------------- 92 | /** Indicates an exported shared library function. */ 93 | #define ONI_API_EXPORT __attribute__ ((visibility("default"))) 94 | 95 | /** Indicates an imported shared library function. */ 96 | #define ONI_API_IMPORT 97 | 98 | /** Indicates a deprecated function */ 99 | #define ONI_API_DEPRECATED(msg) __attribute__((warning("This function is deprecated: " msg))) 100 | 101 | #endif // ONIPLATFORMLINUX_X86_H 102 | 103 | -------------------------------------------------------------------------------- /include/openni2/MacOSX/OniPlatformMacOSX.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * * 3 | * OpenNI 2.x Alpha * 4 | * Copyright (C) 2012 PrimeSense Ltd. * 5 | * * 6 | * This file is part of OpenNI. * 7 | * * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); * 9 | * you may not use this file except in compliance with the License. * 10 | * You may obtain a copy of the License at * 11 | * * 12 | * http://www.apache.org/licenses/LICENSE-2.0 * 13 | * * 14 | * Unless required by applicable law or agreed to in writing, software * 15 | * distributed under the License is distributed on an "AS IS" BASIS, * 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 17 | * See the License for the specific language governing permissions and * 18 | * limitations under the License. * 19 | * * 20 | *****************************************************************************/ 21 | #ifndef ONIPLATFORMMACOSX_H 22 | #define ONIPLATFORMMACOSX_H 23 | 24 | // Start with Linux-x86, and override what's different 25 | #include "../Linux-x86/OniPlatformLinux-x86.h" 26 | 27 | #include 28 | 29 | #undef ONI_PLATFORM 30 | #undef ONI_PLATFORM_STRING 31 | #define ONI_PLATFORM ONI_PLATFORM_MACOSX 32 | #define ONI_PLATFORM_STRING "MacOSX" 33 | 34 | #include "TargetConditionals.h" 35 | #if (TARGET_IPHONE_SIMULATOR == 1) || (TARGET_OS_IPHONE == 1) 36 | #define ONI_PLATFORM_IOS 37 | 38 | #undef ONI_PLATFORM_STRING 39 | #define ONI_PLATFORM_STRING "iOS" 40 | #elif TARGET_OS_MAC 41 | #ifdef XN_XCODE_BUILD 42 | #define ONI_PLATFORM_MACOSX_XCODE 43 | 44 | #undef ONI_PLATFORM_STRING 45 | #define ONI_PLATFORM_STRING "MacOSX-Xcode" 46 | #endif 47 | #endif 48 | 49 | #define ONI_PLATFORM_HAS_NO_TIMED_OPS 50 | #define ONI_PLATFORM_HAS_NO_CLOCK_GETTIME 51 | #define ONI_PLATFORM_HAS_NO_SCHED_PARAM 52 | #define ONI_PLATFORM_HAS_BUILTIN_SEMUN 53 | 54 | #undef ONI_THREAD_STATIC 55 | #define ONI_THREAD_STATIC 56 | 57 | #endif // ONIPLATFORMMACOSX_H 58 | -------------------------------------------------------------------------------- /include/openni2/OniCEnums.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * * 3 | * OpenNI 2.x Alpha * 4 | * Copyright (C) 2012 PrimeSense Ltd. * 5 | * * 6 | * This file is part of OpenNI. * 7 | * * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); * 9 | * you may not use this file except in compliance with the License. * 10 | * You may obtain a copy of the License at * 11 | * * 12 | * http://www.apache.org/licenses/LICENSE-2.0 * 13 | * * 14 | * Unless required by applicable law or agreed to in writing, software * 15 | * distributed under the License is distributed on an "AS IS" BASIS, * 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 17 | * See the License for the specific language governing permissions and * 18 | * limitations under the License. * 19 | * * 20 | *****************************************************************************/ 21 | #ifndef ONICENUMS_H 22 | #define ONICENUMS_H 23 | 24 | /** Possible failure values */ 25 | typedef enum 26 | { 27 | ONI_STATUS_OK = 0, 28 | ONI_STATUS_ERROR = 1, 29 | ONI_STATUS_NOT_IMPLEMENTED = 2, 30 | ONI_STATUS_NOT_SUPPORTED = 3, 31 | ONI_STATUS_BAD_PARAMETER = 4, 32 | ONI_STATUS_OUT_OF_FLOW = 5, 33 | ONI_STATUS_NO_DEVICE = 6, 34 | ONI_STATUS_NOT_WRITE_PUBLIC_KEY = 7, 35 | ONI_STATUS_PUBLIC_KEY_MD5_VERIFY_FAILED = 8, 36 | ONI_STATUS_NOT_WRITE_MD5 =9, 37 | ONI_STATUS_RSKEY_VERIFY_FAILED = 10, 38 | 39 | //New add 40 | ONI_STATUS_DEVICE_IS_ALREADY_OPENED = 0x1001, //Device is already opened 41 | ONI_STATUS_USB_DRIVER_NOT_FOUND = 0x1002, //USB driver not found,for windows! 42 | ONI_STATUS_USB_DEVICE_NOT_FOUND = 0x1003, //USB device not found,for windows and linux 43 | ONI_STATUS_USB_GET_DRIVER_VERSION = 0x1004, //Failed to get the USB driver version,for windows! 44 | ONI_STATUS_USB_GET_SPEED_FAILED = 0x1005, //Failed to get the device speed,for windows! 45 | ONI_STATUS_USB_SET_INTERFACE_FAILED = 0x1006, //Failed to set USB interface! 46 | ONI_STATUS_USB_DEVICE_OPEN_FAILED = 0x1007, //pid,vid,bus id is zero,for linux 47 | ONI_STATUS_USB_ENUMERATE_FAILED = 0x1008, //USB enum fail,for linux 48 | ONI_STATUS_USB_SET_CONFIG_FAILED = 0x1009, //usb set config fail ,for linux 49 | ONI_STATUS_USB_INIT_FAILED = 0x1010, //libusb open fail 50 | ONI_STATUS_LIBUSB_ERROR_NO_MEM = 0x1011, //Insufficient memory 51 | ONI_STATUS_LIBUSB_ERROR_ACCESS = 0x1012, //Access denied (insufficient permissions) 52 | ONI_STATUS_LIBUSB_ERROR_NO_DEVICE = 0x1013, //No such device (it may have been disconnected) 53 | ONI_STATUS_LIBUSB_ERROR_IO = 0x1014, //Input/output error 54 | ONI_STATUS_LIBUSB_ERROR_NOT_FOUND = 0x1015, //Entity not found 55 | ONI_STATUS_LIBUSB_ERROR_BUSY = 0x1016, //Resource busy 56 | ONI_STATUS_LIBUSB_ERROR_OTHER = 0x1000, //Other error 57 | 58 | //ONI_STATUS_STREAM_ALREADY_EXISTS = 25, //stream already exists 59 | //ONI_STATUS_UNSUPPORTED_STREAM = 26, // unsupport stream 60 | 61 | ONI_STATUS_TIME_OUT = 102, 62 | } OniStatus; 63 | 64 | /** The source of the stream */ 65 | typedef enum 66 | { 67 | ONI_SENSOR_IR = 1, 68 | ONI_SENSOR_COLOR = 2, 69 | ONI_SENSOR_DEPTH = 3, 70 | 71 | } OniSensorType; 72 | 73 | /** All available formats of the output of a stream */ 74 | typedef enum 75 | { 76 | // Depth 77 | ONI_PIXEL_FORMAT_DEPTH_1_MM = 100, 78 | ONI_PIXEL_FORMAT_DEPTH_100_UM = 101, 79 | ONI_PIXEL_FORMAT_SHIFT_9_2 = 102, 80 | ONI_PIXEL_FORMAT_SHIFT_9_3 = 103, 81 | 82 | // Color 83 | ONI_PIXEL_FORMAT_RGB888 = 200, 84 | ONI_PIXEL_FORMAT_YUV422 = 201, 85 | ONI_PIXEL_FORMAT_GRAY8 = 202, 86 | ONI_PIXEL_FORMAT_GRAY16 = 203, 87 | ONI_PIXEL_FORMAT_JPEG = 204, 88 | ONI_PIXEL_FORMAT_YUYV = 205, 89 | ONI_PIXEL_FORMAT_LOG = 207, 90 | } OniPixelFormat; 91 | 92 | typedef enum 93 | { 94 | ONI_DEVICE_STATE_OK = 0, 95 | ONI_DEVICE_STATE_ERROR = 1, 96 | ONI_DEVICE_STATE_NOT_READY = 2, 97 | ONI_DEVICE_STATE_EOF = 3 98 | } OniDeviceState; 99 | 100 | typedef enum 101 | { 102 | ONI_IMAGE_REGISTRATION_OFF = 0, 103 | ONI_IMAGE_REGISTRATION_DEPTH_TO_COLOR = 1, 104 | } OniImageRegistrationMode; 105 | 106 | enum 107 | { 108 | ONI_TIMEOUT_NONE = 0, 109 | ONI_TIMEOUT_FOREVER = -1, 110 | }; 111 | 112 | #endif // ONICENUMS_H 113 | -------------------------------------------------------------------------------- /include/openni2/OniCProperties.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * * 3 | * OpenNI 2.x Alpha * 4 | * Copyright (C) 2012 PrimeSense Ltd. * 5 | * * 6 | * This file is part of OpenNI. * 7 | * * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); * 9 | * you may not use this file except in compliance with the License. * 10 | * You may obtain a copy of the License at * 11 | * * 12 | * http://www.apache.org/licenses/LICENSE-2.0 * 13 | * * 14 | * Unless required by applicable law or agreed to in writing, software * 15 | * distributed under the License is distributed on an "AS IS" BASIS, * 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 17 | * See the License for the specific language governing permissions and * 18 | * limitations under the License. * 19 | * * 20 | *****************************************************************************/ 21 | #ifndef ONICPROPERTIES_H 22 | #define ONICPROPERTIES_H 23 | 24 | // Device properties 25 | enum 26 | { 27 | ONI_DEVICE_PROPERTY_FIRMWARE_VERSION = 0, // By implementation 28 | ONI_DEVICE_PROPERTY_DRIVER_VERSION = 1, // OniVersion 29 | ONI_DEVICE_PROPERTY_HARDWARE_VERSION = 2, // int 30 | ONI_DEVICE_PROPERTY_SERIAL_NUMBER = 3, // string 31 | ONI_DEVICE_PROPERTY_ERROR_STATE = 4, // ?? 32 | ONI_DEVICE_PROPERTY_IMAGE_REGISTRATION = 5, // OniImageRegistrationMode 33 | 34 | 35 | //orbbec 36 | OBEXTENSION_ID_IR_GAIN = 11, 37 | OBEXTENSION_ID_IR_EXP = 12, 38 | OBEXTENSION_ID_LDP_EN = 13, 39 | OBEXTENSION_ID_CAM_PARAMS = 14, 40 | OBEXTENSION_ID_LASER_EN = 15, 41 | OBEXTENSION_ID_SERIALNUMBER = 16, 42 | OBEXTENSION_ID_DEVICETYPE = 17, 43 | OBEXTENSION_ID_UPDATE_FIRMWARE = 18, 44 | 45 | 46 | // Files 47 | ONI_DEVICE_PROPERTY_PLAYBACK_SPEED = 100, // float 48 | ONI_DEVICE_PROPERTY_PLAYBACK_REPEAT_ENABLED = 101, // OniBool 49 | }; 50 | 51 | // Stream properties 52 | enum 53 | { 54 | ONI_STREAM_PROPERTY_CROPPING = 0, // OniCropping* 55 | ONI_STREAM_PROPERTY_HORIZONTAL_FOV = 1, // float: radians 56 | ONI_STREAM_PROPERTY_VERTICAL_FOV = 2, // float: radians 57 | ONI_STREAM_PROPERTY_VIDEO_MODE = 3, // OniVideoMode* 58 | 59 | ONI_STREAM_PROPERTY_MAX_VALUE = 4, // int 60 | ONI_STREAM_PROPERTY_MIN_VALUE = 5, // int 61 | 62 | ONI_STREAM_PROPERTY_STRIDE = 6, // int 63 | ONI_STREAM_PROPERTY_MIRRORING = 7, // OniBool 64 | 65 | ONI_STREAM_PROPERTY_NUMBER_OF_FRAMES = 8, // int 66 | 67 | // Camera 68 | ONI_STREAM_PROPERTY_AUTO_WHITE_BALANCE = 100, // OniBool 69 | ONI_STREAM_PROPERTY_AUTO_EXPOSURE = 101, // OniBool 70 | ONI_STREAM_PROPERTY_EXPOSURE = 102, // int 71 | ONI_STREAM_PROPERTY_GAIN = 103, // int 72 | }; 73 | 74 | // Device commands (for Invoke) 75 | enum 76 | { 77 | ONI_DEVICE_COMMAND_SEEK = 1, // OniSeek 78 | }; 79 | 80 | #endif // ONICPROPERTIES_H 81 | -------------------------------------------------------------------------------- /include/openni2/OniEnums.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * * 3 | * OpenNI 2.x Alpha * 4 | * Copyright (C) 2012 PrimeSense Ltd. * 5 | * * 6 | * This file is part of OpenNI. * 7 | * * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); * 9 | * you may not use this file except in compliance with the License. * 10 | * You may obtain a copy of the License at * 11 | * * 12 | * http://www.apache.org/licenses/LICENSE-2.0 * 13 | * * 14 | * Unless required by applicable law or agreed to in writing, software * 15 | * distributed under the License is distributed on an "AS IS" BASIS, * 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 17 | * See the License for the specific language governing permissions and * 18 | * limitations under the License. * 19 | * * 20 | *****************************************************************************/ 21 | #ifndef ONIENUMS_H 22 | #define ONIENUMS_H 23 | 24 | namespace openni 25 | { 26 | 27 | /** Possible failure values */ 28 | typedef enum 29 | { 30 | STATUS_OK = 0, 31 | STATUS_ERROR = 1, 32 | STATUS_NOT_IMPLEMENTED = 2, 33 | STATUS_NOT_SUPPORTED = 3, 34 | STATUS_BAD_PARAMETER = 4, 35 | STATUS_OUT_OF_FLOW = 5, 36 | STATUS_NO_DEVICE = 6, 37 | STATUS_NOT_WRITE_PUBLIC_KEY = 7, 38 | STATUS_PUBLIC_KEY_MD5_VERIFY_FAILED = 8, 39 | STATUS_NOT_WRITE_MD5 = 9, 40 | STATUS_RSKEY_VERIFY_FAILED =10, 41 | 42 | //New add 43 | STATUS_DEVICE_IS_ALREADY_OPENED = 0x1001, //Device is already opened 44 | STATUS_USB_DRIVER_NOT_FOUND = 0x1002, //USB driver not found,for windows! 45 | STATUS_USB_DEVICE_NOT_FOUND = 0x1003, //USB device not found 46 | STATUS_USB_GET_DRIVER_VERSION = 0x1004, //Failed to get the USB driver version,for windows! 47 | STATUS_USB_GET_SPEED_FAILED = 0x1005, //Failed to get the device speed! 48 | STATUS_USB_SET_INTERFACE_FAILED = 0x1006, //Failed to set USB interface! 49 | STATUS_USB_DEVICE_OPEN_FAILED = 0x1007, //pid,vid,bus id is zero,for linux 50 | STATUS_USB_ENUMERATE_FAILED = 0x1008, //USB enum fail,for linux 51 | STATUS_USB_SET_CONFIG_FAILED = 0x1009, //usb set config fail ,for linux 52 | STATUS_USB_INIT_FAILED = 0x1010, //libusb open fail 53 | STATUS_LIBUSB_ERROR_NO_MEM = 0x1011, //Insufficient memory 54 | STATUS_LIBUSB_ERROR_ACCESS = 0x1012, //Access denied (insufficient permissions) 55 | STATUS_LIBUSB_ERROR_NO_DEVICE = 0x1013, //No such device (it may have been disconnected) 56 | STATUS_LIBUSB_ERROR_IO = 0x1014, //Input/output error 57 | STATUS_LIBUSB_ERROR_NOT_FOUND = 0x1015, //Entity not found 58 | STATUS_LIBUSB_ERROR_BUSY = 0x1016, //Resource busy 59 | STATUS_LIBUSB_ERROR_OTHER = 0x1000, //Other error 60 | 61 | //STATUS_STREAM_ALREADY_EXISTS = 25, //stream already exists 62 | //STATUS_UNSUPPORTED_STREAM = 26, // unsupport stream 63 | 64 | STATUS_TIME_OUT = 102, 65 | } Status; 66 | 67 | /** The source of the stream */ 68 | typedef enum 69 | { 70 | SENSOR_IR = 1, 71 | SENSOR_COLOR = 2, 72 | SENSOR_DEPTH = 3, 73 | 74 | } SensorType; 75 | 76 | /** All available formats of the output of a stream */ 77 | typedef enum 78 | { 79 | // Depth 80 | PIXEL_FORMAT_DEPTH_1_MM = 100, 81 | PIXEL_FORMAT_DEPTH_100_UM = 101, 82 | PIXEL_FORMAT_SHIFT_9_2 = 102, 83 | PIXEL_FORMAT_SHIFT_9_3 = 103, 84 | 85 | // Color 86 | PIXEL_FORMAT_RGB888 = 200, 87 | PIXEL_FORMAT_YUV422 = 201, 88 | PIXEL_FORMAT_GRAY8 = 202, 89 | PIXEL_FORMAT_GRAY16 = 203, 90 | PIXEL_FORMAT_JPEG = 204, 91 | PIXEL_FORMAT_YUYV = 205, 92 | PIXEL_FORMAT_LOG = 207, 93 | } PixelFormat; 94 | 95 | typedef enum 96 | { 97 | DEVICE_STATE_OK = 0, 98 | DEVICE_STATE_ERROR = 1, 99 | DEVICE_STATE_NOT_READY = 2, 100 | DEVICE_STATE_EOF = 3 101 | } DeviceState; 102 | 103 | typedef enum 104 | { 105 | IMAGE_REGISTRATION_OFF = 0, 106 | IMAGE_REGISTRATION_DEPTH_TO_COLOR = 1, 107 | } ImageRegistrationMode; 108 | 109 | typedef enum 110 | { 111 | PARAMS_REGISTRATION_OFF = 0, 112 | PARAMS_REGISTRATION_DEPTH_TO_COLOR = 1, 113 | PARAMS_REGISTRATION_USE_DISTORTION = 2, 114 | } ParamsRegistrationMode; 115 | 116 | static const int TIMEOUT_NONE = 0; 117 | static const int TIMEOUT_FOREVER = -1; 118 | 119 | } // namespace openni 120 | 121 | #endif // ONIENUMS_H 122 | -------------------------------------------------------------------------------- /include/openni2/OniPlatform.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * * 3 | * OpenNI 2.x Alpha * 4 | * Copyright (C) 2012 PrimeSense Ltd. * 5 | * * 6 | * This file is part of OpenNI. * 7 | * * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); * 9 | * you may not use this file except in compliance with the License. * 10 | * You may obtain a copy of the License at * 11 | * * 12 | * http://www.apache.org/licenses/LICENSE-2.0 * 13 | * * 14 | * Unless required by applicable law or agreed to in writing, software * 15 | * distributed under the License is distributed on an "AS IS" BASIS, * 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 17 | * See the License for the specific language governing permissions and * 18 | * limitations under the License. * 19 | * * 20 | *****************************************************************************/ 21 | #ifndef ONIPLATFORM_H 22 | #define ONIPLATFORM_H 23 | 24 | 25 | // Supported platforms 26 | #define ONI_PLATFORM_WIN32 1 27 | #define ONI_PLATFORM_LINUX_X86 2 28 | #define ONI_PLATFORM_LINUX_ARM 3 29 | #define ONI_PLATFORM_MACOSX 4 30 | #define ONI_PLATFORM_ANDROID_ARM 5 31 | 32 | #if (defined _WIN32) 33 | # ifndef RC_INVOKED 34 | # if _MSC_VER < 1300 35 | # error OpenNI Platform Abstraction Layer - Win32 - Microsoft Visual Studio version below 2003 (7.0) are not supported! 36 | # endif 37 | # endif 38 | # include "Win32/OniPlatformWin32.h" 39 | #elif defined (ANDROID) && (__arm__|| __aarch64__) 40 | # include "Android-Arm/OniPlatformAndroid-Arm.h" 41 | #elif (__linux__ && (__i386__ || __x86_64__)) 42 | # include "Linux-x86/OniPlatformLinux-x86.h" 43 | #elif (__linux__ && (__arm__ || __aarch64__)) 44 | # include "Linux-Arm/OniPlatformLinux-Arm.h" 45 | #elif _ARC 46 | # include "ARC/OniPlaformARC.h" 47 | #elif (__APPLE__) 48 | # include "MacOSX/OniPlatformMacOSX.h" 49 | #else 50 | # error Xiron Platform Abstraction Layer - Unsupported Platform! 51 | #endif 52 | 53 | #ifdef __cplusplus 54 | # define ONI_C extern "C" 55 | # define ONI_C_API_EXPORT ONI_C ONI_API_EXPORT 56 | # define ONI_C_API_IMPORT ONI_C ONI_API_IMPORT 57 | # define ONI_CPP_API_EXPORT ONI_API_EXPORT 58 | # define ONI_CPP_API_IMPORT ONI_API_IMPORT 59 | #else // __cplusplus 60 | # define ONI_C_API_EXPORT ONI_API_EXPORT 61 | # define ONI_C_API_IMPORT ONI_API_IMPORT 62 | #endif // __cplusplus 63 | 64 | #ifdef OPENNI2_EXPORT 65 | # define ONI_C_API ONI_C_API_EXPORT 66 | # define ONI_CPP_API ONI_CPP_API_EXPORT 67 | #else // OPENNI2_EXPORT 68 | # define ONI_C_API ONI_C_API_IMPORT 69 | # define ONI_CPP_API ONI_CPP_API_IMPORT 70 | #endif // OPENNI2_EXPORT 71 | 72 | 73 | #endif // ONIPLATFORM_H 74 | -------------------------------------------------------------------------------- /include/openni2/OniProperties.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * * 3 | * OpenNI 2.x Alpha * 4 | * Copyright (C) 2012 PrimeSense Ltd. * 5 | * * 6 | * This file is part of OpenNI. * 7 | * * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); * 9 | * you may not use this file except in compliance with the License. * 10 | * You may obtain a copy of the License at * 11 | * * 12 | * http://www.apache.org/licenses/LICENSE-2.0 * 13 | * * 14 | * Unless required by applicable law or agreed to in writing, software * 15 | * distributed under the License is distributed on an "AS IS" BASIS, * 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 17 | * See the License for the specific language governing permissions and * 18 | * limitations under the License. * 19 | * * 20 | *****************************************************************************/ 21 | #ifndef ONIPROPERTIES_H 22 | #define ONIPROPERTIES_H 23 | 24 | namespace openni 25 | { 26 | 27 | // Device properties 28 | enum 29 | { 30 | DEVICE_PROPERTY_FIRMWARE_VERSION = 0, // string 31 | DEVICE_PROPERTY_DRIVER_VERSION = 1, // OniVersion 32 | DEVICE_PROPERTY_HARDWARE_VERSION = 2, // int 33 | DEVICE_PROPERTY_SERIAL_NUMBER = 3, // string 34 | DEVICE_PROPERTY_ERROR_STATE = 4, // ?? 35 | DEVICE_PROPERTY_IMAGE_REGISTRATION = 5, // OniImageRegistrationMode 36 | 37 | //orbbec 38 | OBEXTENSION_ID_IR_GAIN = 11, 39 | OBEXTENSION_ID_IR_EXP = 12, 40 | OBEXTENSION_ID_LDP_EN = 13, 41 | OBEXTENSION_ID_CAM_PARAMS = 14, 42 | OBEXTENSION_ID_LASER_EN = 15, 43 | OBEXTENSION_ID_SERIALNUMBER = 16, 44 | OBEXTENSION_ID_DEVICETYPE = 17, 45 | OBEXTENSION_ID_UPDATE_FIRMWARE = 18, 46 | // Files 47 | DEVICE_PROPERTY_PLAYBACK_SPEED = 100, // float 48 | DEVICE_PROPERTY_PLAYBACK_REPEAT_ENABLED = 101, // OniBool 49 | }; 50 | 51 | // Stream properties 52 | enum 53 | { 54 | STREAM_PROPERTY_CROPPING = 0, // OniCropping* 55 | STREAM_PROPERTY_HORIZONTAL_FOV = 1, // float: radians 56 | STREAM_PROPERTY_VERTICAL_FOV = 2, // float: radians 57 | STREAM_PROPERTY_VIDEO_MODE = 3, // OniVideoMode* 58 | 59 | STREAM_PROPERTY_MAX_VALUE = 4, // int 60 | STREAM_PROPERTY_MIN_VALUE = 5, // int 61 | 62 | STREAM_PROPERTY_STRIDE = 6, // int 63 | STREAM_PROPERTY_MIRRORING = 7, // OniBool 64 | 65 | STREAM_PROPERTY_NUMBER_OF_FRAMES = 8, // int 66 | 67 | // Camera 68 | STREAM_PROPERTY_AUTO_WHITE_BALANCE = 100, // OniBool 69 | STREAM_PROPERTY_AUTO_EXPOSURE = 101, // OniBool 70 | STREAM_PROPERTY_EXPOSURE = 102, // int 71 | STREAM_PROPERTY_GAIN = 103, // int 72 | 73 | STREAM_PROPERTY_SOFTWARE_REGISTRATION = 0x2080FF42, // int 74 | }; 75 | 76 | // Device commands (for Invoke) 77 | enum 78 | { 79 | DEVICE_COMMAND_SEEK = 1, // OniSeek 80 | }; 81 | 82 | } // namespace openni 83 | #endif // ONIPROPERTIES_H 84 | -------------------------------------------------------------------------------- /include/openni2/OniTest.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * * 3 | * OpenNI 2.x Alpha * 4 | * Copyright (C) 2012 PrimeSense Ltd. * 5 | * * 6 | * This file is part of OpenNI. * 7 | * * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); * 9 | * you may not use this file except in compliance with the License. * 10 | * You may obtain a copy of the License at * 11 | * * 12 | * http://www.apache.org/licenses/LICENSE-2.0 * 13 | * * 14 | * Unless required by applicable law or agreed to in writing, software * 15 | * distributed under the License is distributed on an "AS IS" BASIS, * 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 17 | * See the License for the specific language governing permissions and * 18 | * limitations under the License. * 19 | * * 20 | *****************************************************************************/ 21 | #ifndef ONITEST_H 22 | #define ONITEST_H 23 | 24 | #define TEST_DEVICE_NAME "Test" // use with device.open() to create a test device 25 | 26 | /** 27 | * Additional commands for Test device streams 28 | */ 29 | enum 30 | { 31 | TEST_COMMAND_ISSUE_FRAME = 0xFFFF0001, // TestCommandIssueFrame 32 | }; 33 | 34 | typedef struct TestCommandIssueFrame 35 | { 36 | uint64_t timestamp; 37 | void* data; 38 | } TestCommandIssueFrame; 39 | 40 | #endif // ONITEST_H 41 | -------------------------------------------------------------------------------- /include/openni2/OniVersion.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * * 3 | * OpenNI 2.x Alpha * 4 | * Copyright (C) 2012 PrimeSense Ltd. * 5 | * * 6 | * This file is part of OpenNI. * 7 | * * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); * 9 | * you may not use this file except in compliance with the License. * 10 | * You may obtain a copy of the License at * 11 | * * 12 | * http://www.apache.org/licenses/LICENSE-2.0 * 13 | * * 14 | * Unless required by applicable law or agreed to in writing, software * 15 | * distributed under the License is distributed on an "AS IS" BASIS, * 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 17 | * See the License for the specific language governing permissions and * 18 | * limitations under the License. * 19 | * * 20 | *****************************************************************************/ 21 | #ifndef ONIVERSION_H 22 | #define ONIVERSION_H 23 | 24 | #include "OniPlatform.h" 25 | 26 | #define ONI_VERSION_MAJOR 2 27 | #define ONI_VERSION_MINOR 3 28 | #define ONI_VERSION_MAINTENANCE 0 29 | #define ONI_VERSION_BUILD 88 30 | 31 | /** OpenNI version (in brief string format): "Major.Minor.Maintenance (Build)" */ 32 | #define ONI_BRIEF_VERSION_STRING \ 33 | "Standard "\ 34 | ONI_STRINGIFY(ONI_VERSION_MAJOR) "." \ 35 | ONI_STRINGIFY(ONI_VERSION_MINOR) "." \ 36 | ONI_STRINGIFY(ONI_VERSION_MAINTENANCE) \ 37 | " (Build " ONI_STRINGIFY(ONI_VERSION_BUILD) "-beta36)" 38 | 39 | /** OpenNI version (in numeric format): (OpenNI major version * 100000000 + OpenNI minor version * 1000000 + OpenNI maintenance version * 10000 + OpenNI build version). */ 40 | #define ONI_VERSION (ONI_VERSION_MAJOR*100000000 + ONI_VERSION_MINOR*1000000 + ONI_VERSION_MAINTENANCE*10000 + ONI_VERSION_BUILD) 41 | #define ONI_CREATE_API_VERSION(major, minor) ((major)*1000 + (minor)) 42 | #define ONI_API_VERSION ONI_CREATE_API_VERSION(ONI_VERSION_MAJOR, ONI_VERSION_MINOR) 43 | 44 | /** OpenNI version (in string format): "Major.Minor.Maintenance.Build-Platform (MMM DD YYYY HH:MM:SS)". */ 45 | #define ONI_VERSION_STRING \ 46 | ONI_BRIEF_VERSION_STRING "-" \ 47 | ONI_PLATFORM_STRING " (" ONI_TIMESTAMP ")" 48 | 49 | #endif // ONIVERSION_H 50 | -------------------------------------------------------------------------------- /include/openni2/Win32/OniPlatformWin32.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * * 3 | * OpenNI 2.x Alpha * 4 | * Copyright (C) 2012 PrimeSense Ltd. * 5 | * * 6 | * This file is part of OpenNI. * 7 | * * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); * 9 | * you may not use this file except in compliance with the License. * 10 | * You may obtain a copy of the License at * 11 | * * 12 | * http://www.apache.org/licenses/LICENSE-2.0 * 13 | * * 14 | * Unless required by applicable law or agreed to in writing, software * 15 | * distributed under the License is distributed on an "AS IS" BASIS, * 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 17 | * See the License for the specific language governing permissions and * 18 | * limitations under the License. * 19 | * * 20 | *****************************************************************************/ 21 | #ifndef ONIPLATFORMWIN32_H 22 | #define ONIPLATFORMWIN32_H 23 | 24 | //--------------------------------------------------------------------------- 25 | // Prerequisites 26 | //--------------------------------------------------------------------------- 27 | #ifndef WINVER // Allow use of features specific to Windows XP or later 28 | #define WINVER 0x0501 29 | #endif 30 | #ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later 31 | #define _WIN32_WINNT 0x0501 32 | #endif 33 | #ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later 34 | #define _WIN32_WINDOWS 0x0410 35 | #endif 36 | #ifndef _WIN32_IE // Allow use of features specific to IE 6.0 or later 37 | #define _WIN32_IE 0x0600 38 | #endif 39 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 40 | 41 | // Undeprecate CRT functions 42 | #ifndef _CRT_SECURE_NO_DEPRECATE 43 | #define _CRT_SECURE_NO_DEPRECATE 1 44 | #endif 45 | 46 | //--------------------------------------------------------------------------- 47 | // Includes 48 | //--------------------------------------------------------------------------- 49 | #include 50 | #include 51 | #include 52 | #include 53 | #include 54 | #include 55 | #include 56 | #include 57 | #include 58 | 59 | #if _MSC_VER < 1600 // Visual Studio 2008 and older doesn't have stdint.h... 60 | typedef signed char int8_t; 61 | typedef short int16_t; 62 | typedef int int32_t; 63 | typedef __int64 int64_t; 64 | 65 | typedef unsigned char uint8_t; 66 | typedef unsigned short uint16_t; 67 | typedef unsigned int uint32_t; 68 | typedef unsigned __int64 uint64_t; 69 | #else 70 | #include 71 | #endif 72 | 73 | //--------------------------------------------------------------------------- 74 | // Platform Basic Definition 75 | //--------------------------------------------------------------------------- 76 | #define ONI_PLATFORM ONI_PLATFORM_WIN32 77 | #define ONI_PLATFORM_STRING "Win32" 78 | 79 | //--------------------------------------------------------------------------- 80 | // Platform Capabilities 81 | //--------------------------------------------------------------------------- 82 | #define ONI_PLATFORM_ENDIAN_TYPE ONI_PLATFORM_IS_LITTLE_ENDIAN 83 | 84 | #define ONI_PLATFORM_SUPPORTS_DYNAMIC_LIBS 1 85 | 86 | //--------------------------------------------------------------------------- 87 | // Memory 88 | //--------------------------------------------------------------------------- 89 | /** The default memory alignment. */ 90 | #define ONI_DEFAULT_MEM_ALIGN 16 91 | 92 | /** The thread static declarator (using TLS). */ 93 | #define ONI_THREAD_STATIC __declspec(thread) 94 | 95 | //--------------------------------------------------------------------------- 96 | // Files 97 | //--------------------------------------------------------------------------- 98 | /** The maximum allowed file path size (in bytes). */ 99 | #define ONI_FILE_MAX_PATH MAX_PATH 100 | 101 | //--------------------------------------------------------------------------- 102 | // Call backs 103 | //--------------------------------------------------------------------------- 104 | /** The std call type. */ 105 | #define ONI_STDCALL __stdcall 106 | 107 | /** The call back calling convention. */ 108 | #define ONI_CALLBACK_TYPE ONI_STDCALL 109 | 110 | /** The C and C++ calling convension. */ 111 | #define ONI_C_DECL __cdecl 112 | 113 | //--------------------------------------------------------------------------- 114 | // Macros 115 | //--------------------------------------------------------------------------- 116 | /** Returns the date and time at compile time. */ 117 | #define ONI_TIMESTAMP __DATE__ " " __TIME__ 118 | 119 | /** Converts n into a pre-processor string. */ 120 | #define ONI_STRINGIFY(n) ONI_STRINGIFY_HELPER(n) 121 | #define ONI_STRINGIFY_HELPER(n) #n 122 | 123 | //--------------------------------------------------------------------------- 124 | // API Export/Import Macros 125 | //--------------------------------------------------------------------------- 126 | /** Indicates an exported shared library function. */ 127 | #define ONI_API_EXPORT __declspec(dllexport) 128 | 129 | /** Indicates an imported shared library function. */ 130 | #define ONI_API_IMPORT __declspec(dllimport) 131 | 132 | /** Indicates a deprecated function */ 133 | #if _MSC_VER < 1400 // Before VS2005 there was no support for declspec deprecated... 134 | #define ONI_API_DEPRECATED(msg) 135 | #else 136 | #define ONI_API_DEPRECATED(msg) __declspec(deprecated(msg)) 137 | #endif 138 | 139 | #endif // ONIPLATFORMWIN32_H 140 | -------------------------------------------------------------------------------- /include/openni2/util.h: -------------------------------------------------------------------------------- 1 | #ifndef __UTIL_H__ 2 | #define __UTIL_H__ 3 | 4 | 5 | #ifndef true 6 | #define true 1 7 | #endif 8 | #ifndef false 9 | #define false 0 10 | #endif 11 | #ifndef TRUE 12 | #define TRUE 1 13 | #endif 14 | #ifndef FALSE 15 | #define FALSE 0 16 | #endif 17 | //typedef int bool; 18 | typedef bool BOOL; 19 | typedef long LONG; 20 | typedef unsigned long ULONG; 21 | typedef unsigned char BYTE; 22 | typedef unsigned short USHORT; 23 | typedef unsigned int DWORD; 24 | 25 | #define SAFE_DELETE_ARRAY(x) { if (x) free(x); x = NULL; } 26 | 27 | typedef enum 28 | { 29 | EC_UnKnow, 30 | EC_EnumDeviceFail, 31 | EC_DisableFlashWriteProtectFail, 32 | EC_EraseFlashFail, 33 | EC_EraseFlashSectorFail, 34 | EC_GetAsicIdFail, 35 | EC_GetAsicRomVersionFail, 36 | EC_GetAsicRomTypeFail, 37 | EC_ReadAsicRegisterFail, 38 | EC_WriteAsicRegisterFail, 39 | EC_UnKnowSerialFlashType, 40 | EC_BurnerCheckFail, 41 | EC_CoInitializeFail, 42 | EC_NoFindDevice, 43 | EC_MallocMemoryFail, 44 | }ERROR_CODE; 45 | 46 | 47 | typedef enum 48 | { 49 | SFT_UNKNOW, 50 | SFT_MXIC, 51 | SFT_ST, 52 | SFT_SST, 53 | SFT_ATMEL_AT25F, 54 | SFT_ATMEL_AT25FS, 55 | SFT_ATMEL_AT45DB, 56 | SFT_WINBOND, 57 | SFT_PMC, 58 | SFT_MXIC_LIKE , 59 | SFT_AMIC, 60 | SFT_EON, 61 | SF_ESMT, 62 | SFT_GIGA, 63 | SFT_FENTECH 64 | }SERIAL_FLASH_TYPE; 65 | 66 | typedef enum 67 | { 68 | DRT_Unknow, 69 | DRT_32K, 70 | DRT_64K, 71 | DRT_128K, 72 | DRT_256K 73 | }DSP_ROM_TYPE; 74 | #endif 75 | 76 | -------------------------------------------------------------------------------- /include/openni2_redist/arm/OpenNI.ini: -------------------------------------------------------------------------------- 1 | [Log] 2 | ; 0 - Verbose; 1 - Info; 2 - Warning; 3 - Error. Default - None 3 | ;Verbosity=0 4 | ;LogToConsole=1 5 | ;LogToFile=1 6 | ;LogToAndroidLog=1 7 | 8 | [Device] 9 | ;Override= 10 | ;RecordTo= 11 | 12 | [Drivers] 13 | ; Location of the drivers, relative to OpenNI shared library location. When not provided, "OpenNI2/Drivers" will be used. 14 | ;Repository=OpenNI2/Drivers 15 | 16 | ; List of drivers to load, separated by commas. When not provided, OpenNI will try to load each shared library in Repository. 17 | ;List= 18 | -------------------------------------------------------------------------------- /include/openni2_redist/arm/OpenNI2/Drivers/OniFile.ini: -------------------------------------------------------------------------------- 1 | ;---------------- Player Configuration ------------------- 2 | [Player] 3 | ; Speed. 1.0 - 1.0 * fps (default), Values can be R while R is real and grater the 0 4 | ;Speed=1.0 5 | 6 | ; Repeat. 1 - on (default), 0 - off 7 | ;Repeat=1 -------------------------------------------------------------------------------- /include/openni2_redist/arm/OpenNI2/Drivers/libOniFile.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orbbec/ros_astra_camera/affcfae0bc4786b5f64177ba852577742cdefa90/include/openni2_redist/arm/OpenNI2/Drivers/libOniFile.so -------------------------------------------------------------------------------- /include/openni2_redist/arm/OpenNI2/Drivers/liborbbec.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orbbec/ros_astra_camera/affcfae0bc4786b5f64177ba852577742cdefa90/include/openni2_redist/arm/OpenNI2/Drivers/liborbbec.so -------------------------------------------------------------------------------- /include/openni2_redist/arm/PS1080Console: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orbbec/ros_astra_camera/affcfae0bc4786b5f64177ba852577742cdefa90/include/openni2_redist/arm/PS1080Console -------------------------------------------------------------------------------- /include/openni2_redist/arm/SimpleRead: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orbbec/ros_astra_camera/affcfae0bc4786b5f64177ba852577742cdefa90/include/openni2_redist/arm/SimpleRead -------------------------------------------------------------------------------- /include/openni2_redist/arm/libOpenNI2.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orbbec/ros_astra_camera/affcfae0bc4786b5f64177ba852577742cdefa90/include/openni2_redist/arm/libOpenNI2.so -------------------------------------------------------------------------------- /include/openni2_redist/arm64/NiViewer: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orbbec/ros_astra_camera/affcfae0bc4786b5f64177ba852577742cdefa90/include/openni2_redist/arm64/NiViewer -------------------------------------------------------------------------------- /include/openni2_redist/arm64/OpenNI.ini: -------------------------------------------------------------------------------- 1 | [Log] 2 | ; 0 - Verbose; 1 - Info; 2 - Warning; 3 - Error. Default - None 3 | ;Verbosity=0 4 | ;LogToConsole=1 5 | ;LogToFile=1 6 | ;LogToAndroidLog=1 7 | 8 | [Device] 9 | ;Override= 10 | ;RecordTo= 11 | 12 | [Drivers] 13 | ; Location of the drivers, relative to OpenNI shared library location. When not provided, "OpenNI2/Drivers" will be used. 14 | ;Repository=OpenNI2/Drivers 15 | 16 | ; List of drivers to load, separated by commas. When not provided, OpenNI will try to load each shared library in Repository. 17 | ;List= 18 | -------------------------------------------------------------------------------- /include/openni2_redist/arm64/OpenNI2/Drivers/OniFile.ini: -------------------------------------------------------------------------------- 1 | ;---------------- Player Configuration ------------------- 2 | [Player] 3 | ; Speed. 1.0 - 1.0 * fps (default), Values can be R while R is real and grater the 0 4 | ;Speed=1.0 5 | 6 | ; Repeat. 1 - on (default), 0 - off 7 | ;Repeat=1 -------------------------------------------------------------------------------- /include/openni2_redist/arm64/OpenNI2/Drivers/libOniFile.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orbbec/ros_astra_camera/affcfae0bc4786b5f64177ba852577742cdefa90/include/openni2_redist/arm64/OpenNI2/Drivers/libOniFile.so -------------------------------------------------------------------------------- /include/openni2_redist/arm64/OpenNI2/Drivers/liborbbec.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orbbec/ros_astra_camera/affcfae0bc4786b5f64177ba852577742cdefa90/include/openni2_redist/arm64/OpenNI2/Drivers/liborbbec.so -------------------------------------------------------------------------------- /include/openni2_redist/arm64/PS1080Console: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orbbec/ros_astra_camera/affcfae0bc4786b5f64177ba852577742cdefa90/include/openni2_redist/arm64/PS1080Console -------------------------------------------------------------------------------- /include/openni2_redist/arm64/SimpleRead: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orbbec/ros_astra_camera/affcfae0bc4786b5f64177ba852577742cdefa90/include/openni2_redist/arm64/SimpleRead -------------------------------------------------------------------------------- /include/openni2_redist/arm64/libOpenNI2.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orbbec/ros_astra_camera/affcfae0bc4786b5f64177ba852577742cdefa90/include/openni2_redist/arm64/libOpenNI2.so -------------------------------------------------------------------------------- /include/openni2_redist/x64/NiViewer: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orbbec/ros_astra_camera/affcfae0bc4786b5f64177ba852577742cdefa90/include/openni2_redist/x64/NiViewer -------------------------------------------------------------------------------- /include/openni2_redist/x64/OpenNI.ini: -------------------------------------------------------------------------------- 1 | [Log] 2 | ; 0 - Verbose; 1 - Info; 2 - Warning; 3 - Error. Default - None 3 | ;Verbosity=0 4 | ;LogToConsole=1 5 | ;LogToFile=1 6 | ;LogToAndroidLog=1 7 | 8 | [Device] 9 | ;Override= 10 | ;RecordTo= 11 | 12 | [Drivers] 13 | ; Location of the drivers, relative to OpenNI shared library location. When not provided, "OpenNI2/Drivers" will be used. 14 | ;Repository=OpenNI2/Drivers 15 | 16 | ; List of drivers to load, separated by commas. When not provided, OpenNI will try to load each shared library in Repository. 17 | ;List= 18 | -------------------------------------------------------------------------------- /include/openni2_redist/x64/OpenNI2/Drivers/OniFile.ini: -------------------------------------------------------------------------------- 1 | ;---------------- Player Configuration ------------------- 2 | [Player] 3 | ; Speed. 1.0 - 1.0 * fps (default), Values can be R while R is real and grater the 0 4 | ;Speed=1.0 5 | 6 | ; Repeat. 1 - on (default), 0 - off 7 | ;Repeat=1 -------------------------------------------------------------------------------- /include/openni2_redist/x64/OpenNI2/Drivers/libOniFile.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orbbec/ros_astra_camera/affcfae0bc4786b5f64177ba852577742cdefa90/include/openni2_redist/x64/OpenNI2/Drivers/libOniFile.so -------------------------------------------------------------------------------- /include/openni2_redist/x64/OpenNI2/Drivers/liborbbec.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orbbec/ros_astra_camera/affcfae0bc4786b5f64177ba852577742cdefa90/include/openni2_redist/x64/OpenNI2/Drivers/liborbbec.so -------------------------------------------------------------------------------- /include/openni2_redist/x64/PS1080Console: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orbbec/ros_astra_camera/affcfae0bc4786b5f64177ba852577742cdefa90/include/openni2_redist/x64/PS1080Console -------------------------------------------------------------------------------- /include/openni2_redist/x64/SimpleRead: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orbbec/ros_astra_camera/affcfae0bc4786b5f64177ba852577742cdefa90/include/openni2_redist/x64/SimpleRead -------------------------------------------------------------------------------- /include/openni2_redist/x64/libOpenNI2.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orbbec/ros_astra_camera/affcfae0bc4786b5f64177ba852577742cdefa90/include/openni2_redist/x64/libOpenNI2.so -------------------------------------------------------------------------------- /launch/astra.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /launch/astra_pro.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /launch/dabai_dc1.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /launch/dabai_dw.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /launch/dabai_dw2.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /launch/dabai_max.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /launch/dabai_pro.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /launch/dabai_u3.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /launch/deeyea.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /launch/gemini.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /launch/gemini_e.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /launch/gemini_e_lite.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /launch/list_devices.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /launch/multi_astra.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 25 | 26 | -------------------------------------------------------------------------------- /launch/multi_dabai.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /launch/multi_dabai_dcw.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 7 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /launch/multi_dabai_dcw2.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /launch/multi_dabai_pro.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 24 | 25 | -------------------------------------------------------------------------------- /launch/multi_deeyea.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /launch/multi_device.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /launch/multi_gemini.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 25 | 26 | -------------------------------------------------------------------------------- /launch/stereo_s.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /launch/stereo_s_u3.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /msg/DeviceInfo.msg: -------------------------------------------------------------------------------- 1 | std_msgs/Header header 2 | string name 3 | int32 vid 4 | int32 pid 5 | string serial_number 6 | string firmware_version 7 | string supported_min_sdk_version 8 | string hardware_version 9 | -------------------------------------------------------------------------------- /msg/Extrinsics.msg: -------------------------------------------------------------------------------- 1 | std_msgs/Header header 2 | float64[9] rotation 3 | float64[3] translation 4 | -------------------------------------------------------------------------------- /msg/Metadata.msg: -------------------------------------------------------------------------------- 1 | std_msgs/Header header 2 | string json_data 3 | -------------------------------------------------------------------------------- /package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | astra_camera 4 | 1.2.7 5 | Drivers for Orbbec Astra Devices. 6 | Apache License 2.0 7 | Mo Cun 8 | catkin 9 | backward_ros 10 | libdw-dev 11 | cv_bridge 12 | dynamic_reconfigure 13 | git 14 | image_geometry 15 | image_transport 16 | libudev-dev 17 | libusb-1.0-dev 18 | message_generation 19 | message_runtime 20 | rgbd_launch 21 | roscpp 22 | sensor_msgs 23 | std_srvs 24 | tf2_ros 25 | tf2 26 | message_filters 27 | camera_info_manager 28 | 29 | -------------------------------------------------------------------------------- /scripts/create_udev_rules: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "" 4 | echo "This script copies a udev rule to /etc to facilitate bringing" 5 | echo "up the astra usb connection as /dev/astra*" 6 | echo "" 7 | 8 | sudo cp `rospack find astra_camera`/56-orbbec-usb.rules /etc/udev/rules.d 9 | 10 | 11 | echo "" 12 | echo "Restarting udev" 13 | echo "" 14 | sudo service udev reload 15 | sudo service udev restart 16 | #sudo udevadm trigger --action=change 17 | -------------------------------------------------------------------------------- /scripts/depth_to_color.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import message_filters 4 | from sensor_msgs.msg import Image 5 | import rospy 6 | import cv2 7 | from cv_bridge import CvBridge 8 | import numpy as np 9 | from tf2_ros import TransformListener,Buffer 10 | import math 11 | import tf2_ros 12 | from geometry_msgs.msg import PointStamped 13 | from tf2_geometry_msgs import do_transform_point 14 | 15 | 16 | tf_listener = None 17 | tf_buffer = None 18 | def callback( depth_msg : Image): 19 | cv_bridge = CvBridge() 20 | depth_img = cv_bridge.imgmsg_to_cv2(depth_msg, "16UC1") 21 | center_x = depth_img.shape[1] / 2 22 | center_y = depth_img.shape[0] / 2 23 | try: 24 | trans = tf_buffer.lookup_transform('camera_depth_frame', 'camera_color_frame', rospy.Time(0)) 25 | except (tf2_ros.LookupException, tf2_ros.ConnectivityException, tf2_ros.ExtrapolationException) as e: 26 | rospy.loginfo(e) 27 | return 28 | 29 | # Create a point in the depth camera's coordinate frame 30 | depth_point = PointStamped() 31 | depth_point.header.frame_id = 'camera_depth_frame' 32 | depth_point.header.stamp = rospy.Time.now() 33 | depth_point.point.x = center_x 34 | depth_point.point.y = center_y 35 | depth_point.point.z = depth_img[int(center_y), int(center_x)] 36 | 37 | # Now we transform the point from the depth camera's coordinate frame to the color camera's coordinate frame 38 | try: 39 | color_point = do_transform_point(depth_point, trans) 40 | except (tf2_ros.LookupException, tf2_ros.ConnectivityException, tf2_ros.ExtrapolationException) as e: 41 | rospy.loginfo(e) 42 | return 43 | 44 | # The point's position in the color frame is now stored in color_point.point 45 | color_x = color_point.point.x 46 | color_y = color_point.point.y 47 | print("from depth {},{} to color {},{}".format(center_x,center_y,color_x,color_y)) 48 | 49 | 50 | 51 | def main(): 52 | rospy.init_node('test_sync', anonymous=True) 53 | depth_sub = rospy.Subscriber('/camera/depth/image_raw', Image, callback) 54 | global tf_listener, tf_buffer 55 | tf_buffer = Buffer() 56 | tf_listener = TransformListener(tf_buffer) 57 | rospy.spin() 58 | 59 | 60 | if __name__ == '__main__': 61 | main() 62 | -------------------------------------------------------------------------------- /scripts/get_point_cloud_dist.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from numpy import mat 4 | from sensor_msgs.msg import PointCloud2 5 | import sensor_msgs.point_cloud2 as pc2 6 | 7 | import rospy 8 | import math 9 | 10 | def pointCloudCb(data): 11 | for p in pc2.read_points(data, field_names = ("x", "y", "z"), skip_nans=True): 12 | dist = p[0]*p[0] + p[1]*p[1] + p[2] *p[2] 13 | print("dist %s" % math.sqrt(dist)) 14 | 15 | 16 | def main(): 17 | rospy.init_node('get_point_cloud_dist', anonymous=True) 18 | rospy.Subscriber("/camera/depth/points", PointCloud2, pointCloudCb) 19 | rospy.spin() 20 | 21 | if __name__ == '__main__': 22 | main() 23 | -------------------------------------------------------------------------------- /scripts/get_supported_video_modes.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from astra_camera.srv import GetString 4 | 5 | import rospy 6 | import math 7 | import sys 8 | import json 9 | 10 | 11 | def main(): 12 | rospy.init_node('GetSupportedVideoModes', anonymous=True) 13 | stream = sys.argv[1] 14 | service = "/camera/get_" + stream + "_supported_video_modes" 15 | rospy.wait_for_service(service) 16 | try: 17 | res = rospy.ServiceProxy(service, GetString) 18 | response = res() 19 | data = json.loads(response.data) 20 | for item in data: 21 | print("%s" % item) 22 | except rospy.ServiceException as e: 23 | print("Service call failed: %s"%e) 24 | 25 | rospy.spin() 26 | 27 | 28 | if __name__ == '__main__': 29 | main() -------------------------------------------------------------------------------- /scripts/sync.py: -------------------------------------------------------------------------------- 1 | import message_filters 2 | from sensor_msgs.msg import Image 3 | import rospy 4 | 5 | 6 | def callback(depth_msg, rgb_msg): 7 | print("hello") 8 | 9 | 10 | def main(): 11 | rospy.init_node('test_sync', anonymous=True) 12 | rgb_sub = message_filters.Subscriber('/camera/rgb/image_raw', Image) 13 | depth_sub = message_filters.Subscriber('/camera/depth/image_raw', Image) 14 | 15 | ts = message_filters.ApproximateTimeSynchronizer([rgb_sub, depth_sub], 10, 1) 16 | ts.registerCallback(callback) 17 | rospy.spin() 18 | 19 | 20 | if __name__ == '__main__': 21 | main() 22 | -------------------------------------------------------------------------------- /scripts/test_open_close_stream.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | import imp 3 | import rospy 4 | import time 5 | from sensor_msgs.msg import Image 6 | import sys 7 | 8 | get_msg = False 9 | 10 | 11 | def callback(data): 12 | global get_msg 13 | get_msg = True 14 | 15 | 16 | def main(): 17 | rospy.init_node('test_sub', anonymous=True) 18 | try: 19 | for i in range(100000): 20 | sub = rospy.Subscriber("/camera/depth/image_raw", Image, callback) 21 | global get_msg 22 | while not get_msg: 23 | time.sleep(0.1) 24 | get_msg = False 25 | sub.unregister() 26 | print("%d test case passed" % i) 27 | except KeyboardInterrupt: 28 | sys.exit(0) 29 | 30 | 31 | if __name__ == '__main__': 32 | main() -------------------------------------------------------------------------------- /src/d2c_viewer.cpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* Copyright (c) 2013-2022 Orbbec 3D Technology, Inc */ 4 | /* */ 5 | /* PROPRIETARY RIGHTS of Orbbec 3D Technology are involved in the */ 6 | /* subject matter of this material. All manufacturing, reproduction, use, */ 7 | /* and sales rights pertaining to this subject matter are governed by the */ 8 | /* license agreement. The recipient of this software implicitly accepts */ 9 | /* the terms of the license. */ 10 | /* */ 11 | /**************************************************************************/ 12 | 13 | #include "astra_camera/d2c_viewer.h" 14 | 15 | #include 16 | #include 17 | 18 | #include 19 | 20 | namespace astra_camera { 21 | D2CViewer::D2CViewer(ros::NodeHandle& nh, ros::NodeHandle& nh_private) 22 | : nh_(nh), nh_private_(nh_private) { 23 | rgb_sub_.subscribe(nh_, "color/image_raw", 1); 24 | depth_sub_.subscribe(nh_, "depth/image_raw", 1); 25 | sync_ = std::make_unique>(MySyncPolicy(10), rgb_sub_, 26 | depth_sub_); 27 | sync_->registerCallback(boost::bind(&D2CViewer::messageCallback, this, _1, _2)); 28 | d2c_pub_ = nh_.advertise("depth_to_color/image_raw", 1); 29 | } 30 | D2CViewer::~D2CViewer() = default; 31 | 32 | void D2CViewer::messageCallback(const sensor_msgs::ImageConstPtr& rgb_msg, 33 | const sensor_msgs::ImageConstPtr& depth_msg) { 34 | if (rgb_msg->width != depth_msg->width || rgb_msg->height != depth_msg->height) { 35 | ROS_ERROR("rgb and depth image size not match(%d, %d) vs (%d, %d)", rgb_msg->width, 36 | rgb_msg->height, depth_msg->width, depth_msg->height); 37 | return; 38 | } 39 | auto rgb_img_ptr = cv_bridge::toCvCopy(rgb_msg, sensor_msgs::image_encodings::RGB8); 40 | auto depth_img_ptr = cv_bridge::toCvCopy(depth_msg, sensor_msgs::image_encodings::TYPE_16UC1); 41 | cv::Mat gray_depth, depth_img, d2c_img; 42 | depth_img_ptr->image.convertTo(gray_depth, CV_8UC1); 43 | cv::cvtColor(gray_depth, depth_img, cv::COLOR_GRAY2RGB); 44 | cv::bitwise_or(rgb_img_ptr->image, depth_img, d2c_img); 45 | sensor_msgs::ImagePtr d2c_msg = 46 | cv_bridge::CvImage(std_msgs::Header(), sensor_msgs::image_encodings::RGB8, d2c_img) 47 | .toImageMsg(); 48 | d2c_msg->header = rgb_msg->header; 49 | d2c_pub_.publish(d2c_msg); 50 | } 51 | } // namespace astra_camera 52 | -------------------------------------------------------------------------------- /src/list_devices_node.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************/ 2 | /* */ 3 | /* Copyright (c) 2013-2022 Orbbec 3D Technology, Inc */ 4 | /* */ 5 | /* PROPRIETARY RIGHTS of Orbbec 3D Technology are involved in the */ 6 | /* subject matter of this material. All manufacturing, reproduction, use, */ 7 | /* and sales rights pertaining to this subject matter are governed by the */ 8 | /* license agreement. The recipient of this software implicitly accepts */ 9 | /* the terms of the license. */ 10 | /* */ 11 | /**************************************************************************/ 12 | #include 13 | 14 | #include "astra_camera/ob_context.h" 15 | 16 | void DeviceConnectedCallback(const openni::DeviceInfo* device_info) { 17 | std::cout << "Device connected: " << device_info->getName() << std::endl; 18 | auto device = std::make_shared(); 19 | auto uri = device_info->getUri(); 20 | std::cout << "URI: " << uri << std::endl; 21 | device->open(uri); 22 | char serial_number[64]; 23 | int data_size = sizeof(serial_number); 24 | device->getProperty(openni::OBEXTENSION_ID_SERIALNUMBER, serial_number, &data_size); 25 | std::cout << "Serial number: " << serial_number << std::endl; 26 | device->close(); 27 | } 28 | 29 | int main() { 30 | openni::OpenNI::initialize(); 31 | auto disconnected_cb = [](const openni::DeviceInfo* device_info) { 32 | std::cout << "device " << device_info->getUri() << " disconnected" << std::endl; 33 | }; 34 | auto context = std::make_unique(disconnected_cb); 35 | auto device_list = context->queryDeviceList(); 36 | for (auto& device_info : device_list) { 37 | DeviceConnectedCallback(&device_info); 38 | } 39 | openni::OpenNI::shutdown(); 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************/ 2 | /* */ 3 | /* Copyright (c) 2013-2022 Orbbec 3D Technology, Inc */ 4 | /* */ 5 | /* PROPRIETARY RIGHTS of Orbbec 3D Technology are involved in the */ 6 | /* subject matter of this material. All manufacturing, reproduction, use, */ 7 | /* and sales rights pertaining to this subject matter are governed by the */ 8 | /* license agreement. The recipient of this software implicitly accepts */ 9 | /* the terms of the license. */ 10 | /* */ 11 | /**************************************************************************/ 12 | 13 | #include 14 | 15 | #include "astra_camera/ob_camera_node_factory.h" 16 | using namespace astra_camera; 17 | int main(int argc, char** argv) { 18 | ROS_INFO_STREAM("Starting camera node..."); 19 | ros::init(argc, argv, "astra_camera_node"); 20 | ros::NodeHandle nh; 21 | ros::NodeHandle nh_private("~"); 22 | ROS_INFO_STREAM("Creating camera node..."); 23 | OBCameraNodeFactory node_factory(nh, nh_private); 24 | ROS_INFO_STREAM("Creating camera node done..."); 25 | ros::spin(); 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /src/ob_context.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************/ 2 | /* */ 3 | /* Copyright (c) 2013-2022 Orbbec 3D Technology, Inc */ 4 | /* */ 5 | /* PROPRIETARY RIGHTS of Orbbec 3D Technology are involved in the */ 6 | /* subject matter of this material. All manufacturing, reproduction, use, */ 7 | /* and sales rights pertaining to this subject matter are governed by the */ 8 | /* license agreement. The recipient of this software implicitly accepts */ 9 | /* the terms of the license. */ 10 | /* */ 11 | /**************************************************************************/ 12 | 13 | #include 14 | 15 | namespace astra_camera { 16 | Context::Context(DeviceDisconnectedCb device_disconnected_cb) 17 | : openni::OpenNI::DeviceConnectedListener(), 18 | openni::OpenNI::DeviceDisconnectedListener(), 19 | openni::OpenNI::DeviceStateChangedListener(), 20 | device_disconnected_cb_(std::move(device_disconnected_cb)) { 21 | openni::OpenNI::addDeviceConnectedListener(this); 22 | openni::OpenNI::addDeviceDisconnectedListener(this); 23 | openni::OpenNI::addDeviceStateChangedListener(this); 24 | } 25 | 26 | std::vector Context::queryDeviceList() { 27 | // get list of currently connected devices 28 | std::vector device_list; 29 | if (first_time_query_) { 30 | openni::Array device_info_list; 31 | openni::OpenNI::enumerateDevices(&device_info_list); 32 | ROS_INFO_STREAM("Found " << device_info_list.getSize() << " devices"); 33 | for (int i = 0; i < device_info_list.getSize(); ++i) { 34 | device_list.emplace_back(device_info_list[i]); 35 | std::lock_guard lock(mutex_); 36 | device_info_list_[device_info_list[i].getUri()] = device_info_list[i]; 37 | } 38 | first_time_query_ = false; 39 | } else { 40 | std::lock_guard lock(mutex_); 41 | for (auto& device_info : device_info_list_) { 42 | device_list.emplace_back(device_info.second); 43 | } 44 | } 45 | return device_list; 46 | } 47 | 48 | Context::~Context() { 49 | openni::OpenNI::removeDeviceConnectedListener(this); 50 | openni::OpenNI::removeDeviceDisconnectedListener(this); 51 | openni::OpenNI::removeDeviceStateChangedListener(this); 52 | } 53 | 54 | void Context::onDeviceStateChanged(const openni::DeviceInfo* device_info, 55 | openni::DeviceState state) { 56 | ROS_INFO_STREAM("Device " << device_info->getUri() << " state changed to " << state); 57 | } 58 | 59 | void Context::onDeviceConnected(const openni::DeviceInfo* device_info) { 60 | ROS_INFO_STREAM("Context::onDeviceConnected"); 61 | std::lock_guard lock(mutex_); 62 | device_info_list_[device_info->getUri()] = *device_info; 63 | ROS_INFO_STREAM("Context::onDeviceConnected done"); 64 | } 65 | 66 | void Context::onDeviceDisconnected(const openni::DeviceInfo* device_info) { 67 | ROS_INFO_STREAM("Context::onDeviceDisconnected"); 68 | std::lock_guard lock(mutex_); 69 | device_disconnected_cb_(device_info); 70 | ROS_INFO_STREAM("Context::onDeviceDisconnected done."); 71 | device_info_list_.erase(device_info->getUri()); 72 | } 73 | } // namespace astra_camera 74 | -------------------------------------------------------------------------------- /src/point_cloud_proc/point_cloud_xyz.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | * Software License Agreement (BSD License) 3 | * 4 | * Copyright (c) 2008, Willow Garage, Inc. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following 15 | * disclaimer in the documentation and/or other materials provided 16 | * with the distribution. 17 | * * Neither the name of the Willow Garage nor the names of its 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 31 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | * POSSIBILITY OF SUCH DAMAGE. 33 | *********************************************************************/ 34 | 35 | #include "astra_camera/point_cloud_proc/point_cloud_xyz.h" 36 | 37 | namespace astra_camera { 38 | PointCloudXyzNode::PointCloudXyzNode(ros::NodeHandle &nh, ros::NodeHandle &nh_private) 39 | : nh_(nh), nh_private_(nh_private) { 40 | nh_private_.param("queue_size", queue_size_, 5); 41 | ros::SubscriberStatusCallback connect_cb = std::bind(&PointCloudXyzNode::connectCb, this); 42 | ros::SubscriberStatusCallback disconnect_cb = std::bind(&PointCloudXyzNode::disconnectCb, this); 43 | it_.reset(new image_transport::ImageTransport(nh)); 44 | 45 | std::lock_guard lock_(connect_mutex_); 46 | pub_point_cloud_ = nh_.advertise("depth/points", queue_size_, 47 | connect_cb, disconnect_cb); 48 | save_point_cloud_srv_ = nh_.advertiseService( 49 | "save_point_cloud_xyz", 50 | [this](auto &&req, auto &&res) { return this->SavePointCloudXyzCallback(req, res); }); 51 | } 52 | 53 | PointCloudXyzNode::~PointCloudXyzNode() = default; 54 | 55 | void PointCloudXyzNode::connectCb() { 56 | std::lock_guard lock(connect_mutex_); 57 | if (!sub_depth_) { 58 | image_transport::TransportHints hints("raw", ros::TransportHints(), nh_private_); 59 | sub_depth_ = it_->subscribeCamera("depth/image_raw", queue_size_, &PointCloudXyzNode::depthCb, 60 | this, hints); 61 | } 62 | } 63 | 64 | void PointCloudXyzNode::disconnectCb() { 65 | if (pub_point_cloud_.getNumSubscribers() == 0) { 66 | sub_depth_.shutdown(); 67 | } 68 | } 69 | 70 | void PointCloudXyzNode::depthCb(const sensor_msgs::ImageConstPtr &depth_msg, 71 | const sensor_msgs::CameraInfoConstPtr &info_msg) { 72 | PointCloud2::Ptr cloud_msg(new PointCloud2); 73 | cloud_msg->header = depth_msg->header; 74 | cloud_msg->height = depth_msg->height; 75 | cloud_msg->width = depth_msg->width; 76 | cloud_msg->is_dense = false; 77 | cloud_msg->is_bigendian = false; 78 | sensor_msgs::PointCloud2Modifier pcd_modifier(*cloud_msg); 79 | pcd_modifier.setPointCloud2FieldsByString(1, "xyz"); 80 | 81 | // Update camera model 82 | model_.fromCameraInfo(info_msg); 83 | 84 | if (depth_msg->encoding == enc::TYPE_16UC1 || depth_msg->encoding == enc::MONO16) { 85 | convert(depth_msg, cloud_msg, model_); 86 | } else if (depth_msg->encoding == enc::TYPE_32FC1) { 87 | convert(depth_msg, cloud_msg, model_); 88 | } else { 89 | ROS_WARN_THROTTLE(5, "Depth image has unsupported encoding [%s]", depth_msg->encoding.c_str()); 90 | return; 91 | } 92 | if (save_cloud_) { 93 | save_cloud_ = false; 94 | auto now = std::time(nullptr); 95 | std::stringstream ss; 96 | ss << std::put_time(std::localtime(&now), "%Y%m%d_%H%M%S"); 97 | auto current_path = boost::filesystem::current_path().string(); 98 | std::string filename = current_path + "/point_cloud/points_xyz_" + ss.str() + ".ply"; 99 | if (!boost::filesystem::exists(current_path + "/point_cloud")) { 100 | boost::filesystem::create_directory(current_path + "/point_cloud"); 101 | } 102 | ROS_INFO_STREAM("Saving point cloud to " << filename); 103 | savePointToPly(cloud_msg, filename); 104 | } 105 | pub_point_cloud_.publish(cloud_msg); 106 | } 107 | 108 | bool PointCloudXyzNode::SavePointCloudXyzCallback(std_srvs::Empty::Request &request, 109 | std_srvs::Empty::Response &response) { 110 | (void)request; 111 | (void)response; 112 | ROS_INFO("SavePointCloudXyzCallback"); 113 | save_cloud_ = true; 114 | return true; 115 | } 116 | 117 | } // namespace astra_camera 118 | -------------------------------------------------------------------------------- /srv/GetBool.srv: -------------------------------------------------------------------------------- 1 | --- 2 | bool data 3 | bool success 4 | string message 5 | -------------------------------------------------------------------------------- /srv/GetCameraInfo.srv: -------------------------------------------------------------------------------- 1 | --- 2 | sensor_msgs/CameraInfo info 3 | bool success 4 | string message 5 | -------------------------------------------------------------------------------- /srv/GetCameraParams.srv: -------------------------------------------------------------------------------- 1 | --- 2 | float32[4] l_intr_p 3 | float32[4] r_intr_p 4 | float32[9] r2l_r 5 | float32[3] r2l_t 6 | float32[5] l_k 7 | float32[5] r_k 8 | bool success 9 | string message 10 | -------------------------------------------------------------------------------- /srv/GetDeviceInfo.srv: -------------------------------------------------------------------------------- 1 | --- 2 | DeviceInfo info 3 | bool success 4 | string message 5 | -------------------------------------------------------------------------------- /srv/GetDouble.srv: -------------------------------------------------------------------------------- 1 | --- 2 | float64 data 3 | bool success 4 | string message 5 | -------------------------------------------------------------------------------- /srv/GetInt32.srv: -------------------------------------------------------------------------------- 1 | --- 2 | int32 data 3 | bool success 4 | string message 5 | -------------------------------------------------------------------------------- /srv/GetString.srv: -------------------------------------------------------------------------------- 1 | --- 2 | string data 3 | bool success 4 | string message 5 | -------------------------------------------------------------------------------- /srv/SetInt32.srv: -------------------------------------------------------------------------------- 1 | int32 data 2 | --- 3 | bool success 4 | string message 5 | -------------------------------------------------------------------------------- /srv/SetString.srv: -------------------------------------------------------------------------------- 1 | string data 2 | --- 3 | bool success 4 | string message 5 | -------------------------------------------------------------------------------- /test/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orbbec/ros_astra_camera/affcfae0bc4786b5f64177ba852577742cdefa90/test/.gitkeep --------------------------------------------------------------------------------