From a1fe767681368d0a7ee0bfddd8cff3bf014d2e39 Mon Sep 17 00:00:00 2001 From: Xiaocheng <2544262366@qq.com> Date: Wed, 14 Jan 2026 17:50:12 +0800 Subject: [PATCH] =?UTF-8?q?huan=20=E5=88=86=E6=94=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- User/module/cmd.c | 4 ++++ User/module/cmd.h | 7 +++++++ User/task/shoot.c | 26 ++++++++++++++++++++++++-- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/User/module/cmd.c b/User/module/cmd.c index fcf0275..a8ec393 100644 --- a/User/module/cmd.c +++ b/User/module/cmd.c @@ -146,15 +146,19 @@ int8_t CMD_CtrlSet(Chassis_CMD_t *c_cmd, const CMD_RC_t *rc, Gimbal_CMD_t *g_cmd { case CMD_SW_UP: g_cmd->ctrl_mode = GIMBAL_MODE_REMOTE; + s_cmd->control_mode = SHOOT_REMOTE; break; case CMD_SW_MID: g_cmd->ctrl_mode = GIMBAL_MODE_AI; + s_cmd->control_mode = SHOOT_AI; break; case CMD_SW_DOWN: g_cmd->ctrl_mode = GIMBAL_MODE_AI; + s_cmd->control_mode = SHOOT_AI; break; case CMD_SW_ERR: g_cmd->ctrl_mode = GIMBAL_MODE_REMOTE; + s_cmd->control_mode = SHOOT_REMOTE; break; } diff --git a/User/module/cmd.h b/User/module/cmd.h index 136d450..cd9090e 100644 --- a/User/module/cmd.h +++ b/User/module/cmd.h @@ -126,8 +126,15 @@ typedef enum { SHOOT_MODE_NUM }Shoot_Mode_t; +typedef enum { + SHOOT_REMOTE = 0,/* 遥控器控制 */ + SHOOT_AI, /* AI控制 */ +} Shoot_Control_Mode_t; + typedef struct { Shoot_Mode_t mode;/* 射击模式 */ + + Shoot_Control_Mode_t control_mode;/* 控制模式 */ bool ready; /* 准备射击 */ bool firecmd; /* 射击 */ }Shoot_CMD_t; diff --git a/User/task/shoot.c b/User/task/shoot.c index 3565cb0..1b0b648 100644 --- a/User/task/shoot.c +++ b/User/task/shoot.c @@ -4,11 +4,12 @@ */ /* Includes ----------------------------------------------------------------- */ +#include "module/cmd.h" #include "task/user_task.h" /* USER INCLUDE BEGIN */ #include "module/shoot.h" #include "module/config.h" - +#include "device/ai.h" /* USER INCLUDE END */ /* Private typedef ---------------------------------------------------------- */ @@ -18,6 +19,7 @@ /* USER STRUCT BEGIN */ Shoot_t shoot; Shoot_CMD_t shoot_cmd; +AI_cmd_t shoot_ai_cmd; /* USER STRUCT END */ /* Private function --------------------------------------------------------- */ @@ -42,8 +44,28 @@ Shoot_SetMode(&shoot,SHOOT_MODE_SINGLE); tick += delay_tick; /* 计算下一个唤醒时刻 */ /* USER CODE BEGIN */ osMessageQueueGet(task_runtime.msgq.shoot.cmd, &shoot_cmd, NULL, 0); - +osMessageQueueGet(task_runtime.msgq.gimbal.ai.s_cmd, &shoot_ai_cmd, NULL, 0); +if(shoot_cmd.control_mode==SHOOT_REMOTE) +{ + //do nothing,使用遥控器的指令 +} +else if(shoot_cmd.control_mode==SHOOT_AI) +{ + shoot_cmd.mode = SHOOT_MODE_SINGLE; +if(shoot_ai_cmd.mode==0 || shoot_ai_cmd.mode==1) +{ + shoot_cmd.firecmd=false; + shoot_cmd.ready=true; + +} +else if(shoot_ai_cmd.mode==2) +{ + + shoot_cmd.firecmd=true; + shoot_cmd.ready=true; +} + } Shoot_UpdateFeedback(&shoot); Shoot_SetMode(&shoot,shoot_cmd.mode);