# RMCOD2026_Hero **Repository Path**: cod_-control/rmcod2026_-hero ## Basic Information - **Project Name**: RMCOD2026_Hero - **Description**: No description available - **Primary Language**: C - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-07-17 - **Last Updated**: 2026-01-26 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # RMCOD2026_Hero #### 介绍 26赛季全向英雄代码 环境依赖 开发工具:Keil V5.38a,VsCode 软件环境:Window11 硬件环境:大疆RoboMaster开发板C型 (STM32F407IGHX) 编译工具:Arm Compiler V6.22,C/C++编译 #### 使用说明 开发任务主要都在.task文件中 ### Gimbal主要内容 ### 遥控器控制时云台的模式控制 ``` static void Gimbal_Mode_Update(Control_Info_Typedef *Control_Info) { if(remote_ctrl.rc_lost == 1) { Control_Info->Gimbal.Mode = GIMBAL_OFF; Control_Info->Shoot.Mode = SHOOTER_OFF; return; } // 更新视觉状态标志 Vision_Lose_Transform_Normal = (Vision_Info.Distance > 0) ? 1 : 0; // 只在遥控模式下处理控制逻辑 if(Control_Info->Control_Mode != CONTROL_REMOTE) { Control_Info->Gimbal.Mode = GIMBAL_OFF; Control_Info->Shoot.Mode = SHOOTER_OFF; return; } // 根据遥控器开关状态设置不同的工作模式 switch(remote_ctrl.rc.s[0]) { case 1: // 右侧开关处于上面 if(remote_ctrl.rc.s[1] == 1) { // 左侧开关也处于上面 - 启动射击模式 Control_Info->Shoot.Mode = SHOOTER_NORMAL; } else if(remote_ctrl.rc.s[1] == 3) { // 左侧开关处于中间 - 小陀螺模式 Control_Info->Gimbal.Mode = CONTROL_GYR_CONTROL; Control_Info->Shoot.Mode = SHOOTER_OFF; } else { // 其他情况关闭射击 Control_Info->Shoot.Mode = SHOOTER_OFF; } break; case 2: // 右侧开关处于下位 - 紧急停止 Control_Info->Gimbal.Mode = GIMBAL_OFF; Control_Info->Shoot.Mode = SHOOTER_OFF; break; case 3: // 右侧开关处于中间 if(remote_ctrl.rc.s[1] == 1) { // 左侧开关处于上面 - 视觉模式或普通控制模式 Control_Info->Gimbal.Mode = Vision_Lose_Transform_Normal ? GIMBAL_VISION : CONTROL_NOMAL_CONTROL; } else if(remote_ctrl.rc.s[1] == 3) { // 左侧开关也处于中间- 普通控制模式 Control_Info->Gimbal.Mode = CONTROL_NOMAL_CONTROL; Control_Info->Shoot.Mode = SHOOTER_OFF; } else { // 其他情况关闭射击 Control_Info->Shoot.Mode = SHOOTER_OFF; } break; default: // 默认情况下关闭云台和射击 Control_Info->Gimbal.Mode = GIMBAL_OFF; Control_Info->Shoot.Mode = SHOOTER_OFF; break; } } ``` ### 对于不同模式切换时云台状态的平滑处理 ``` static void Gimbal_Taget_Update() { // 公共默认动作:当不需要特殊控制时,目标等于当前测量值 float default_pitch = Control_Info.Gimbal.Measure.Pitch_Angle; float default_yaw = Control_Info.Gimbal.Measure.Yaw_Angle; if (Control_Info.Control_Mode == CONTROL_REMOTE) { if ((Control_Info.Gimbal.Mode == CONTROL_NOMAL_CONTROL) || (Control_Info.Gimbal.Mode == CONTROL_GYR_CONTROL)) { if (Machine_Star_reload == 1) { if (Vision_Transform_Normal == 1) { Control_Info.Gimbal.Target.Pitch_Angle = default_pitch; Control_Info.Gimbal.Target.Yaw_Angle = default_yaw; Vision_Transform_Normal = 0; } if (Vision_Transform_Normal == 0) { Control_Info.Gimbal.Target.Pitch_Angle += remote_ctrl.rc.ch[1] * 0.00009f; Control_Info.Gimbal.Target.Yaw_Angle += -remote_ctrl.rc.ch[0] * 0.0004f; } } else // Machine_Star_reload == 0 { Control_Info.Gimbal.Target.Pitch_Angle = default_pitch; Control_Info.Gimbal.Target.Yaw_Angle = default_yaw; Machine_Star_reload = 1; } } else if (Control_Info.Gimbal.Mode == GIMBAL_VISION) { if (Vision_Info.Distance > 0) { Control_Info.Gimbal.Target.Pitch_Angle = Vision_Info.Target_Pitch; Control_Info.Gimbal.Target.Yaw_Angle = -Vision_Info.Target_Yaw; } else { Control_Info.Gimbal.Target.Pitch_Angle = -default_pitch; Control_Info.Gimbal.Target.Yaw_Angle = -default_yaw; } Vision_Transform_Normal = 1; } else if (Control_Info.Gimbal.Mode == GIMBAL_OFF) { Control_Info.Gimbal.Target.Pitch_Angle = default_pitch; Control_Info.Gimbal.Target.Yaw_Angle = default_yaw; Machine_Star_reload = 0; } else { // 默认情况也设为目标等于当前位置 Control_Info.Gimbal.Target.Pitch_Angle = default_pitch; Control_Info.Gimbal.Target.Yaw_Angle = default_yaw; } } else { Control_Info.Gimbal.Target.Pitch_Angle = default_pitch; Control_Info.Gimbal.Target.Yaw_Angle = default_yaw; } // 归一化Yaw角至[-180, 180] normalize_angle(&Control_Info.Gimbal.Target.Yaw_Angle); } ``` ### Chassis主要内容 Control_task.c中对底盘解算等的控制 Detect_task.c中对整车不同状态时的检测 ### 参考开源 1.[辽宁科技大学COD战队STM32F407 通用控制系统](http://https://gitee.com/cod_-control/hero_2025)