/*
 * 自瞄模组
 */

#pragma once

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ----------------------------------------------------------------- */
#include "component\user_math.h"
#include "gimbal.h"
struct __attribute__((packed)) GimbalToVision
{
  uint8_t head[2];
  uint8_t mode;  // 0: 空闲, 1: 自瞄, 2: 小符, 3: 大符
  float q[4];    // wxyz顺序	/q4,q0,q1,q2/
  float yaw;
  float yaw_vel;
  float pitch;
  float pitch_vel;
  float bullet_speed;
  uint16_t bullet_count;  // 子弹累计发送次数
  uint16_t crc16;
};

struct __attribute__((packed)) VisionToGimbal
{
  uint8_t head[2];
  uint8_t mode;  // 0: 不控制, 1: 控制云台但不开火，2: 控制云台且开火
  float yaw;
  float yaw_vel;
  float yaw_acc;
  float pitch;
  float pitch_vel;
  float pitch_acc;
  uint16_t crc16;
};

typedef struct __attribute__((packed)) {
	uint8_t mode;
	struct{
//	Gimbal_CMD_t g_cmd;
		struct{
				float yaw;
				float pit;		
		}setpoint;
		
		
		struct{
					float pit;
					float yaw;	
					}accl;
		struct{
					float pit;
					float yaw;	
					}vel;		
	}gimbal_t;
	
}AI_cmd_t;


typedef struct __attribute__((packed)) {
	struct GimbalToVision TX;
	struct VisionToGimbal RX;
}AI_t;


int8_t AI_StartReceiving(AI_t *ai);

int8_t AI_Get_NUC(AI_t *ai,AI_cmd_t* ai_cmd);

int8_t AI_ParseHost(AI_t* ai,Gimbal_Feedback_t* g_feedback);

int8_t AI_StartSend(AI_t *ai);

#ifdef __cplusplus
}
#endif
