R2_NEW/User/device/cmd.h

141 lines
2.6 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef _CMD_H
#define _CMD_H
#include "struct_typedef.h"
#include "device.h"
#define MID (0x09)
#define PICK (0x06)
typedef enum{
RCcontrol,//遥控器控制,左按键上,控制上层
AUTO,
RELAXED,//异常模式
}CMD_CtrlType_t;
typedef enum{
Normal, //无模式
AUTO_NAVI,
AUTO_PICK,
Dribble , //运球
Pitch, //投篮,底盘锁定
Dribbl_transfer
}CMD_mode_t;
typedef struct {
uint8_t status_fromnuc;
uint8_t ctrl_status; //取其中每一个二进制位用作通信
struct
{
fp32 vx;
fp32 vy;
fp32 wz;
}navi;
struct
{
fp32 posx;
fp32 posy;
fp32 posw;
}pick;
struct
{
fp32 angle;
}sick_cali;
} CMD_NUC_t;
/* 拨杆位置 */
typedef enum {
CMD_SW_ERR = 0,
CMD_SW_UP = 1,
CMD_SW_MID = 3,
CMD_SW_DOWN = 2,
} CMD_SwitchPos_t;
/*遥控器值使用CMD_RcLogic函数传入CMD_t结构体*/
typedef struct {
float ch_l_x; /* 遥控器左侧摇杆横轴值,上为正 */
float ch_l_y; /* 遥控器左侧摇杆纵轴值,右为正 */
float ch_r_x; /* 遥控器右侧摇杆横轴值,上为正 */
float ch_r_y; /* 遥控器右侧摇杆纵轴值,右为正 */
float ch_res; /* 第五通道值 */
CMD_SwitchPos_t sw_r; /* 右侧拨杆位置 */
CMD_SwitchPos_t sw_l; /* 左侧拨杆位置 */
uint16_t key; /* 按键值 */
uint16_t res; /* 保留,未启用 */
} __attribute__((packed))CMD_RC_t;
typedef struct {
uint8_t cmd_status;
uint8_t raw_status;
uint8_t status[7];
fp32 key_ctrl_l;
fp32 key_ctrl_r;
fp32 Vx;
fp32 Vy;
fp32 Vw;
fp32 poscamear;
struct
{
fp32 posx;
fp32 posy;
fp32 posw;
}cmd_pick;
struct
{
fp32 posx;
fp32 posy;
fp32 posw;
}cmd_MID360;
CMD_mode_t CMD_mode;
CMD_CtrlType_t CMD_CtrlType;
} CMD_t;
/*nuc数据统一到cmd*/
/*
该任务用来处理来自不同控制方式下传回的期望的控制指令在此处统一为通用格式的控制指令发送给其他任务
*/
/* Includes ----------------------------------------------------------------- */
#include "cmd.h"
#include "gpio.h"
#include "user_math.h"
#include <string.h>
/* Private function -------------------------------------------------------- */
/*Export function --------------------------------------------------------------*/
int8_t CMD_Init(CMD_t *cmd);
static void CMD_RcLogic(const CMD_RC_t *rc, CMD_t *cmd) ;
static void CMD_RcLostLogic(CMD_t *cmd);
int8_t CMD_ParseRc(CMD_t *cmd,CMD_RC_t *rc);
int8_t CMD_ParseNuc(CMD_t *cmd,CMD_NUC_t *n);
int8_t CMD_ParseRC(CMD_t *cmd,const CMD_RC_t *rc) ;
#endif