├── .gitignore ├── README.md ├── demo ├── obstacle_bypass │ ├── balance_strategy │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ ├── DJICommonType.h │ │ │ ├── DJI_API.h │ │ │ ├── DJI_App.h │ │ │ ├── DJI_Camera.h │ │ │ ├── DJI_Codec.h │ │ │ ├── DJI_Config.h │ │ │ ├── DJI_Flight.h │ │ │ ├── DJI_Follow.h │ │ │ ├── DJI_HardDriver.h │ │ │ ├── DJI_HardDriver_Manifold.h │ │ │ ├── DJI_HotPoint.h │ │ │ ├── DJI_Link.h │ │ │ ├── DJI_Memory.h │ │ │ ├── DJI_Mission.h │ │ │ ├── DJI_Type.h │ │ │ ├── DJI_Version.h │ │ │ ├── DJI_VirtualRC.h │ │ │ ├── DJI_WayPoint.h │ │ │ ├── DJI_guidance.h │ │ │ ├── DJI_utility.h │ │ │ ├── imagetransfer.h │ │ │ ├── libDJI_guidance.so │ │ │ └── usb_transfer.h │ │ ├── launch │ │ │ └── sdk_demo.launch │ │ ├── package.xml │ │ └── src │ │ │ ├── dji_sdk_node.cpp │ │ │ └── sdk_lib │ │ │ ├── DJI_API.cpp │ │ │ ├── DJI_App.cpp │ │ │ ├── DJI_Camera.cpp │ │ │ ├── DJI_Codec.cpp │ │ │ ├── DJI_Flight.cpp │ │ │ ├── DJI_Follow.cpp │ │ │ ├── DJI_HardDriver.cpp │ │ │ ├── DJI_HotPoint.cpp │ │ │ ├── DJI_Link.cpp │ │ │ ├── DJI_Memory.cpp │ │ │ ├── DJI_Mission.cpp │ │ │ ├── DJI_VirtualRC.cpp │ │ │ ├── DJI_WayPoint.cpp │ │ │ └── DJI_utility.cpp │ ├── discontinuity-balance_strategy │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ ├── DJICommonType.h │ │ │ ├── DJI_API.h │ │ │ ├── DJI_App.h │ │ │ ├── DJI_Camera.h │ │ │ ├── DJI_Codec.h │ │ │ ├── DJI_Config.h │ │ │ ├── DJI_Flight.h │ │ │ ├── DJI_Follow.h │ │ │ ├── DJI_HardDriver.h │ │ │ ├── DJI_HardDriver_Manifold.h │ │ │ ├── DJI_HotPoint.h │ │ │ ├── DJI_Link.h │ │ │ ├── DJI_Memory.h │ │ │ ├── DJI_Mission.h │ │ │ ├── DJI_Type.h │ │ │ ├── DJI_Version.h │ │ │ ├── DJI_VirtualRC.h │ │ │ ├── DJI_WayPoint.h │ │ │ ├── DJI_guidance.h │ │ │ ├── DJI_utility.h │ │ │ ├── imagetransfer.h │ │ │ ├── libDJI_guidance.so │ │ │ └── usb_transfer.h │ │ ├── launch │ │ │ └── sdk_demo.launch │ │ ├── package.xml │ │ └── src │ │ │ ├── dji_sdk_node.cpp │ │ │ └── sdk_lib │ │ │ ├── DJI_API.cpp │ │ │ ├── DJI_App.cpp │ │ │ ├── DJI_Camera.cpp │ │ │ ├── DJI_Codec.cpp │ │ │ ├── DJI_Flight.cpp │ │ │ ├── DJI_Follow.cpp │ │ │ ├── DJI_HardDriver.cpp │ │ │ ├── DJI_HotPoint.cpp │ │ │ ├── DJI_Link.cpp │ │ │ ├── DJI_Memory.cpp │ │ │ ├── DJI_Mission.cpp │ │ │ ├── DJI_VirtualRC.cpp │ │ │ ├── DJI_WayPoint.cpp │ │ │ └── DJI_utility.cpp │ ├── discontinuity_strategy │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ ├── DJICommonType.h │ │ │ ├── DJI_API.h │ │ │ ├── DJI_App.h │ │ │ ├── DJI_Camera.h │ │ │ ├── DJI_Codec.h │ │ │ ├── DJI_Config.h │ │ │ ├── DJI_Flight.h │ │ │ ├── DJI_Follow.h │ │ │ ├── DJI_HardDriver.h │ │ │ ├── DJI_HardDriver_Manifold.h │ │ │ ├── DJI_HotPoint.h │ │ │ ├── DJI_Link.h │ │ │ ├── DJI_Memory.h │ │ │ ├── DJI_Mission.h │ │ │ ├── DJI_Type.h │ │ │ ├── DJI_Version.h │ │ │ ├── DJI_VirtualRC.h │ │ │ ├── DJI_WayPoint.h │ │ │ ├── DJI_guidance.h │ │ │ ├── DJI_utility.h │ │ │ ├── imagetransfer.h │ │ │ ├── libDJI_guidance.so │ │ │ └── usb_transfer.h │ │ ├── launch │ │ │ └── sdk_demo.launch │ │ ├── package.xml │ │ └── src │ │ │ ├── dji_sdk_node.cpp │ │ │ └── sdk_lib │ │ │ ├── DJI_API.cpp │ │ │ ├── DJI_App.cpp │ │ │ ├── DJI_Camera.cpp │ │ │ ├── DJI_Codec.cpp │ │ │ ├── DJI_Flight.cpp │ │ │ ├── DJI_Follow.cpp │ │ │ ├── DJI_HardDriver.cpp │ │ │ ├── DJI_HotPoint.cpp │ │ │ ├── DJI_Link.cpp │ │ │ ├── DJI_Memory.cpp │ │ │ ├── DJI_Mission.cpp │ │ │ ├── DJI_VirtualRC.cpp │ │ │ ├── DJI_WayPoint.cpp │ │ │ └── DJI_utility.cpp │ └── readme.md └── sdk_tracking_camshift │ ├── camshift.2010.sln │ ├── camshift.2010.suo │ ├── camshift.2013.sln │ ├── camshift.2013.v12.suo │ ├── camshift │ ├── DJI_utility.cpp │ ├── DJI_utility.h │ ├── Makefile │ ├── camshift.2010.vcxproj │ ├── camshift.2010.vcxproj.filters │ ├── camshift.2010.vcxproj.user │ ├── camshift.2013.vcxproj │ ├── camshift.2013.vcxproj.filters │ ├── camshift.2013.vcxproj.user │ ├── camshiftDepth.cpp │ └── log.txt │ ├── readme.txt │ ├── use_Guidance_vs2010_x64.props │ ├── use_Guidance_vs2010_x86.props │ ├── use_Guidance_vs2013_x64.props │ ├── use_Guidance_vs2013_x86.props │ ├── use_opencv_debug_vs2010_x64.props │ ├── use_opencv_debug_vs2010_x86.props │ ├── use_opencv_release_vs2010_x64.props │ ├── use_opencv_release_vs2010_x86.props │ ├── use_opencv_release_vs2013_x64.props │ └── use_opencv_release_vs2013_x86.props ├── doc └── 51-guidance.rules ├── examples ├── uart_example │ ├── Makefile │ ├── crc16.cpp │ ├── crc16.h │ ├── crc32.cpp │ ├── crc32.h │ ├── linux │ │ ├── serial.cpp │ │ └── serial.h │ ├── main.cpp │ ├── protocal_uart_sdk.cpp │ ├── protocal_uart_sdk.h │ ├── uart_sdk_2010.sln │ ├── uart_sdk_2010.vcxproj │ ├── uart_sdk_2010.vcxproj.filters │ ├── uart_sdk_2010.vcxproj.user │ └── windows │ │ ├── serial.cpp │ │ └── serial.h └── usb_example │ ├── DJI_guidance_example-vs2013.sln │ ├── DJI_guidance_example │ ├── CMakeLists.txt │ ├── DJI_guidance_example_vs2010.vcxproj │ ├── DJI_guidance_example_vs2010.vcxproj.filters │ ├── DJI_guidance_example_vs2010.vcxproj.user │ ├── DJI_guidance_example_vs2013.vcxproj │ ├── DJI_guidance_example_vs2013.vcxproj.user │ ├── DJI_utility.cpp │ ├── DJI_utility.h │ ├── Makefile │ ├── Makefile_noOpenCV │ └── main.cpp │ ├── DJI_guidance_example_vs2010.sln │ ├── DJI_guidance_for_matlab │ ├── DJI_guidance_for_matlab.cpp │ ├── DJI_guidance_for_matlab_2010.vcxproj │ ├── DJI_guidance_for_matlab_2010.vcxproj.filters │ ├── DJI_guidance_for_matlab_2010.vcxproj.user │ ├── DJI_utility.cpp │ ├── DJI_utility.h │ └── matlabGuidance.m │ ├── use_Guidance_vs2010_x64.props │ ├── use_Guidance_vs2010_x86.props │ ├── use_Guidance_vs2013_x64.props │ ├── use_Guidance_vs2013_x86.props │ ├── use_opencv_debug_vs2010_x64.props │ ├── use_opencv_debug_vs2010_x86.props │ ├── use_opencv_release_vs2010_x64.props │ ├── use_opencv_release_vs2010_x86.props │ ├── use_opencv_release_vs2013_x64.props │ └── use_opencv_release_vs2013_x86.props ├── include └── DJI_guidance.h ├── lib ├── 2010 │ ├── x64 │ │ ├── DJI_guidance.dll │ │ └── DJI_guidance.lib │ └── x86 │ │ ├── DJI_guidance.dll │ │ └── DJI_guidance.lib └── 2013 │ ├── x64 │ ├── DJI_guidance.dll │ └── DJI_guidance.lib │ └── x86 │ ├── DJI_guidance.dll │ └── DJI_guidance.lib └── so ├── TX1 ├── Makefile ├── README.txt └── libDJI_guidance.so ├── XU3 └── libDJI_guidance.so ├── arm └── libDJI_guidance.so ├── x64 └── libDJI_guidance.so └── x86 └── libDJI_guidance.so /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *~ 3 | *.user 4 | *.suo -------------------------------------------------------------------------------- /demo/obstacle_bypass/balance_strategy/include/DJICommonType.h: -------------------------------------------------------------------------------- 1 | #ifndef DJICOMMONTYPE 2 | #define DJICOMMONTYPE 3 | 4 | #include 5 | 6 | namespace DJI 7 | { 8 | 9 | typedef uint64_t time_ms; 10 | typedef uint64_t time_us; // about 0.3 million years 11 | 12 | typedef void *UserData; 13 | typedef uint32_t Flag; 14 | 15 | typedef uint8_t size8_t; 16 | typedef uint16_t size16_t; 17 | 18 | typedef struct Measure 19 | { 20 | double data; 21 | float precision; 22 | } Measure; 23 | 24 | typedef struct SpaceVector 25 | { 26 | double x; 27 | double y; 28 | double z; 29 | } SpaceVector; 30 | 31 | /*! @todo range mathematial class 32 | class Angle 33 | { 34 | public: 35 | Angle(double degree = 0); 36 | 37 | private: 38 | double degree; 39 | }; 40 | */ 41 | 42 | typedef double Angle; 43 | 44 | typedef struct EulerianAngle 45 | { 46 | Angle yaw; 47 | Angle roll; 48 | Angle pitch; 49 | } EulerianAngle; 50 | 51 | } // namespace DJI 52 | 53 | #endif // DJICOMMONTYPE 54 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/balance_strategy/include/DJI_App.h: -------------------------------------------------------------------------------- 1 | /*! @brief 2 | * @file DJI_APP.h 3 | * @version 3.0 4 | * @date Dec 16, 2015 5 | * 6 | * @abstract 7 | * Core API Link upper level for DJI onboardSDK library 8 | * 9 | * @attention 10 | * Project configuration: 11 | * 12 | * @version features: 13 | * -* @version V3.0 14 | * -* DJI-onboard-SDK for Windows,QT,STM32,ROS,Cmake 15 | * -* @date Dec 16, 2015 16 | * -* @author william.wu 17 | * 18 | * */ 19 | 20 | #ifndef DJI_APP_H 21 | #define DJI_APP_H 22 | 23 | #include 24 | 25 | #include "DJI_Link.h" 26 | #include "DJI_Type.h" 27 | 28 | #define MSG_ENABLE_FLAG_LEN 2 29 | 30 | //---------------------------------------------------------------------- 31 | // App layer function 32 | //---------------------------------------------------------------------- 33 | typedef struct 34 | { 35 | unsigned short sequence_number; 36 | unsigned char session_id : 5; 37 | unsigned char need_encrypt : 1; 38 | unsigned char reserve : 2; 39 | } req_id_t; 40 | 41 | #define EXC_DATA_SIZE (16u) 42 | #define SET_CMD_SIZE (2u) 43 | 44 | //---------------------------------------------------------------------- 45 | // for cmd agency 46 | //---------------------------------------------------------------------- 47 | #define REQ_TIME_OUT 0x0000 48 | #define REQ_REFUSE 0x0001 49 | #define CMD_RECIEVE 0x0002 50 | #define STATUS_CMD_EXECUTING 0x0003 51 | #define STATUS_CMD_EXE_FAIL 0x0004 52 | #define STATUS_CMD_EXE_SUCCESS 0x0005 53 | 54 | //! @todo move to type.h 55 | #pragma pack(1) 56 | 57 | typedef struct ActivateData 58 | { 59 | unsigned int ID; 60 | unsigned int reserved; 61 | unsigned int version; 62 | unsigned char iosID[32]; 63 | char *encKey; 64 | } ActivateData; 65 | 66 | typedef struct VersionData 67 | { 68 | unsigned short version_ack; 69 | unsigned int version_crc; 70 | char version_ID[11]; 71 | char version_name[32]; 72 | DJI::onboardSDK::Version version; 73 | } VersionData; 74 | 75 | #pragma pack() 76 | 77 | #endif // DJI_APP_H 78 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/balance_strategy/include/DJI_Camera.h: -------------------------------------------------------------------------------- 1 | /*! @brief 2 | * @file DJI_Camera.h 3 | * @version 3.0 4 | * @date Dec 16, 2015 5 | * 6 | * @abstract 7 | * Camera control API for DJI onboardSDK library 8 | * 9 | * @attention 10 | * Project configuration: 11 | * 12 | * @version features: 13 | * -* @version V3.0 14 | * -* DJI-onboard-SDK for Windows,QT,STM32,ROS,Cmake 15 | * -* @date Dec 16, 2015 16 | * -* @author william.wu 17 | * 18 | * */ 19 | 20 | #ifndef DJI_CAMERA_H 21 | #define DJI_CAMERA_H 22 | 23 | #include "DJI_API.h" 24 | 25 | namespace DJI 26 | { 27 | namespace onboardSDK 28 | { 29 | class Camera 30 | { 31 | public: 32 | enum CAMERA_CODE 33 | { 34 | CODE_GIMBAL_SPEED = 0x1A, 35 | CODE_GIMBAL_ANGLE = 0x1B, 36 | CODE_CAMERA_SHOT = 0x20, 37 | CODE_CAMERA_VIDEO_START = 0x21, 38 | CODE_CAMERA_VIDEO_STOP = 0x22 39 | }; 40 | 41 | public: 42 | Camera(CoreAPI *ControlAPI = 0); 43 | 44 | //! @note all camera control functions are none-callback function. 45 | void setCamera(CAMERA_CODE camera_cmd); 46 | void setGimbalAngle(GimbalAngleData *data); 47 | void setGimbalSpeed(GimbalSpeedData *data); 48 | 49 | GimbalData getGimbal() const; 50 | float32_t getYaw() const; 51 | float32_t getRoll() const; 52 | float32_t getPitch() const; 53 | bool isYawLimit() const; 54 | bool isRollLimit() const; 55 | bool isPitchLimit() const; 56 | 57 | public: //! @note Access method 58 | CoreAPI *getApi() const; 59 | void setApi(CoreAPI *value); 60 | 61 | private: 62 | CoreAPI *api; 63 | }; 64 | } // namespace onboardSDK 65 | } // namespace DJI 66 | 67 | #endif // DJI_CAMERA_H 68 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/balance_strategy/include/DJI_Codec.h: -------------------------------------------------------------------------------- 1 | /*! @brief 2 | * @file DJI_Codec.h 3 | * @version 3.0 4 | * @date Dec 16, 2015 5 | * 6 | * @abstract 7 | * Encode functions for DJI onboardSDK library 8 | * 9 | * @attention 10 | * Project configuration: 11 | * 12 | * @todo spilt this header into 4 header files 13 | * 14 | * @version features: 15 | * -* @version V3.0 16 | * -* DJI-onboard-SDK for Windows,QT,STM32,ROS,Cmake 17 | * -* @date Dec 16, 2015 18 | * -* @author william.wu 19 | * 20 | * */ 21 | 22 | #ifndef DJI_CODEC_H 23 | #define DJI_CODEC_H 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include "DJI_Type.h" 30 | 31 | #define _SDK_MAX_RECV_SIZE (BUFFER_SIZE) 32 | #define _SDK_SOF ((unsigned char)(0xAA)) 33 | #define _SDK_CRC_HEAD_SIZE (2) // CRC16 34 | #define _SDK_CRC_DATA_SIZE (4) // CRC32 35 | #define _SDK_HEAD_DATA_LEN (sizeof(DJI::onboardSDK::Header) - 2) 36 | #define _SDK_FULL_DATA_SIZE_MIN (sizeof(DJI::onboardSDK::Header) + _SDK_CRC_DATA_SIZE) 37 | 38 | #define _SDK_U32_SET(_addr, _val) (*((unsigned int *)(_addr)) = (_val)) 39 | #define _SDK_U16_SET(_addr, _val) (*((unsigned short *)(_addr)) = (_val)) 40 | 41 | #define _SDK_CALC_CRC_HEAD(_msg, _len) \ 42 | sdk_stream_crc16_calc((const unsigned char *)(_msg), _len) 43 | #define _SDK_CALC_CRC_TAIL(_msg, _len) \ 44 | sdk_stream_crc32_calc((const unsigned char *)(_msg), _len) 45 | 46 | 47 | void transformTwoByte(const char *pstr, unsigned char *pdata); 48 | 49 | #endif // DJI_CODEC_H 50 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/balance_strategy/include/DJI_Config.h: -------------------------------------------------------------------------------- 1 | /*! @brief 2 | * @file DJI_Config.h 3 | * @version 3.0 4 | * @date Dec 16, 2015 5 | * 6 | * @abstract 7 | * Configuration optional Micro definitions for DJI onboardSDK library. 8 | * 9 | * @attention 10 | * Project configuration: 11 | * None 12 | * 13 | * @version features: 14 | * -* @version V3.0 15 | * -* DJI-onboard-SDK for Windows,QT,STM32,ROS,Cmake 16 | * -* @date Dec 16, 2015 17 | * -* @author william.wu 18 | * 19 | * */ 20 | 21 | #ifndef DJI_CONFIG_H 22 | #define DJI_CONFIG_H 23 | 24 | #include 25 | #define MEMORY_SIZE 1024 // unit is byte 26 | #define BUFFER_SIZE 1024 27 | #define ACK_SIZE 10 28 | 29 | //! @note it means DJI onboardSDK library will not alloc memory from heap. 30 | //! @todo not available yet, only affect WayPoint 31 | //#define STATIC_MEMORY 32 | 33 | //#define API_MISSION_DATA 34 | //#define API_DEBUG_DATA 35 | //#define API_BUFFER_DATA 36 | //#define API_RTK_DEBUG 37 | #define API_ERROR_DATA 38 | #define API_STATUS_DATA 39 | 40 | //! @note if you do not want to use AES encrypt, comment this micro below 41 | #define USE_ENCRYPT 42 | //#define USE_SIMULATION 43 | 44 | #include "DJI_Version.h" 45 | 46 | #endif // DJI_CONFIG_H 47 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/balance_strategy/include/DJI_Follow.h: -------------------------------------------------------------------------------- 1 | /*! @brief 2 | * @file DJI_Follow.h 3 | * @version 3.0 4 | * @date Dec 16, 2015 5 | * 6 | * @abstract 7 | * Follow API for DJI onboardSDK library 8 | * 9 | * @attention 10 | * Project configuration: 11 | * 12 | * @version features: 13 | * -* @version V3.0 14 | * -* DJI-onboard-SDK for Windows,QT,STM32,ROS,Cmake 15 | * -* @date Dec 21, 2015 16 | * -* @author william.wu 17 | * 18 | * */ 19 | 20 | #ifndef DJI_FOLLOW_H 21 | #define DJI_FOLLOW_H 22 | 23 | #include "DJI_Mission.h" 24 | 25 | namespace DJI 26 | { 27 | namespace onboardSDK 28 | { 29 | 30 | #pragma pack(1) 31 | 32 | typedef struct FollowTarget 33 | { 34 | float64_t latitude; 35 | float64_t longitude; 36 | uint16_t height; 37 | uint16_t angle; 38 | } FollowTarget; 39 | 40 | typedef struct FollowData 41 | { 42 | uint8_t mode; 43 | uint8_t yaw; 44 | FollowTarget target; 45 | uint8_t sensitivity; 46 | } FollowData; 47 | 48 | #pragma pack() 49 | 50 | class Follow 51 | { 52 | public: 53 | enum MODE 54 | { 55 | MODE_RELATIVE = 0, 56 | MODE_ROUTE = 1, //! @note Flight control not support now 57 | MODE_SMART = 2 //! @note Flight control not support now 58 | }; 59 | 60 | enum YAW_TYPE 61 | { 62 | YAW_TOTARGET = 0, 63 | YAW_CUSTOM = 1 64 | }; 65 | 66 | enum SENSITIVITY 67 | { 68 | SENSE_LOW = 0, //! @note Flight control not support now 69 | SENSE_MID = 1, 70 | SENSE_HIGH = 2 //! @note Flight control not support now 71 | }; 72 | 73 | public: 74 | Follow(CoreAPI *ControlAPI = 0); 75 | void resetData(); 76 | 77 | void start(FollowData *Data = 0, CallBack callback = 0, UserData userData = 0); 78 | void stop(CallBack callback = 0, UserData userData = 0); 79 | //! @note true for pause, false for resume 80 | void pause(bool isPause, CallBack callback = 0, UserData userData = 0); 81 | void updateTarget(FollowTarget target); //! @note no ack command 82 | void updateTarget(float64_t latitude, float64_t longitude, uint16_t height, 83 | uint16_t angle); //! @note no ack command 84 | 85 | public: 86 | void setData(const FollowData &value); 87 | void setMode(const MODE mode); 88 | void setTarget(FollowTarget target); 89 | void setYawType(const YAW_TYPE type); 90 | void setSensitivity(const SENSITIVITY sense); 91 | 92 | FollowData getData() const; 93 | 94 | private: 95 | CoreAPI *api; 96 | FollowData data; 97 | }; 98 | 99 | } // namespace onboardSDK 100 | } // namespace DJI 101 | 102 | #endif // DJI_FOLLOW_H 103 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/balance_strategy/include/DJI_HardDriver.h: -------------------------------------------------------------------------------- 1 | /*! @brief 2 | * @file DJI_HardDriver.h 3 | * @version 3.0 4 | * @date Dec 9, 2015 5 | * 6 | * @abstract 7 | * Hard ware level for DJI onboardSDK library 8 | * 9 | * @attention 10 | * Project configuration: 11 | * 12 | * @version features: 13 | * -* @version V3.0 14 | * -* DJI-onboard-SDK for Windows,QT,STM32,ROS,Cmake 15 | * -* @date Dec 9, 2015 16 | * -* @author william.wu 17 | * 18 | * */ 19 | #ifndef DJI_HARDDRIVER_H 20 | #define DJI_HARDDRIVER_H 21 | 22 | #include 23 | #include 24 | #include "DJI_Type.h" 25 | 26 | namespace DJI 27 | { 28 | namespace onboardSDK 29 | { 30 | 31 | class HardDriver 32 | { 33 | public: 34 | HardDriver() {} 35 | 36 | /*! @note How to use 37 | * In order to provide platform crossable DJI onboardSDK library, 38 | * we abstract this class as a hardware level. 39 | * 40 | * @note function descriptions: 41 | * 42 | * void init(); 43 | * @brief After calling this function, HardDriver should be able to 44 | * read and send correctly, through a correct UART part 45 | * 46 | * unsigned int getTimeStamp(); 47 | * @brief returns a TimeStamp data in unit msec. 48 | * The difference between the return value of the function call two times 49 | * is the excat time between them in msec. 50 | * 51 | * size_t send(const uint8_t *buf, size_t len); 52 | * @brief return sent data length. 53 | * 54 | * size_t readall(uint8_t *buf, size_t maxlen) = 0; 55 | * @brief return read data length. 56 | * 57 | * void lockMemory();/ void freeMemory(); 58 | * @brief provide a mutex for multi-thread. when operating memory. 59 | * 60 | * void lockMSG();/ void freeMSG(); 61 | * @brief provide a mutex for multi-thread. when operating messages. 62 | * 63 | * void displayLog(char *buf); 64 | * @brief Micro "API_LOG" invoked this function, to pass datalog. 65 | * In order to pass data through different stream or channel. 66 | * We abstract this virtual function for user. 67 | * And different from others, this interface is not a pure virtual funcion. 68 | * The default data-passing channel is stdout (printf). 69 | * See also "DJI_HardDriver.cpp". 70 | * 71 | * @attention 72 | * when writting and reading data, there might have multi-thread problems. 73 | * Abstract class HardDriver did not consider these issue. 74 | * Please be careful when you are going to implement send and readall 75 | * funtions. 76 | * 77 | * @note 78 | * we strongly suggest you to inherit this class in your own file, not just 79 | * implement 80 | * it in DJI_HardDriver.cpp or inside this class 81 | * 82 | * */ 83 | public: 84 | virtual void init() = 0; 85 | virtual time_ms getTimeStamp() = 0; 86 | virtual size_t send(const uint8_t *buf, size_t len) = 0; 87 | virtual size_t readall(uint8_t *buf, size_t maxlen) = 0; 88 | 89 | public: 90 | virtual void lockMemory() = 0; 91 | virtual void freeMemory() = 0; 92 | 93 | virtual void lockMSG() = 0; 94 | virtual void freeMSG() = 0; 95 | 96 | public: 97 | virtual void displayLog(const char *buf = 0); 98 | }; 99 | } // namespace onboardSDK 100 | } // namespace DJI 101 | 102 | #endif // DJI_HARDDRIVER_H 103 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/balance_strategy/include/DJI_HotPoint.h: -------------------------------------------------------------------------------- 1 | /*! @brief 2 | * @file DJI_HotPoint.h 3 | * @version 3.0 4 | * @date Dec 16, 2015 5 | * 6 | * @abstract 7 | * HotPoint API for DJI onboardSDK library 8 | * 9 | * @attention 10 | * Project configuration: 11 | * 12 | * @version features: 13 | * -* @version V3.0 14 | * -* DJI-onboard-SDK for Windows,QT,STM32,ROS,Cmake 15 | * -* @date Dec 16, 2015 16 | * -* @author william.wu 17 | * 18 | * */ 19 | 20 | #ifndef DJI_HOTPOINT_H 21 | #define DJI_HOTPOINT_H 22 | 23 | #include "DJI_Mission.h" 24 | 25 | namespace DJI 26 | { 27 | namespace onboardSDK 28 | { 29 | 30 | #pragma pack(1) 31 | 32 | typedef struct HotPointData 33 | { 34 | uint8_t version; 35 | 36 | float64_t latitude; 37 | float64_t longitude; 38 | float64_t height; 39 | 40 | float64_t radius; 41 | float32_t palstance; // degree 42 | 43 | uint8_t clockwise; 44 | uint8_t startPoint; 45 | uint8_t yawMode; 46 | uint8_t reserved[11]; 47 | } HotPointData; 48 | 49 | #pragma pack() 50 | 51 | class HotPoint 52 | { 53 | public: 54 | #pragma pack(1) 55 | typedef struct StartACK 56 | { 57 | uint8_t ack; 58 | float32_t maxRadius; 59 | } StartACK; 60 | 61 | typedef struct Palstance 62 | { 63 | uint8_t clockwise; 64 | float32_t palstance; 65 | } Palstance; 66 | 67 | typedef struct ReadACK 68 | { 69 | MissionACK ack; 70 | HotPointData data; 71 | } ReadACK; 72 | #pragma pack() 73 | 74 | enum View 75 | { 76 | VIEW_NORTH = 0, 77 | VIEW_SOUTH = 1, 78 | VIEW_WEST = 2, 79 | VIEW_EAST = 3, 80 | VIEW_NEARBY = 4 81 | }; 82 | 83 | enum YawMode 84 | { 85 | YAW_AUTO = 0, 86 | YAW_INSIDE = 1, 87 | YAW_OUTSIDE = 2, 88 | YAW_CUSTOM = 3, 89 | YAW_STATIC = 4, 90 | }; 91 | 92 | public: 93 | HotPoint(CoreAPI *ControlAPI = 0); 94 | void initData(); 95 | 96 | /*! @note API functions 97 | * @attention difference between set and update 98 | * Set functions only change the HotPoint data in this class, 99 | * Update functions will change the Mission status. 100 | * In other words: drone will response update functions immediately. 101 | * */ 102 | 103 | void start(CallBack callback = 0, UserData userData = 0); 104 | void stop(CallBack callback = 0, UserData userData = 0); 105 | void pause(bool isPause, CallBack callback = 0, UserData userData = 0); 106 | 107 | void updatePalstance(Palstance &Data, CallBack callback = 0, UserData userData = 0); 108 | void updatePalstance(float32_t palstance, bool isClockwise, CallBack callback = 0, 109 | UserData userData = 0); 110 | void updateRadius(float32_t meter, CallBack callback = 0, UserData userData = 0); 111 | void resetYaw(CallBack callback = 0, UserData userData = 0); 112 | 113 | void readData(CallBack callback = 0, UserData userData = 0); 114 | 115 | public: 116 | //! @note data access functions 117 | void setData(const HotPointData &value); 118 | void setHotPoint(float64_t longtitude, float64_t latitude, float64_t altitude); 119 | void setHotPoint(GPSPositionData gps); 120 | void setRadius(float64_t meter); 121 | void setPalstance(float32_t defree); 122 | void setClockwise(bool isClockwise); 123 | void setCameraView(View view); 124 | void setYawMode(YawMode mode); 125 | 126 | HotPointData getData() const; 127 | 128 | public: 129 | static void startCallback(CoreAPI *This, Header *header, UserData userdata = 0); 130 | static void readCallback(CoreAPI *This, Header *header, UserData userdata); 131 | 132 | private: 133 | CoreAPI *api; 134 | HotPointData data; 135 | }; 136 | 137 | } // namespace onboardSDK 138 | } // namespace DJI 139 | 140 | #endif // DJI_HOTPOINT_H 141 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/balance_strategy/include/DJI_Link.h: -------------------------------------------------------------------------------- 1 | /*! @brief 2 | * @file DJI_Link.h 3 | * @version 3.0 4 | * @date Dec 4, 2015 5 | * 6 | * @abstract 7 | * 8 | * @attention 9 | * Project configuration: 10 | * 11 | * @version features: 12 | * -* @version V3.0 13 | * -* DJI-onboard-SDK for Windows,QT,STM32,ROS,Cmake 14 | * -* @date Nov 15, 2015 15 | * -* @author william.wu 16 | * -* 17 | * -* @version V2.0 18 | * -* C-like DJI-onboard-SDK library 19 | * -* @date Mar 12, 2015 20 | * -* @author wuyuwei 21 | * 22 | * */ 23 | #ifndef DJI_LINK_H 24 | #define DJI_LINK_H 25 | 26 | #define ACK_SESSION_IDLE 0 27 | #define ACK_SESSION_PROCESS 1 28 | #define ACK_SESSION_USING 2 29 | #define CMD_SESSION_0 0 30 | #define CMD_SESSION_1 1 31 | #define CMD_SESSION_AUTO 32 32 | 33 | 34 | #define POLL_TICK 20 // unit is ms 35 | 36 | #include "DJI_Type.h" 37 | 38 | #endif // DJI_LINK_H 39 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/balance_strategy/include/DJI_Memory.h: -------------------------------------------------------------------------------- 1 | #ifndef DJI_MEMORY_H 2 | #define DJI_MEMORY_H 3 | 4 | #include "DJI_Type.h" 5 | 6 | #endif // DJI_MEMORY_H 7 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/balance_strategy/include/DJI_Mission.h: -------------------------------------------------------------------------------- 1 | /*! @brief 2 | * @file DJI_Codec.h 3 | * @version 3.0 4 | * @date Dec 16, 2015 5 | * 6 | * @abstract 7 | * Mission framework for DJI onboardSDK library 8 | * 9 | * @attention 10 | * Project configuration: 11 | * 12 | * @version features: 13 | * -* @version V3.0 14 | * -* DJI-onboard-SDK for Windows,QT,STM32,ROS,Cmake 15 | * -* @date Dec 16, 2015 16 | * -* @author william.wu 17 | * 18 | * */ 19 | 20 | #ifndef DJI_MISSION_H 21 | #define DJI_MISSION_H 22 | 23 | #include "DJI_Config.h" 24 | #include "DJI_API.h" 25 | 26 | namespace DJI 27 | { 28 | namespace onboardSDK 29 | { 30 | #pragma pack(1) 31 | 32 | typedef struct HotPointACKData 33 | { 34 | uint8_t status; 35 | uint16_t radius; // in cm 36 | uint8_t failReasion; 37 | uint8_t palstance; 38 | } HotPointADKData; 39 | 40 | //! @todo unify the naming style 41 | typedef struct GSPushData 42 | { 43 | uint8_t type; 44 | uint8_t data_1; 45 | uint8_t data_2; 46 | uint8_t data_3; 47 | uint8_t data_4; 48 | uint8_t data_5; 49 | } GSPushData; 50 | 51 | #pragma pack() 52 | 53 | typedef struct MissionACKMap 54 | { 55 | uint8_t code; 56 | const char *meaning; 57 | } MissionACKMap; 58 | 59 | void missionCallback(CoreAPI *This, Header *header, UserData userdata = 0); 60 | 61 | } // namespace onboardSDK 62 | } // namespace DJI 63 | 64 | #endif // DJI_MISSION_H 65 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/balance_strategy/include/DJI_Version.h: -------------------------------------------------------------------------------- 1 | /*! @brief 2 | * @file DJI_Version.h 3 | * @version 3.0 4 | * @date Dec 16, 2015 5 | * 6 | * @abstract 7 | * Version control definition for DJI onboardSDK library 8 | * Maintain officially 9 | * 10 | * @attention 11 | * Maintain officially, readonly for users 12 | * Do not modify any definition in this file, 13 | * if you are not sure what are you doing exactlly, 14 | * or we will not provide any support. 15 | * 16 | * Project configuration: 17 | * 18 | * @version features: 19 | * -* @version V3.0 20 | * -* DJI-onboard-SDK for Windows,QT,STM32,ROS,Cmake 21 | * -* @date Dec 16, 2015 22 | * -* @author william.wu 23 | * 24 | * */ 25 | 26 | /*! @attention 27 | * Maintain officially, readonly for users 28 | * Do not modify any definition in this file, 29 | * if you are not sure what are you doing exactlly, 30 | * or we will not provide any support. 31 | * */ 32 | 33 | #ifndef DJI_VERSION_H 34 | #define DJI_VERSION_H 35 | 36 | #include 37 | 38 | #define MAKE_VERSION(a, b, c, d) \ 39 | (((a << 24) & 0xff000000) | ((b << 16) & 0x00ff0000) | ((c << 8) & 0x0000ff00) | \ 40 | (d & 0x000000ff)) 41 | 42 | namespace DJI 43 | { 44 | namespace onboardSDK 45 | { 46 | //! @todo better version control structure 47 | typedef uint32_t Version; 48 | 49 | const Version versionM100_23 = (MAKE_VERSION(2, 3, 10, 0)); 50 | const Version versionM100_31 = (MAKE_VERSION(3, 1, 10, 0)); 51 | const Version versionA3_31 = (MAKE_VERSION(3, 1, 100, 0)); 52 | const Version SDK_VERSION = versionM100_31; 53 | 54 | #ifdef SDK_DEV 55 | #include "dev.h" 56 | #endif // SDK_DEV 57 | 58 | } // namespace DJI 59 | } // namespace onboardSDK 60 | 61 | #endif // DJI_VERSION_H 62 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/balance_strategy/include/DJI_VirtualRC.h: -------------------------------------------------------------------------------- 1 | /*! @brief 2 | * @file DJI_Codec.h 3 | * @version 3.0 4 | * @date Dec 16, 2015 5 | * 6 | * @abstract 7 | * Virtual Radio Control API for DJI onboardSDK library 8 | * 9 | * @attention 10 | * Project configuration: 11 | * 12 | * @version features: 13 | * -* @version V3.0 14 | * -* DJI-onboard-SDK for Windows,QT,STM32,ROS,Cmake 15 | * -* @date Dec 16, 2015 16 | * -* @author william.wu 17 | * 18 | * */ 19 | 20 | #ifndef DJI_VIRTUALRC_H 21 | #define DJI_VIRTUALRC_H 22 | 23 | #include "DJI_API.h" 24 | 25 | namespace DJI 26 | { 27 | namespace onboardSDK 28 | { 29 | 30 | class VirtualRC 31 | { 32 | public: 33 | //! @todo spelling correction 34 | enum CutOff 35 | { 36 | CutOff_ToLogic = 0, 37 | CutOff_ToRealRC = 1 38 | }; 39 | 40 | public: 41 | VirtualRC(CoreAPI *ControlAPI = 0); 42 | 43 | /*! @attention Safety notes 44 | * You must use these methods below really carefully with following rules: 45 | * - Use API setControl(bool enable, CutOff cutoffType); only once in your main loop; 46 | * - Check your control device status by useing the following method: 47 | * if(getControlDevice() != CONTROL_BY_VIRTUALRC) 48 | * { 49 | * reset code; 50 | * } 51 | * - @attention Your reset code must not be "setControl(true);" without any status check 52 | * It may cause your drone became a nut drone. 53 | * - @note You could quit your VRC(Virtual Remot Control) by switching your remote 54 | * controller out of modeF 55 | * - @attention Most dangerous, setControl(true); must not be called over 0.5Hz or your 56 | * drone will be locked in a logic-checking loop. And you cannot exit VirtualRC mode by 57 | * switching your remote controller's mode. Actually, in this situation your drone will 58 | * be a full automatically controlled by it self. It will keep flying until its bettery 59 | * is empty or your code make it stop. 60 | * - @attention If you do not know what reset code you need to write, please just output 61 | * your datalog and keep it empty. 62 | * - @attention It would be realy dangous if you keep calling sendData(); in a loop with out 63 | * control-losing protection. like : 64 | * 65 | * Global: 66 | * VirtualRCData myData; 67 | * 68 | * Thread 1: 69 | * while(1) 70 | * { 71 | * myData = myAPIToSetupDataFromGroundStation(); 72 | * } 73 | * 74 | * Thread 2: 75 | * while(1) 76 | * { 77 | * sendData(myData); 78 | * msleep(200); 79 | * } 80 | * 81 | * When your drone lose signal, it will keep the recent command sent by your API: 82 | * myAPIToSetupDataFromGroundStation(); 83 | * Somehow, you will never get your drone back in one pice, if this tragedy happend. 84 | * 85 | * @note API "sendData();" need to be called above 2Hz, and not greater than 25hz. 86 | * @note API "sendSafeModeData();" will lead your drone hover; 87 | * 88 | * */ 89 | void setControl(bool enable, CutOff cutoffType); 90 | void sendData(VirtualRCData Data); 91 | void sendData(); 92 | void resetData(); 93 | void sendSafeModeData(); 94 | 95 | VirtualRCData getVRCData() const; 96 | RadioData getRCData() const; 97 | 98 | void setVRCData(const VirtualRCData &value); 99 | 100 | bool isVirtualRC() const; 101 | 102 | public: 103 | static RadioData toRadioData(VirtualRCData &vData); 104 | static VirtualRCData toVirtualRCData(RadioData &rData); 105 | 106 | public: 107 | CoreAPI *getApi() const; 108 | void setApi(CoreAPI *value); 109 | 110 | private: 111 | CoreAPI *api; 112 | VirtualRCData data; 113 | }; 114 | 115 | } // namespace onboardSDK 116 | } // namespace DJI 117 | 118 | #endif // DJI_VIRTUALRC_H 119 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/balance_strategy/include/DJI_utility.h: -------------------------------------------------------------------------------- 1 | #ifndef __DJI_UTILITY_H__ 2 | #define __DJI_UTILITY_H__ 3 | #include 4 | 5 | #ifdef WIN32 6 | 7 | #include 8 | #include 9 | 10 | class DJI_lock 11 | { 12 | public: 13 | DJI_lock(); 14 | ~DJI_lock(); 15 | void enter(); 16 | void leave(); 17 | private: 18 | CRITICAL_SECTION m_critical_section; 19 | }; 20 | 21 | class DJI_event 22 | { 23 | public: 24 | DJI_event(); 25 | ~DJI_event(); 26 | int set_DJI_event(); 27 | int wait_DJI_event(); 28 | private: 29 | HANDLE m_pipe_read; 30 | HANDLE m_pipe_write; 31 | }; 32 | 33 | #else 34 | 35 | #include 36 | #include 37 | 38 | class DJI_lock 39 | { 40 | public: 41 | DJI_lock(); 42 | ~DJI_lock(); 43 | void enter(); 44 | void leave(); 45 | private: 46 | pthread_mutex_t m_lock; 47 | }; 48 | 49 | class DJI_event 50 | { 51 | public: 52 | DJI_event(); 53 | ~DJI_event(); 54 | int set_DJI_event(); 55 | int wait_DJI_event(); 56 | private: 57 | sem_t m_sem; 58 | }; 59 | 60 | #endif 61 | 62 | void sleep( int microsecond ); 63 | 64 | 65 | #endif -------------------------------------------------------------------------------- /demo/obstacle_bypass/balance_strategy/include/imagetransfer.h: -------------------------------------------------------------------------------- 1 | #ifndef __IMAGE_TRANSFER_H__ 2 | #define __IMAGE_TRANSFER_H__ 3 | #include "usb_transfer.h" 4 | #include "DJI_guidance.h" 5 | 6 | #define LOWEST_VERSION 2 7 | #define PC_VERSION 2 8 | 9 | typedef void (*update_dialog_handler)( char **camera_pair_data[], char **other_data ); 10 | 11 | SDK_API void set_can_protocal( int nProtocal ); 12 | 13 | SDK_API void set_save_file_flag( bool bSaveFlag ); 14 | 15 | SDK_API int get_online_flag( int *online_flag ); 16 | 17 | SDK_API void set_update_dialog_handler( update_dialog_handler handler ); 18 | 19 | SDK_API int write_cmos( unsigned int *p_address_value, unsigned int un_address_num ); 20 | 21 | SDK_API int send_data( unsigned int id, char *data, unsigned int length ); 22 | 23 | SDK_API int get_data( unsigned int id, char *data, unsigned int max_length ); 24 | 25 | //DLL_API int get_config( char *data, unsigned int max_length ); 26 | 27 | SDK_API int push_file( const char *local_file_name, const char *remote_file_path ); 28 | 29 | SDK_API int push_file( const char *content, unsigned int file_len, const char *remote_file_full_name ); 30 | 31 | SDK_API int pull_file( const char *remote_file_name, const char *local_file_path ); 32 | 33 | SDK_API void set_register_param( unsigned int *register_addr, unsigned int *p_register_, unsigned int un_register_num ); 34 | 35 | SDK_API int set_selected_datetype( unsigned int *p_datatype_index, unsigned int un_datatype_num ); 36 | 37 | SDK_API int select_image( unsigned int camera_pair_index, unsigned int data_type ); 38 | 39 | SDK_API int set_cmos_read_address( unsigned int *p_address, unsigned int un_address_num ); 40 | 41 | SDK_API int suspend_image_transfer(); 42 | 43 | SDK_API int start_image_transfer(); 44 | 45 | SDK_API int init_image_transfer(); 46 | 47 | SDK_API int release_image_transfer(); 48 | 49 | SDK_API bool is_libusb_connected(); 50 | 51 | #ifdef WIN32 52 | SDK_API int open_console(); 53 | #endif 54 | 55 | SDK_API int get_soc_version(); 56 | 57 | SDK_API int get_vision_version( int &vision_version ); 58 | 59 | SDK_API int upgrade_sonar( unsigned int direction ); 60 | 61 | SDK_API int reboot_fastboot(); 62 | 63 | SDK_API int start_can_uart_test(); 64 | 65 | SDK_API int get_can_uart_test_result(); 66 | 67 | SDK_API int set_left_work_time( int left_work_time ); 68 | 69 | SDK_API int upgrade_soc_version(); 70 | 71 | SDK_API int set_sonar_serial_code( unsigned int logic_direction, const unsigned char *serial_code ); 72 | 73 | SDK_API int get_sonar_serial_code( unsigned int logic_direction, unsigned char *serial_code ); 74 | 75 | SDK_API int set_oa_manu_test_flag(); 76 | 77 | SDK_API int restart_master(); 78 | 79 | SDK_API int reboot_soc(); 80 | 81 | SDK_API int get_sonar_version( unsigned int logic_direction, char *hardware_version, int &loader_version, int &app_version ); 82 | 83 | SDK_API int set_event_handler( user_call_back handler ); 84 | 85 | SDK_API int save_cali_param( unsigned int logic_direction, char *cali_data, unsigned int data_len ); 86 | 87 | SDK_API int send_heartbeat_request(); 88 | 89 | SDK_API int set_manu_test_flag( int flag ); 90 | 91 | SDK_API void set_sdk_protocal( int protocal_version ); 92 | 93 | SDK_API int set_serial_code( const char *product_id, const char *code ); 94 | 95 | SDK_API int get_serial_code( char *code ); 96 | 97 | SDK_API int enable_adb( bool enable_flag ); 98 | 99 | SDK_API int enable_mvo( bool enable_flag ); 100 | 101 | SDK_API int get_token(); 102 | 103 | SDK_API int get_app_id(); 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/balance_strategy/include/libDJI_guidance.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dji-sdk/Guidance-SDK/9f666b4338ea37f7ce62dd1292d531918b37c18c/demo/obstacle_bypass/balance_strategy/include/libDJI_guidance.so -------------------------------------------------------------------------------- /demo/obstacle_bypass/balance_strategy/include/usb_transfer.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dji-sdk/Guidance-SDK/9f666b4338ea37f7ce62dd1292d531918b37c18c/demo/obstacle_bypass/balance_strategy/include/usb_transfer.h -------------------------------------------------------------------------------- /demo/obstacle_bypass/balance_strategy/launch/sdk_demo.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/balance_strategy/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | dji_sdk 4 | 0.0.0 5 | The dji_sdk package 6 | 7 | 8 | 9 | 10 | iarc 11 | 12 | 13 | 14 | 15 | 16 | TODO 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 | catkin 43 | 44 | 45 | std_msgs 46 | 47 | 48 | std_msgs 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/balance_strategy/src/sdk_lib/DJI_Camera.cpp: -------------------------------------------------------------------------------- 1 | #include "DJI_Camera.h" 2 | 3 | using namespace DJI::onboardSDK; 4 | 5 | Camera::Camera(CoreAPI *ControlAPI) { api = ControlAPI; } 6 | 7 | void Camera::setCamera(Camera::CAMERA_CODE camera_cmd) 8 | { 9 | unsigned char send_data = 0; 10 | api->send(0, encrypt, SET_CONTROL, camera_cmd, &send_data, 1); 11 | } 12 | 13 | void Camera::setGimbalAngle(GimbalAngleData *data) 14 | { 15 | api->send(0, encrypt, SET_CONTROL, Camera::CODE_GIMBAL_ANGLE, (unsigned char *)data, 16 | sizeof(GimbalAngleData)); 17 | } 18 | 19 | void Camera::setGimbalSpeed(GimbalSpeedData *data) 20 | { 21 | data->reserved = 0x80; 22 | api->send(0, encrypt, SET_CONTROL, Camera::CODE_GIMBAL_SPEED, (unsigned char *)data, 23 | sizeof(GimbalSpeedData)); 24 | } 25 | 26 | GimbalData Camera::getGimbal() const { return api->getBroadcastData().gimbal; } 27 | 28 | float32_t Camera::getYaw() const { return api->getBroadcastData().gimbal.yaw; } 29 | 30 | float32_t Camera::getRoll() const { return api->getBroadcastData().gimbal.roll; } 31 | 32 | float32_t Camera::getPitch() const { return api->getBroadcastData().gimbal.pitch; } 33 | 34 | bool Camera::isYawLimit() const 35 | { 36 | if (api->getSDKVersion() != versionM100_23) 37 | return api->getBroadcastData().gimbal.yawLimit ? true : false; 38 | return false; 39 | } 40 | 41 | bool Camera::isRollLimit() const 42 | { 43 | if (api->getSDKVersion() != versionM100_23) 44 | return api->getBroadcastData().gimbal.rollLimit ? true : false; 45 | return false; 46 | } 47 | bool Camera::isPitchLimit() const 48 | { 49 | if (api->getSDKVersion() != versionM100_23) 50 | return api->getBroadcastData().gimbal.pitchLimit ? true : false; 51 | return false; 52 | } 53 | 54 | CoreAPI *Camera::getApi() const { return api; } 55 | 56 | void Camera::setApi(CoreAPI *value) { api = value; } 57 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/balance_strategy/src/sdk_lib/DJI_Follow.cpp: -------------------------------------------------------------------------------- 1 | #include "DJI_Follow.h" 2 | 3 | using namespace DJI; 4 | using namespace DJI::onboardSDK; 5 | 6 | Follow::Follow(CoreAPI *ControlAPI) 7 | { 8 | api = ControlAPI; 9 | resetData(); 10 | } 11 | 12 | void Follow::resetData() 13 | { 14 | data.mode = MODE_RELATIVE; 15 | data.yaw = YAW_TOTARGET; 16 | data.target.latitude = api->getBroadcastData().pos.latitude; 17 | data.target.longitude = api->getBroadcastData().pos.longitude; 18 | data.target.height = api->getBroadcastData().pos.altitude; 19 | data.target.angle = 0; 20 | data.sensitivity = 1; 21 | } 22 | 23 | void Follow::start(FollowData *Data, CallBack callback, UserData userData) 24 | { 25 | if (Data) 26 | data = *Data; 27 | else 28 | resetData(); 29 | api->send(2, encrypt, SET_MISSION, CODE_FOLLOW_START, &data, sizeof(data), 500, 2, 30 | callback ? callback : missionCallback, userData); 31 | } 32 | 33 | void Follow::stop(CallBack callback, UserData userData) 34 | { 35 | uint8_t zero = 0; 36 | api->send(2, encrypt, SET_MISSION, CODE_FOLLOW_STOP, &zero, sizeof(zero), 500, 2, 37 | callback ? callback : missionCallback, userData); 38 | } 39 | 40 | void Follow::pause(bool isPause, CallBack callback, UserData userData) 41 | { 42 | uint8_t data = isPause ? 0 : 1; 43 | api->send(2, encrypt, SET_MISSION, CODE_FOLLOW_SETPAUSE, &data, sizeof(data), 500, 2, 44 | callback ? callback : missionCallback, userData); 45 | } 46 | 47 | void Follow::updateTarget(FollowTarget target) 48 | { 49 | data.target = target; 50 | api->send(0, encrypt, SET_MISSION, CODE_FOLLOW_TARGET, &(data.target), sizeof(FollowTarget)); 51 | } 52 | 53 | void Follow::updateTarget(float64_t latitude, float64_t longitude, uint16_t height, 54 | uint16_t angle) 55 | { 56 | FollowTarget target; 57 | target.latitude = latitude; 58 | target.longitude = longitude; 59 | target.height = height; 60 | target.angle = angle; 61 | updateTarget(target); 62 | } 63 | 64 | FollowData Follow::getData() const { return data; } 65 | 66 | void Follow::setData(const FollowData &value) { data = value; } 67 | 68 | void Follow::setMode(const Follow::MODE mode __UNUSED) 69 | { 70 | API_LOG(api->getDriver(), STATUS_LOG, "no available mode but default"); 71 | data.mode = 0; 72 | } 73 | 74 | void Follow::setTarget(FollowTarget target) { data.target = target; } 75 | 76 | void Follow::setYawType(const Follow::YAW_TYPE type) { data.yaw = type; } 77 | 78 | void Follow::setSensitivity(const Follow::SENSITIVITY sense __UNUSED) 79 | { 80 | API_LOG(api->getDriver(), STATUS_LOG, "no available mode but default"); 81 | data.sensitivity = 1; 82 | } 83 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/balance_strategy/src/sdk_lib/DJI_HardDriver.cpp: -------------------------------------------------------------------------------- 1 | #include "DJI_HardDriver.h" 2 | 3 | using namespace DJI::onboardSDK; 4 | 5 | char DJI::onboardSDK::buffer[DJI::onboardSDK::bufsize]; 6 | 7 | void HardDriver::displayLog(const char *buf) 8 | { 9 | if (buf) 10 | printf("%s", buf); 11 | else 12 | printf("%s", DJI::onboardSDK::buffer); 13 | } 14 | 15 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/balance_strategy/src/sdk_lib/DJI_VirtualRC.cpp: -------------------------------------------------------------------------------- 1 | #include "DJI_VirtualRC.h" 2 | 3 | using namespace DJI::onboardSDK; 4 | 5 | DJI::onboardSDK::VirtualRC::VirtualRC(CoreAPI *ControlAPI) 6 | { 7 | api = ControlAPI; 8 | resetData(); 9 | } 10 | 11 | void VirtualRC::setControl(bool enable, VirtualRC::CutOff cutoffType) 12 | { 13 | VirtualRCSetting setting; 14 | setting.cutoff = cutoffType; 15 | setting.enable = enable ? 1 : 0; 16 | api->send(0, encrypt, SET_VIRTUALRC, CODE_VIRTUALRC_SETTINGS, &setting, sizeof(setting)); 17 | } 18 | 19 | void VirtualRC::sendData(VirtualRCData Data) 20 | { 21 | data = Data; 22 | sendData(); 23 | } 24 | 25 | void VirtualRC::sendData() 26 | { 27 | api->send(0, encrypt, SET_VIRTUALRC, CODE_VIRTUALRC_DATA, &data, sizeof(data)); 28 | } 29 | 30 | void VirtualRC::resetData() 31 | { 32 | data.roll = 1024; 33 | data.pitch = 1024; 34 | data.throttle = 1024; 35 | data.yaw = 1024; 36 | data.gear = 1024; 37 | data.reserved = 1024; 38 | data.mode = 1024; 39 | data.Channel_07 = 1024; 40 | data.Channel_08 = 1024; 41 | data.Channel_09 = 1024; 42 | data.Channel_10 = 1024; 43 | data.Channel_11 = 1024; 44 | data.Channel_12 = 1024; 45 | data.Channel_13 = 1024; 46 | data.Channel_14 = 1024; 47 | data.Channel_15 = 1024; 48 | } 49 | 50 | void VirtualRC::sendSafeModeData() 51 | { 52 | resetData(); 53 | sendData(); 54 | } 55 | 56 | RadioData VirtualRC::getRCData() const { return api->getBroadcastData().rc; } 57 | 58 | CoreAPI *VirtualRC::getApi() const { return api; } 59 | void VirtualRC::setApi(CoreAPI *value) { api = value; } 60 | 61 | VirtualRCData VirtualRC::getVRCData() const { return data; } 62 | void VirtualRC::setVRCData(const VirtualRCData &value) { data = value; } 63 | 64 | bool VirtualRC::isVirtualRC() const 65 | { 66 | return api->getBroadcastData().ctrlInfo.vrcStatus == 0 ? false : true; 67 | } 68 | 69 | RadioData VirtualRC::toRadioData(VirtualRCData &vData) 70 | { 71 | RadioData rd; 72 | rd.gear = (vData.gear == 1324) ? -454 : -10000; 73 | rd.mode = (1024 - vData.mode ) * 10000 / 660; 74 | rd.pitch = (vData.pitch - 1024) * (10000) / 660; 75 | rd.roll = (vData.roll - 1024) * (10000) / 660; 76 | rd.yaw = (vData.yaw - 1024) * (10000) / 660; 77 | rd.throttle = (vData.throttle - 1024) * (10000) / 660; 78 | return rd; 79 | } 80 | 81 | VirtualRCData VirtualRC::toVirtualRCData(RadioData &rData) 82 | { 83 | VirtualRCData vd; 84 | vd.yaw = rData.yaw * 660 / 10000 + 1024; 85 | vd.throttle = rData.throttle * 660 / 10000 + 1024; 86 | vd.pitch = rData.pitch * 660 / 10000 + 1024; 87 | vd.roll = rData.roll * 660 / 10000 + 1024; 88 | vd.gear = (rData.gear == -4545) ? 1324 : 1684; 89 | vd.reserved = 1024; 90 | vd.mode = rData.mode * 660 / (-10000) + 1024; 91 | vd.Channel_07 = 1024; 92 | vd.Channel_08 = 1024; 93 | vd.Channel_09 = 1024; 94 | vd.Channel_10 = 1024; 95 | vd.Channel_11 = 1024; 96 | vd.Channel_12 = 1024; 97 | vd.Channel_13 = 1024; 98 | vd.Channel_14 = 1024; 99 | vd.Channel_15 = 1024; 100 | return vd; 101 | } 102 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/balance_strategy/src/sdk_lib/DJI_utility.cpp: -------------------------------------------------------------------------------- 1 | #include "DJI_utility.h" 2 | 3 | #ifdef WIN32 4 | 5 | DJI_lock::DJI_lock() 6 | { 7 | InitializeCriticalSection( &m_critical_section ); 8 | } 9 | 10 | DJI_lock::~DJI_lock() 11 | { 12 | } 13 | 14 | void DJI_lock::enter() 15 | { 16 | EnterCriticalSection( &m_critical_section ); 17 | } 18 | 19 | void DJI_lock::leave() 20 | { 21 | LeaveCriticalSection( &m_critical_section ); 22 | } 23 | 24 | void sleep( int microsecond ) 25 | { 26 | Sleep( ( microsecond + 999 ) / 1000 ); 27 | } 28 | 29 | 30 | DJI_event::DJI_event() 31 | { 32 | SECURITY_ATTRIBUTES sa; 33 | sa.nLength = sizeof(sa); 34 | sa.lpSecurityDescriptor = NULL; 35 | sa.bInheritHandle = TRUE; 36 | CreatePipe( &m_pipe_read, &m_pipe_write, &sa, 0 ); 37 | } 38 | 39 | DJI_event::~DJI_event() 40 | { 41 | CloseHandle( m_pipe_read ); 42 | CloseHandle( m_pipe_write ); 43 | } 44 | 45 | int DJI_event::set_DJI_event() 46 | { 47 | char buffer[1] = {0}; 48 | int count = 0; 49 | int ret = WriteFile( m_pipe_write, (LPWORD)buffer, 1, (LPDWORD)&count, NULL ); 50 | return ret; 51 | } 52 | 53 | int DJI_event::wait_DJI_event() 54 | { 55 | char buffer[1] = {0}; 56 | int count = 0; 57 | int ret = ReadFile( m_pipe_read, (LPWORD)buffer, 1, (LPDWORD)&count, NULL ); 58 | return ret; 59 | } 60 | 61 | #else 62 | 63 | DJI_lock::DJI_lock() 64 | { 65 | pthread_mutex_init( &m_lock, NULL ); 66 | } 67 | 68 | DJI_lock::~DJI_lock() 69 | { 70 | } 71 | 72 | void DJI_lock::enter() 73 | { 74 | pthread_mutex_lock( &m_lock ); 75 | } 76 | 77 | void DJI_lock::leave() 78 | { 79 | pthread_mutex_unlock( &m_lock ); 80 | } 81 | 82 | DJI_event::DJI_event() 83 | { 84 | sem_init( &m_sem, 0, 0 ); 85 | } 86 | 87 | DJI_event::~DJI_event() 88 | { 89 | } 90 | 91 | int DJI_event::set_DJI_event() 92 | { 93 | int ret = sem_post( &m_sem ); 94 | return ret; 95 | } 96 | 97 | int DJI_event::wait_DJI_event() 98 | { 99 | int ret = sem_wait( &m_sem ); 100 | return ret; 101 | } 102 | 103 | #endif 104 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity-balance_strategy/include/DJICommonType.h: -------------------------------------------------------------------------------- 1 | #ifndef DJICOMMONTYPE 2 | #define DJICOMMONTYPE 3 | 4 | #include 5 | 6 | namespace DJI 7 | { 8 | 9 | typedef uint64_t time_ms; 10 | typedef uint64_t time_us; // about 0.3 million years 11 | 12 | typedef void *UserData; 13 | typedef uint32_t Flag; 14 | 15 | typedef uint8_t size8_t; 16 | typedef uint16_t size16_t; 17 | 18 | typedef struct Measure 19 | { 20 | double data; 21 | float precision; 22 | } Measure; 23 | 24 | typedef struct SpaceVector 25 | { 26 | double x; 27 | double y; 28 | double z; 29 | } SpaceVector; 30 | 31 | /*! @todo range mathematial class 32 | class Angle 33 | { 34 | public: 35 | Angle(double degree = 0); 36 | 37 | private: 38 | double degree; 39 | }; 40 | */ 41 | 42 | typedef double Angle; 43 | 44 | typedef struct EulerianAngle 45 | { 46 | Angle yaw; 47 | Angle roll; 48 | Angle pitch; 49 | } EulerianAngle; 50 | 51 | } // namespace DJI 52 | 53 | #endif // DJICOMMONTYPE 54 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity-balance_strategy/include/DJI_App.h: -------------------------------------------------------------------------------- 1 | /*! @brief 2 | * @file DJI_APP.h 3 | * @version 3.0 4 | * @date Dec 16, 2015 5 | * 6 | * @abstract 7 | * Core API Link upper level for DJI onboardSDK library 8 | * 9 | * @attention 10 | * Project configuration: 11 | * 12 | * @version features: 13 | * -* @version V3.0 14 | * -* DJI-onboard-SDK for Windows,QT,STM32,ROS,Cmake 15 | * -* @date Dec 16, 2015 16 | * -* @author william.wu 17 | * 18 | * */ 19 | 20 | #ifndef DJI_APP_H 21 | #define DJI_APP_H 22 | 23 | #include 24 | 25 | #include "DJI_Link.h" 26 | #include "DJI_Type.h" 27 | 28 | #define MSG_ENABLE_FLAG_LEN 2 29 | 30 | //---------------------------------------------------------------------- 31 | // App layer function 32 | //---------------------------------------------------------------------- 33 | typedef struct 34 | { 35 | unsigned short sequence_number; 36 | unsigned char session_id : 5; 37 | unsigned char need_encrypt : 1; 38 | unsigned char reserve : 2; 39 | } req_id_t; 40 | 41 | #define EXC_DATA_SIZE (16u) 42 | #define SET_CMD_SIZE (2u) 43 | 44 | //---------------------------------------------------------------------- 45 | // for cmd agency 46 | //---------------------------------------------------------------------- 47 | #define REQ_TIME_OUT 0x0000 48 | #define REQ_REFUSE 0x0001 49 | #define CMD_RECIEVE 0x0002 50 | #define STATUS_CMD_EXECUTING 0x0003 51 | #define STATUS_CMD_EXE_FAIL 0x0004 52 | #define STATUS_CMD_EXE_SUCCESS 0x0005 53 | 54 | //! @todo move to type.h 55 | #pragma pack(1) 56 | 57 | typedef struct ActivateData 58 | { 59 | unsigned int ID; 60 | unsigned int reserved; 61 | unsigned int version; 62 | unsigned char iosID[32]; 63 | char *encKey; 64 | } ActivateData; 65 | 66 | typedef struct VersionData 67 | { 68 | unsigned short version_ack; 69 | unsigned int version_crc; 70 | char version_ID[11]; 71 | char version_name[32]; 72 | DJI::onboardSDK::Version version; 73 | } VersionData; 74 | 75 | #pragma pack() 76 | 77 | #endif // DJI_APP_H 78 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity-balance_strategy/include/DJI_Camera.h: -------------------------------------------------------------------------------- 1 | /*! @brief 2 | * @file DJI_Camera.h 3 | * @version 3.0 4 | * @date Dec 16, 2015 5 | * 6 | * @abstract 7 | * Camera control API for DJI onboardSDK library 8 | * 9 | * @attention 10 | * Project configuration: 11 | * 12 | * @version features: 13 | * -* @version V3.0 14 | * -* DJI-onboard-SDK for Windows,QT,STM32,ROS,Cmake 15 | * -* @date Dec 16, 2015 16 | * -* @author william.wu 17 | * 18 | * */ 19 | 20 | #ifndef DJI_CAMERA_H 21 | #define DJI_CAMERA_H 22 | 23 | #include "DJI_API.h" 24 | 25 | namespace DJI 26 | { 27 | namespace onboardSDK 28 | { 29 | class Camera 30 | { 31 | public: 32 | enum CAMERA_CODE 33 | { 34 | CODE_GIMBAL_SPEED = 0x1A, 35 | CODE_GIMBAL_ANGLE = 0x1B, 36 | CODE_CAMERA_SHOT = 0x20, 37 | CODE_CAMERA_VIDEO_START = 0x21, 38 | CODE_CAMERA_VIDEO_STOP = 0x22 39 | }; 40 | 41 | public: 42 | Camera(CoreAPI *ControlAPI = 0); 43 | 44 | //! @note all camera control functions are none-callback function. 45 | void setCamera(CAMERA_CODE camera_cmd); 46 | void setGimbalAngle(GimbalAngleData *data); 47 | void setGimbalSpeed(GimbalSpeedData *data); 48 | 49 | GimbalData getGimbal() const; 50 | float32_t getYaw() const; 51 | float32_t getRoll() const; 52 | float32_t getPitch() const; 53 | bool isYawLimit() const; 54 | bool isRollLimit() const; 55 | bool isPitchLimit() const; 56 | 57 | public: //! @note Access method 58 | CoreAPI *getApi() const; 59 | void setApi(CoreAPI *value); 60 | 61 | private: 62 | CoreAPI *api; 63 | }; 64 | } // namespace onboardSDK 65 | } // namespace DJI 66 | 67 | #endif // DJI_CAMERA_H 68 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity-balance_strategy/include/DJI_Codec.h: -------------------------------------------------------------------------------- 1 | /*! @brief 2 | * @file DJI_Codec.h 3 | * @version 3.0 4 | * @date Dec 16, 2015 5 | * 6 | * @abstract 7 | * Encode functions for DJI onboardSDK library 8 | * 9 | * @attention 10 | * Project configuration: 11 | * 12 | * @todo spilt this header into 4 header files 13 | * 14 | * @version features: 15 | * -* @version V3.0 16 | * -* DJI-onboard-SDK for Windows,QT,STM32,ROS,Cmake 17 | * -* @date Dec 16, 2015 18 | * -* @author william.wu 19 | * 20 | * */ 21 | 22 | #ifndef DJI_CODEC_H 23 | #define DJI_CODEC_H 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include "DJI_Type.h" 30 | 31 | #define _SDK_MAX_RECV_SIZE (BUFFER_SIZE) 32 | #define _SDK_SOF ((unsigned char)(0xAA)) 33 | #define _SDK_CRC_HEAD_SIZE (2) // CRC16 34 | #define _SDK_CRC_DATA_SIZE (4) // CRC32 35 | #define _SDK_HEAD_DATA_LEN (sizeof(DJI::onboardSDK::Header) - 2) 36 | #define _SDK_FULL_DATA_SIZE_MIN (sizeof(DJI::onboardSDK::Header) + _SDK_CRC_DATA_SIZE) 37 | 38 | #define _SDK_U32_SET(_addr, _val) (*((unsigned int *)(_addr)) = (_val)) 39 | #define _SDK_U16_SET(_addr, _val) (*((unsigned short *)(_addr)) = (_val)) 40 | 41 | #define _SDK_CALC_CRC_HEAD(_msg, _len) \ 42 | sdk_stream_crc16_calc((const unsigned char *)(_msg), _len) 43 | #define _SDK_CALC_CRC_TAIL(_msg, _len) \ 44 | sdk_stream_crc32_calc((const unsigned char *)(_msg), _len) 45 | 46 | 47 | void transformTwoByte(const char *pstr, unsigned char *pdata); 48 | 49 | #endif // DJI_CODEC_H 50 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity-balance_strategy/include/DJI_Config.h: -------------------------------------------------------------------------------- 1 | /*! @brief 2 | * @file DJI_Config.h 3 | * @version 3.0 4 | * @date Dec 16, 2015 5 | * 6 | * @abstract 7 | * Configuration optional Micro definitions for DJI onboardSDK library. 8 | * 9 | * @attention 10 | * Project configuration: 11 | * None 12 | * 13 | * @version features: 14 | * -* @version V3.0 15 | * -* DJI-onboard-SDK for Windows,QT,STM32,ROS,Cmake 16 | * -* @date Dec 16, 2015 17 | * -* @author william.wu 18 | * 19 | * */ 20 | 21 | #ifndef DJI_CONFIG_H 22 | #define DJI_CONFIG_H 23 | 24 | #include 25 | #define MEMORY_SIZE 1024 // unit is byte 26 | #define BUFFER_SIZE 1024 27 | #define ACK_SIZE 10 28 | 29 | //! @note it means DJI onboardSDK library will not alloc memory from heap. 30 | //! @todo not available yet, only affect WayPoint 31 | //#define STATIC_MEMORY 32 | 33 | //#define API_MISSION_DATA 34 | //#define API_DEBUG_DATA 35 | //#define API_BUFFER_DATA 36 | //#define API_RTK_DEBUG 37 | #define API_ERROR_DATA 38 | #define API_STATUS_DATA 39 | 40 | //! @note if you do not want to use AES encrypt, comment this micro below 41 | #define USE_ENCRYPT 42 | //#define USE_SIMULATION 43 | 44 | #include "DJI_Version.h" 45 | 46 | #endif // DJI_CONFIG_H 47 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity-balance_strategy/include/DJI_Follow.h: -------------------------------------------------------------------------------- 1 | /*! @brief 2 | * @file DJI_Follow.h 3 | * @version 3.0 4 | * @date Dec 16, 2015 5 | * 6 | * @abstract 7 | * Follow API for DJI onboardSDK library 8 | * 9 | * @attention 10 | * Project configuration: 11 | * 12 | * @version features: 13 | * -* @version V3.0 14 | * -* DJI-onboard-SDK for Windows,QT,STM32,ROS,Cmake 15 | * -* @date Dec 21, 2015 16 | * -* @author william.wu 17 | * 18 | * */ 19 | 20 | #ifndef DJI_FOLLOW_H 21 | #define DJI_FOLLOW_H 22 | 23 | #include "DJI_Mission.h" 24 | 25 | namespace DJI 26 | { 27 | namespace onboardSDK 28 | { 29 | 30 | #pragma pack(1) 31 | 32 | typedef struct FollowTarget 33 | { 34 | float64_t latitude; 35 | float64_t longitude; 36 | uint16_t height; 37 | uint16_t angle; 38 | } FollowTarget; 39 | 40 | typedef struct FollowData 41 | { 42 | uint8_t mode; 43 | uint8_t yaw; 44 | FollowTarget target; 45 | uint8_t sensitivity; 46 | } FollowData; 47 | 48 | #pragma pack() 49 | 50 | class Follow 51 | { 52 | public: 53 | enum MODE 54 | { 55 | MODE_RELATIVE = 0, 56 | MODE_ROUTE = 1, //! @note Flight control not support now 57 | MODE_SMART = 2 //! @note Flight control not support now 58 | }; 59 | 60 | enum YAW_TYPE 61 | { 62 | YAW_TOTARGET = 0, 63 | YAW_CUSTOM = 1 64 | }; 65 | 66 | enum SENSITIVITY 67 | { 68 | SENSE_LOW = 0, //! @note Flight control not support now 69 | SENSE_MID = 1, 70 | SENSE_HIGH = 2 //! @note Flight control not support now 71 | }; 72 | 73 | public: 74 | Follow(CoreAPI *ControlAPI = 0); 75 | void resetData(); 76 | 77 | void start(FollowData *Data = 0, CallBack callback = 0, UserData userData = 0); 78 | void stop(CallBack callback = 0, UserData userData = 0); 79 | //! @note true for pause, false for resume 80 | void pause(bool isPause, CallBack callback = 0, UserData userData = 0); 81 | void updateTarget(FollowTarget target); //! @note no ack command 82 | void updateTarget(float64_t latitude, float64_t longitude, uint16_t height, 83 | uint16_t angle); //! @note no ack command 84 | 85 | public: 86 | void setData(const FollowData &value); 87 | void setMode(const MODE mode); 88 | void setTarget(FollowTarget target); 89 | void setYawType(const YAW_TYPE type); 90 | void setSensitivity(const SENSITIVITY sense); 91 | 92 | FollowData getData() const; 93 | 94 | private: 95 | CoreAPI *api; 96 | FollowData data; 97 | }; 98 | 99 | } // namespace onboardSDK 100 | } // namespace DJI 101 | 102 | #endif // DJI_FOLLOW_H 103 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity-balance_strategy/include/DJI_HardDriver.h: -------------------------------------------------------------------------------- 1 | /*! @brief 2 | * @file DJI_HardDriver.h 3 | * @version 3.0 4 | * @date Dec 9, 2015 5 | * 6 | * @abstract 7 | * Hard ware level for DJI onboardSDK library 8 | * 9 | * @attention 10 | * Project configuration: 11 | * 12 | * @version features: 13 | * -* @version V3.0 14 | * -* DJI-onboard-SDK for Windows,QT,STM32,ROS,Cmake 15 | * -* @date Dec 9, 2015 16 | * -* @author william.wu 17 | * 18 | * */ 19 | #ifndef DJI_HARDDRIVER_H 20 | #define DJI_HARDDRIVER_H 21 | 22 | #include 23 | #include 24 | #include "DJI_Type.h" 25 | 26 | namespace DJI 27 | { 28 | namespace onboardSDK 29 | { 30 | 31 | class HardDriver 32 | { 33 | public: 34 | HardDriver() {} 35 | 36 | /*! @note How to use 37 | * In order to provide platform crossable DJI onboardSDK library, 38 | * we abstract this class as a hardware level. 39 | * 40 | * @note function descriptions: 41 | * 42 | * void init(); 43 | * @brief After calling this function, HardDriver should be able to 44 | * read and send correctly, through a correct UART part 45 | * 46 | * unsigned int getTimeStamp(); 47 | * @brief returns a TimeStamp data in unit msec. 48 | * The difference between the return value of the function call two times 49 | * is the excat time between them in msec. 50 | * 51 | * size_t send(const uint8_t *buf, size_t len); 52 | * @brief return sent data length. 53 | * 54 | * size_t readall(uint8_t *buf, size_t maxlen) = 0; 55 | * @brief return read data length. 56 | * 57 | * void lockMemory();/ void freeMemory(); 58 | * @brief provide a mutex for multi-thread. when operating memory. 59 | * 60 | * void lockMSG();/ void freeMSG(); 61 | * @brief provide a mutex for multi-thread. when operating messages. 62 | * 63 | * void displayLog(char *buf); 64 | * @brief Micro "API_LOG" invoked this function, to pass datalog. 65 | * In order to pass data through different stream or channel. 66 | * We abstract this virtual function for user. 67 | * And different from others, this interface is not a pure virtual funcion. 68 | * The default data-passing channel is stdout (printf). 69 | * See also "DJI_HardDriver.cpp". 70 | * 71 | * @attention 72 | * when writting and reading data, there might have multi-thread problems. 73 | * Abstract class HardDriver did not consider these issue. 74 | * Please be careful when you are going to implement send and readall 75 | * funtions. 76 | * 77 | * @note 78 | * we strongly suggest you to inherit this class in your own file, not just 79 | * implement 80 | * it in DJI_HardDriver.cpp or inside this class 81 | * 82 | * */ 83 | public: 84 | virtual void init() = 0; 85 | virtual time_ms getTimeStamp() = 0; 86 | virtual size_t send(const uint8_t *buf, size_t len) = 0; 87 | virtual size_t readall(uint8_t *buf, size_t maxlen) = 0; 88 | 89 | public: 90 | virtual void lockMemory() = 0; 91 | virtual void freeMemory() = 0; 92 | 93 | virtual void lockMSG() = 0; 94 | virtual void freeMSG() = 0; 95 | 96 | public: 97 | virtual void displayLog(const char *buf = 0); 98 | }; 99 | } // namespace onboardSDK 100 | } // namespace DJI 101 | 102 | #endif // DJI_HARDDRIVER_H 103 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity-balance_strategy/include/DJI_HotPoint.h: -------------------------------------------------------------------------------- 1 | /*! @brief 2 | * @file DJI_HotPoint.h 3 | * @version 3.0 4 | * @date Dec 16, 2015 5 | * 6 | * @abstract 7 | * HotPoint API for DJI onboardSDK library 8 | * 9 | * @attention 10 | * Project configuration: 11 | * 12 | * @version features: 13 | * -* @version V3.0 14 | * -* DJI-onboard-SDK for Windows,QT,STM32,ROS,Cmake 15 | * -* @date Dec 16, 2015 16 | * -* @author william.wu 17 | * 18 | * */ 19 | 20 | #ifndef DJI_HOTPOINT_H 21 | #define DJI_HOTPOINT_H 22 | 23 | #include "DJI_Mission.h" 24 | 25 | namespace DJI 26 | { 27 | namespace onboardSDK 28 | { 29 | 30 | #pragma pack(1) 31 | 32 | typedef struct HotPointData 33 | { 34 | uint8_t version; 35 | 36 | float64_t latitude; 37 | float64_t longitude; 38 | float64_t height; 39 | 40 | float64_t radius; 41 | float32_t palstance; // degree 42 | 43 | uint8_t clockwise; 44 | uint8_t startPoint; 45 | uint8_t yawMode; 46 | uint8_t reserved[11]; 47 | } HotPointData; 48 | 49 | #pragma pack() 50 | 51 | class HotPoint 52 | { 53 | public: 54 | #pragma pack(1) 55 | typedef struct StartACK 56 | { 57 | uint8_t ack; 58 | float32_t maxRadius; 59 | } StartACK; 60 | 61 | typedef struct Palstance 62 | { 63 | uint8_t clockwise; 64 | float32_t palstance; 65 | } Palstance; 66 | 67 | typedef struct ReadACK 68 | { 69 | MissionACK ack; 70 | HotPointData data; 71 | } ReadACK; 72 | #pragma pack() 73 | 74 | enum View 75 | { 76 | VIEW_NORTH = 0, 77 | VIEW_SOUTH = 1, 78 | VIEW_WEST = 2, 79 | VIEW_EAST = 3, 80 | VIEW_NEARBY = 4 81 | }; 82 | 83 | enum YawMode 84 | { 85 | YAW_AUTO = 0, 86 | YAW_INSIDE = 1, 87 | YAW_OUTSIDE = 2, 88 | YAW_CUSTOM = 3, 89 | YAW_STATIC = 4, 90 | }; 91 | 92 | public: 93 | HotPoint(CoreAPI *ControlAPI = 0); 94 | void initData(); 95 | 96 | /*! @note API functions 97 | * @attention difference between set and update 98 | * Set functions only change the HotPoint data in this class, 99 | * Update functions will change the Mission status. 100 | * In other words: drone will response update functions immediately. 101 | * */ 102 | 103 | void start(CallBack callback = 0, UserData userData = 0); 104 | void stop(CallBack callback = 0, UserData userData = 0); 105 | void pause(bool isPause, CallBack callback = 0, UserData userData = 0); 106 | 107 | void updatePalstance(Palstance &Data, CallBack callback = 0, UserData userData = 0); 108 | void updatePalstance(float32_t palstance, bool isClockwise, CallBack callback = 0, 109 | UserData userData = 0); 110 | void updateRadius(float32_t meter, CallBack callback = 0, UserData userData = 0); 111 | void resetYaw(CallBack callback = 0, UserData userData = 0); 112 | 113 | void readData(CallBack callback = 0, UserData userData = 0); 114 | 115 | public: 116 | //! @note data access functions 117 | void setData(const HotPointData &value); 118 | void setHotPoint(float64_t longtitude, float64_t latitude, float64_t altitude); 119 | void setHotPoint(GPSPositionData gps); 120 | void setRadius(float64_t meter); 121 | void setPalstance(float32_t defree); 122 | void setClockwise(bool isClockwise); 123 | void setCameraView(View view); 124 | void setYawMode(YawMode mode); 125 | 126 | HotPointData getData() const; 127 | 128 | public: 129 | static void startCallback(CoreAPI *This, Header *header, UserData userdata = 0); 130 | static void readCallback(CoreAPI *This, Header *header, UserData userdata); 131 | 132 | private: 133 | CoreAPI *api; 134 | HotPointData data; 135 | }; 136 | 137 | } // namespace onboardSDK 138 | } // namespace DJI 139 | 140 | #endif // DJI_HOTPOINT_H 141 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity-balance_strategy/include/DJI_Link.h: -------------------------------------------------------------------------------- 1 | /*! @brief 2 | * @file DJI_Link.h 3 | * @version 3.0 4 | * @date Dec 4, 2015 5 | * 6 | * @abstract 7 | * 8 | * @attention 9 | * Project configuration: 10 | * 11 | * @version features: 12 | * -* @version V3.0 13 | * -* DJI-onboard-SDK for Windows,QT,STM32,ROS,Cmake 14 | * -* @date Nov 15, 2015 15 | * -* @author william.wu 16 | * -* 17 | * -* @version V2.0 18 | * -* C-like DJI-onboard-SDK library 19 | * -* @date Mar 12, 2015 20 | * -* @author wuyuwei 21 | * 22 | * */ 23 | #ifndef DJI_LINK_H 24 | #define DJI_LINK_H 25 | 26 | #define ACK_SESSION_IDLE 0 27 | #define ACK_SESSION_PROCESS 1 28 | #define ACK_SESSION_USING 2 29 | #define CMD_SESSION_0 0 30 | #define CMD_SESSION_1 1 31 | #define CMD_SESSION_AUTO 32 32 | 33 | 34 | #define POLL_TICK 20 // unit is ms 35 | 36 | #include "DJI_Type.h" 37 | 38 | #endif // DJI_LINK_H 39 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity-balance_strategy/include/DJI_Memory.h: -------------------------------------------------------------------------------- 1 | #ifndef DJI_MEMORY_H 2 | #define DJI_MEMORY_H 3 | 4 | #include "DJI_Type.h" 5 | 6 | #endif // DJI_MEMORY_H 7 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity-balance_strategy/include/DJI_Mission.h: -------------------------------------------------------------------------------- 1 | /*! @brief 2 | * @file DJI_Codec.h 3 | * @version 3.0 4 | * @date Dec 16, 2015 5 | * 6 | * @abstract 7 | * Mission framework for DJI onboardSDK library 8 | * 9 | * @attention 10 | * Project configuration: 11 | * 12 | * @version features: 13 | * -* @version V3.0 14 | * -* DJI-onboard-SDK for Windows,QT,STM32,ROS,Cmake 15 | * -* @date Dec 16, 2015 16 | * -* @author william.wu 17 | * 18 | * */ 19 | 20 | #ifndef DJI_MISSION_H 21 | #define DJI_MISSION_H 22 | 23 | #include "DJI_Config.h" 24 | #include "DJI_API.h" 25 | 26 | namespace DJI 27 | { 28 | namespace onboardSDK 29 | { 30 | #pragma pack(1) 31 | 32 | typedef struct HotPointACKData 33 | { 34 | uint8_t status; 35 | uint16_t radius; // in cm 36 | uint8_t failReasion; 37 | uint8_t palstance; 38 | } HotPointADKData; 39 | 40 | //! @todo unify the naming style 41 | typedef struct GSPushData 42 | { 43 | uint8_t type; 44 | uint8_t data_1; 45 | uint8_t data_2; 46 | uint8_t data_3; 47 | uint8_t data_4; 48 | uint8_t data_5; 49 | } GSPushData; 50 | 51 | #pragma pack() 52 | 53 | typedef struct MissionACKMap 54 | { 55 | uint8_t code; 56 | const char *meaning; 57 | } MissionACKMap; 58 | 59 | void missionCallback(CoreAPI *This, Header *header, UserData userdata = 0); 60 | 61 | } // namespace onboardSDK 62 | } // namespace DJI 63 | 64 | #endif // DJI_MISSION_H 65 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity-balance_strategy/include/DJI_Version.h: -------------------------------------------------------------------------------- 1 | /*! @brief 2 | * @file DJI_Version.h 3 | * @version 3.0 4 | * @date Dec 16, 2015 5 | * 6 | * @abstract 7 | * Version control definition for DJI onboardSDK library 8 | * Maintain officially 9 | * 10 | * @attention 11 | * Maintain officially, readonly for users 12 | * Do not modify any definition in this file, 13 | * if you are not sure what are you doing exactlly, 14 | * or we will not provide any support. 15 | * 16 | * Project configuration: 17 | * 18 | * @version features: 19 | * -* @version V3.0 20 | * -* DJI-onboard-SDK for Windows,QT,STM32,ROS,Cmake 21 | * -* @date Dec 16, 2015 22 | * -* @author william.wu 23 | * 24 | * */ 25 | 26 | /*! @attention 27 | * Maintain officially, readonly for users 28 | * Do not modify any definition in this file, 29 | * if you are not sure what are you doing exactlly, 30 | * or we will not provide any support. 31 | * */ 32 | 33 | #ifndef DJI_VERSION_H 34 | #define DJI_VERSION_H 35 | 36 | #include 37 | 38 | #define MAKE_VERSION(a, b, c, d) \ 39 | (((a << 24) & 0xff000000) | ((b << 16) & 0x00ff0000) | ((c << 8) & 0x0000ff00) | \ 40 | (d & 0x000000ff)) 41 | 42 | namespace DJI 43 | { 44 | namespace onboardSDK 45 | { 46 | //! @todo better version control structure 47 | typedef uint32_t Version; 48 | 49 | const Version versionM100_23 = (MAKE_VERSION(2, 3, 10, 0)); 50 | const Version versionM100_31 = (MAKE_VERSION(3, 1, 10, 0)); 51 | const Version versionA3_31 = (MAKE_VERSION(3, 1, 100, 0)); 52 | const Version SDK_VERSION = versionM100_31; 53 | 54 | #ifdef SDK_DEV 55 | #include "dev.h" 56 | #endif // SDK_DEV 57 | 58 | } // namespace DJI 59 | } // namespace onboardSDK 60 | 61 | #endif // DJI_VERSION_H 62 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity-balance_strategy/include/DJI_VirtualRC.h: -------------------------------------------------------------------------------- 1 | /*! @brief 2 | * @file DJI_Codec.h 3 | * @version 3.0 4 | * @date Dec 16, 2015 5 | * 6 | * @abstract 7 | * Virtual Radio Control API for DJI onboardSDK library 8 | * 9 | * @attention 10 | * Project configuration: 11 | * 12 | * @version features: 13 | * -* @version V3.0 14 | * -* DJI-onboard-SDK for Windows,QT,STM32,ROS,Cmake 15 | * -* @date Dec 16, 2015 16 | * -* @author william.wu 17 | * 18 | * */ 19 | 20 | #ifndef DJI_VIRTUALRC_H 21 | #define DJI_VIRTUALRC_H 22 | 23 | #include "DJI_API.h" 24 | 25 | namespace DJI 26 | { 27 | namespace onboardSDK 28 | { 29 | 30 | class VirtualRC 31 | { 32 | public: 33 | //! @todo spelling correction 34 | enum CutOff 35 | { 36 | CutOff_ToLogic = 0, 37 | CutOff_ToRealRC = 1 38 | }; 39 | 40 | public: 41 | VirtualRC(CoreAPI *ControlAPI = 0); 42 | 43 | /*! @attention Safety notes 44 | * You must use these methods below really carefully with following rules: 45 | * - Use API setControl(bool enable, CutOff cutoffType); only once in your main loop; 46 | * - Check your control device status by useing the following method: 47 | * if(getControlDevice() != CONTROL_BY_VIRTUALRC) 48 | * { 49 | * reset code; 50 | * } 51 | * - @attention Your reset code must not be "setControl(true);" without any status check 52 | * It may cause your drone became a nut drone. 53 | * - @note You could quit your VRC(Virtual Remot Control) by switching your remote 54 | * controller out of modeF 55 | * - @attention Most dangerous, setControl(true); must not be called over 0.5Hz or your 56 | * drone will be locked in a logic-checking loop. And you cannot exit VirtualRC mode by 57 | * switching your remote controller's mode. Actually, in this situation your drone will 58 | * be a full automatically controlled by it self. It will keep flying until its bettery 59 | * is empty or your code make it stop. 60 | * - @attention If you do not know what reset code you need to write, please just output 61 | * your datalog and keep it empty. 62 | * - @attention It would be realy dangous if you keep calling sendData(); in a loop with out 63 | * control-losing protection. like : 64 | * 65 | * Global: 66 | * VirtualRCData myData; 67 | * 68 | * Thread 1: 69 | * while(1) 70 | * { 71 | * myData = myAPIToSetupDataFromGroundStation(); 72 | * } 73 | * 74 | * Thread 2: 75 | * while(1) 76 | * { 77 | * sendData(myData); 78 | * msleep(200); 79 | * } 80 | * 81 | * When your drone lose signal, it will keep the recent command sent by your API: 82 | * myAPIToSetupDataFromGroundStation(); 83 | * Somehow, you will never get your drone back in one pice, if this tragedy happend. 84 | * 85 | * @note API "sendData();" need to be called above 2Hz, and not greater than 25hz. 86 | * @note API "sendSafeModeData();" will lead your drone hover; 87 | * 88 | * */ 89 | void setControl(bool enable, CutOff cutoffType); 90 | void sendData(VirtualRCData Data); 91 | void sendData(); 92 | void resetData(); 93 | void sendSafeModeData(); 94 | 95 | VirtualRCData getVRCData() const; 96 | RadioData getRCData() const; 97 | 98 | void setVRCData(const VirtualRCData &value); 99 | 100 | bool isVirtualRC() const; 101 | 102 | public: 103 | static RadioData toRadioData(VirtualRCData &vData); 104 | static VirtualRCData toVirtualRCData(RadioData &rData); 105 | 106 | public: 107 | CoreAPI *getApi() const; 108 | void setApi(CoreAPI *value); 109 | 110 | private: 111 | CoreAPI *api; 112 | VirtualRCData data; 113 | }; 114 | 115 | } // namespace onboardSDK 116 | } // namespace DJI 117 | 118 | #endif // DJI_VIRTUALRC_H 119 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity-balance_strategy/include/DJI_utility.h: -------------------------------------------------------------------------------- 1 | #ifndef __DJI_UTILITY_H__ 2 | #define __DJI_UTILITY_H__ 3 | #include 4 | 5 | #ifdef WIN32 6 | 7 | #include 8 | #include 9 | 10 | class DJI_lock 11 | { 12 | public: 13 | DJI_lock(); 14 | ~DJI_lock(); 15 | void enter(); 16 | void leave(); 17 | private: 18 | CRITICAL_SECTION m_critical_section; 19 | }; 20 | 21 | class DJI_event 22 | { 23 | public: 24 | DJI_event(); 25 | ~DJI_event(); 26 | int set_DJI_event(); 27 | int wait_DJI_event(); 28 | private: 29 | HANDLE m_pipe_read; 30 | HANDLE m_pipe_write; 31 | }; 32 | 33 | #else 34 | 35 | #include 36 | #include 37 | 38 | class DJI_lock 39 | { 40 | public: 41 | DJI_lock(); 42 | ~DJI_lock(); 43 | void enter(); 44 | void leave(); 45 | private: 46 | pthread_mutex_t m_lock; 47 | }; 48 | 49 | class DJI_event 50 | { 51 | public: 52 | DJI_event(); 53 | ~DJI_event(); 54 | int set_DJI_event(); 55 | int wait_DJI_event(); 56 | private: 57 | sem_t m_sem; 58 | }; 59 | 60 | #endif 61 | 62 | void sleep( int microsecond ); 63 | 64 | 65 | #endif -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity-balance_strategy/include/imagetransfer.h: -------------------------------------------------------------------------------- 1 | #ifndef __IMAGE_TRANSFER_H__ 2 | #define __IMAGE_TRANSFER_H__ 3 | #include "usb_transfer.h" 4 | #include "DJI_guidance.h" 5 | 6 | #define LOWEST_VERSION 2 7 | #define PC_VERSION 2 8 | 9 | typedef void (*update_dialog_handler)( char **camera_pair_data[], char **other_data ); 10 | 11 | SDK_API void set_can_protocal( int nProtocal ); 12 | 13 | SDK_API void set_save_file_flag( bool bSaveFlag ); 14 | 15 | SDK_API int get_online_flag( int *online_flag ); 16 | 17 | SDK_API void set_update_dialog_handler( update_dialog_handler handler ); 18 | 19 | SDK_API int write_cmos( unsigned int *p_address_value, unsigned int un_address_num ); 20 | 21 | SDK_API int send_data( unsigned int id, char *data, unsigned int length ); 22 | 23 | SDK_API int get_data( unsigned int id, char *data, unsigned int max_length ); 24 | 25 | //DLL_API int get_config( char *data, unsigned int max_length ); 26 | 27 | SDK_API int push_file( const char *local_file_name, const char *remote_file_path ); 28 | 29 | SDK_API int push_file( const char *content, unsigned int file_len, const char *remote_file_full_name ); 30 | 31 | SDK_API int pull_file( const char *remote_file_name, const char *local_file_path ); 32 | 33 | SDK_API void set_register_param( unsigned int *register_addr, unsigned int *p_register_, unsigned int un_register_num ); 34 | 35 | SDK_API int set_selected_datetype( unsigned int *p_datatype_index, unsigned int un_datatype_num ); 36 | 37 | SDK_API int select_image( unsigned int camera_pair_index, unsigned int data_type ); 38 | 39 | SDK_API int set_cmos_read_address( unsigned int *p_address, unsigned int un_address_num ); 40 | 41 | SDK_API int suspend_image_transfer(); 42 | 43 | SDK_API int start_image_transfer(); 44 | 45 | SDK_API int init_image_transfer(); 46 | 47 | SDK_API int release_image_transfer(); 48 | 49 | SDK_API bool is_libusb_connected(); 50 | 51 | #ifdef WIN32 52 | SDK_API int open_console(); 53 | #endif 54 | 55 | SDK_API int get_soc_version(); 56 | 57 | SDK_API int get_vision_version( int &vision_version ); 58 | 59 | SDK_API int upgrade_sonar( unsigned int direction ); 60 | 61 | SDK_API int reboot_fastboot(); 62 | 63 | SDK_API int start_can_uart_test(); 64 | 65 | SDK_API int get_can_uart_test_result(); 66 | 67 | SDK_API int set_left_work_time( int left_work_time ); 68 | 69 | SDK_API int upgrade_soc_version(); 70 | 71 | SDK_API int set_sonar_serial_code( unsigned int logic_direction, const unsigned char *serial_code ); 72 | 73 | SDK_API int get_sonar_serial_code( unsigned int logic_direction, unsigned char *serial_code ); 74 | 75 | SDK_API int set_oa_manu_test_flag(); 76 | 77 | SDK_API int restart_master(); 78 | 79 | SDK_API int reboot_soc(); 80 | 81 | SDK_API int get_sonar_version( unsigned int logic_direction, char *hardware_version, int &loader_version, int &app_version ); 82 | 83 | SDK_API int set_event_handler( user_call_back handler ); 84 | 85 | SDK_API int save_cali_param( unsigned int logic_direction, char *cali_data, unsigned int data_len ); 86 | 87 | SDK_API int send_heartbeat_request(); 88 | 89 | SDK_API int set_manu_test_flag( int flag ); 90 | 91 | SDK_API void set_sdk_protocal( int protocal_version ); 92 | 93 | SDK_API int set_serial_code( const char *product_id, const char *code ); 94 | 95 | SDK_API int get_serial_code( char *code ); 96 | 97 | SDK_API int enable_adb( bool enable_flag ); 98 | 99 | SDK_API int enable_mvo( bool enable_flag ); 100 | 101 | SDK_API int get_token(); 102 | 103 | SDK_API int get_app_id(); 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity-balance_strategy/include/libDJI_guidance.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dji-sdk/Guidance-SDK/9f666b4338ea37f7ce62dd1292d531918b37c18c/demo/obstacle_bypass/discontinuity-balance_strategy/include/libDJI_guidance.so -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity-balance_strategy/include/usb_transfer.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dji-sdk/Guidance-SDK/9f666b4338ea37f7ce62dd1292d531918b37c18c/demo/obstacle_bypass/discontinuity-balance_strategy/include/usb_transfer.h -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity-balance_strategy/launch/sdk_demo.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity-balance_strategy/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | dji_sdk 4 | 0.0.0 5 | The dji_sdk package 6 | 7 | 8 | 9 | 10 | iarc 11 | 12 | 13 | 14 | 15 | 16 | TODO 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 | catkin 43 | 44 | 45 | std_msgs 46 | 47 | 48 | std_msgs 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity-balance_strategy/src/sdk_lib/DJI_Camera.cpp: -------------------------------------------------------------------------------- 1 | #include "DJI_Camera.h" 2 | 3 | using namespace DJI::onboardSDK; 4 | 5 | Camera::Camera(CoreAPI *ControlAPI) { api = ControlAPI; } 6 | 7 | void Camera::setCamera(Camera::CAMERA_CODE camera_cmd) 8 | { 9 | unsigned char send_data = 0; 10 | api->send(0, encrypt, SET_CONTROL, camera_cmd, &send_data, 1); 11 | } 12 | 13 | void Camera::setGimbalAngle(GimbalAngleData *data) 14 | { 15 | api->send(0, encrypt, SET_CONTROL, Camera::CODE_GIMBAL_ANGLE, (unsigned char *)data, 16 | sizeof(GimbalAngleData)); 17 | } 18 | 19 | void Camera::setGimbalSpeed(GimbalSpeedData *data) 20 | { 21 | data->reserved = 0x80; 22 | api->send(0, encrypt, SET_CONTROL, Camera::CODE_GIMBAL_SPEED, (unsigned char *)data, 23 | sizeof(GimbalSpeedData)); 24 | } 25 | 26 | GimbalData Camera::getGimbal() const { return api->getBroadcastData().gimbal; } 27 | 28 | float32_t Camera::getYaw() const { return api->getBroadcastData().gimbal.yaw; } 29 | 30 | float32_t Camera::getRoll() const { return api->getBroadcastData().gimbal.roll; } 31 | 32 | float32_t Camera::getPitch() const { return api->getBroadcastData().gimbal.pitch; } 33 | 34 | bool Camera::isYawLimit() const 35 | { 36 | if (api->getSDKVersion() != versionM100_23) 37 | return api->getBroadcastData().gimbal.yawLimit ? true : false; 38 | return false; 39 | } 40 | 41 | bool Camera::isRollLimit() const 42 | { 43 | if (api->getSDKVersion() != versionM100_23) 44 | return api->getBroadcastData().gimbal.rollLimit ? true : false; 45 | return false; 46 | } 47 | bool Camera::isPitchLimit() const 48 | { 49 | if (api->getSDKVersion() != versionM100_23) 50 | return api->getBroadcastData().gimbal.pitchLimit ? true : false; 51 | return false; 52 | } 53 | 54 | CoreAPI *Camera::getApi() const { return api; } 55 | 56 | void Camera::setApi(CoreAPI *value) { api = value; } 57 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity-balance_strategy/src/sdk_lib/DJI_Follow.cpp: -------------------------------------------------------------------------------- 1 | #include "DJI_Follow.h" 2 | 3 | using namespace DJI; 4 | using namespace DJI::onboardSDK; 5 | 6 | Follow::Follow(CoreAPI *ControlAPI) 7 | { 8 | api = ControlAPI; 9 | resetData(); 10 | } 11 | 12 | void Follow::resetData() 13 | { 14 | data.mode = MODE_RELATIVE; 15 | data.yaw = YAW_TOTARGET; 16 | data.target.latitude = api->getBroadcastData().pos.latitude; 17 | data.target.longitude = api->getBroadcastData().pos.longitude; 18 | data.target.height = api->getBroadcastData().pos.altitude; 19 | data.target.angle = 0; 20 | data.sensitivity = 1; 21 | } 22 | 23 | void Follow::start(FollowData *Data, CallBack callback, UserData userData) 24 | { 25 | if (Data) 26 | data = *Data; 27 | else 28 | resetData(); 29 | api->send(2, encrypt, SET_MISSION, CODE_FOLLOW_START, &data, sizeof(data), 500, 2, 30 | callback ? callback : missionCallback, userData); 31 | } 32 | 33 | void Follow::stop(CallBack callback, UserData userData) 34 | { 35 | uint8_t zero = 0; 36 | api->send(2, encrypt, SET_MISSION, CODE_FOLLOW_STOP, &zero, sizeof(zero), 500, 2, 37 | callback ? callback : missionCallback, userData); 38 | } 39 | 40 | void Follow::pause(bool isPause, CallBack callback, UserData userData) 41 | { 42 | uint8_t data = isPause ? 0 : 1; 43 | api->send(2, encrypt, SET_MISSION, CODE_FOLLOW_SETPAUSE, &data, sizeof(data), 500, 2, 44 | callback ? callback : missionCallback, userData); 45 | } 46 | 47 | void Follow::updateTarget(FollowTarget target) 48 | { 49 | data.target = target; 50 | api->send(0, encrypt, SET_MISSION, CODE_FOLLOW_TARGET, &(data.target), sizeof(FollowTarget)); 51 | } 52 | 53 | void Follow::updateTarget(float64_t latitude, float64_t longitude, uint16_t height, 54 | uint16_t angle) 55 | { 56 | FollowTarget target; 57 | target.latitude = latitude; 58 | target.longitude = longitude; 59 | target.height = height; 60 | target.angle = angle; 61 | updateTarget(target); 62 | } 63 | 64 | FollowData Follow::getData() const { return data; } 65 | 66 | void Follow::setData(const FollowData &value) { data = value; } 67 | 68 | void Follow::setMode(const Follow::MODE mode __UNUSED) 69 | { 70 | API_LOG(api->getDriver(), STATUS_LOG, "no available mode but default"); 71 | data.mode = 0; 72 | } 73 | 74 | void Follow::setTarget(FollowTarget target) { data.target = target; } 75 | 76 | void Follow::setYawType(const Follow::YAW_TYPE type) { data.yaw = type; } 77 | 78 | void Follow::setSensitivity(const Follow::SENSITIVITY sense __UNUSED) 79 | { 80 | API_LOG(api->getDriver(), STATUS_LOG, "no available mode but default"); 81 | data.sensitivity = 1; 82 | } 83 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity-balance_strategy/src/sdk_lib/DJI_HardDriver.cpp: -------------------------------------------------------------------------------- 1 | #include "DJI_HardDriver.h" 2 | 3 | using namespace DJI::onboardSDK; 4 | 5 | char DJI::onboardSDK::buffer[DJI::onboardSDK::bufsize]; 6 | 7 | void HardDriver::displayLog(const char *buf) 8 | { 9 | if (buf) 10 | printf("%s", buf); 11 | else 12 | printf("%s", DJI::onboardSDK::buffer); 13 | } 14 | 15 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity-balance_strategy/src/sdk_lib/DJI_VirtualRC.cpp: -------------------------------------------------------------------------------- 1 | #include "DJI_VirtualRC.h" 2 | 3 | using namespace DJI::onboardSDK; 4 | 5 | DJI::onboardSDK::VirtualRC::VirtualRC(CoreAPI *ControlAPI) 6 | { 7 | api = ControlAPI; 8 | resetData(); 9 | } 10 | 11 | void VirtualRC::setControl(bool enable, VirtualRC::CutOff cutoffType) 12 | { 13 | VirtualRCSetting setting; 14 | setting.cutoff = cutoffType; 15 | setting.enable = enable ? 1 : 0; 16 | api->send(0, encrypt, SET_VIRTUALRC, CODE_VIRTUALRC_SETTINGS, &setting, sizeof(setting)); 17 | } 18 | 19 | void VirtualRC::sendData(VirtualRCData Data) 20 | { 21 | data = Data; 22 | sendData(); 23 | } 24 | 25 | void VirtualRC::sendData() 26 | { 27 | api->send(0, encrypt, SET_VIRTUALRC, CODE_VIRTUALRC_DATA, &data, sizeof(data)); 28 | } 29 | 30 | void VirtualRC::resetData() 31 | { 32 | data.roll = 1024; 33 | data.pitch = 1024; 34 | data.throttle = 1024; 35 | data.yaw = 1024; 36 | data.gear = 1024; 37 | data.reserved = 1024; 38 | data.mode = 1024; 39 | data.Channel_07 = 1024; 40 | data.Channel_08 = 1024; 41 | data.Channel_09 = 1024; 42 | data.Channel_10 = 1024; 43 | data.Channel_11 = 1024; 44 | data.Channel_12 = 1024; 45 | data.Channel_13 = 1024; 46 | data.Channel_14 = 1024; 47 | data.Channel_15 = 1024; 48 | } 49 | 50 | void VirtualRC::sendSafeModeData() 51 | { 52 | resetData(); 53 | sendData(); 54 | } 55 | 56 | RadioData VirtualRC::getRCData() const { return api->getBroadcastData().rc; } 57 | 58 | CoreAPI *VirtualRC::getApi() const { return api; } 59 | void VirtualRC::setApi(CoreAPI *value) { api = value; } 60 | 61 | VirtualRCData VirtualRC::getVRCData() const { return data; } 62 | void VirtualRC::setVRCData(const VirtualRCData &value) { data = value; } 63 | 64 | bool VirtualRC::isVirtualRC() const 65 | { 66 | return api->getBroadcastData().ctrlInfo.vrcStatus == 0 ? false : true; 67 | } 68 | 69 | RadioData VirtualRC::toRadioData(VirtualRCData &vData) 70 | { 71 | RadioData rd; 72 | rd.gear = (vData.gear == 1324) ? -454 : -10000; 73 | rd.mode = (1024 - vData.mode ) * 10000 / 660; 74 | rd.pitch = (vData.pitch - 1024) * (10000) / 660; 75 | rd.roll = (vData.roll - 1024) * (10000) / 660; 76 | rd.yaw = (vData.yaw - 1024) * (10000) / 660; 77 | rd.throttle = (vData.throttle - 1024) * (10000) / 660; 78 | return rd; 79 | } 80 | 81 | VirtualRCData VirtualRC::toVirtualRCData(RadioData &rData) 82 | { 83 | VirtualRCData vd; 84 | vd.yaw = rData.yaw * 660 / 10000 + 1024; 85 | vd.throttle = rData.throttle * 660 / 10000 + 1024; 86 | vd.pitch = rData.pitch * 660 / 10000 + 1024; 87 | vd.roll = rData.roll * 660 / 10000 + 1024; 88 | vd.gear = (rData.gear == -4545) ? 1324 : 1684; 89 | vd.reserved = 1024; 90 | vd.mode = rData.mode * 660 / (-10000) + 1024; 91 | vd.Channel_07 = 1024; 92 | vd.Channel_08 = 1024; 93 | vd.Channel_09 = 1024; 94 | vd.Channel_10 = 1024; 95 | vd.Channel_11 = 1024; 96 | vd.Channel_12 = 1024; 97 | vd.Channel_13 = 1024; 98 | vd.Channel_14 = 1024; 99 | vd.Channel_15 = 1024; 100 | return vd; 101 | } 102 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity-balance_strategy/src/sdk_lib/DJI_utility.cpp: -------------------------------------------------------------------------------- 1 | #include "DJI_utility.h" 2 | 3 | #ifdef WIN32 4 | 5 | DJI_lock::DJI_lock() 6 | { 7 | InitializeCriticalSection( &m_critical_section ); 8 | } 9 | 10 | DJI_lock::~DJI_lock() 11 | { 12 | } 13 | 14 | void DJI_lock::enter() 15 | { 16 | EnterCriticalSection( &m_critical_section ); 17 | } 18 | 19 | void DJI_lock::leave() 20 | { 21 | LeaveCriticalSection( &m_critical_section ); 22 | } 23 | 24 | void sleep( int microsecond ) 25 | { 26 | Sleep( ( microsecond + 999 ) / 1000 ); 27 | } 28 | 29 | 30 | DJI_event::DJI_event() 31 | { 32 | SECURITY_ATTRIBUTES sa; 33 | sa.nLength = sizeof(sa); 34 | sa.lpSecurityDescriptor = NULL; 35 | sa.bInheritHandle = TRUE; 36 | CreatePipe( &m_pipe_read, &m_pipe_write, &sa, 0 ); 37 | } 38 | 39 | DJI_event::~DJI_event() 40 | { 41 | CloseHandle( m_pipe_read ); 42 | CloseHandle( m_pipe_write ); 43 | } 44 | 45 | int DJI_event::set_DJI_event() 46 | { 47 | char buffer[1] = {0}; 48 | int count = 0; 49 | int ret = WriteFile( m_pipe_write, (LPWORD)buffer, 1, (LPDWORD)&count, NULL ); 50 | return ret; 51 | } 52 | 53 | int DJI_event::wait_DJI_event() 54 | { 55 | char buffer[1] = {0}; 56 | int count = 0; 57 | int ret = ReadFile( m_pipe_read, (LPWORD)buffer, 1, (LPDWORD)&count, NULL ); 58 | return ret; 59 | } 60 | 61 | #else 62 | 63 | DJI_lock::DJI_lock() 64 | { 65 | pthread_mutex_init( &m_lock, NULL ); 66 | } 67 | 68 | DJI_lock::~DJI_lock() 69 | { 70 | } 71 | 72 | void DJI_lock::enter() 73 | { 74 | pthread_mutex_lock( &m_lock ); 75 | } 76 | 77 | void DJI_lock::leave() 78 | { 79 | pthread_mutex_unlock( &m_lock ); 80 | } 81 | 82 | DJI_event::DJI_event() 83 | { 84 | sem_init( &m_sem, 0, 0 ); 85 | } 86 | 87 | DJI_event::~DJI_event() 88 | { 89 | } 90 | 91 | int DJI_event::set_DJI_event() 92 | { 93 | int ret = sem_post( &m_sem ); 94 | return ret; 95 | } 96 | 97 | int DJI_event::wait_DJI_event() 98 | { 99 | int ret = sem_wait( &m_sem ); 100 | return ret; 101 | } 102 | 103 | #endif 104 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity_strategy/include/DJICommonType.h: -------------------------------------------------------------------------------- 1 | #ifndef DJICOMMONTYPE 2 | #define DJICOMMONTYPE 3 | 4 | #include 5 | 6 | namespace DJI 7 | { 8 | 9 | typedef uint64_t time_ms; 10 | typedef uint64_t time_us; // about 0.3 million years 11 | 12 | typedef void *UserData; 13 | typedef uint32_t Flag; 14 | 15 | typedef uint8_t size8_t; 16 | typedef uint16_t size16_t; 17 | 18 | typedef struct Measure 19 | { 20 | double data; 21 | float precision; 22 | } Measure; 23 | 24 | typedef struct SpaceVector 25 | { 26 | double x; 27 | double y; 28 | double z; 29 | } SpaceVector; 30 | 31 | /*! @todo range mathematial class 32 | class Angle 33 | { 34 | public: 35 | Angle(double degree = 0); 36 | 37 | private: 38 | double degree; 39 | }; 40 | */ 41 | 42 | typedef double Angle; 43 | 44 | typedef struct EulerianAngle 45 | { 46 | Angle yaw; 47 | Angle roll; 48 | Angle pitch; 49 | } EulerianAngle; 50 | 51 | } // namespace DJI 52 | 53 | #endif // DJICOMMONTYPE 54 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity_strategy/include/DJI_App.h: -------------------------------------------------------------------------------- 1 | /*! @brief 2 | * @file DJI_APP.h 3 | * @version 3.0 4 | * @date Dec 16, 2015 5 | * 6 | * @abstract 7 | * Core API Link upper level for DJI onboardSDK library 8 | * 9 | * @attention 10 | * Project configuration: 11 | * 12 | * @version features: 13 | * -* @version V3.0 14 | * -* DJI-onboard-SDK for Windows,QT,STM32,ROS,Cmake 15 | * -* @date Dec 16, 2015 16 | * -* @author william.wu 17 | * 18 | * */ 19 | 20 | #ifndef DJI_APP_H 21 | #define DJI_APP_H 22 | 23 | #include 24 | 25 | #include "DJI_Link.h" 26 | #include "DJI_Type.h" 27 | 28 | #define MSG_ENABLE_FLAG_LEN 2 29 | 30 | //---------------------------------------------------------------------- 31 | // App layer function 32 | //---------------------------------------------------------------------- 33 | typedef struct 34 | { 35 | unsigned short sequence_number; 36 | unsigned char session_id : 5; 37 | unsigned char need_encrypt : 1; 38 | unsigned char reserve : 2; 39 | } req_id_t; 40 | 41 | #define EXC_DATA_SIZE (16u) 42 | #define SET_CMD_SIZE (2u) 43 | 44 | //---------------------------------------------------------------------- 45 | // for cmd agency 46 | //---------------------------------------------------------------------- 47 | #define REQ_TIME_OUT 0x0000 48 | #define REQ_REFUSE 0x0001 49 | #define CMD_RECIEVE 0x0002 50 | #define STATUS_CMD_EXECUTING 0x0003 51 | #define STATUS_CMD_EXE_FAIL 0x0004 52 | #define STATUS_CMD_EXE_SUCCESS 0x0005 53 | 54 | //! @todo move to type.h 55 | #pragma pack(1) 56 | 57 | typedef struct ActivateData 58 | { 59 | unsigned int ID; 60 | unsigned int reserved; 61 | unsigned int version; 62 | unsigned char iosID[32]; 63 | char *encKey; 64 | } ActivateData; 65 | 66 | typedef struct VersionData 67 | { 68 | unsigned short version_ack; 69 | unsigned int version_crc; 70 | char version_ID[11]; 71 | char version_name[32]; 72 | DJI::onboardSDK::Version version; 73 | } VersionData; 74 | 75 | #pragma pack() 76 | 77 | #endif // DJI_APP_H 78 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity_strategy/include/DJI_Camera.h: -------------------------------------------------------------------------------- 1 | /*! @brief 2 | * @file DJI_Camera.h 3 | * @version 3.0 4 | * @date Dec 16, 2015 5 | * 6 | * @abstract 7 | * Camera control API for DJI onboardSDK library 8 | * 9 | * @attention 10 | * Project configuration: 11 | * 12 | * @version features: 13 | * -* @version V3.0 14 | * -* DJI-onboard-SDK for Windows,QT,STM32,ROS,Cmake 15 | * -* @date Dec 16, 2015 16 | * -* @author william.wu 17 | * 18 | * */ 19 | 20 | #ifndef DJI_CAMERA_H 21 | #define DJI_CAMERA_H 22 | 23 | #include "DJI_API.h" 24 | 25 | namespace DJI 26 | { 27 | namespace onboardSDK 28 | { 29 | class Camera 30 | { 31 | public: 32 | enum CAMERA_CODE 33 | { 34 | CODE_GIMBAL_SPEED = 0x1A, 35 | CODE_GIMBAL_ANGLE = 0x1B, 36 | CODE_CAMERA_SHOT = 0x20, 37 | CODE_CAMERA_VIDEO_START = 0x21, 38 | CODE_CAMERA_VIDEO_STOP = 0x22 39 | }; 40 | 41 | public: 42 | Camera(CoreAPI *ControlAPI = 0); 43 | 44 | //! @note all camera control functions are none-callback function. 45 | void setCamera(CAMERA_CODE camera_cmd); 46 | void setGimbalAngle(GimbalAngleData *data); 47 | void setGimbalSpeed(GimbalSpeedData *data); 48 | 49 | GimbalData getGimbal() const; 50 | float32_t getYaw() const; 51 | float32_t getRoll() const; 52 | float32_t getPitch() const; 53 | bool isYawLimit() const; 54 | bool isRollLimit() const; 55 | bool isPitchLimit() const; 56 | 57 | public: //! @note Access method 58 | CoreAPI *getApi() const; 59 | void setApi(CoreAPI *value); 60 | 61 | private: 62 | CoreAPI *api; 63 | }; 64 | } // namespace onboardSDK 65 | } // namespace DJI 66 | 67 | #endif // DJI_CAMERA_H 68 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity_strategy/include/DJI_Codec.h: -------------------------------------------------------------------------------- 1 | /*! @brief 2 | * @file DJI_Codec.h 3 | * @version 3.0 4 | * @date Dec 16, 2015 5 | * 6 | * @abstract 7 | * Encode functions for DJI onboardSDK library 8 | * 9 | * @attention 10 | * Project configuration: 11 | * 12 | * @todo spilt this header into 4 header files 13 | * 14 | * @version features: 15 | * -* @version V3.0 16 | * -* DJI-onboard-SDK for Windows,QT,STM32,ROS,Cmake 17 | * -* @date Dec 16, 2015 18 | * -* @author william.wu 19 | * 20 | * */ 21 | 22 | #ifndef DJI_CODEC_H 23 | #define DJI_CODEC_H 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include "DJI_Type.h" 30 | 31 | #define _SDK_MAX_RECV_SIZE (BUFFER_SIZE) 32 | #define _SDK_SOF ((unsigned char)(0xAA)) 33 | #define _SDK_CRC_HEAD_SIZE (2) // CRC16 34 | #define _SDK_CRC_DATA_SIZE (4) // CRC32 35 | #define _SDK_HEAD_DATA_LEN (sizeof(DJI::onboardSDK::Header) - 2) 36 | #define _SDK_FULL_DATA_SIZE_MIN (sizeof(DJI::onboardSDK::Header) + _SDK_CRC_DATA_SIZE) 37 | 38 | #define _SDK_U32_SET(_addr, _val) (*((unsigned int *)(_addr)) = (_val)) 39 | #define _SDK_U16_SET(_addr, _val) (*((unsigned short *)(_addr)) = (_val)) 40 | 41 | #define _SDK_CALC_CRC_HEAD(_msg, _len) \ 42 | sdk_stream_crc16_calc((const unsigned char *)(_msg), _len) 43 | #define _SDK_CALC_CRC_TAIL(_msg, _len) \ 44 | sdk_stream_crc32_calc((const unsigned char *)(_msg), _len) 45 | 46 | 47 | void transformTwoByte(const char *pstr, unsigned char *pdata); 48 | 49 | #endif // DJI_CODEC_H 50 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity_strategy/include/DJI_Config.h: -------------------------------------------------------------------------------- 1 | /*! @brief 2 | * @file DJI_Config.h 3 | * @version 3.0 4 | * @date Dec 16, 2015 5 | * 6 | * @abstract 7 | * Configuration optional Micro definitions for DJI onboardSDK library. 8 | * 9 | * @attention 10 | * Project configuration: 11 | * None 12 | * 13 | * @version features: 14 | * -* @version V3.0 15 | * -* DJI-onboard-SDK for Windows,QT,STM32,ROS,Cmake 16 | * -* @date Dec 16, 2015 17 | * -* @author william.wu 18 | * 19 | * */ 20 | 21 | #ifndef DJI_CONFIG_H 22 | #define DJI_CONFIG_H 23 | 24 | #include 25 | #define MEMORY_SIZE 1024 // unit is byte 26 | #define BUFFER_SIZE 1024 27 | #define ACK_SIZE 10 28 | 29 | //! @note it means DJI onboardSDK library will not alloc memory from heap. 30 | //! @todo not available yet, only affect WayPoint 31 | //#define STATIC_MEMORY 32 | 33 | //#define API_MISSION_DATA 34 | //#define API_DEBUG_DATA 35 | //#define API_BUFFER_DATA 36 | //#define API_RTK_DEBUG 37 | #define API_ERROR_DATA 38 | #define API_STATUS_DATA 39 | 40 | //! @note if you do not want to use AES encrypt, comment this micro below 41 | #define USE_ENCRYPT 42 | //#define USE_SIMULATION 43 | 44 | #include "DJI_Version.h" 45 | 46 | #endif // DJI_CONFIG_H 47 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity_strategy/include/DJI_Follow.h: -------------------------------------------------------------------------------- 1 | /*! @brief 2 | * @file DJI_Follow.h 3 | * @version 3.0 4 | * @date Dec 16, 2015 5 | * 6 | * @abstract 7 | * Follow API for DJI onboardSDK library 8 | * 9 | * @attention 10 | * Project configuration: 11 | * 12 | * @version features: 13 | * -* @version V3.0 14 | * -* DJI-onboard-SDK for Windows,QT,STM32,ROS,Cmake 15 | * -* @date Dec 21, 2015 16 | * -* @author william.wu 17 | * 18 | * */ 19 | 20 | #ifndef DJI_FOLLOW_H 21 | #define DJI_FOLLOW_H 22 | 23 | #include "DJI_Mission.h" 24 | 25 | namespace DJI 26 | { 27 | namespace onboardSDK 28 | { 29 | 30 | #pragma pack(1) 31 | 32 | typedef struct FollowTarget 33 | { 34 | float64_t latitude; 35 | float64_t longitude; 36 | uint16_t height; 37 | uint16_t angle; 38 | } FollowTarget; 39 | 40 | typedef struct FollowData 41 | { 42 | uint8_t mode; 43 | uint8_t yaw; 44 | FollowTarget target; 45 | uint8_t sensitivity; 46 | } FollowData; 47 | 48 | #pragma pack() 49 | 50 | class Follow 51 | { 52 | public: 53 | enum MODE 54 | { 55 | MODE_RELATIVE = 0, 56 | MODE_ROUTE = 1, //! @note Flight control not support now 57 | MODE_SMART = 2 //! @note Flight control not support now 58 | }; 59 | 60 | enum YAW_TYPE 61 | { 62 | YAW_TOTARGET = 0, 63 | YAW_CUSTOM = 1 64 | }; 65 | 66 | enum SENSITIVITY 67 | { 68 | SENSE_LOW = 0, //! @note Flight control not support now 69 | SENSE_MID = 1, 70 | SENSE_HIGH = 2 //! @note Flight control not support now 71 | }; 72 | 73 | public: 74 | Follow(CoreAPI *ControlAPI = 0); 75 | void resetData(); 76 | 77 | void start(FollowData *Data = 0, CallBack callback = 0, UserData userData = 0); 78 | void stop(CallBack callback = 0, UserData userData = 0); 79 | //! @note true for pause, false for resume 80 | void pause(bool isPause, CallBack callback = 0, UserData userData = 0); 81 | void updateTarget(FollowTarget target); //! @note no ack command 82 | void updateTarget(float64_t latitude, float64_t longitude, uint16_t height, 83 | uint16_t angle); //! @note no ack command 84 | 85 | public: 86 | void setData(const FollowData &value); 87 | void setMode(const MODE mode); 88 | void setTarget(FollowTarget target); 89 | void setYawType(const YAW_TYPE type); 90 | void setSensitivity(const SENSITIVITY sense); 91 | 92 | FollowData getData() const; 93 | 94 | private: 95 | CoreAPI *api; 96 | FollowData data; 97 | }; 98 | 99 | } // namespace onboardSDK 100 | } // namespace DJI 101 | 102 | #endif // DJI_FOLLOW_H 103 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity_strategy/include/DJI_HardDriver.h: -------------------------------------------------------------------------------- 1 | /*! @brief 2 | * @file DJI_HardDriver.h 3 | * @version 3.0 4 | * @date Dec 9, 2015 5 | * 6 | * @abstract 7 | * Hard ware level for DJI onboardSDK library 8 | * 9 | * @attention 10 | * Project configuration: 11 | * 12 | * @version features: 13 | * -* @version V3.0 14 | * -* DJI-onboard-SDK for Windows,QT,STM32,ROS,Cmake 15 | * -* @date Dec 9, 2015 16 | * -* @author william.wu 17 | * 18 | * */ 19 | #ifndef DJI_HARDDRIVER_H 20 | #define DJI_HARDDRIVER_H 21 | 22 | #include 23 | #include 24 | #include "DJI_Type.h" 25 | 26 | namespace DJI 27 | { 28 | namespace onboardSDK 29 | { 30 | 31 | class HardDriver 32 | { 33 | public: 34 | HardDriver() {} 35 | 36 | /*! @note How to use 37 | * In order to provide platform crossable DJI onboardSDK library, 38 | * we abstract this class as a hardware level. 39 | * 40 | * @note function descriptions: 41 | * 42 | * void init(); 43 | * @brief After calling this function, HardDriver should be able to 44 | * read and send correctly, through a correct UART part 45 | * 46 | * unsigned int getTimeStamp(); 47 | * @brief returns a TimeStamp data in unit msec. 48 | * The difference between the return value of the function call two times 49 | * is the excat time between them in msec. 50 | * 51 | * size_t send(const uint8_t *buf, size_t len); 52 | * @brief return sent data length. 53 | * 54 | * size_t readall(uint8_t *buf, size_t maxlen) = 0; 55 | * @brief return read data length. 56 | * 57 | * void lockMemory();/ void freeMemory(); 58 | * @brief provide a mutex for multi-thread. when operating memory. 59 | * 60 | * void lockMSG();/ void freeMSG(); 61 | * @brief provide a mutex for multi-thread. when operating messages. 62 | * 63 | * void displayLog(char *buf); 64 | * @brief Micro "API_LOG" invoked this function, to pass datalog. 65 | * In order to pass data through different stream or channel. 66 | * We abstract this virtual function for user. 67 | * And different from others, this interface is not a pure virtual funcion. 68 | * The default data-passing channel is stdout (printf). 69 | * See also "DJI_HardDriver.cpp". 70 | * 71 | * @attention 72 | * when writting and reading data, there might have multi-thread problems. 73 | * Abstract class HardDriver did not consider these issue. 74 | * Please be careful when you are going to implement send and readall 75 | * funtions. 76 | * 77 | * @note 78 | * we strongly suggest you to inherit this class in your own file, not just 79 | * implement 80 | * it in DJI_HardDriver.cpp or inside this class 81 | * 82 | * */ 83 | public: 84 | virtual void init() = 0; 85 | virtual time_ms getTimeStamp() = 0; 86 | virtual size_t send(const uint8_t *buf, size_t len) = 0; 87 | virtual size_t readall(uint8_t *buf, size_t maxlen) = 0; 88 | 89 | public: 90 | virtual void lockMemory() = 0; 91 | virtual void freeMemory() = 0; 92 | 93 | virtual void lockMSG() = 0; 94 | virtual void freeMSG() = 0; 95 | 96 | public: 97 | virtual void displayLog(const char *buf = 0); 98 | }; 99 | } // namespace onboardSDK 100 | } // namespace DJI 101 | 102 | #endif // DJI_HARDDRIVER_H 103 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity_strategy/include/DJI_HotPoint.h: -------------------------------------------------------------------------------- 1 | /*! @brief 2 | * @file DJI_HotPoint.h 3 | * @version 3.0 4 | * @date Dec 16, 2015 5 | * 6 | * @abstract 7 | * HotPoint API for DJI onboardSDK library 8 | * 9 | * @attention 10 | * Project configuration: 11 | * 12 | * @version features: 13 | * -* @version V3.0 14 | * -* DJI-onboard-SDK for Windows,QT,STM32,ROS,Cmake 15 | * -* @date Dec 16, 2015 16 | * -* @author william.wu 17 | * 18 | * */ 19 | 20 | #ifndef DJI_HOTPOINT_H 21 | #define DJI_HOTPOINT_H 22 | 23 | #include "DJI_Mission.h" 24 | 25 | namespace DJI 26 | { 27 | namespace onboardSDK 28 | { 29 | 30 | #pragma pack(1) 31 | 32 | typedef struct HotPointData 33 | { 34 | uint8_t version; 35 | 36 | float64_t latitude; 37 | float64_t longitude; 38 | float64_t height; 39 | 40 | float64_t radius; 41 | float32_t palstance; // degree 42 | 43 | uint8_t clockwise; 44 | uint8_t startPoint; 45 | uint8_t yawMode; 46 | uint8_t reserved[11]; 47 | } HotPointData; 48 | 49 | #pragma pack() 50 | 51 | class HotPoint 52 | { 53 | public: 54 | #pragma pack(1) 55 | typedef struct StartACK 56 | { 57 | uint8_t ack; 58 | float32_t maxRadius; 59 | } StartACK; 60 | 61 | typedef struct Palstance 62 | { 63 | uint8_t clockwise; 64 | float32_t palstance; 65 | } Palstance; 66 | 67 | typedef struct ReadACK 68 | { 69 | MissionACK ack; 70 | HotPointData data; 71 | } ReadACK; 72 | #pragma pack() 73 | 74 | enum View 75 | { 76 | VIEW_NORTH = 0, 77 | VIEW_SOUTH = 1, 78 | VIEW_WEST = 2, 79 | VIEW_EAST = 3, 80 | VIEW_NEARBY = 4 81 | }; 82 | 83 | enum YawMode 84 | { 85 | YAW_AUTO = 0, 86 | YAW_INSIDE = 1, 87 | YAW_OUTSIDE = 2, 88 | YAW_CUSTOM = 3, 89 | YAW_STATIC = 4, 90 | }; 91 | 92 | public: 93 | HotPoint(CoreAPI *ControlAPI = 0); 94 | void initData(); 95 | 96 | /*! @note API functions 97 | * @attention difference between set and update 98 | * Set functions only change the HotPoint data in this class, 99 | * Update functions will change the Mission status. 100 | * In other words: drone will response update functions immediately. 101 | * */ 102 | 103 | void start(CallBack callback = 0, UserData userData = 0); 104 | void stop(CallBack callback = 0, UserData userData = 0); 105 | void pause(bool isPause, CallBack callback = 0, UserData userData = 0); 106 | 107 | void updatePalstance(Palstance &Data, CallBack callback = 0, UserData userData = 0); 108 | void updatePalstance(float32_t palstance, bool isClockwise, CallBack callback = 0, 109 | UserData userData = 0); 110 | void updateRadius(float32_t meter, CallBack callback = 0, UserData userData = 0); 111 | void resetYaw(CallBack callback = 0, UserData userData = 0); 112 | 113 | void readData(CallBack callback = 0, UserData userData = 0); 114 | 115 | public: 116 | //! @note data access functions 117 | void setData(const HotPointData &value); 118 | void setHotPoint(float64_t longtitude, float64_t latitude, float64_t altitude); 119 | void setHotPoint(GPSPositionData gps); 120 | void setRadius(float64_t meter); 121 | void setPalstance(float32_t defree); 122 | void setClockwise(bool isClockwise); 123 | void setCameraView(View view); 124 | void setYawMode(YawMode mode); 125 | 126 | HotPointData getData() const; 127 | 128 | public: 129 | static void startCallback(CoreAPI *This, Header *header, UserData userdata = 0); 130 | static void readCallback(CoreAPI *This, Header *header, UserData userdata); 131 | 132 | private: 133 | CoreAPI *api; 134 | HotPointData data; 135 | }; 136 | 137 | } // namespace onboardSDK 138 | } // namespace DJI 139 | 140 | #endif // DJI_HOTPOINT_H 141 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity_strategy/include/DJI_Link.h: -------------------------------------------------------------------------------- 1 | /*! @brief 2 | * @file DJI_Link.h 3 | * @version 3.0 4 | * @date Dec 4, 2015 5 | * 6 | * @abstract 7 | * 8 | * @attention 9 | * Project configuration: 10 | * 11 | * @version features: 12 | * -* @version V3.0 13 | * -* DJI-onboard-SDK for Windows,QT,STM32,ROS,Cmake 14 | * -* @date Nov 15, 2015 15 | * -* @author william.wu 16 | * -* 17 | * -* @version V2.0 18 | * -* C-like DJI-onboard-SDK library 19 | * -* @date Mar 12, 2015 20 | * -* @author wuyuwei 21 | * 22 | * */ 23 | #ifndef DJI_LINK_H 24 | #define DJI_LINK_H 25 | 26 | #define ACK_SESSION_IDLE 0 27 | #define ACK_SESSION_PROCESS 1 28 | #define ACK_SESSION_USING 2 29 | #define CMD_SESSION_0 0 30 | #define CMD_SESSION_1 1 31 | #define CMD_SESSION_AUTO 32 32 | 33 | 34 | #define POLL_TICK 20 // unit is ms 35 | 36 | #include "DJI_Type.h" 37 | 38 | #endif // DJI_LINK_H 39 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity_strategy/include/DJI_Memory.h: -------------------------------------------------------------------------------- 1 | #ifndef DJI_MEMORY_H 2 | #define DJI_MEMORY_H 3 | 4 | #include "DJI_Type.h" 5 | 6 | #endif // DJI_MEMORY_H 7 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity_strategy/include/DJI_Mission.h: -------------------------------------------------------------------------------- 1 | /*! @brief 2 | * @file DJI_Codec.h 3 | * @version 3.0 4 | * @date Dec 16, 2015 5 | * 6 | * @abstract 7 | * Mission framework for DJI onboardSDK library 8 | * 9 | * @attention 10 | * Project configuration: 11 | * 12 | * @version features: 13 | * -* @version V3.0 14 | * -* DJI-onboard-SDK for Windows,QT,STM32,ROS,Cmake 15 | * -* @date Dec 16, 2015 16 | * -* @author william.wu 17 | * 18 | * */ 19 | 20 | #ifndef DJI_MISSION_H 21 | #define DJI_MISSION_H 22 | 23 | #include "DJI_Config.h" 24 | #include "DJI_API.h" 25 | 26 | namespace DJI 27 | { 28 | namespace onboardSDK 29 | { 30 | #pragma pack(1) 31 | 32 | typedef struct HotPointACKData 33 | { 34 | uint8_t status; 35 | uint16_t radius; // in cm 36 | uint8_t failReasion; 37 | uint8_t palstance; 38 | } HotPointADKData; 39 | 40 | //! @todo unify the naming style 41 | typedef struct GSPushData 42 | { 43 | uint8_t type; 44 | uint8_t data_1; 45 | uint8_t data_2; 46 | uint8_t data_3; 47 | uint8_t data_4; 48 | uint8_t data_5; 49 | } GSPushData; 50 | 51 | #pragma pack() 52 | 53 | typedef struct MissionACKMap 54 | { 55 | uint8_t code; 56 | const char *meaning; 57 | } MissionACKMap; 58 | 59 | void missionCallback(CoreAPI *This, Header *header, UserData userdata = 0); 60 | 61 | } // namespace onboardSDK 62 | } // namespace DJI 63 | 64 | #endif // DJI_MISSION_H 65 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity_strategy/include/DJI_Version.h: -------------------------------------------------------------------------------- 1 | /*! @brief 2 | * @file DJI_Version.h 3 | * @version 3.0 4 | * @date Dec 16, 2015 5 | * 6 | * @abstract 7 | * Version control definition for DJI onboardSDK library 8 | * Maintain officially 9 | * 10 | * @attention 11 | * Maintain officially, readonly for users 12 | * Do not modify any definition in this file, 13 | * if you are not sure what are you doing exactlly, 14 | * or we will not provide any support. 15 | * 16 | * Project configuration: 17 | * 18 | * @version features: 19 | * -* @version V3.0 20 | * -* DJI-onboard-SDK for Windows,QT,STM32,ROS,Cmake 21 | * -* @date Dec 16, 2015 22 | * -* @author william.wu 23 | * 24 | * */ 25 | 26 | /*! @attention 27 | * Maintain officially, readonly for users 28 | * Do not modify any definition in this file, 29 | * if you are not sure what are you doing exactlly, 30 | * or we will not provide any support. 31 | * */ 32 | 33 | #ifndef DJI_VERSION_H 34 | #define DJI_VERSION_H 35 | 36 | #include 37 | 38 | #define MAKE_VERSION(a, b, c, d) \ 39 | (((a << 24) & 0xff000000) | ((b << 16) & 0x00ff0000) | ((c << 8) & 0x0000ff00) | \ 40 | (d & 0x000000ff)) 41 | 42 | namespace DJI 43 | { 44 | namespace onboardSDK 45 | { 46 | //! @todo better version control structure 47 | typedef uint32_t Version; 48 | 49 | const Version versionM100_23 = (MAKE_VERSION(2, 3, 10, 0)); 50 | const Version versionM100_31 = (MAKE_VERSION(3, 1, 10, 0)); 51 | const Version versionA3_31 = (MAKE_VERSION(3, 1, 100, 0)); 52 | const Version SDK_VERSION = versionM100_31; 53 | 54 | #ifdef SDK_DEV 55 | #include "dev.h" 56 | #endif // SDK_DEV 57 | 58 | } // namespace DJI 59 | } // namespace onboardSDK 60 | 61 | #endif // DJI_VERSION_H 62 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity_strategy/include/DJI_VirtualRC.h: -------------------------------------------------------------------------------- 1 | /*! @brief 2 | * @file DJI_Codec.h 3 | * @version 3.0 4 | * @date Dec 16, 2015 5 | * 6 | * @abstract 7 | * Virtual Radio Control API for DJI onboardSDK library 8 | * 9 | * @attention 10 | * Project configuration: 11 | * 12 | * @version features: 13 | * -* @version V3.0 14 | * -* DJI-onboard-SDK for Windows,QT,STM32,ROS,Cmake 15 | * -* @date Dec 16, 2015 16 | * -* @author william.wu 17 | * 18 | * */ 19 | 20 | #ifndef DJI_VIRTUALRC_H 21 | #define DJI_VIRTUALRC_H 22 | 23 | #include "DJI_API.h" 24 | 25 | namespace DJI 26 | { 27 | namespace onboardSDK 28 | { 29 | 30 | class VirtualRC 31 | { 32 | public: 33 | //! @todo spelling correction 34 | enum CutOff 35 | { 36 | CutOff_ToLogic = 0, 37 | CutOff_ToRealRC = 1 38 | }; 39 | 40 | public: 41 | VirtualRC(CoreAPI *ControlAPI = 0); 42 | 43 | /*! @attention Safety notes 44 | * You must use these methods below really carefully with following rules: 45 | * - Use API setControl(bool enable, CutOff cutoffType); only once in your main loop; 46 | * - Check your control device status by useing the following method: 47 | * if(getControlDevice() != CONTROL_BY_VIRTUALRC) 48 | * { 49 | * reset code; 50 | * } 51 | * - @attention Your reset code must not be "setControl(true);" without any status check 52 | * It may cause your drone became a nut drone. 53 | * - @note You could quit your VRC(Virtual Remot Control) by switching your remote 54 | * controller out of modeF 55 | * - @attention Most dangerous, setControl(true); must not be called over 0.5Hz or your 56 | * drone will be locked in a logic-checking loop. And you cannot exit VirtualRC mode by 57 | * switching your remote controller's mode. Actually, in this situation your drone will 58 | * be a full automatically controlled by it self. It will keep flying until its bettery 59 | * is empty or your code make it stop. 60 | * - @attention If you do not know what reset code you need to write, please just output 61 | * your datalog and keep it empty. 62 | * - @attention It would be realy dangous if you keep calling sendData(); in a loop with out 63 | * control-losing protection. like : 64 | * 65 | * Global: 66 | * VirtualRCData myData; 67 | * 68 | * Thread 1: 69 | * while(1) 70 | * { 71 | * myData = myAPIToSetupDataFromGroundStation(); 72 | * } 73 | * 74 | * Thread 2: 75 | * while(1) 76 | * { 77 | * sendData(myData); 78 | * msleep(200); 79 | * } 80 | * 81 | * When your drone lose signal, it will keep the recent command sent by your API: 82 | * myAPIToSetupDataFromGroundStation(); 83 | * Somehow, you will never get your drone back in one pice, if this tragedy happend. 84 | * 85 | * @note API "sendData();" need to be called above 2Hz, and not greater than 25hz. 86 | * @note API "sendSafeModeData();" will lead your drone hover; 87 | * 88 | * */ 89 | void setControl(bool enable, CutOff cutoffType); 90 | void sendData(VirtualRCData Data); 91 | void sendData(); 92 | void resetData(); 93 | void sendSafeModeData(); 94 | 95 | VirtualRCData getVRCData() const; 96 | RadioData getRCData() const; 97 | 98 | void setVRCData(const VirtualRCData &value); 99 | 100 | bool isVirtualRC() const; 101 | 102 | public: 103 | static RadioData toRadioData(VirtualRCData &vData); 104 | static VirtualRCData toVirtualRCData(RadioData &rData); 105 | 106 | public: 107 | CoreAPI *getApi() const; 108 | void setApi(CoreAPI *value); 109 | 110 | private: 111 | CoreAPI *api; 112 | VirtualRCData data; 113 | }; 114 | 115 | } // namespace onboardSDK 116 | } // namespace DJI 117 | 118 | #endif // DJI_VIRTUALRC_H 119 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity_strategy/include/DJI_utility.h: -------------------------------------------------------------------------------- 1 | #ifndef __DJI_UTILITY_H__ 2 | #define __DJI_UTILITY_H__ 3 | #include 4 | 5 | #ifdef WIN32 6 | 7 | #include 8 | #include 9 | 10 | class DJI_lock 11 | { 12 | public: 13 | DJI_lock(); 14 | ~DJI_lock(); 15 | void enter(); 16 | void leave(); 17 | private: 18 | CRITICAL_SECTION m_critical_section; 19 | }; 20 | 21 | class DJI_event 22 | { 23 | public: 24 | DJI_event(); 25 | ~DJI_event(); 26 | int set_DJI_event(); 27 | int wait_DJI_event(); 28 | private: 29 | HANDLE m_pipe_read; 30 | HANDLE m_pipe_write; 31 | }; 32 | 33 | #else 34 | 35 | #include 36 | #include 37 | 38 | class DJI_lock 39 | { 40 | public: 41 | DJI_lock(); 42 | ~DJI_lock(); 43 | void enter(); 44 | void leave(); 45 | private: 46 | pthread_mutex_t m_lock; 47 | }; 48 | 49 | class DJI_event 50 | { 51 | public: 52 | DJI_event(); 53 | ~DJI_event(); 54 | int set_DJI_event(); 55 | int wait_DJI_event(); 56 | private: 57 | sem_t m_sem; 58 | }; 59 | 60 | #endif 61 | 62 | void sleep( int microsecond ); 63 | 64 | 65 | #endif -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity_strategy/include/imagetransfer.h: -------------------------------------------------------------------------------- 1 | #ifndef __IMAGE_TRANSFER_H__ 2 | #define __IMAGE_TRANSFER_H__ 3 | #include "usb_transfer.h" 4 | #include "DJI_guidance.h" 5 | 6 | #define LOWEST_VERSION 2 7 | #define PC_VERSION 2 8 | 9 | typedef void (*update_dialog_handler)( char **camera_pair_data[], char **other_data ); 10 | 11 | SDK_API void set_can_protocal( int nProtocal ); 12 | 13 | SDK_API void set_save_file_flag( bool bSaveFlag ); 14 | 15 | SDK_API int get_online_flag( int *online_flag ); 16 | 17 | SDK_API void set_update_dialog_handler( update_dialog_handler handler ); 18 | 19 | SDK_API int write_cmos( unsigned int *p_address_value, unsigned int un_address_num ); 20 | 21 | SDK_API int send_data( unsigned int id, char *data, unsigned int length ); 22 | 23 | SDK_API int get_data( unsigned int id, char *data, unsigned int max_length ); 24 | 25 | //DLL_API int get_config( char *data, unsigned int max_length ); 26 | 27 | SDK_API int push_file( const char *local_file_name, const char *remote_file_path ); 28 | 29 | SDK_API int push_file( const char *content, unsigned int file_len, const char *remote_file_full_name ); 30 | 31 | SDK_API int pull_file( const char *remote_file_name, const char *local_file_path ); 32 | 33 | SDK_API void set_register_param( unsigned int *register_addr, unsigned int *p_register_, unsigned int un_register_num ); 34 | 35 | SDK_API int set_selected_datetype( unsigned int *p_datatype_index, unsigned int un_datatype_num ); 36 | 37 | SDK_API int select_image( unsigned int camera_pair_index, unsigned int data_type ); 38 | 39 | SDK_API int set_cmos_read_address( unsigned int *p_address, unsigned int un_address_num ); 40 | 41 | SDK_API int suspend_image_transfer(); 42 | 43 | SDK_API int start_image_transfer(); 44 | 45 | SDK_API int init_image_transfer(); 46 | 47 | SDK_API int release_image_transfer(); 48 | 49 | SDK_API bool is_libusb_connected(); 50 | 51 | #ifdef WIN32 52 | SDK_API int open_console(); 53 | #endif 54 | 55 | SDK_API int get_soc_version(); 56 | 57 | SDK_API int get_vision_version( int &vision_version ); 58 | 59 | SDK_API int upgrade_sonar( unsigned int direction ); 60 | 61 | SDK_API int reboot_fastboot(); 62 | 63 | SDK_API int start_can_uart_test(); 64 | 65 | SDK_API int get_can_uart_test_result(); 66 | 67 | SDK_API int set_left_work_time( int left_work_time ); 68 | 69 | SDK_API int upgrade_soc_version(); 70 | 71 | SDK_API int set_sonar_serial_code( unsigned int logic_direction, const unsigned char *serial_code ); 72 | 73 | SDK_API int get_sonar_serial_code( unsigned int logic_direction, unsigned char *serial_code ); 74 | 75 | SDK_API int set_oa_manu_test_flag(); 76 | 77 | SDK_API int restart_master(); 78 | 79 | SDK_API int reboot_soc(); 80 | 81 | SDK_API int get_sonar_version( unsigned int logic_direction, char *hardware_version, int &loader_version, int &app_version ); 82 | 83 | SDK_API int set_event_handler( user_call_back handler ); 84 | 85 | SDK_API int save_cali_param( unsigned int logic_direction, char *cali_data, unsigned int data_len ); 86 | 87 | SDK_API int send_heartbeat_request(); 88 | 89 | SDK_API int set_manu_test_flag( int flag ); 90 | 91 | SDK_API void set_sdk_protocal( int protocal_version ); 92 | 93 | SDK_API int set_serial_code( const char *product_id, const char *code ); 94 | 95 | SDK_API int get_serial_code( char *code ); 96 | 97 | SDK_API int enable_adb( bool enable_flag ); 98 | 99 | SDK_API int enable_mvo( bool enable_flag ); 100 | 101 | SDK_API int get_token(); 102 | 103 | SDK_API int get_app_id(); 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity_strategy/include/libDJI_guidance.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dji-sdk/Guidance-SDK/9f666b4338ea37f7ce62dd1292d531918b37c18c/demo/obstacle_bypass/discontinuity_strategy/include/libDJI_guidance.so -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity_strategy/include/usb_transfer.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dji-sdk/Guidance-SDK/9f666b4338ea37f7ce62dd1292d531918b37c18c/demo/obstacle_bypass/discontinuity_strategy/include/usb_transfer.h -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity_strategy/launch/sdk_demo.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity_strategy/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | dji_sdk 4 | 0.0.0 5 | The dji_sdk package 6 | 7 | 8 | 9 | 10 | iarc 11 | 12 | 13 | 14 | 15 | 16 | TODO 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 | catkin 43 | 44 | 45 | std_msgs 46 | 47 | 48 | std_msgs 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity_strategy/src/sdk_lib/DJI_Camera.cpp: -------------------------------------------------------------------------------- 1 | #include "DJI_Camera.h" 2 | 3 | using namespace DJI::onboardSDK; 4 | 5 | Camera::Camera(CoreAPI *ControlAPI) { api = ControlAPI; } 6 | 7 | void Camera::setCamera(Camera::CAMERA_CODE camera_cmd) 8 | { 9 | unsigned char send_data = 0; 10 | api->send(0, encrypt, SET_CONTROL, camera_cmd, &send_data, 1); 11 | } 12 | 13 | void Camera::setGimbalAngle(GimbalAngleData *data) 14 | { 15 | api->send(0, encrypt, SET_CONTROL, Camera::CODE_GIMBAL_ANGLE, (unsigned char *)data, 16 | sizeof(GimbalAngleData)); 17 | } 18 | 19 | void Camera::setGimbalSpeed(GimbalSpeedData *data) 20 | { 21 | data->reserved = 0x80; 22 | api->send(0, encrypt, SET_CONTROL, Camera::CODE_GIMBAL_SPEED, (unsigned char *)data, 23 | sizeof(GimbalSpeedData)); 24 | } 25 | 26 | GimbalData Camera::getGimbal() const { return api->getBroadcastData().gimbal; } 27 | 28 | float32_t Camera::getYaw() const { return api->getBroadcastData().gimbal.yaw; } 29 | 30 | float32_t Camera::getRoll() const { return api->getBroadcastData().gimbal.roll; } 31 | 32 | float32_t Camera::getPitch() const { return api->getBroadcastData().gimbal.pitch; } 33 | 34 | bool Camera::isYawLimit() const 35 | { 36 | if (api->getSDKVersion() != versionM100_23) 37 | return api->getBroadcastData().gimbal.yawLimit ? true : false; 38 | return false; 39 | } 40 | 41 | bool Camera::isRollLimit() const 42 | { 43 | if (api->getSDKVersion() != versionM100_23) 44 | return api->getBroadcastData().gimbal.rollLimit ? true : false; 45 | return false; 46 | } 47 | bool Camera::isPitchLimit() const 48 | { 49 | if (api->getSDKVersion() != versionM100_23) 50 | return api->getBroadcastData().gimbal.pitchLimit ? true : false; 51 | return false; 52 | } 53 | 54 | CoreAPI *Camera::getApi() const { return api; } 55 | 56 | void Camera::setApi(CoreAPI *value) { api = value; } 57 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity_strategy/src/sdk_lib/DJI_Follow.cpp: -------------------------------------------------------------------------------- 1 | #include "DJI_Follow.h" 2 | 3 | using namespace DJI; 4 | using namespace DJI::onboardSDK; 5 | 6 | Follow::Follow(CoreAPI *ControlAPI) 7 | { 8 | api = ControlAPI; 9 | resetData(); 10 | } 11 | 12 | void Follow::resetData() 13 | { 14 | data.mode = MODE_RELATIVE; 15 | data.yaw = YAW_TOTARGET; 16 | data.target.latitude = api->getBroadcastData().pos.latitude; 17 | data.target.longitude = api->getBroadcastData().pos.longitude; 18 | data.target.height = api->getBroadcastData().pos.altitude; 19 | data.target.angle = 0; 20 | data.sensitivity = 1; 21 | } 22 | 23 | void Follow::start(FollowData *Data, CallBack callback, UserData userData) 24 | { 25 | if (Data) 26 | data = *Data; 27 | else 28 | resetData(); 29 | api->send(2, encrypt, SET_MISSION, CODE_FOLLOW_START, &data, sizeof(data), 500, 2, 30 | callback ? callback : missionCallback, userData); 31 | } 32 | 33 | void Follow::stop(CallBack callback, UserData userData) 34 | { 35 | uint8_t zero = 0; 36 | api->send(2, encrypt, SET_MISSION, CODE_FOLLOW_STOP, &zero, sizeof(zero), 500, 2, 37 | callback ? callback : missionCallback, userData); 38 | } 39 | 40 | void Follow::pause(bool isPause, CallBack callback, UserData userData) 41 | { 42 | uint8_t data = isPause ? 0 : 1; 43 | api->send(2, encrypt, SET_MISSION, CODE_FOLLOW_SETPAUSE, &data, sizeof(data), 500, 2, 44 | callback ? callback : missionCallback, userData); 45 | } 46 | 47 | void Follow::updateTarget(FollowTarget target) 48 | { 49 | data.target = target; 50 | api->send(0, encrypt, SET_MISSION, CODE_FOLLOW_TARGET, &(data.target), sizeof(FollowTarget)); 51 | } 52 | 53 | void Follow::updateTarget(float64_t latitude, float64_t longitude, uint16_t height, 54 | uint16_t angle) 55 | { 56 | FollowTarget target; 57 | target.latitude = latitude; 58 | target.longitude = longitude; 59 | target.height = height; 60 | target.angle = angle; 61 | updateTarget(target); 62 | } 63 | 64 | FollowData Follow::getData() const { return data; } 65 | 66 | void Follow::setData(const FollowData &value) { data = value; } 67 | 68 | void Follow::setMode(const Follow::MODE mode __UNUSED) 69 | { 70 | API_LOG(api->getDriver(), STATUS_LOG, "no available mode but default"); 71 | data.mode = 0; 72 | } 73 | 74 | void Follow::setTarget(FollowTarget target) { data.target = target; } 75 | 76 | void Follow::setYawType(const Follow::YAW_TYPE type) { data.yaw = type; } 77 | 78 | void Follow::setSensitivity(const Follow::SENSITIVITY sense __UNUSED) 79 | { 80 | API_LOG(api->getDriver(), STATUS_LOG, "no available mode but default"); 81 | data.sensitivity = 1; 82 | } 83 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity_strategy/src/sdk_lib/DJI_HardDriver.cpp: -------------------------------------------------------------------------------- 1 | #include "DJI_HardDriver.h" 2 | 3 | using namespace DJI::onboardSDK; 4 | 5 | char DJI::onboardSDK::buffer[DJI::onboardSDK::bufsize]; 6 | 7 | void HardDriver::displayLog(const char *buf) 8 | { 9 | if (buf) 10 | printf("%s", buf); 11 | else 12 | printf("%s", DJI::onboardSDK::buffer); 13 | } 14 | 15 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity_strategy/src/sdk_lib/DJI_VirtualRC.cpp: -------------------------------------------------------------------------------- 1 | #include "DJI_VirtualRC.h" 2 | 3 | using namespace DJI::onboardSDK; 4 | 5 | DJI::onboardSDK::VirtualRC::VirtualRC(CoreAPI *ControlAPI) 6 | { 7 | api = ControlAPI; 8 | resetData(); 9 | } 10 | 11 | void VirtualRC::setControl(bool enable, VirtualRC::CutOff cutoffType) 12 | { 13 | VirtualRCSetting setting; 14 | setting.cutoff = cutoffType; 15 | setting.enable = enable ? 1 : 0; 16 | api->send(0, encrypt, SET_VIRTUALRC, CODE_VIRTUALRC_SETTINGS, &setting, sizeof(setting)); 17 | } 18 | 19 | void VirtualRC::sendData(VirtualRCData Data) 20 | { 21 | data = Data; 22 | sendData(); 23 | } 24 | 25 | void VirtualRC::sendData() 26 | { 27 | api->send(0, encrypt, SET_VIRTUALRC, CODE_VIRTUALRC_DATA, &data, sizeof(data)); 28 | } 29 | 30 | void VirtualRC::resetData() 31 | { 32 | data.roll = 1024; 33 | data.pitch = 1024; 34 | data.throttle = 1024; 35 | data.yaw = 1024; 36 | data.gear = 1024; 37 | data.reserved = 1024; 38 | data.mode = 1024; 39 | data.Channel_07 = 1024; 40 | data.Channel_08 = 1024; 41 | data.Channel_09 = 1024; 42 | data.Channel_10 = 1024; 43 | data.Channel_11 = 1024; 44 | data.Channel_12 = 1024; 45 | data.Channel_13 = 1024; 46 | data.Channel_14 = 1024; 47 | data.Channel_15 = 1024; 48 | } 49 | 50 | void VirtualRC::sendSafeModeData() 51 | { 52 | resetData(); 53 | sendData(); 54 | } 55 | 56 | RadioData VirtualRC::getRCData() const { return api->getBroadcastData().rc; } 57 | 58 | CoreAPI *VirtualRC::getApi() const { return api; } 59 | void VirtualRC::setApi(CoreAPI *value) { api = value; } 60 | 61 | VirtualRCData VirtualRC::getVRCData() const { return data; } 62 | void VirtualRC::setVRCData(const VirtualRCData &value) { data = value; } 63 | 64 | bool VirtualRC::isVirtualRC() const 65 | { 66 | return api->getBroadcastData().ctrlInfo.vrcStatus == 0 ? false : true; 67 | } 68 | 69 | RadioData VirtualRC::toRadioData(VirtualRCData &vData) 70 | { 71 | RadioData rd; 72 | rd.gear = (vData.gear == 1324) ? -454 : -10000; 73 | rd.mode = (1024 - vData.mode ) * 10000 / 660; 74 | rd.pitch = (vData.pitch - 1024) * (10000) / 660; 75 | rd.roll = (vData.roll - 1024) * (10000) / 660; 76 | rd.yaw = (vData.yaw - 1024) * (10000) / 660; 77 | rd.throttle = (vData.throttle - 1024) * (10000) / 660; 78 | return rd; 79 | } 80 | 81 | VirtualRCData VirtualRC::toVirtualRCData(RadioData &rData) 82 | { 83 | VirtualRCData vd; 84 | vd.yaw = rData.yaw * 660 / 10000 + 1024; 85 | vd.throttle = rData.throttle * 660 / 10000 + 1024; 86 | vd.pitch = rData.pitch * 660 / 10000 + 1024; 87 | vd.roll = rData.roll * 660 / 10000 + 1024; 88 | vd.gear = (rData.gear == -4545) ? 1324 : 1684; 89 | vd.reserved = 1024; 90 | vd.mode = rData.mode * 660 / (-10000) + 1024; 91 | vd.Channel_07 = 1024; 92 | vd.Channel_08 = 1024; 93 | vd.Channel_09 = 1024; 94 | vd.Channel_10 = 1024; 95 | vd.Channel_11 = 1024; 96 | vd.Channel_12 = 1024; 97 | vd.Channel_13 = 1024; 98 | vd.Channel_14 = 1024; 99 | vd.Channel_15 = 1024; 100 | return vd; 101 | } 102 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/discontinuity_strategy/src/sdk_lib/DJI_utility.cpp: -------------------------------------------------------------------------------- 1 | #include "DJI_utility.h" 2 | 3 | #ifdef WIN32 4 | 5 | DJI_lock::DJI_lock() 6 | { 7 | InitializeCriticalSection( &m_critical_section ); 8 | } 9 | 10 | DJI_lock::~DJI_lock() 11 | { 12 | } 13 | 14 | void DJI_lock::enter() 15 | { 16 | EnterCriticalSection( &m_critical_section ); 17 | } 18 | 19 | void DJI_lock::leave() 20 | { 21 | LeaveCriticalSection( &m_critical_section ); 22 | } 23 | 24 | void sleep( int microsecond ) 25 | { 26 | Sleep( ( microsecond + 999 ) / 1000 ); 27 | } 28 | 29 | 30 | DJI_event::DJI_event() 31 | { 32 | SECURITY_ATTRIBUTES sa; 33 | sa.nLength = sizeof(sa); 34 | sa.lpSecurityDescriptor = NULL; 35 | sa.bInheritHandle = TRUE; 36 | CreatePipe( &m_pipe_read, &m_pipe_write, &sa, 0 ); 37 | } 38 | 39 | DJI_event::~DJI_event() 40 | { 41 | CloseHandle( m_pipe_read ); 42 | CloseHandle( m_pipe_write ); 43 | } 44 | 45 | int DJI_event::set_DJI_event() 46 | { 47 | char buffer[1] = {0}; 48 | int count = 0; 49 | int ret = WriteFile( m_pipe_write, (LPWORD)buffer, 1, (LPDWORD)&count, NULL ); 50 | return ret; 51 | } 52 | 53 | int DJI_event::wait_DJI_event() 54 | { 55 | char buffer[1] = {0}; 56 | int count = 0; 57 | int ret = ReadFile( m_pipe_read, (LPWORD)buffer, 1, (LPDWORD)&count, NULL ); 58 | return ret; 59 | } 60 | 61 | #else 62 | 63 | DJI_lock::DJI_lock() 64 | { 65 | pthread_mutex_init( &m_lock, NULL ); 66 | } 67 | 68 | DJI_lock::~DJI_lock() 69 | { 70 | } 71 | 72 | void DJI_lock::enter() 73 | { 74 | pthread_mutex_lock( &m_lock ); 75 | } 76 | 77 | void DJI_lock::leave() 78 | { 79 | pthread_mutex_unlock( &m_lock ); 80 | } 81 | 82 | DJI_event::DJI_event() 83 | { 84 | sem_init( &m_sem, 0, 0 ); 85 | } 86 | 87 | DJI_event::~DJI_event() 88 | { 89 | } 90 | 91 | int DJI_event::set_DJI_event() 92 | { 93 | int ret = sem_post( &m_sem ); 94 | return ret; 95 | } 96 | 97 | int DJI_event::wait_DJI_event() 98 | { 99 | int ret = sem_wait( &m_sem ); 100 | return ret; 101 | } 102 | 103 | #endif 104 | -------------------------------------------------------------------------------- /demo/obstacle_bypass/readme.md: -------------------------------------------------------------------------------- 1 | # Obstacle Bypass 2 | 3 | This demo project performs a fully autonomous flight, with online obstacle avoidance algorithms, using image output from **Guidance SDK** to detect obstacles and implement avoidance strategy via control input to **Onboard SDK**. This project is build on **ROS**. It contains three different strategies, each working independently. 4 | 5 | ## How To Run 6 | 7 | 1. Install and configure ROS. 8 | 2. Put the directory of the desired strategy in catkin workspace. 9 | 3. Build the project: `catkin_make` 10 | 4. Execute project: `sudo ./devel/lib/dji_sdk/dji_sdk_node` 11 | 5. Press Enter to end autonomous flight 12 | 13 | ## Output Data 14 | 15 | Images from the flight are displayed in real time with observed keypoints in blue, detected obstacles in red, and corresponding suggested maneuvers in green. 16 | -------------------------------------------------------------------------------- /demo/sdk_tracking_camshift/camshift.2010.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "camshift.2010", "camshift\camshift.2010.vcxproj", "{53273C6A-3D23-4424-830D-E19A813698C9}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Debug|x64 = Debug|x64 10 | Release|Win32 = Release|Win32 11 | Release|x64 = Release|x64 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {53273C6A-3D23-4424-830D-E19A813698C9}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {53273C6A-3D23-4424-830D-E19A813698C9}.Debug|Win32.Build.0 = Debug|Win32 16 | {53273C6A-3D23-4424-830D-E19A813698C9}.Debug|x64.ActiveCfg = Debug|x64 17 | {53273C6A-3D23-4424-830D-E19A813698C9}.Debug|x64.Build.0 = Debug|x64 18 | {53273C6A-3D23-4424-830D-E19A813698C9}.Release|Win32.ActiveCfg = Release|Win32 19 | {53273C6A-3D23-4424-830D-E19A813698C9}.Release|Win32.Build.0 = Release|Win32 20 | {53273C6A-3D23-4424-830D-E19A813698C9}.Release|x64.ActiveCfg = Release|x64 21 | {53273C6A-3D23-4424-830D-E19A813698C9}.Release|x64.Build.0 = Release|x64 22 | EndGlobalSection 23 | GlobalSection(SolutionProperties) = preSolution 24 | HideSolutionNode = FALSE 25 | EndGlobalSection 26 | EndGlobal 27 | -------------------------------------------------------------------------------- /demo/sdk_tracking_camshift/camshift.2010.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dji-sdk/Guidance-SDK/9f666b4338ea37f7ce62dd1292d531918b37c18c/demo/sdk_tracking_camshift/camshift.2010.suo -------------------------------------------------------------------------------- /demo/sdk_tracking_camshift/camshift.2013.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.21005.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "camshift", "camshift\camshift.2013.vcxproj", "{53273C6A-3D23-4424-830D-E19A813698C9}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Debug|x64 = Debug|x64 12 | Release|Win32 = Release|Win32 13 | Release|x64 = Release|x64 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {53273C6A-3D23-4424-830D-E19A813698C9}.Debug|Win32.ActiveCfg = Debug|Win32 17 | {53273C6A-3D23-4424-830D-E19A813698C9}.Debug|Win32.Build.0 = Debug|Win32 18 | {53273C6A-3D23-4424-830D-E19A813698C9}.Debug|x64.ActiveCfg = Debug|x64 19 | {53273C6A-3D23-4424-830D-E19A813698C9}.Debug|x64.Build.0 = Debug|x64 20 | {53273C6A-3D23-4424-830D-E19A813698C9}.Release|Win32.ActiveCfg = Release|Win32 21 | {53273C6A-3D23-4424-830D-E19A813698C9}.Release|Win32.Build.0 = Release|Win32 22 | {53273C6A-3D23-4424-830D-E19A813698C9}.Release|x64.ActiveCfg = Release|x64 23 | {53273C6A-3D23-4424-830D-E19A813698C9}.Release|x64.Build.0 = Release|x64 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /demo/sdk_tracking_camshift/camshift.2013.v12.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dji-sdk/Guidance-SDK/9f666b4338ea37f7ce62dd1292d531918b37c18c/demo/sdk_tracking_camshift/camshift.2013.v12.suo -------------------------------------------------------------------------------- /demo/sdk_tracking_camshift/camshift/DJI_utility.cpp: -------------------------------------------------------------------------------- 1 | #include "DJI_utility.h" 2 | 3 | #ifdef WIN32 4 | 5 | DJI_lock::DJI_lock() 6 | { 7 | InitializeCriticalSection( &m_critical_section ); 8 | } 9 | 10 | DJI_lock::~DJI_lock() 11 | { 12 | } 13 | 14 | void DJI_lock::enter() 15 | { 16 | EnterCriticalSection( &m_critical_section ); 17 | } 18 | 19 | void DJI_lock::leave() 20 | { 21 | LeaveCriticalSection( &m_critical_section ); 22 | } 23 | 24 | void sleep( int microsecond ) 25 | { 26 | Sleep( ( microsecond + 999 ) / 1000 ); 27 | } 28 | DJI_event::DJI_event() 29 | { 30 | SECURITY_ATTRIBUTES sa; 31 | sa.nLength = sizeof(sa); 32 | sa.lpSecurityDescriptor = NULL; 33 | sa.bInheritHandle = TRUE; 34 | CreatePipe( &m_pipe_read, &m_pipe_write, &sa, 0 ); 35 | } 36 | 37 | DJI_event::~DJI_event() 38 | { 39 | CloseHandle( m_pipe_read ); 40 | CloseHandle( m_pipe_write ); 41 | } 42 | 43 | int DJI_event::set_event() 44 | { 45 | char buffer[1] = {0}; 46 | int count = 0; 47 | int ret = WriteFile( m_pipe_write, (LPWORD)buffer, 1, (LPDWORD)&count, NULL ); 48 | return ret; 49 | } 50 | 51 | int DJI_event::wait_event() 52 | { 53 | char buffer[1] = {0}; 54 | int count = 0; 55 | int ret = ReadFile( m_pipe_read, (LPWORD)buffer, 1, (LPDWORD)&count, NULL ); 56 | return ret; 57 | } 58 | 59 | #else 60 | 61 | DJI_lock::DJI_lock() 62 | { 63 | pthread_mutex_init( &m_lock, NULL ); 64 | } 65 | 66 | DJI_lock::~DJI_lock() 67 | { 68 | } 69 | 70 | void DJI_lock::enter() 71 | { 72 | pthread_mutex_lock( &m_lock ); 73 | } 74 | 75 | void DJI_lock::leave() 76 | { 77 | pthread_mutex_unlock( &m_lock ); 78 | } 79 | 80 | DJI_event::DJI_event() 81 | { 82 | sem_init( &m_sem, 0, 0 ); 83 | } 84 | 85 | DJI_event::~DJI_event() 86 | { 87 | } 88 | 89 | int DJI_event::set_event() 90 | { 91 | int ret = sem_post( &m_sem ); 92 | return ret; 93 | } 94 | 95 | int DJI_event::wait_event() 96 | { 97 | int ret = sem_wait( &m_sem ); 98 | return ret; 99 | } 100 | 101 | #endif 102 | -------------------------------------------------------------------------------- /demo/sdk_tracking_camshift/camshift/DJI_utility.h: -------------------------------------------------------------------------------- 1 | #ifndef __DJI_UTILITY_H__ 2 | #define __DJI_UTILITY_H__ 3 | #include 4 | 5 | #ifdef WIN32 6 | 7 | #include 8 | #include 9 | 10 | class DJI_lock 11 | { 12 | public: 13 | DJI_lock(); 14 | ~DJI_lock(); 15 | void enter(); 16 | void leave(); 17 | private: 18 | CRITICAL_SECTION m_critical_section; 19 | }; 20 | 21 | class DJI_event 22 | { 23 | public: 24 | DJI_event(); 25 | ~DJI_event(); 26 | int set_event(); 27 | int wait_event(); 28 | private: 29 | HANDLE m_pipe_read; 30 | HANDLE m_pipe_write; 31 | }; 32 | 33 | #else 34 | 35 | #include 36 | #include 37 | 38 | class DJI_lock 39 | { 40 | public: 41 | DJI_lock(); 42 | ~DJI_lock(); 43 | void enter(); 44 | void leave(); 45 | private: 46 | pthread_mutex_t m_lock; 47 | }; 48 | 49 | class DJI_event 50 | { 51 | public: 52 | DJI_event(); 53 | ~DJI_event(); 54 | int set_event(); 55 | int wait_event(); 56 | private: 57 | sem_t m_sem; 58 | }; 59 | 60 | #endif 61 | 62 | void sleep( int microsecond ); 63 | 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /demo/sdk_tracking_camshift/camshift/Makefile: -------------------------------------------------------------------------------- 1 | CXX = g++ 2 | TARGET = camshiftDemo 3 | OBJECTS = camshiftDepth.o DJI_utility.o 4 | CFLAGS = -g -Wall -I../include `pkg-config --cflags opencv` 5 | LDFLAGS = -Wl,-rpath,./ -lpthread -lrt -L./ -L/usr/local/lib/ -lDJI_guidance -lusb-1.0 `pkg-config --libs opencv` 6 | 7 | $(TARGET) : $(OBJECTS) 8 | $(CXX) -o $(TARGET) $(OBJECTS) $(LDFLAGS) 9 | camshiftDepth.o : camshiftDepth.cpp DJI_utility.h 10 | $(CXX) $(CFLAGS) -c camshiftDepth.cpp DJI_utility.h 11 | DJI_utility.o : DJI_utility.cpp DJI_utility.h 12 | $(CXX) $(CFLAGS) -c DJI_utility.cpp DJI_utility.h 13 | clean: 14 | rm -rf *.o *.gch *.avi $(TARGET) 15 | -------------------------------------------------------------------------------- /demo/sdk_tracking_camshift/camshift/camshift.2010.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | 23 | 24 | Source Files 25 | 26 | 27 | Source Files 28 | 29 | 30 | -------------------------------------------------------------------------------- /demo/sdk_tracking_camshift/camshift/camshift.2010.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /demo/sdk_tracking_camshift/camshift/camshift.2013.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | 26 | 27 | Source Files 28 | 29 | 30 | Source Files 31 | 32 | 33 | -------------------------------------------------------------------------------- /demo/sdk_tracking_camshift/camshift/camshift.2013.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /demo/sdk_tracking_camshift/camshift/log.txt: -------------------------------------------------------------------------------- 1 | 2 | 2015-07-07-17-07-57 enter TranslateFunc 3 | 2015-07-07-17-07-57 start to read frames! -------------------------------------------------------------------------------- /demo/sdk_tracking_camshift/readme.txt: -------------------------------------------------------------------------------- 1 | This is the package of depth-based tracking with camshift algorithm. It uses one grayscale image and one corresponding depth image to track an object. 2 | 3 | This package has been tested on Windows 7, 2010 and 2013. 4 | 5 | BUILD ========================= 6 | - Modified the path and lib versions for OpenCV in the property sheets use_opencv_debug.props and use_opencv_release.props. 7 | - Open the solution file camshift.2013.sln or camshift.2010.sln, and build. 8 | 9 | RUN =========================== 10 | - Connect computer with Guidance. 11 | - Run the program with mouse-click: 12 | -- Run the binary file without parameters (e.g. camshift.2010.exe). 13 | -- Select rectangle surrounding the interested object on the tracking window with mouse. 14 | -------------------------------------------------------------------------------- /demo/sdk_tracking_camshift/use_Guidance_vs2010_x64.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | $(SolutionDir)..\..\include;%(AdditionalIncludeDirectories); 9 | /DWIN32 %(AdditionalOptions) 10 | 11 | 12 | $(SolutionDir)..\..\lib\2010\x64;%(AdditionalLibraryDirectories); 13 | DJI_guidance.lib;%(AdditionalDependencies) 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /demo/sdk_tracking_camshift/use_Guidance_vs2010_x86.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | $(SolutionDir)..\..\include;;%(AdditionalIncludeDirectories); 9 | /DWIN32 %(AdditionalOptions) 10 | 11 | 12 | $(SolutionDir)..\..\lib\2010\x86;%(AdditionalLibraryDirectories); 13 | DJI_guidance.lib;%(AdditionalDependencies) 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /demo/sdk_tracking_camshift/use_Guidance_vs2013_x64.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | $(SolutionDir)..\..\include;%(AdditionalIncludeDirectories); 9 | /DWIN32 %(AdditionalOptions) 10 | 11 | 12 | $(SolutionDir)..\..\lib\2013\x64;%(AdditionalLibraryDirectories); 13 | DJI_guidance.lib;%(AdditionalDependencies) 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /demo/sdk_tracking_camshift/use_Guidance_vs2013_x86.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | $(SolutionDir)..\..\include;%(AdditionalIncludeDirectories); 9 | /DWIN32 %(AdditionalOptions) 10 | 11 | 12 | $(SolutionDir)..\..\lib\2013\x86;%(AdditionalLibraryDirectories); 13 | DJI_guidance.lib;%(AdditionalDependencies) 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /demo/sdk_tracking_camshift/use_opencv_debug_vs2010_x64.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | $(SolutionDir)bin\ 7 | <_PropertySheetDisplayName>use_opencv_debug_x64 8 | 9 | 10 | 11 | $(OPENCVROOT)\build\include\;%(AdditionalIncludeDirectories); 12 | 13 | 14 | $(OPENCVROOT)\build\x64\vc10\lib;%(AdditionalLibraryDirectories); 15 | opencv_calib3d2411d.lib;opencv_contrib2411d.lib;opencv_core2411d.lib;opencv_features2d2411d.lib;opencv_flann2411d.lib;opencv_gpu2411d.lib;opencv_highgui2411d.lib;opencv_imgproc2411d.lib;opencv_legacy2411d.lib;;opencv_ml2411d.lib;opencv_nonfree2411d.lib;opencv_objdetect2411d.lib;opencv_ocl2411d.lib;opencv_photo2411d.lib;opencv_stitching2411d.lib;opencv_superres2411d.lib;opencv_ts2411d.lib;opencv_video2411d.lib;opencv_videostab2411d.lib;%(AdditionalDependencies); 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /demo/sdk_tracking_camshift/use_opencv_debug_vs2010_x86.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | $(SolutionDir)bin\ 7 | <_PropertySheetDisplayName>use_opencv_debug_x86 8 | 9 | 10 | 11 | $(OPENCVROOT)\build\include\;%(AdditionalIncludeDirectories); 12 | 13 | 14 | $(OPENCVROOT)\build\x86\vc10\lib;%(AdditionalLibraryDirectories); 15 | opencv_calib3d2411d.lib;opencv_contrib2411d.lib;opencv_core2411d.lib;opencv_features2d2411d.lib;opencv_flann2411d.lib;opencv_gpu2411d.lib;opencv_highgui2411d.lib;opencv_imgproc2411d.lib;opencv_legacy2411d.lib;;opencv_ml2411d.lib;opencv_nonfree2411d.lib;opencv_objdetect2411d.lib;opencv_ocl2411d.lib;opencv_photo2411d.lib;opencv_stitching2411d.lib;opencv_superres2411d.lib;opencv_ts2411d.lib;opencv_video2411d.lib;opencv_videostab2411d.lib;%(AdditionalDependencies); 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /demo/sdk_tracking_camshift/use_opencv_release_vs2010_x64.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | $(SolutionDir)bin\ 7 | <_PropertySheetDisplayName>use_opencv_release_x64 8 | 9 | 10 | 11 | $(OPENCVROOT)\build\include\;%(AdditionalIncludeDirectories); 12 | 13 | 14 | $(OPENCVROOT)\build\x64\vc10\lib;%(AdditionalLibraryDirectories); 15 | opencv_calib3d2411.lib;opencv_contrib2411.lib;opencv_core2411.lib;opencv_features2d2411.lib;opencv_flann2411.lib;opencv_gpu2411.lib;opencv_highgui2411.lib;opencv_imgproc2411.lib;opencv_legacy2411.lib;;opencv_ml2411.lib;opencv_nonfree2411.lib;opencv_objdetect2411.lib;opencv_ocl2411.lib;opencv_photo2411.lib;opencv_stitching2411.lib;opencv_superres2411.lib;opencv_ts2411.lib;opencv_video2411.lib;opencv_videostab2411.lib;%(AdditionalDependencies); 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /demo/sdk_tracking_camshift/use_opencv_release_vs2010_x86.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | $(SolutionDir)bin\ 7 | <_PropertySheetDisplayName>use_opencv_release_x86 8 | 9 | 10 | 11 | $(OPENCVROOT)\build\include\;%(AdditionalIncludeDirectories); 12 | 13 | 14 | $(OPENCVROOT)\build\x86\vc10\lib;%(AdditionalLibraryDirectories); 15 | opencv_calib3d2411.lib;opencv_contrib2411.lib;opencv_core2411.lib;opencv_features2d2411.lib;opencv_flann2411.lib;opencv_gpu2411.lib;opencv_highgui2411.lib;opencv_imgproc2411.lib;opencv_legacy2411.lib;;opencv_ml2411.lib;opencv_nonfree2411.lib;opencv_objdetect2411.lib;opencv_ocl2411.lib;opencv_photo2411.lib;opencv_stitching2411.lib;opencv_superres2411.lib;opencv_ts2411.lib;opencv_video2411.lib;opencv_videostab2411.lib;%(AdditionalDependencies); 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /demo/sdk_tracking_camshift/use_opencv_release_vs2013_x64.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | $(SolutionDir)bin\ 7 | 8 | 9 | 10 | $(OPENCVROOT)\build\include\;%(AdditionalIncludeDirectories); 11 | 12 | 13 | $(OPENCVROOT)\build\x64\vc12\lib;%(AdditionalLibraryDirectories); 14 | opencv_calib3d2411.lib;opencv_contrib2411.lib;opencv_core2411.lib;opencv_features2d2411.lib;opencv_flann2411.lib;opencv_gpu2411.lib;opencv_highgui2411.lib;opencv_imgproc2411.lib;opencv_legacy2411.lib;;opencv_ml2411.lib;opencv_nonfree2411.lib;opencv_objdetect2411.lib;opencv_ocl2411.lib;opencv_photo2411.lib;opencv_stitching2411.lib;opencv_superres2411.lib;opencv_ts2411.lib;opencv_video2411.lib;opencv_videostab2411.lib;%(AdditionalDependencies); 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /demo/sdk_tracking_camshift/use_opencv_release_vs2013_x86.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | $(SolutionDir)bin\ 7 | 8 | 9 | 10 | $(OPENCVROOT)\build\include\;%(AdditionalIncludeDirectories); 11 | 12 | 13 | $(OPENCVROOT)\build\x86\vc12\lib;%(AdditionalLibraryDirectories); 14 | opencv_calib3d2411.lib;opencv_contrib2411.lib;opencv_core2411.lib;opencv_features2d2411.lib;opencv_flann2411.lib;opencv_gpu2411.lib;opencv_highgui2411.lib;opencv_imgproc2411.lib;opencv_legacy2411.lib;;opencv_ml2411.lib;opencv_nonfree2411.lib;opencv_objdetect2411.lib;opencv_ocl2411.lib;opencv_photo2411.lib;opencv_stitching2411.lib;opencv_superres2411.lib;opencv_ts2411.lib;opencv_video2411.lib;opencv_videostab2411.lib;%(AdditionalDependencies); 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /doc/51-guidance.rules: -------------------------------------------------------------------------------- 1 | SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="d009", MODE="0666" 2 | -------------------------------------------------------------------------------- /examples/uart_example/Makefile: -------------------------------------------------------------------------------- 1 | TARGET = uart_example 2 | 3 | OBJECTS = main.o crc16.o crc32.o protocal_uart_sdk.o serial.o 4 | 5 | CFLAGS = -g -Wall -I/usr/local/include -I./linux 6 | 7 | LDFLAGS = -Wl,-rpath,./ -lpthread -lrt 8 | 9 | CXX = g++ 10 | 11 | $(TARGET) : $(OBJECTS) 12 | $(CXX) -o $(TARGET) $(OBJECTS) $(LDFLAGS) 13 | 14 | main.o : main.cpp 15 | $(CXX) $(CFLAGS) -c main.cpp 16 | 17 | crc16.o : crc16.cpp crc16.h 18 | $(CXX) $(CFLAGS) -c crc16.cpp crc16.h 19 | 20 | crc32.o : crc32.cpp crc32.h 21 | $(CXX) $(CFLAGS) -c crc32.cpp crc32.h 22 | 23 | protocal_uart_sdk.o : protocal_uart_sdk.cpp protocal_uart_sdk.h 24 | $(CXX) $(CFLAGS) -c protocal_uart_sdk.cpp protocal_uart_sdk.h 25 | 26 | serial.o : linux/serial.cpp linux/serial.h 27 | $(CXX) $(CFLAGS) -c linux/serial.cpp linux/serial.h 28 | 29 | clean: 30 | rm *.o *.gch $(TARGET) 31 | 32 | -------------------------------------------------------------------------------- /examples/uart_example/crc16.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dji-sdk/Guidance-SDK/9f666b4338ea37f7ce62dd1292d531918b37c18c/examples/uart_example/crc16.cpp -------------------------------------------------------------------------------- /examples/uart_example/crc16.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** global function 3 | */ 4 | extern unsigned short Get_CRC16_Check_Sum(unsigned char *pchMessage,unsigned int dwLength,unsigned short wCRC); 5 | extern unsigned int Verify_CRC16_Check_Sum(unsigned char* pchMessage, unsigned int dwLength); 6 | extern void Append_CRC16_Check_Sum(unsigned char* pchMessage, unsigned int dwLength); 7 | 8 | /* 9 | ** global const variable 10 | */ 11 | extern const unsigned short wCRC_Table[256]; 12 | extern const unsigned short CRC_INIT; -------------------------------------------------------------------------------- /examples/uart_example/crc32.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "crc32.h" 5 | 6 | #define POLYNOMIAL 0x04c11db7L // Standard CRC-32 ppolynomial 7 | #define BUFFER_LEN 4096L // Length of buffer 8 | 9 | static word32 crc_table[256]; // Table of 8-bit remainders 10 | 11 | class crc32 12 | { 13 | public: 14 | crc32(); 15 | }; 16 | 17 | crc32::crc32() 18 | { 19 | gen_crc_table(); 20 | } 21 | 22 | crc32 g_crc32; 23 | 24 | void gen_crc_table(void) 25 | { 26 | register word16 i, j; 27 | register word32 crc_accum; 28 | 29 | for (i=0; i<256; i++) 30 | { 31 | crc_accum = ( (word32) i << 24 ); 32 | for ( j = 0; j < 8; j++ ) 33 | { 34 | if ( crc_accum & 0x80000000L ) 35 | crc_accum = (crc_accum << 1) ^ POLYNOMIAL; 36 | else 37 | crc_accum = (crc_accum << 1); 38 | } 39 | crc_table[i] = crc_accum; 40 | } 41 | } 42 | 43 | word32 update_crc(word32 crc_accum, byte *data_blk_ptr, word32 data_blk_size) 44 | { 45 | if ( data_blk_size < sizeof(word32) ) 46 | { 47 | return 0; 48 | } 49 | 50 | register word32 i, j; 51 | 52 | for (j=0; j> 24) ^ *data_blk_ptr++) & 0xFF; 55 | crc_accum = (crc_accum << 8) ^ crc_table[i]; 56 | } 57 | crc_accum = ~crc_accum; 58 | memcpy( data_blk_ptr + data_blk_size - sizeof(word32), &crc_accum, sizeof(word32) ); 59 | 60 | return crc_accum; 61 | } 62 | -------------------------------------------------------------------------------- /examples/uart_example/crc32.h: -------------------------------------------------------------------------------- 1 | 2 | //----- Type defines ---------------------------------------------------------- 3 | typedef unsigned char byte; // Byte is a char 4 | typedef unsigned short int word16; // 16-bit word is a short int 5 | typedef unsigned int word32; // 32-bit word is an int 6 | 7 | //----- Prototypes ------------------------------------------------------------ 8 | void gen_crc_table(void); 9 | word32 update_crc(word32 crc_accum, byte *data_blk_ptr, word32 data_blk_size); 10 | -------------------------------------------------------------------------------- /examples/uart_example/linux/serial.h: -------------------------------------------------------------------------------- 1 | #ifndef SERIAL_H 2 | #define SERIAL_H 3 | 4 | int connect_serial(char port, int baudrate = 115200); 5 | 6 | int read_serial( unsigned char* data, int max_size, int timeout ); 7 | 8 | void disconnect_serial(); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /examples/uart_example/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #ifdef WIN32 4 | #include "windows/serial.h" 5 | #else 6 | #include "linux/serial.h" 7 | #endif 8 | #include "crc32.h" 9 | #include "protocal_uart_sdk.h" 10 | #include "../../include/DJI_guidance.h" 11 | 12 | #define UART 1 13 | #define CAMERA_PAIR_NUM 5 14 | #ifdef WIN32 15 | #define UART_PORT "COM5" 16 | #else 17 | #define UART_PORT 0 18 | #endif 19 | 20 | int main() 21 | { 22 | if ( connect_serial( UART_PORT ) < 0 ) 23 | { 24 | printf( "connect serial error\n" ); 25 | return 0; 26 | } 27 | 28 | for ( int i = 0; i < 1000; ++i ) 29 | { 30 | unsigned char data[1000] = {0}; 31 | int max_size = (int)sizeof(data); 32 | int timeout = 1000; 33 | int n = read_serial( data, max_size, timeout); 34 | if( n <= 0 ) 35 | { 36 | continue; 37 | } 38 | 39 | push( data, sizeof(data) ); 40 | for ( ; ; ) 41 | { 42 | unsigned int len = 0; 43 | int has_packet = pop( data, len ); 44 | if ( has_packet ) 45 | { 46 | if ( len ) 47 | { 48 | unsigned char cmd_id = data[1]; 49 | if ( e_imu == cmd_id ) 50 | { 51 | imu imu_data; 52 | memcpy( &imu_data, data + 2, sizeof(imu_data) ); 53 | printf( "imu:%f %f %f,%f %f %f %f\n", imu_data.acc_x, imu_data.acc_y, imu_data.acc_z, 54 | imu_data.q[0], imu_data.q[1], imu_data.q[2], imu_data.q[3] ); 55 | printf( "frame index:%d,stamp:%d\n", imu_data.frame_index, imu_data.time_stamp ); 56 | printf( "\n" ); 57 | } 58 | if ( e_ultrasonic == cmd_id ) 59 | { 60 | ultrasonic_data ultrasonic; 61 | memcpy( &ultrasonic, data + 2, sizeof(ultrasonic) ); 62 | for ( int d = 0; d < CAMERA_PAIR_NUM; ++d ) 63 | { 64 | printf( "distance:%f,reliability:%d\n", ultrasonic.ultrasonic[d] * 0.001f, (int)ultrasonic.reliability[d] ); 65 | } 66 | printf( "frame index:%d,stamp:%d\n", ultrasonic.frame_index, ultrasonic.time_stamp ); 67 | printf( "\n" ); 68 | } 69 | if ( e_velocity == cmd_id ) 70 | { 71 | velocity vo; 72 | soc2pc_vo_can_output output; 73 | memcpy( &output, data + 2, sizeof(vo) ); 74 | vo.vx = output.m_vo_output.vx; 75 | vo.vy = output.m_vo_output.vy; 76 | vo.vz = output.m_vo_output.vz; 77 | printf( "vx:%f vy:%f vz:%f\n", 0.001f * vo.vx, 0.001f * vo.vy, 0.001f * vo.vz ); 78 | printf( "frame index:%d,stamp:%d\n", vo.frame_index, vo.time_stamp ); 79 | printf( "\n" ); 80 | } 81 | if ( e_obstacle_distance == cmd_id ) 82 | { 83 | obstacle_distance oa; 84 | memcpy( &oa, data + 2, sizeof(oa) ); 85 | printf( "obstacle distance:" ); 86 | for ( int direction = 0; direction < CAMERA_PAIR_NUM; ++direction ) 87 | { 88 | printf( " %f ", 0.01f * oa.distance[direction] ); 89 | } 90 | printf( "\n" ); 91 | printf( "frame index:%d,stamp:%d\n", oa.frame_index, oa.time_stamp ); 92 | printf( "\n" ); 93 | } 94 | } 95 | else 96 | { 97 | printf( "err\n" ); 98 | } 99 | } 100 | else 101 | { 102 | break; 103 | } 104 | } 105 | } 106 | 107 | disconnect_serial(); 108 | 109 | return 0; 110 | } 111 | -------------------------------------------------------------------------------- /examples/uart_example/protocal_uart_sdk.cpp: -------------------------------------------------------------------------------- 1 | #include "protocal_uart_sdk.h" 2 | #include 3 | #include "crc32.h" 4 | #include "crc16.h" 5 | #include 6 | #include 7 | 8 | #define LOG_TAG "protocal" 9 | 10 | void format_protocal_sdk_uart( unsigned char *src_buf, unsigned int original_len, 11 | unsigned char *dst_buf, unsigned int &new_len, 12 | unsigned short seq_num, unsigned char is_ack, 13 | unsigned char enc_type 14 | ) 15 | { 16 | protocal_sdk_uart_header *header = (protocal_sdk_uart_header*)dst_buf; 17 | header->m_header = 0xaa; 18 | new_len = original_len + sizeof(protocal_sdk_uart_header) + 2 + 4; 19 | header->m_length = new_len; 20 | header->m_version = 0; 21 | header->m_session_id = 0; 22 | header->m_A = is_ack; 23 | header->m_R = 0; 24 | header->m_padding = 0; 25 | header->m_enc_type = enc_type; 26 | header->m_seq_num = seq_num; 27 | Append_CRC16_Check_Sum( (unsigned char *)header, sizeof(protocal_sdk_uart_header) ); 28 | memcpy( dst_buf + sizeof(protocal_sdk_uart_header), src_buf, original_len ); 29 | 30 | word32 crc32; // 32-bit CRC value 31 | crc32 = update_crc( -1, (byte*)dst_buf, header->m_length ); 32 | printf("CRC = %08X \n", crc32); 33 | } 34 | 35 | bool is_header_valid( protocal_sdk_uart_header *header ) 36 | { 37 | return 0!=Verify_CRC16_Check_Sum( (unsigned char*)header, sizeof(*header) ); 38 | } 39 | 40 | bool is_packet_valid( protocal_sdk_uart_header *header ) 41 | { 42 | char buffer[1024] = {0}; 43 | if ( header->m_length > 1024 ) 44 | { 45 | return false; 46 | } 47 | 48 | memcpy( buffer, header, header->m_length ); 49 | word32 crc32; // 32-bit CRC value 50 | crc32 = update_crc( -1, (byte*)buffer, header->m_length ); 51 | char *p1 = buffer + header->m_length - 2, *p2 = (char*)header + header->m_length - 2; 52 | return ( p1[0] == p2[0] && p1[1] == p2[1] ); 53 | } 54 | 55 | unsigned char s_data[10240] = {0}; 56 | unsigned int s_len = 0; 57 | unsigned int s_cur = 0; 58 | 59 | int push( unsigned char *data, unsigned int len ) 60 | { 61 | memcpy( s_data + s_len, data, len ); 62 | s_len += len; 63 | 64 | return 0; 65 | } 66 | 67 | int pop( unsigned char *data, unsigned int &len ) 68 | { 69 | static int pack_num = 0; 70 | 71 | for ( ; s_cur < s_len - sizeof(protocal_sdk_uart_header); ++s_cur ) 72 | { 73 | if ( 0xaa != s_data[s_cur] ) 74 | { 75 | continue; 76 | } 77 | 78 | protocal_sdk_uart_header *header = (protocal_sdk_uart_header*)(s_data + s_cur); 79 | if ( is_header_valid( header ) ) 80 | { 81 | if ( s_cur + header->m_length > s_len ) 82 | { 83 | char buffer[1024] = {0}; 84 | memcpy( buffer, s_data + s_cur, s_len - s_cur ); 85 | memcpy( s_data, buffer, s_len - s_cur ); 86 | s_len = s_len - s_cur; 87 | s_cur = 0; 88 | break; 89 | } 90 | else if( is_packet_valid( header ) ) 91 | { 92 | len = header->m_length - sizeof(protocal_sdk_uart_header) - 4; 93 | memcpy( data, s_data + s_cur + sizeof(protocal_sdk_uart_header), len ); 94 | s_cur = s_cur + header->m_length; 95 | static unsigned short seq_num = 0; 96 | if( seq_num + 1 == header->m_seq_num ) 97 | { 98 | seq_num = header->m_seq_num; 99 | } 100 | else if( 0 != seq_num ) 101 | { 102 | seq_num = header->m_seq_num; 103 | } 104 | pack_num++; 105 | return 1; 106 | } 107 | else 108 | { 109 | printf( "packet err!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" ); 110 | } 111 | } 112 | else 113 | { 114 | printf( "header err!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" ); 115 | } 116 | } 117 | 118 | return 0; 119 | } 120 | -------------------------------------------------------------------------------- /examples/uart_example/protocal_uart_sdk.h: -------------------------------------------------------------------------------- 1 | #ifndef __PROTOCAL_UART_SDK_H__ 2 | #define __PROTOCAL_UART_SDK_H__ 3 | 4 | #pragma pack(1) 5 | 6 | typedef struct _protocal_sdk_uart_header 7 | { 8 | unsigned char m_header; 9 | unsigned short m_version : 6; 10 | unsigned short m_length : 10; 11 | unsigned char m_R : 2; 12 | unsigned char m_A : 1; 13 | unsigned char m_session_id :5; 14 | unsigned char m_enc_type : 3; 15 | unsigned char m_padding : 5; 16 | unsigned char m_reserved[3]; 17 | unsigned short m_seq_num; 18 | unsigned short m_header_checksum; 19 | }protocal_sdk_uart_header; 20 | 21 | #pragma pack() 22 | 23 | typedef struct _VO_OUTPUT 24 | { 25 | short cnt; 26 | 27 | short vx; 28 | short vy; 29 | short vz; 30 | 31 | float x; 32 | float y; 33 | float z; 34 | 35 | float reserved[12]; 36 | 37 | float height; 38 | float uncertainty_height; 39 | 40 | unsigned char reserve[4]; 41 | }VO_OUTPUT; 42 | 43 | #pragma pack() 44 | 45 | class soc2pc_vo_can_output 46 | { 47 | public: 48 | VO_OUTPUT m_vo_output; 49 | unsigned int m_frame_index; 50 | unsigned int m_time_stamp; 51 | unsigned int m_reserved[9]; 52 | }; 53 | 54 | bool is_header_valid( protocal_sdk_uart_header *header ); 55 | 56 | bool is_packet_valid( protocal_sdk_uart_header *header ); 57 | 58 | int pop( unsigned char *data, unsigned int &len ); 59 | 60 | int push( unsigned char *data, unsigned int len ); 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /examples/uart_example/uart_sdk_2010.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "uart_sdk", "uart_sdk_2010.vcxproj", "{1CF791E0-4219-4C78-844C-1A9C4D1476FD}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Debug|x64 = Debug|x64 10 | Release|Win32 = Release|Win32 11 | Release|x64 = Release|x64 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {1CF791E0-4219-4C78-844C-1A9C4D1476FD}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {1CF791E0-4219-4C78-844C-1A9C4D1476FD}.Debug|Win32.Build.0 = Debug|Win32 16 | {1CF791E0-4219-4C78-844C-1A9C4D1476FD}.Debug|x64.ActiveCfg = Debug|x64 17 | {1CF791E0-4219-4C78-844C-1A9C4D1476FD}.Debug|x64.Build.0 = Debug|x64 18 | {1CF791E0-4219-4C78-844C-1A9C4D1476FD}.Release|Win32.ActiveCfg = Release|Win32 19 | {1CF791E0-4219-4C78-844C-1A9C4D1476FD}.Release|Win32.Build.0 = Release|Win32 20 | {1CF791E0-4219-4C78-844C-1A9C4D1476FD}.Release|x64.ActiveCfg = Release|x64 21 | {1CF791E0-4219-4C78-844C-1A9C4D1476FD}.Release|x64.Build.0 = Release|x64 22 | EndGlobalSection 23 | GlobalSection(SolutionProperties) = preSolution 24 | HideSolutionNode = FALSE 25 | EndGlobalSection 26 | EndGlobal 27 | -------------------------------------------------------------------------------- /examples/uart_example/uart_sdk_2010.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | 35 | 36 | Header Files 37 | 38 | 39 | Header Files 40 | 41 | 42 | Header Files 43 | 44 | 45 | Header Files 46 | 47 | 48 | Header Files 49 | 50 | 51 | -------------------------------------------------------------------------------- /examples/uart_example/uart_sdk_2010.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /examples/uart_example/windows/serial.cpp: -------------------------------------------------------------------------------- 1 | #define _CRT_SECURE_NO_WARNINGS 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | using namespace std; 10 | enum 11 | { 12 | Timeout = 1, // [msec] 13 | EachTimeout = 2, // [msec] 14 | bufferSize = 8192,//8K 15 | }; 16 | 17 | HANDLE HCom = INVALID_HANDLE_VALUE; 18 | int ReadableSize = 0; 19 | char ErrorMessage[32] = "no error."; 20 | unsigned char send_buffer[bufferSize]; 21 | unsigned char receive_buffer[bufferSize]; 22 | 23 | int changeBaudrate(long baudrate) 24 | { 25 | DCB dcb; 26 | GetCommState(HCom, &dcb); 27 | dcb.BaudRate = baudrate; 28 | dcb.ByteSize = 8; 29 | dcb.Parity = NOPARITY; 30 | dcb.fParity = FALSE; 31 | dcb.StopBits = ONESTOPBIT; 32 | SetCommState(HCom, &dcb); 33 | return 0; 34 | } 35 | 36 | int connect_serial(const char* device, long baudrate) 37 | {// currently only support baud rate 115200 38 | char adjust_device[16]; 39 | _snprintf(adjust_device, 16, "\\\\.\\%s", device); 40 | HCom = CreateFileA(adjust_device, GENERIC_READ | GENERIC_WRITE, 0, 41 | NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); 42 | 43 | if (HCom == INVALID_HANDLE_VALUE) 44 | { 45 | return -1; 46 | } 47 | return changeBaudrate(baudrate); 48 | } 49 | 50 | 51 | void disconnect_serial(void) 52 | { 53 | if (HCom != INVALID_HANDLE_VALUE) 54 | { 55 | CloseHandle(HCom); 56 | HCom = INVALID_HANDLE_VALUE; 57 | } 58 | } 59 | 60 | int read_serial(unsigned char* data, int max_size, int timeout) 61 | { 62 | if (max_size <= 0) 63 | { 64 | return 0; 65 | } 66 | 67 | if (ReadableSize < max_size) 68 | { 69 | DWORD dwErrors; 70 | COMSTAT ComStat; 71 | ClearCommError(HCom, &dwErrors, &ComStat); 72 | ReadableSize = ComStat.cbInQue; 73 | } 74 | 75 | if (max_size > ReadableSize) 76 | { 77 | COMMTIMEOUTS pcto; 78 | int each_timeout = 2; 79 | 80 | if (timeout == 0) 81 | { 82 | max_size = ReadableSize; 83 | 84 | } 85 | else 86 | { 87 | if (timeout < 0) 88 | { 89 | /* If Timeout is 0, this function wait data infinity */ 90 | timeout = 0; 91 | each_timeout = 0; 92 | } 93 | 94 | /* set Timeout */ 95 | GetCommTimeouts(HCom, &pcto); 96 | pcto.ReadIntervalTimeout = timeout; 97 | pcto.ReadTotalTimeoutMultiplier = each_timeout; 98 | pcto.ReadTotalTimeoutConstant = timeout; 99 | SetCommTimeouts(HCom, &pcto); 100 | } 101 | } 102 | 103 | DWORD n; 104 | ReadFile(HCom, data, (DWORD)max_size, &n, NULL); 105 | 106 | if (n > 0) 107 | { 108 | ReadableSize -= n; 109 | } 110 | 111 | return n; 112 | } 113 | -------------------------------------------------------------------------------- /examples/uart_example/windows/serial.h: -------------------------------------------------------------------------------- 1 | #ifndef SERIAL_H 2 | #define SERIAL_H 3 | 4 | int connect_serial( const char* device, long baudrate = 115200); 5 | 6 | int read_serial( unsigned char* data, int max_size, int timeout ); 7 | 8 | void disconnect_serial(); 9 | 10 | #endif -------------------------------------------------------------------------------- /examples/usb_example/DJI_guidance_example-vs2013.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.21005.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DJI_guidance_example", "DJI_guidance_example\DJI_guidance_example_vs2013.vcxproj", "{53273C6A-3D23-4424-830D-E19A813698C9}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Debug|x64 = Debug|x64 12 | Release|Win32 = Release|Win32 13 | Release|x64 = Release|x64 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {53273C6A-3D23-4424-830D-E19A813698C9}.Debug|Win32.ActiveCfg = Debug|Win32 17 | {53273C6A-3D23-4424-830D-E19A813698C9}.Debug|Win32.Build.0 = Debug|Win32 18 | {53273C6A-3D23-4424-830D-E19A813698C9}.Debug|x64.ActiveCfg = Debug|x64 19 | {53273C6A-3D23-4424-830D-E19A813698C9}.Debug|x64.Build.0 = Debug|x64 20 | {53273C6A-3D23-4424-830D-E19A813698C9}.Release|Win32.ActiveCfg = Release|Win32 21 | {53273C6A-3D23-4424-830D-E19A813698C9}.Release|Win32.Build.0 = Release|Win32 22 | {53273C6A-3D23-4424-830D-E19A813698C9}.Release|x64.ActiveCfg = Release|x64 23 | {53273C6A-3D23-4424-830D-E19A813698C9}.Release|x64.Build.0 = Release|x64 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /examples/usb_example/DJI_guidance_example/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | project( dji_guidance_usb ) 3 | CMAKE_POLICY( SET CMP0015 NEW ) 4 | find_package( OpenCV ) 5 | if(OpenCV_FOUND) 6 | add_definitions(-DHAVE_OPENCV) 7 | endif() 8 | 9 | add_executable( dji_guidance_usb main.cpp DJI_utility.cpp ) 10 | include_directories($(SOURCE_DIR)/../../../include) 11 | 12 | if(WIN32) 13 | find_library(Guidance_Lib DJI_guidance.lib HINTS $(SOURCE_DIR)/../../../../lib/2013/x86) 14 | else() 15 | find_library(Guidance_Lib DJI_guidance HINTS $(SOURCE_DIR)/../../../../so/x64) 16 | target_link_libraries( dji_guidance_usb pthread) 17 | endif() 18 | 19 | if(OpenCV_FOUND) 20 | target_link_libraries( dji_guidance_usb ${OpenCV_LIBS} ${Guidance_Lib}) 21 | else() 22 | target_link_libraries( dji_guidance_usb ${Guidance_Lib}) 23 | endif() -------------------------------------------------------------------------------- /examples/usb_example/DJI_guidance_example/DJI_guidance_example_vs2010.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | 26 | 27 | Header Files 28 | 29 | 30 | -------------------------------------------------------------------------------- /examples/usb_example/DJI_guidance_example/DJI_guidance_example_vs2010.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /examples/usb_example/DJI_guidance_example/DJI_guidance_example_vs2013.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /examples/usb_example/DJI_guidance_example/DJI_utility.cpp: -------------------------------------------------------------------------------- 1 | #include "DJI_utility.h" 2 | 3 | #ifdef WIN32 4 | 5 | DJI_lock::DJI_lock() 6 | { 7 | InitializeCriticalSection( &m_critical_section ); 8 | } 9 | 10 | DJI_lock::~DJI_lock() 11 | { 12 | } 13 | 14 | void DJI_lock::enter() 15 | { 16 | EnterCriticalSection( &m_critical_section ); 17 | } 18 | 19 | void DJI_lock::leave() 20 | { 21 | LeaveCriticalSection( &m_critical_section ); 22 | } 23 | 24 | void sleep( int microsecond ) 25 | { 26 | Sleep( ( microsecond + 999 ) / 1000 ); 27 | } 28 | DJI_event::DJI_event() 29 | { 30 | SECURITY_ATTRIBUTES sa; 31 | sa.nLength = sizeof(sa); 32 | sa.lpSecurityDescriptor = NULL; 33 | sa.bInheritHandle = TRUE; 34 | CreatePipe( &m_pipe_read, &m_pipe_write, &sa, 0 ); 35 | } 36 | 37 | DJI_event::~DJI_event() 38 | { 39 | CloseHandle( m_pipe_read ); 40 | CloseHandle( m_pipe_write ); 41 | } 42 | 43 | int DJI_event::set_event() 44 | { 45 | char buffer[1] = {0}; 46 | int count = 0; 47 | int ret = WriteFile( m_pipe_write, (LPWORD)buffer, 1, (LPDWORD)&count, NULL ); 48 | return ret; 49 | } 50 | 51 | int DJI_event::wait_event() 52 | { 53 | char buffer[1] = {0}; 54 | int count = 0; 55 | int ret = ReadFile( m_pipe_read, (LPWORD)buffer, 1, (LPDWORD)&count, NULL ); 56 | return ret; 57 | } 58 | 59 | #else 60 | 61 | DJI_lock::DJI_lock() 62 | { 63 | pthread_mutex_init( &m_lock, NULL ); 64 | } 65 | 66 | DJI_lock::~DJI_lock() 67 | { 68 | } 69 | 70 | void DJI_lock::enter() 71 | { 72 | pthread_mutex_lock( &m_lock ); 73 | } 74 | 75 | void DJI_lock::leave() 76 | { 77 | pthread_mutex_unlock( &m_lock ); 78 | } 79 | 80 | DJI_event::DJI_event() 81 | { 82 | sem_init( &m_sem, 0, 0 ); 83 | } 84 | 85 | DJI_event::~DJI_event() 86 | { 87 | } 88 | 89 | int DJI_event::set_event() 90 | { 91 | int ret = sem_post( &m_sem ); 92 | return ret; 93 | } 94 | 95 | int DJI_event::wait_event() 96 | { 97 | int ret = sem_wait( &m_sem ); 98 | return ret; 99 | } 100 | 101 | #endif 102 | -------------------------------------------------------------------------------- /examples/usb_example/DJI_guidance_example/DJI_utility.h: -------------------------------------------------------------------------------- 1 | #ifndef __DJI_UTILITY_H__ 2 | #define __DJI_UTILITY_H__ 3 | #include 4 | 5 | #ifdef WIN32 6 | 7 | #include 8 | #include 9 | 10 | class DJI_lock 11 | { 12 | public: 13 | DJI_lock(); 14 | ~DJI_lock(); 15 | void enter(); 16 | void leave(); 17 | private: 18 | CRITICAL_SECTION m_critical_section; 19 | }; 20 | 21 | class DJI_event 22 | { 23 | public: 24 | DJI_event(); 25 | ~DJI_event(); 26 | int set_event(); 27 | int wait_event(); 28 | private: 29 | HANDLE m_pipe_read; 30 | HANDLE m_pipe_write; 31 | }; 32 | 33 | #else 34 | 35 | #include 36 | #include 37 | 38 | class DJI_lock 39 | { 40 | public: 41 | DJI_lock(); 42 | ~DJI_lock(); 43 | void enter(); 44 | void leave(); 45 | private: 46 | pthread_mutex_t m_lock; 47 | }; 48 | 49 | class DJI_event 50 | { 51 | public: 52 | DJI_event(); 53 | ~DJI_event(); 54 | int set_event(); 55 | int wait_event(); 56 | private: 57 | sem_t m_sem; 58 | }; 59 | 60 | #endif 61 | 62 | void sleep( int microsecond ); 63 | 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /examples/usb_example/DJI_guidance_example/Makefile: -------------------------------------------------------------------------------- 1 | TARGET = guidance_example 2 | 3 | OBJECTS = main.o DJI_utility.o 4 | 5 | CFLAGS = -g -Wall -I/usr/local/include -I../../../include -DHAVE_OPENCV -I/usr/local/include/opencv2 6 | 7 | LDFLAGS = -Wl,-rpath,./ -lpthread -lrt -L./ -L/usr/local/lib/ -lDJI_guidance -lusb-1.0 -lopencv_core -lopencv_highgui 8 | 9 | CXX = g++ 10 | 11 | $(TARGET) : $(OBJECTS) 12 | $(CXX) -o $(TARGET) $(OBJECTS) $(LDFLAGS) 13 | rm *.gch 14 | 15 | main.o : main.cpp DJI_utility.h 16 | $(CXX) $(CFLAGS) -c main.cpp DJI_utility.h 17 | 18 | DJI_utility.o : DJI_utility.cpp DJI_utility.h 19 | $(CXX) $(CFLAGS) -c DJI_utility.cpp DJI_utility.h 20 | 21 | clean: 22 | rm *.o *.gch $(TARGET) 23 | 24 | -------------------------------------------------------------------------------- /examples/usb_example/DJI_guidance_example/Makefile_noOpenCV: -------------------------------------------------------------------------------- 1 | TARGET = guidance_example 2 | 3 | OBJECTS = main.o DJI_utility.o 4 | 5 | CFLAGS = -g -Wall -I/usr/local/include -I../../../include 6 | 7 | LDFLAGS = -Wl,-rpath,./ -lpthread -lrt -L./ -L/usr/local/lib/ -lDJI_guidance -lusb-1.0 8 | 9 | CXX = g++ 10 | 11 | $(TARGET) : $(OBJECTS) 12 | $(CXX) -o $(TARGET) $(OBJECTS) $(LDFLAGS) 13 | rm *.gch 14 | 15 | main.o : main.cpp DJI_utility.h 16 | $(CXX) $(CFLAGS) -c main.cpp DJI_utility.h 17 | 18 | DJI_utility.o : DJI_utility.cpp DJI_utility.h 19 | $(CXX) $(CFLAGS) -c DJI_utility.cpp DJI_utility.h 20 | 21 | clean: 22 | rm *.o *.gch $(TARGET) 23 | 24 | -------------------------------------------------------------------------------- /examples/usb_example/DJI_guidance_example_vs2010.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DJI_guidance_example", "DJI_guidance_example\DJI_guidance_example_vs2010.vcxproj", "{53273C6A-3D23-4424-830D-E19A813698C9}" 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DJI_guidance_for_matlab", "DJI_guidance_for_matlab\DJI_guidance_for_matlab_2010.vcxproj", "{7D4AAB03-A706-42B4-A94C-BBBAC33961A4}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Debug|x64 = Debug|x64 12 | Release|Win32 = Release|Win32 13 | Release|x64 = Release|x64 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {53273C6A-3D23-4424-830D-E19A813698C9}.Debug|Win32.ActiveCfg = Debug|Win32 17 | {53273C6A-3D23-4424-830D-E19A813698C9}.Debug|Win32.Build.0 = Debug|Win32 18 | {53273C6A-3D23-4424-830D-E19A813698C9}.Debug|x64.ActiveCfg = Debug|x64 19 | {53273C6A-3D23-4424-830D-E19A813698C9}.Debug|x64.Build.0 = Debug|x64 20 | {53273C6A-3D23-4424-830D-E19A813698C9}.Release|Win32.ActiveCfg = Release|Win32 21 | {53273C6A-3D23-4424-830D-E19A813698C9}.Release|Win32.Build.0 = Release|Win32 22 | {53273C6A-3D23-4424-830D-E19A813698C9}.Release|x64.ActiveCfg = Release|x64 23 | {53273C6A-3D23-4424-830D-E19A813698C9}.Release|x64.Build.0 = Release|x64 24 | {7D4AAB03-A706-42B4-A94C-BBBAC33961A4}.Debug|Win32.ActiveCfg = Debug|Win32 25 | {7D4AAB03-A706-42B4-A94C-BBBAC33961A4}.Debug|Win32.Build.0 = Debug|Win32 26 | {7D4AAB03-A706-42B4-A94C-BBBAC33961A4}.Debug|x64.ActiveCfg = Debug|x64 27 | {7D4AAB03-A706-42B4-A94C-BBBAC33961A4}.Debug|x64.Build.0 = Debug|x64 28 | {7D4AAB03-A706-42B4-A94C-BBBAC33961A4}.Release|Win32.ActiveCfg = Release|Win32 29 | {7D4AAB03-A706-42B4-A94C-BBBAC33961A4}.Release|Win32.Build.0 = Release|Win32 30 | {7D4AAB03-A706-42B4-A94C-BBBAC33961A4}.Release|x64.ActiveCfg = Release|x64 31 | {7D4AAB03-A706-42B4-A94C-BBBAC33961A4}.Release|x64.Build.0 = Release|x64 32 | EndGlobalSection 33 | GlobalSection(SolutionProperties) = preSolution 34 | HideSolutionNode = FALSE 35 | EndGlobalSection 36 | EndGlobal 37 | -------------------------------------------------------------------------------- /examples/usb_example/DJI_guidance_for_matlab/DJI_guidance_for_matlab_2010.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | 26 | 27 | Header Files 28 | 29 | 30 | Header Files 31 | 32 | 33 | -------------------------------------------------------------------------------- /examples/usb_example/DJI_guidance_for_matlab/DJI_guidance_for_matlab_2010.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /examples/usb_example/DJI_guidance_for_matlab/DJI_utility.cpp: -------------------------------------------------------------------------------- 1 | #include "DJI_utility.h" 2 | 3 | #ifdef WIN32 4 | 5 | lock::lock() 6 | { 7 | InitializeCriticalSection( &m_critical_section ); 8 | } 9 | 10 | lock::~lock() 11 | { 12 | } 13 | 14 | void lock::enter() 15 | { 16 | EnterCriticalSection( &m_critical_section ); 17 | } 18 | 19 | void lock::leave() 20 | { 21 | LeaveCriticalSection( &m_critical_section ); 22 | } 23 | 24 | void sleep( int microsecond ) 25 | { 26 | Sleep( ( microsecond + 999 ) / 1000 ); 27 | } 28 | 29 | 30 | event::event() 31 | { 32 | SECURITY_ATTRIBUTES sa; 33 | sa.nLength = sizeof(sa); 34 | sa.lpSecurityDescriptor = NULL; 35 | sa.bInheritHandle = TRUE; 36 | CreatePipe( &m_pipe_read, &m_pipe_write, &sa, 0 ); 37 | } 38 | 39 | event::~event() 40 | { 41 | CloseHandle( m_pipe_read ); 42 | CloseHandle( m_pipe_write ); 43 | } 44 | 45 | int event::set_event() 46 | { 47 | char buffer[1] = {0}; 48 | int count = 0; 49 | int ret = WriteFile( m_pipe_write, (LPWORD)buffer, 1, (LPDWORD)&count, NULL ); 50 | return ret; 51 | } 52 | 53 | int event::wait_event() 54 | { 55 | char buffer[1] = {0}; 56 | int count = 0; 57 | int ret = ReadFile( m_pipe_read, (LPWORD)buffer, 1, (LPDWORD)&count, NULL ); 58 | return ret; 59 | } 60 | 61 | #else 62 | 63 | lock::lock() 64 | { 65 | pthread_mutex_init( &m_lock, NULL ); 66 | } 67 | 68 | lock::~lock() 69 | { 70 | } 71 | 72 | void lock::enter() 73 | { 74 | pthread_mutex_lock( &m_lock ); 75 | } 76 | 77 | void lock::leave() 78 | { 79 | pthread_mutex_unlock( &m_lock ); 80 | } 81 | 82 | event::event() 83 | { 84 | sem_init( &m_sem, 0, 0 ); 85 | } 86 | 87 | event::~event() 88 | { 89 | } 90 | 91 | int event::set_event() 92 | { 93 | int ret = sem_post( &m_sem ); 94 | return ret; 95 | } 96 | 97 | int event::wait_event() 98 | { 99 | int ret = sem_wait( &m_sem ); 100 | return ret; 101 | } 102 | 103 | #endif 104 | -------------------------------------------------------------------------------- /examples/usb_example/DJI_guidance_for_matlab/DJI_utility.h: -------------------------------------------------------------------------------- 1 | #ifndef __DJI_UTILITY_H__ 2 | #define __DJI_UTILITY_H__ 3 | #include 4 | 5 | #ifdef WIN32 6 | 7 | #include 8 | #include 9 | 10 | class lock 11 | { 12 | public: 13 | lock(); 14 | ~lock(); 15 | void enter(); 16 | void leave(); 17 | private: 18 | CRITICAL_SECTION m_critical_section; 19 | }; 20 | 21 | class event 22 | { 23 | public: 24 | event(); 25 | ~event(); 26 | int set_event(); 27 | int wait_event(); 28 | private: 29 | HANDLE m_pipe_read; 30 | HANDLE m_pipe_write; 31 | }; 32 | 33 | #else 34 | 35 | #include 36 | #include 37 | 38 | class lock 39 | { 40 | public: 41 | lock(); 42 | ~lock(); 43 | void enter(); 44 | void leave(); 45 | private: 46 | pthread_mutex_t m_lock; 47 | }; 48 | 49 | class event 50 | { 51 | public: 52 | event(); 53 | ~event(); 54 | int set_event(); 55 | int wait_event(); 56 | private: 57 | sem_t m_sem; 58 | }; 59 | 60 | #endif 61 | 62 | void sleep( int microsecond ); 63 | 64 | 65 | #endif -------------------------------------------------------------------------------- /examples/usb_example/DJI_guidance_for_matlab/matlabGuidance.m: -------------------------------------------------------------------------------- 1 | function matlabGuidance 2 | % demo_Guidance 3 | DISPLAY_IMAGE = 1; 4 | fig_img = 1; 5 | fig_vo = 2; 6 | fig_imu = 3; 7 | %% Read image data 8 | filename_imleft = 'imleft.dat'; 9 | % Create the communications file if it is not already there. 10 | while ~exist(filename_imleft, 'file') 11 | fprintf('Cannot open file "%s"', filename_imleft); 12 | pause(1); 13 | end 14 | % Memory map the file. 15 | m_imleft = memmapfile(filename_imleft, 'Writable', true, 'Format', {'uint8',[320,240],'im';'int32',[1,1],'hasData'}); 16 | 17 | %% Read depth data 18 | filename_depth = 'imdepth.dat'; 19 | % Create the communications file if it is not already there. 20 | while ~exist(filename_depth, 'file') 21 | fprintf('Cannot open file "%s"', filename_depth); 22 | pause(1); 23 | end 24 | % Memory map the file. 25 | m_depth = memmapfile(filename_depth, 'Writable', true, 'Format', {'uint16',[320,240],'im';'int32',[1,1],'hasData'}); 26 | 27 | %% Read IMU data 28 | filename_imu = 'imu.dat'; 29 | % Create the communications file if it is not already there. 30 | while ~exist(filename_imu, 'file') 31 | fprintf('Cannot open file "%s"', filename_imu); 32 | pause(1); 33 | end 34 | % Memory map the file. 35 | m_imu = memmapfile(filename_imu, 'Writable', true, 'Format', {'int32',[1,1],'hasData';'single',[1,3],'acc';'single',[1,4],'q'}); 36 | 37 | %% Read VO data 38 | filename_vo = 'vo.dat'; 39 | % Create the communications file if it is not already there. 40 | while ~exist(filename_vo, 'file') 41 | fprintf('Cannot open file "%s"', filename_vo); 42 | pause(1); 43 | end 44 | % Memory map the file. 45 | m_vo = memmapfile(filename_vo, 'Writable', true, 'Format', {'int32',[1,1],'hasData';'int16',[1,3],'vel'}); 46 | fileInfo = dir(filename_vo); 47 | vo_available = 1; 48 | if(fileInfo.bytes<10) 49 | vo_available = 0; 50 | end 51 | vel_all = zeros(100,3); 52 | %% the main loop to extract data from file 53 | while true 54 | % Wait until the first byte is not zero. 55 | if m_imleft.Data.hasData 56 | imleft = m_imleft.Data.im'; % transpose to convert C array to matlab array 57 | if DISPLAY_IMAGE 58 | figure(fig_img); subplot(121); imshow(imleft); 59 | end 60 | m_imleft.Data.hasData = int32(0); 61 | end 62 | 63 | if m_depth.Data.hasData 64 | imdepth = m_depth.Data.im'; 65 | if DISPLAY_IMAGE 66 | subplot(122); imshow(uint8(imdepth)); 67 | end 68 | m_depth.Data.hasData = int32(0); 69 | end 70 | 71 | if m_imu.Data.hasData 72 | acc = m_imu.Data.acc; 73 | q = m_imu.Data.q; 74 | disp([acc,q]); 75 | 76 | m_imu.Data.hasData = int32(0); 77 | end 78 | 79 | if vo_available 80 | if m_vo.Data.hasData 81 | vel = m_vo.Data.vel; 82 | disp(vel); 83 | 84 | vel_all = [vel_all(2:end,:); vel]; 85 | figure(fig_vo); 86 | subplot(131); plot(vel_all(:,1)); title('x'); 87 | subplot(132); plot(vel_all(:,2)); title('y'); 88 | subplot(133); plot(vel_all(:,3)); title('z'); 89 | 90 | m_vo.Data.hasData = int32(0); 91 | end 92 | end 93 | 94 | pause(.01); 95 | end 96 | 97 | 98 | -------------------------------------------------------------------------------- /examples/usb_example/use_Guidance_vs2010_x64.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | $(SolutionDir)..\..\include;%(AdditionalIncludeDirectories); 9 | /DWIN32 %(AdditionalOptions) 10 | 11 | 12 | $(SolutionDir)..\..\lib\2010\x64;%(AdditionalLibraryDirectories); 13 | DJI_guidance.lib;%(AdditionalDependencies) 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /examples/usb_example/use_Guidance_vs2010_x86.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | $(SolutionDir)..\..\include;;%(AdditionalIncludeDirectories); 9 | /DWIN32 %(AdditionalOptions) 10 | 11 | 12 | $(SolutionDir)..\..\lib\2010\x86;%(AdditionalLibraryDirectories); 13 | DJI_guidance.lib;%(AdditionalDependencies) 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /examples/usb_example/use_Guidance_vs2013_x64.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | $(SolutionDir)..\..\include;%(AdditionalIncludeDirectories); 9 | /DWIN32 %(AdditionalOptions) 10 | 11 | 12 | $(SolutionDir)..\..\lib\2013\x64;%(AdditionalLibraryDirectories); 13 | DJI_guidance.lib;%(AdditionalDependencies) 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /examples/usb_example/use_Guidance_vs2013_x86.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | $(SolutionDir)..\..\include;%(AdditionalIncludeDirectories); 9 | /DWIN32 %(AdditionalOptions) 10 | 11 | 12 | $(SolutionDir)..\..\lib\2013\x86;%(AdditionalLibraryDirectories); 13 | DJI_guidance.lib;%(AdditionalDependencies) 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /examples/usb_example/use_opencv_debug_vs2010_x64.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | $(SolutionDir)bin\ 7 | <_PropertySheetDisplayName>use_opencv_debug_x64 8 | 9 | 10 | 11 | $(OPENCVROOT)\build\include\;%(AdditionalIncludeDirectories); 12 | 13 | 14 | $(OPENCVROOT)\build\x64\vc10\lib;%(AdditionalLibraryDirectories); 15 | opencv_calib3d2411d.lib;opencv_contrib2411d.lib;opencv_core2411d.lib;opencv_features2d2411d.lib;opencv_flann2411d.lib;opencv_gpu2411d.lib;opencv_highgui2411d.lib;opencv_imgproc2411d.lib;opencv_legacy2411d.lib;;opencv_ml2411d.lib;opencv_nonfree2411d.lib;opencv_objdetect2411d.lib;opencv_ocl2411d.lib;opencv_photo2411d.lib;opencv_stitching2411d.lib;opencv_superres2411d.lib;opencv_ts2411d.lib;opencv_video2411d.lib;opencv_videostab2411d.lib;%(AdditionalDependencies); 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /examples/usb_example/use_opencv_debug_vs2010_x86.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | $(SolutionDir)bin\ 7 | <_PropertySheetDisplayName>use_opencv_debug_x86 8 | 9 | 10 | 11 | $(OPENCVROOT)\build\include\;%(AdditionalIncludeDirectories); 12 | 13 | 14 | $(OPENCVROOT)\build\x86\vc10\lib;%(AdditionalLibraryDirectories); 15 | opencv_calib3d2411d.lib;opencv_contrib2411d.lib;opencv_core2411d.lib;opencv_features2d2411d.lib;opencv_flann2411d.lib;opencv_gpu2411d.lib;opencv_highgui2411d.lib;opencv_imgproc2411d.lib;opencv_legacy2411d.lib;;opencv_ml2411d.lib;opencv_nonfree2411d.lib;opencv_objdetect2411d.lib;opencv_ocl2411d.lib;opencv_photo2411d.lib;opencv_stitching2411d.lib;opencv_superres2411d.lib;opencv_ts2411d.lib;opencv_video2411d.lib;opencv_videostab2411d.lib;%(AdditionalDependencies); 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /examples/usb_example/use_opencv_release_vs2010_x64.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | $(SolutionDir)bin\ 7 | <_PropertySheetDisplayName>use_opencv_release_x64 8 | 9 | 10 | 11 | $(OPENCVROOT)\build\include\;%(AdditionalIncludeDirectories); 12 | 13 | 14 | $(OPENCVROOT)\build\x64\vc10\lib;%(AdditionalLibraryDirectories); 15 | opencv_calib3d2411.lib;opencv_contrib2411.lib;opencv_core2411.lib;opencv_features2d2411.lib;opencv_flann2411.lib;opencv_gpu2411.lib;opencv_highgui2411.lib;opencv_imgproc2411.lib;opencv_legacy2411.lib;;opencv_ml2411.lib;opencv_nonfree2411.lib;opencv_objdetect2411.lib;opencv_ocl2411.lib;opencv_photo2411.lib;opencv_stitching2411.lib;opencv_superres2411.lib;opencv_ts2411.lib;opencv_video2411.lib;opencv_videostab2411.lib;%(AdditionalDependencies); 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /examples/usb_example/use_opencv_release_vs2010_x86.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | $(SolutionDir)bin\ 7 | <_PropertySheetDisplayName>use_opencv_release_x86 8 | 9 | 10 | 11 | $(OPENCVROOT)\build\include\;%(AdditionalIncludeDirectories); 12 | 13 | 14 | $(OPENCVROOT)\build\x86\vc10\lib;%(AdditionalLibraryDirectories); 15 | opencv_calib3d2411.lib;opencv_contrib2411.lib;opencv_core2411.lib;opencv_features2d2411.lib;opencv_flann2411.lib;opencv_gpu2411.lib;opencv_highgui2411.lib;opencv_imgproc2411.lib;opencv_legacy2411.lib;;opencv_ml2411.lib;opencv_nonfree2411.lib;opencv_objdetect2411.lib;opencv_ocl2411.lib;opencv_photo2411.lib;opencv_stitching2411.lib;opencv_superres2411.lib;opencv_ts2411.lib;opencv_video2411.lib;opencv_videostab2411.lib;%(AdditionalDependencies); 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /examples/usb_example/use_opencv_release_vs2013_x64.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | $(SolutionDir)bin\ 7 | 8 | 9 | 10 | $(OPENCVROOT)\build\include\;%(AdditionalIncludeDirectories); 11 | 12 | 13 | $(OPENCVROOT)\build\x64\vc12\lib;%(AdditionalLibraryDirectories); 14 | opencv_calib3d2411.lib;opencv_contrib2411.lib;opencv_core2411.lib;opencv_features2d2411.lib;opencv_flann2411.lib;opencv_gpu2411.lib;opencv_highgui2411.lib;opencv_imgproc2411.lib;opencv_legacy2411.lib;;opencv_ml2411.lib;opencv_nonfree2411.lib;opencv_objdetect2411.lib;opencv_ocl2411.lib;opencv_photo2411.lib;opencv_stitching2411.lib;opencv_superres2411.lib;opencv_ts2411.lib;opencv_video2411.lib;opencv_videostab2411.lib;%(AdditionalDependencies); 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /examples/usb_example/use_opencv_release_vs2013_x86.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | $(SolutionDir)bin\ 7 | 8 | 9 | 10 | $(OPENCVROOT)\build\include\;%(AdditionalIncludeDirectories); 11 | 12 | 13 | $(OPENCVROOT)\build\x86\vc12\lib;%(AdditionalLibraryDirectories); 14 | opencv_calib3d2411.lib;opencv_contrib2411.lib;opencv_core2411.lib;opencv_features2d2411.lib;opencv_flann2411.lib;opencv_gpu2411.lib;opencv_highgui2411.lib;opencv_imgproc2411.lib;opencv_legacy2411.lib;;opencv_ml2411.lib;opencv_nonfree2411.lib;opencv_objdetect2411.lib;opencv_ocl2411.lib;opencv_photo2411.lib;opencv_stitching2411.lib;opencv_superres2411.lib;opencv_ts2411.lib;opencv_video2411.lib;opencv_videostab2411.lib;%(AdditionalDependencies); 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /lib/2010/x64/DJI_guidance.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dji-sdk/Guidance-SDK/9f666b4338ea37f7ce62dd1292d531918b37c18c/lib/2010/x64/DJI_guidance.dll -------------------------------------------------------------------------------- /lib/2010/x64/DJI_guidance.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dji-sdk/Guidance-SDK/9f666b4338ea37f7ce62dd1292d531918b37c18c/lib/2010/x64/DJI_guidance.lib -------------------------------------------------------------------------------- /lib/2010/x86/DJI_guidance.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dji-sdk/Guidance-SDK/9f666b4338ea37f7ce62dd1292d531918b37c18c/lib/2010/x86/DJI_guidance.dll -------------------------------------------------------------------------------- /lib/2010/x86/DJI_guidance.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dji-sdk/Guidance-SDK/9f666b4338ea37f7ce62dd1292d531918b37c18c/lib/2010/x86/DJI_guidance.lib -------------------------------------------------------------------------------- /lib/2013/x64/DJI_guidance.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dji-sdk/Guidance-SDK/9f666b4338ea37f7ce62dd1292d531918b37c18c/lib/2013/x64/DJI_guidance.dll -------------------------------------------------------------------------------- /lib/2013/x64/DJI_guidance.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dji-sdk/Guidance-SDK/9f666b4338ea37f7ce62dd1292d531918b37c18c/lib/2013/x64/DJI_guidance.lib -------------------------------------------------------------------------------- /lib/2013/x86/DJI_guidance.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dji-sdk/Guidance-SDK/9f666b4338ea37f7ce62dd1292d531918b37c18c/lib/2013/x86/DJI_guidance.dll -------------------------------------------------------------------------------- /lib/2013/x86/DJI_guidance.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dji-sdk/Guidance-SDK/9f666b4338ea37f7ce62dd1292d531918b37c18c/lib/2013/x86/DJI_guidance.lib -------------------------------------------------------------------------------- /so/TX1/Makefile: -------------------------------------------------------------------------------- 1 | TARGET = ./TX1/libDJI_guidance.so 2 | OBJECTS = config.o frame.o imagetransfer.o log.o usb.o protocal.o linux_wrapper.o DJI_guidance.o 3 | CFLAGS = -rdynamic -Wall -fPIC -I./libusb-1.0 4 | LDFLAGS = -shared -Wl,-rpath,./ -L -lusb-1.0.so 5 | 6 | CXX = g++ 7 | 8 | $(TARGET) : $(OBJECTS) 9 | $(CXX) -o $(TARGET) $(OBJECTS) $(LDFLAGS) 10 | 11 | bmp.o : bmp.cpp bmp.h 12 | $(CXX) $(CFLAGS) -c bmp.cpp bmp.h 13 | 14 | config.o : config.cpp config.h 15 | $(CXX) $(CFLAGS) -c config.cpp config.h 16 | 17 | frame.o : frame.cpp frame.h 18 | $(CXX) $(CFLAGS) -c frame.cpp frame.h 19 | 20 | framecontainer.o : framecontainer.cpp framecontainer.h 21 | $(CXX) $(CFLAGS) -c framecontainer.cpp framecontainer.h 22 | 23 | imagetransfer.o : imagetransfer.cpp imagetransfer.h 24 | $(CXX) $(CFLAGS) -c imagetransfer.cpp imagetransfer.h 25 | 26 | DJI_guidance.o : DJI_guidance.cpp DJI_guidance.h 27 | $(CXX) $(CFLAGS) -c DJI_guidance.cpp DJI_guidance.h 28 | 29 | log.o : log.cpp log.h 30 | $(CXX) $(CFLAGS) -c log.cpp log.h 31 | 32 | protocal.o : protocal.cpp protocal.h 33 | $(CXX) $(CFLAGS) -c protocal.cpp protocal.h 34 | 35 | stack.o : stack.cpp stack.h 36 | $(CXX) $(CFLAGS) -c stack.cpp stack.h 37 | 38 | usb.o : usb.cpp usb.h 39 | $(CXX) $(CFLAGS) -c usb.cpp usb.h 40 | 41 | linux_wrapper.o : ./os/linux_wrapper.cpp platform.h 42 | $(CXX) $(CFLAGS) -c ./os/linux_wrapper.cpp platform.h 43 | 44 | clean: 45 | rm *.o *.gch $(TARGET) 46 | -------------------------------------------------------------------------------- /so/TX1/README.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dji-sdk/Guidance-SDK/9f666b4338ea37f7ce62dd1292d531918b37c18c/so/TX1/README.txt -------------------------------------------------------------------------------- /so/TX1/libDJI_guidance.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dji-sdk/Guidance-SDK/9f666b4338ea37f7ce62dd1292d531918b37c18c/so/TX1/libDJI_guidance.so -------------------------------------------------------------------------------- /so/XU3/libDJI_guidance.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dji-sdk/Guidance-SDK/9f666b4338ea37f7ce62dd1292d531918b37c18c/so/XU3/libDJI_guidance.so -------------------------------------------------------------------------------- /so/arm/libDJI_guidance.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dji-sdk/Guidance-SDK/9f666b4338ea37f7ce62dd1292d531918b37c18c/so/arm/libDJI_guidance.so -------------------------------------------------------------------------------- /so/x64/libDJI_guidance.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dji-sdk/Guidance-SDK/9f666b4338ea37f7ce62dd1292d531918b37c18c/so/x64/libDJI_guidance.so -------------------------------------------------------------------------------- /so/x86/libDJI_guidance.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dji-sdk/Guidance-SDK/9f666b4338ea37f7ce62dd1292d531918b37c18c/so/x86/libDJI_guidance.so --------------------------------------------------------------------------------