Keywords: OSDK 4.x obstacle avoidance
Update code file:
dji_flight_assistant_module.hpp
Complete the original hashvalue:
enum ParamHashValue : uint32_t {
USE_RTK_DATA = 1288992843, /*! Set rtk switch on or off*/
GO_HOME_ALTITUDE = 952919004, /*! Set return home altitude*/
HORIZ_AVOID = 3001460201, /*! Set horiz avoid enable*/
UPWARDS_AVOID = 854709684,
};
To:
enum ParamHashValue : uint32_t {
USE_RTK_DATA = 3301673070, /*! Set rtk switch on or off*/
GO_HOME_ALTITUDE = 3581930365, /*! Set return home altitude*/
HORIZ_AVOID = 1076454642, /*! Set horiz avoid enable*/
HORIZ_VISION_AVOID = 1705638792,
HORIZ_RADAR_AVOID = 3350259798,
UPWARDS_AVOID = 854709684,
UPWARDS_VISION_AVOID = 2415881690,
UPWARDS_RADAR_AVOID = 4157105210,
DOWN_AVOID = 901246535, //
};
dji_flight_assistant_module.cpp
horizontal :
ErrorCode::ErrorCodeType FlightAssistant::setCollisionAvoidanceEnabledSync(
AvoidEnable avoidEnable, int timeout) {
ErrorCode::ErrorCodeType ret;
if(ACK::SUCCESS == writeParameterByHashSync(ParamHashValue::HORIZ_AVOID,
(void*)&avoidEnable, sizeof(avoidEnable),
timeout))
{
ret = writeParameterByHashSync(ParamHashValue::HORIZ_VISION_AVOID,
(void*)&avoidEnable, sizeof(avoidEnable),
timeout);
}
return ret;
}
upwards :
ErrorCode::ErrorCodeType FlightAssistant::setCollisionAvoidanceEnabledSync(
AvoidEnable avoidEnable, int timeout) {
ErrorCode::ErrorCodeType ret;
if(ACK::SUCCESS == writeParameterByHashSync(ParamHashValue::UPWARDS_AVOID,
(void*)&avoidEnable, sizeof(avoidEnable),
timeout))
{
ret = writeParameterByHashSync(ParamHashValue::UPWARDS_VISION_AVOID,
(void*)&avoidEnable, sizeof(avoidEnable),
timeout);
}
return ret;
}
downwards:
ErrorCode::ErrorCodeType FlightAssistant::setCollisionAvoidanceEnabledSync(
AvoidEnable avoidEnable, int timeout) {
return writeParameterByHashSync(ParamHashValue::DOWN_AVOID,
(void*)&avoidEnable, sizeof(avoidEnable),
timeout);
}
Set/Get avoidance status in dji_flight_assistant_module.cpp
ErrorCode::ErrorCodeType FlightAssistant::setHorizCollisionAvoidanceEnabledSync(
AvoidEnable avoidEnable, int timeout) {
ErrorCode::ErrorCodeType ret;
if(ACK::SUCCESS == writeParameterByHashSync(ParamHashValue::HORIZ_AVOID,
(void*)&avoidEnable, sizeof(avoidEnable),
timeout))
{
ret = writeParameterByHashSync(ParamHashValue::HORIZ_VISION_AVOID,
(void*)&avoidEnable, sizeof(avoidEnable),
timeout);
}
return ret;
}
#if 0
void FlightAssistant::setHorizCollisionAvoidanceEnabledAsync(
FlightAssistant::AvoidEnable avoidEnable,
void (*UserCallBack)(ErrorCode::ErrorCodeType retCode, UserData userData),
UserData userData) {
writeParameterByHashAsync(ParamHashValue::HORIZ_AVOID, (void*)&avoidEnable,
sizeof(avoidEnable), setParameterDecoder,
UserCallBack, userData);
}
#endif
ErrorCode::ErrorCodeType FlightAssistant::getHorizCollisionAvoidanceEnabledSync(
AvoidEnable& avoidEnable, int timeout) {
uint8_t param[MAX_PARAMETER_VALUE_LENGTH];
ErrorCode::ErrorCodeType ret =
readParameterByHashSync(ParamHashValue::HORIZ_VISION_AVOID, param, timeout);
if (ret == ErrorCode::SysCommonErr::Success) {
avoidEnable = *(AvoidEnable*)param;
}
return ret;
}
#if 0
void FlightAssistant::getHorizCollisionAvoidanceEnabledAsync(
void (*UserCallBack)(ErrorCode::ErrorCodeType retCode,
AvoidEnable avoidEnable, UserData userData),
UserData userData) {
readParameterByHashAsync<AvoidEnable>(ParamHashValue::HORIZ_AVOID,
getAvoidEnableDecoder, UserCallBack,
userData);
}
#endif
ErrorCode::ErrorCodeType FlightAssistant::setUpwardsAvoidanceEnabledSync(UpwardsAvoidEnable upwardsAvoidEnable, int timeout)
{
ErrorCode::ErrorCodeType ret;
if(ACK::SUCCESS == writeParameterByHashSync(ParamHashValue::UPWARDS_AVOID,
(void*)&upwardsAvoidEnable,
sizeof(upwardsAvoidEnable), timeout))
{
ret = writeParameterByHashSync(ParamHashValue::UPWARDS_VISION_AVOID,
(void*)&upwardsAvoidEnable, sizeof(upwardsAvoidEnable),
timeout);
}
return ret;
}
#if 0
void FlightAssistant::setUpwardsAvoidanceEnabledAsync(
UpwardsAvoidEnable upwardsAvoidEnable,
void (*UserCallBack)(ErrorCode::ErrorCodeType retCode, UserData userData),
UserData userData) {
writeParameterByHashAsync(
ParamHashValue::UPWARDS_AVOID, (void*)&upwardsAvoidEnable,
sizeof(upwardsAvoidEnable), setParameterDecoder, UserCallBack, userData);
}
#endif
ErrorCode::ErrorCodeType FlightAssistant::getUpwardsAvoidanceEnabledSync(
UpwardsAvoidEnable& upwardsAvoidEnable, int timeout) {
uint8_t param[MAX_PARAMETER_VALUE_LENGTH];
ErrorCode::ErrorCodeType ret =
readParameterByHashSync(ParamHashValue::UPWARDS_VISION_AVOID, param, timeout);
if (ret == ErrorCode::SysCommonErr::Success) {
upwardsAvoidEnable = *(UpwardsAvoidEnable*)param;
}
return ret;
}
#if 0
void FlightAssistant::getUpwardsAvoidanceEnabledAsync(
void (*UserCallBack)(ErrorCode::ErrorCodeType retCode,
UpwardsAvoidEnable upwardsEnable, UserData userData),
UserData userData) {
readParameterByHashAsync<UpwardsAvoidEnable>(ParamHashValue::UPWARDS_AVOID,
getUpwardsAvoidEnableDecoder,
UserCallBack, userData);
}
#endif
ErrorCode::ErrorCodeType FlightAssistant::setDownwardsAvoidanceEnabledSync(AvoidEnable avoidEnable, int timeout)
{
return writeParameterByHashSync(ParamHashValue::DOWN_AVOID, (void*)&avoidEnable, sizeof(avoidEnable), timeout);
}
ErrorCode::ErrorCodeType FlightAssistant::getDownwardsAvoidanceEnabledSync(AvoidEnable& avoidEnable, int timeout)
{
uint8_t param[MAX_PARAMETER_VALUE_LENGTH];
ErrorCode::ErrorCodeType ret = readParameterByHashSync(ParamHashValue::DOWN_AVOID, param, timeout);
if (ret == ErrorCode::SysCommonErr::Success) {
avoidEnable = *(AvoidEnable*)param;
}
return ret;
}
Comments
0 comments
Please sign in to leave a comment.