Skip to content

Commit

Permalink
OSDK 3.6: Improvements to OSDK Core and new demos for camera data
Browse files Browse the repository at this point in the history
  • Loading branch information
amenonDJI committed Feb 3, 2018
1 parent ef705a6 commit 42f645a
Show file tree
Hide file tree
Showing 59 changed files with 2,242 additions and 219 deletions.
24 changes: 20 additions & 4 deletions License.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,17 +142,33 @@ Onboard-SDK
│   │   │   ├── tracking_utility.cpp
│   │   │   └── tracking_utility.hpp
│   │   ├── CMakeLists.txt
│ │ ├── stereo_vision_depth_perception_sample
│ │ │ ├── utility
│   │   │   │  ├── camera_param.cpp
│   │   │   │  ├── camera_param.hpp
│   │   │   │  ├── config.cpp
│   │   │   │  ├── config.hpp
│   │   │   │  ├── frame.hpp
│   │   │   │  ├── point_cloud_viewer.cpp
│   │   │   │  ├── point_cloud_viewer.hpp
│   │   │   │  ├── stereo_frame.cpp
│   │   │   │  └── stereo_frame.hpp
│   │   │   ├── stereo_vision_depth_perception_sample.cpp
│   │   │   ├── stereo_vision_depth_perception_sample.hpp
│   │   │   ├── CMakeLists.txt
│   │   │   ├── stereo_process_container.cpp
│   │   │   └── stereo_process_container.hpp
│   │   ├── stereo_vision_multi_thread_sample
│   │   │   ├── advanced_sensing_multi_thread_sample.cpp
│   │   │   ├── advanced_sensing_multi_thread_sample.hpp
│   │   │   ├── stereo_vision_multi_thread_sample.cpp
│   │   │   ├── stereo_vision_multi_thread_sample.hpp
│   │   │   ├── CMakeLists.txt
│   │   │   ├── image_process_container.cpp
│   │   │   ├── image_process_container.hpp
│   │   │   ├── utility_thread.cpp
│   │   │   └── utility_thread.hpp
│   │   └── stereo_vision_single_thread_sample
│   │   ├── advanced_sensing_sample.cpp
│   │   ├── advanced_sensing_sample.hpp
│   │   ├── stereo_vision_single_thread_sample.cpp
│   │   ├── stereo_vision_single_thread_sample.hpp
│   │   └── CMakeLists.txt
│   ├── camera-gimbal
│   │   ├── camera_gimbal_sample.cpp
Expand Down
5 changes: 3 additions & 2 deletions osdk-core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,9 @@ if(ADVANCED_SENSING)
find_package(FFMPEG REQUIRED)

if(FFMPEG_FOUND)
message("Found FFMPEG FFMPEG_INCLUDE_DIR = ${FFMPEG_INCLUDE_DIR}")
message("Found FFMPEG FFMPEG_LIBRARIES = ${FFMPEG_LIBRARIES}")
message( STATUS "Found FFmpeg ${FFMPEG_VERSION} installed in the system.")
message( STATUS " - Includes: ${FFMPEG_INCLUDE_DIRS}")
message( STATUS " - Libraries: ${FFMPEG_LIBRARIES}")
else()
message("Cannot Find FFMPEG")
endif(FFMPEG_FOUND)
Expand Down
49 changes: 46 additions & 3 deletions osdk-core/api/inc/dji_subscription.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,11 @@ class SubscriptionPackage
UserData userData);

bool isOccupied();

void setOccupied(bool status);

bool hasLeftOverData();
void setLeftOverDataFlag(bool flag);

// Accessors to private variables:
PackageInfo getInfo();
uint32_t* getUidList(); // explicitly show it's a pointer
Expand All @@ -121,6 +123,7 @@ class SubscriptionPackage

private: // Private variables
bool occupied;
bool leftOverDataFlag;
PackageInfo info;

// We have only 30 topics and 5 packages.
Expand Down Expand Up @@ -208,9 +211,45 @@ class DataSubscription
*/
ACK::ErrorCode startPackage(int packageID, int timeout); // blocking call

/*!
* @brief Non-blocking call for start package
* @param packageID
* @return
*/
void removePackage(int packageID);

/*!
* @brief Non-blocking call for start package
* @param packageID
* @param timeout
* @return
*/
ACK::ErrorCode removePackage(int packageID, int timeout); // blocking call

/*!
* @brief Remove leftover incoming telemetry data due to unclean quit
* @return
*/
void removeLeftOverPackages();

/*!
* @brief Remove all occupied packages
* @return
*/
void removeAllExistingPackages();

/*!
* @brief Non-blocking call for resetting all packages.
* @return
*/
void reset();

/*!
* @brief Blocking call for resetting all packages.
* @param timeout
*/
ACK::ErrorCode reset(int timeout);

/*!
* @brief Register a callback function after package[packageID] is received
* @param packageID
Expand All @@ -221,8 +260,8 @@ class DataSubscription
UserData userData = NULL);

// Not implemented yet
bool pausePackage(int packageID);
bool resumePackage(int packageID);
// bool pausePackage(int packageID);
// bool resumePackage(int packageID);
// bool changePackageFrequency(int packageID, uint16_t newFreq);

/*!
Expand All @@ -243,6 +282,10 @@ class DataSubscription
RecvContainer rcvContainer,
UserData pkgHandle);

static void resetCallback(Vehicle* vehiclePtr,
RecvContainer rcvContainer,
UserData pkgHandle);

/*!
* @brief This callback function is called by recvReqData, case
* CMD_ID_SUBSCRIBE.
Expand Down
11 changes: 9 additions & 2 deletions osdk-core/api/inc/dji_vehicle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ class Vehicle
* @return NULL
*/
void processAdvancedSensingImgs(RecvContainer* receivedFrame);

bool advSensingErrorPrintOnce;
#endif

//! User sets this to true in order to enable Callback thread with Non
Expand Down Expand Up @@ -339,7 +341,7 @@ class Vehicle
/*! @brief Initialize all functional Vehicle components
* like, Subscription, Broadcast, Control, Gimbal, ect
*/
void functionalSetUp();
int functionalSetUp();

private:
/*! @brief Initialize minimal Vehicle components
Expand All @@ -350,7 +352,12 @@ class Vehicle
* @details
* @return false if error, true if success
*/
bool initPlatformSupport();
bool initFullPlatformSupport();
/*!
* @brief Initialize main read thread to support UART communication
* @return fasle if error, true if success
*/
bool initMainReadThread();
bool initOpenProtocol();
void initCallbacks();
void initCMD_SetSupportMatrix();
Expand Down
7 changes: 4 additions & 3 deletions osdk-core/api/src/dji_ack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const std::pair<const uint32_t, const char*> commonData[] = {
(const char*)"ACK_SUCCESS\n"),
std::make_pair(
OpenProtocolCMD::ErrorCode::CommonACK::START_MOTOR_FAIL_MOTOR_STARTED,
(const char*)"START_MOTOR_FAIL_MOTOR_STARTED\n"),
(const char*)"START_MOTOR_FAILED_MOTOR_ALREADY_STARTED\n"),
std::make_pair(
OpenProtocolCMD::ErrorCode::CommonACK::MOTOR_FAIL_COMPASS_ABNORMAL,
(const char*)"COMPASS_CALIB_FAIL_DUE_TO_MOTOR_ON\n"),
Expand Down Expand Up @@ -651,6 +651,7 @@ ACK::getErrorCodeMessage(ACK::ErrorCode ack, const char* func)
case OpenProtocolCMD::CMDSet::control:
// Get message by CMD_ID
getCMDSetControlMSG(ack);
break;
case OpenProtocolCMD::CMDSet::broadcast:
getSetBroadcastMSG(ack);
break;
Expand All @@ -672,7 +673,7 @@ ACK::getErrorCodeMessage(ACK::ErrorCode ack, const char* func)
getCMDSetSubscribeMSG(ack);
break;
default:
DSTATUS("UNKNOWN_ACK_ERROR_CODE\n");
getCommonErrorCodeMessage(ack);
break;
}
}
Expand Down Expand Up @@ -776,7 +777,7 @@ ACK::getCMDIDSetControlMSG(uint8_t ack, Version::FirmWare version)
if (msg->first ==
OpenProtocolCMD::ErrorCode::ControlACK::SetControl::RC_MODE_ERROR)
{
if (version != Version::M100_31 || version != Version::A3_31)
if (version != Version::M100_31 && version != Version::A3_31)
{
DSTATUS("RC_NEED_MODE_P\n");
}
Expand Down
10 changes: 5 additions & 5 deletions osdk-core/api/src/dji_control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ Control::positionAndYawCtrl(float32_t x, float32_t y, float32_t z,
HORIZONTAL_GROUND | STABLE_ENABLE);
CtrlData data(ctrl_flag, x, y, z, yaw);

return this->flightCtrl(data);
this->flightCtrl(data);
}

void
Expand All @@ -379,7 +379,7 @@ Control::velocityAndYawRateCtrl(float32_t Vx, float32_t Vy, float32_t Vz,
(VERTICAL_VELOCITY | HORIZONTAL_VELOCITY | YAW_RATE | HORIZONTAL_GROUND);
CtrlData data(ctrl_flag, Vx, Vy, Vz, yawRate);

return this->flightCtrl(data);
this->flightCtrl(data);
}

void
Expand All @@ -391,7 +391,7 @@ Control::attitudeAndVertPosCtrl(float32_t roll, float32_t pitch, float32_t yaw,
(VERTICAL_POSITION | HORIZONTAL_ANGLE | YAW_ANGLE | HORIZONTAL_BODY);
CtrlData data(ctrl_flag, roll, pitch, z, yaw);

return this->flightCtrl(data);
this->flightCtrl(data);
}

void
Expand All @@ -405,7 +405,7 @@ Control::angularRateAndVertPosCtrl(float32_t rollRate, float32_t pitchRate,
YAW_RATE | HORIZONTAL_BODY);
CtrlData data(ctrl_flag, rollRate, pitchRate, z, yawRate);

return this->flightCtrl(data);
this->flightCtrl(data);
}
else
{
Expand All @@ -428,7 +428,7 @@ Control::emergencyBrake()
//! @note 75 is the flag value of this mode
AdvancedCtrlData data(72, 0, 0, 0, 0, 0, 0);

return this->flightCtrl(data);
this->flightCtrl(data);
}
else
{
Expand Down
6 changes: 4 additions & 2 deletions osdk-core/api/src/dji_mission_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ MissionManager::init(DJI_MISSION_TYPE type, int timeout, UserData missionData)
DERROR("Cannot recognize the mission type provided\n");
// @todo return a false ack
ACK::ErrorCode ack;
ack.data = false;
ack.info.cmd_set = OpenProtocolCMD::CMDSet::mission;
ack.data = ErrorCode::MissionACK::Common::INVALID_COMMAND;
return ack;
}
}
Expand Down Expand Up @@ -135,7 +136,8 @@ MissionManager::initHotptMission(int timeout, UserData hotptData)

// @todo this initData() does not return ack
ACK::ErrorCode ack;
ack.data = ACK::SUCCESS;
ack.info.cmd_set = OpenProtocolCMD::CMDSet::mission;
ack.data = ErrorCode::MissionACK::Common::SUCCESS;

return ack;
}
Expand Down
Loading

0 comments on commit 42f645a

Please sign in to comment.