|
|
|
@ -20,6 +20,7 @@
@@ -20,6 +20,7 @@
|
|
|
|
|
#include <string.h> |
|
|
|
|
#include <stdio.h> |
|
|
|
|
#include <AP_Math/crc.h> |
|
|
|
|
#include <AP_Logger/AP_Logger.h> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define ZR_API_DEBUG 1 |
|
|
|
@ -300,6 +301,15 @@ bool AC_ZR_Serial_API::get_control_data(uint8_t mode, ZR_Msg_Type &type,Vector3l
@@ -300,6 +301,15 @@ bool AC_ZR_Serial_API::get_control_data(uint8_t mode, ZR_Msg_Type &type,Vector3l
|
|
|
|
|
if(control_data_last_time == last_time){ // 数据没更新,直接退出
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
AP::logger().Write("DATR", "TimeUS,Mode,Type,X,Y,Z,Yaw", "QBBB", |
|
|
|
|
AP_HAL::micros64(), |
|
|
|
|
mode, |
|
|
|
|
flight_control_parser.msg.type, |
|
|
|
|
flight_control_parser.msg.x, |
|
|
|
|
flight_control_parser.msg.y, |
|
|
|
|
flight_control_parser.msg.z, |
|
|
|
|
flight_control_parser.msg.yaw); |
|
|
|
|
|
|
|
|
|
last_time = control_data_last_time; |
|
|
|
|
WITH_SEMAPHORE(sem); |
|
|
|
|
if(flight_control_parser.msg.head != MSG_HEAD){ // 帧头
|
|
|
|
@ -322,7 +332,7 @@ bool AC_ZR_Serial_API::get_control_data(uint8_t mode, ZR_Msg_Type &type,Vector3l
@@ -322,7 +332,7 @@ bool AC_ZR_Serial_API::get_control_data(uint8_t mode, ZR_Msg_Type &type,Vector3l
|
|
|
|
|
return false; // 校验失败
|
|
|
|
|
} |
|
|
|
|
type = flight_control_parser.msg.type; |
|
|
|
|
if(type < ZR_Msg_Type::MSG_CONTROL_TKOFF || type > ZR_Msg_Type::MSG_CONTROL_VEL_P ){ |
|
|
|
|
if(type < ZR_Msg_Type::MSG_CONTROL_TKOFF || type > ZR_Msg_Type::MSG_CONTROL_MODE ){ |
|
|
|
|
set_control_ask(flight_control_parser.msg.msg_id,flight_control_parser.msg.type,ZR_Msg_ASK::MSG_ASK_ERRTYPE); // 应答控制类型错误
|
|
|
|
|
if(get_param_debug()){ |
|
|
|
|
|
|
|
|
@ -330,7 +340,7 @@ bool AC_ZR_Serial_API::get_control_data(uint8_t mode, ZR_Msg_Type &type,Vector3l
@@ -330,7 +340,7 @@ bool AC_ZR_Serial_API::get_control_data(uint8_t mode, ZR_Msg_Type &type,Vector3l
|
|
|
|
|
} |
|
|
|
|
return false; // 控制类型错误
|
|
|
|
|
} |
|
|
|
|
if(type != ZR_Msg_Type::MSG_CONTROL_TKOFF && mode != 4){ |
|
|
|
|
if(type != ZR_Msg_Type::MSG_CONTROL_MODE && type != ZR_Msg_Type::MSG_CONTROL_TKOFF && mode != 4 ){ |
|
|
|
|
set_control_ask(flight_control_parser.msg.msg_id,flight_control_parser.msg.type,ZR_Msg_ASK::MSG_ASK_ERRMODE);
|
|
|
|
|
if(get_param_debug()){ |
|
|
|
|
Debug("mode error: %d",mode); |
|
|
|
|