侧向,热控开关,小大井一起

This commit is contained in:
zyx 2024-05-17 06:23:18 +08:00
parent 3390dcc7de
commit 6aaab646b0
15 changed files with 9079 additions and 8834 deletions

View File

@ -132,7 +132,15 @@ void ChassisInit() {
.can_handle = &hcan1,
.tx_id = 0x210,
.rx_id = 0x211,
}};
},
.buffer_config_pid = {
.Kp = 1.0f,
.Ki = 0,
.Kd = 0,
.MaxOut = 300,
},
};
cap = SuperCapInit(&cap_conf); // 超级电容初始化
//用一阶滤波代替斜波函数生成 //增大更能刹住
@ -184,6 +192,10 @@ static void OmniCalculate() {
}
static const float motor_power_K[3] = {1.6301e-6f,5.7501e-7f,2.5863e-7f};
float input;
float P_max;
///依据3508电机功率模型预测电机输出功率
static float EstimatePower(DJIMotorInstance* chassis_motor)
{
@ -201,21 +213,29 @@ static float EstimatePower(DJIMotorInstance* chassis_motor)
*/
static void LimitChassisOutput()
{
float Plimit = 1.0f;
// float Plimit = 1.0f;
float P_cmd = motor_rf->motor_controller.motor_power_predict +
motor_rb->motor_controller.motor_power_predict +
motor_lb->motor_controller.motor_power_predict +
motor_lf->motor_controller.motor_power_predict + 3.6f;
if(chassis_cmd_recv.buffer_energy<50&&chassis_cmd_recv.buffer_energy>=40) Plimit=0.9f;
else if(chassis_cmd_recv.buffer_energy<40&&chassis_cmd_recv.buffer_energy>=35) Plimit=0.75f;
else if(chassis_cmd_recv.buffer_energy<35&&chassis_cmd_recv.buffer_energy>=30) Plimit=0.5f;
else if(chassis_cmd_recv.buffer_energy<30&&chassis_cmd_recv.buffer_energy>=20) Plimit=0.25f;
else if(chassis_cmd_recv.buffer_energy<20&&chassis_cmd_recv.buffer_energy>=10) Plimit=0.125f;
else if(chassis_cmd_recv.buffer_energy<10&&chassis_cmd_recv.buffer_energy>=0) Plimit=0.05f;
else if(chassis_cmd_recv.buffer_energy==60) Plimit=1.0f;
// if(chassis_cmd_recv.buffer_energy<50&&chassis_cmd_recv.buffer_energy>=40) Plimit=0.9f;
// else if(chassis_cmd_recv.buffer_energy<40&&chassis_cmd_recv.buffer_energy>=35) Plimit=0.75f;
// else if(chassis_cmd_recv.buffer_energy<35&&chassis_cmd_recv.buffer_energy>=30) Plimit=0.5f;
// else if(chassis_cmd_recv.buffer_energy<30&&chassis_cmd_recv.buffer_energy>=20) Plimit=0.25f;
// else if(chassis_cmd_recv.buffer_energy<20&&chassis_cmd_recv.buffer_energy>=10) Plimit=0.125f;
// else if(chassis_cmd_recv.buffer_energy<10&&chassis_cmd_recv.buffer_energy>=0) Plimit=0.05f;
// else if(chassis_cmd_recv.buffer_energy==60) Plimit=1.0f;
float K = ((float)(chassis_cmd_recv.chassis_power_limit - 3) * (Plimit + 0.50f) + (float)(chassis_cmd_recv.buffer_supercap)) / P_cmd;
if (cap->cap_msg.cap_vol>1800)
{
P_max = input + chassis_cmd_recv.buffer_supercap ;
}
else
{
P_max = input;
}
float K = P_max / P_cmd;
if(chassis_cmd_recv.buffer_energy<5)//当缓冲功率过小时,限制功率给小;
K = (float)(chassis_cmd_recv.chassis_power_limit - 3) / P_cmd;
@ -239,11 +259,13 @@ static void LimitChassisOutput()
*/
static void SuperCapSetUpdate()
{
if(last_chassis_power_limit != chassis_cmd_recv.chassis_power_limit)
{
SuperCapSetPower(cap,chassis_cmd_recv.chassis_power_limit); // 超级电容限制功率
last_chassis_power_limit = chassis_cmd_recv.chassis_power_limit;
}
PIDCalculate(&cap->buffer_pid, chassis_cmd_recv.buffer_energy,30);//对缓冲功率进行闭环
input = chassis_cmd_recv.chassis_power_limit - cap->buffer_pid.Output;
LIMIT_MIN_MAX(input, 30, 130);
SuperCapSetPower(cap,input);
}
/**
* @brief ,,
@ -286,6 +308,11 @@ void ChassisTask() {
break;
case CHASSIS_FOLLOW_GIMBAL_YAW: // 跟随云台,不单独设置pid,以误差角度平方为速度输出
chassis_cmd_recv.wz = 10.0f * chassis_cmd_recv.offset_angle * abs(chassis_cmd_recv.offset_angle);
LIMIT_MIN_MAX(chassis_cmd_recv.wz,-30000,30000);
break;
case CHASSIS_SIDEWAYS: // 侧向,不单独设置pid,以误差角度平方为速度输出
chassis_cmd_recv.wz = 10.0f * (chassis_cmd_recv.offset_angle - 45)* abs(chassis_cmd_recv.offset_angle - 45);
LIMIT_MIN_MAX(chassis_cmd_recv.wz,-30000,30000);
break;
case CHASSIS_ROTATE: // 自旋,同时保持全向机动;当前wz维持定值,后续增加不规则的变速策略
chassis_cmd_recv.wz = 30000;
@ -317,7 +344,8 @@ void ChassisTask() {
// 根据控制模式进行正运动学解算,计算底盘输出
//MecanumCalculate();
OmniCalculate();
////对缓冲功率进行闭环
SuperCapSetUpdate();
// 根据裁判系统的反馈数据和电容数据对输出限幅并设定闭环参考值
LimitChassisOutput();
@ -337,8 +365,7 @@ void ChassisTask() {
//chassis_feedback_data.bullet_speed = referee_data->GameRobotState.shooter_id1_17mm_speed_limit;
chassis_feedback_data.cap_vol = cap->cap_msg.cap_vol;
//每次随等级更新超电的设定功率
SuperCapSetUpdate();
// 推送反馈消息
#ifdef ONE_BOARD
PubPushMessage(chassis_pub, (void *) &chassis_feedback_data);

View File

@ -139,6 +139,7 @@ static void update_ui_data() {
ui_data.friction_mode = shoot_cmd_send.friction_mode;
//ui_data.shoot_mode = shoot_cmd_send.shoot_mode;
ui_data.lid_mode = shoot_cmd_send.lid_mode;
ui_data.heat_mode = shoot_cmd_send.heat_mode;
ui_data.aim_fire = aim_select.suggest_fire;
//ui_data.loader_mode = shoot_cmd_send.loader_mode;
@ -183,7 +184,7 @@ static void auto_aim_mode() {
gimbal_cmd_send.pitch = -trajectory_cal.cmd_pitch * 180 / PI;
if (yaw_err <= 0.5) //3度
if (yaw_err <= 2) //3度
{
aim_select.suggest_fire = 1;
}
@ -269,7 +270,7 @@ static void RemoteControlSet() {
// }
// 射频控制,固定每秒1发,后续可以根据左侧拨轮的值大小切换射频,
shoot_cmd_send.shoot_rate = 18;
shoot_cmd_send.shoot_rate = 18;// 小 18
if(shoot_fetch_data.stalled_flag ==1)
shoot_cmd_send.loader_mode = LOAD_REVERSE;
@ -358,7 +359,7 @@ static void MouseKeySet() {
shoot_cmd_send.friction_mode = FRICTION_ON;
break;
}
switch (rc_data[TEMP].key_count[KEY_PRESS][Key_B] % 2) // Q键开关弹舱盖
switch (rc_data[TEMP].key_count[KEY_PRESS][Key_B] % 2) // B键开关弹舱盖
{
case 0:
shoot_cmd_send.lid_mode = LID_CLOSE;
@ -367,15 +368,54 @@ static void MouseKeySet() {
shoot_cmd_send.lid_mode = LID_OPEN;
break;
}
switch (rc_data[TEMP].key_count[KEY_PRESS][Key_E] % 2) // E键开关小陀螺
// switch (rc_data[TEMP].key_count[KEY_PRESS][Key_E] % 2) // E键开关小陀螺
// {
// case 0:
// chassis_cmd_send.chassis_mode = CHASSIS_FOLLOW_GIMBAL_YAW;
// gimbal_cmd_send.gimbal_mode = GIMBAL_FREE_MODE;
// break;
// default:
// chassis_cmd_send.chassis_mode = CHASSIS_ROTATE;
// gimbal_cmd_send.gimbal_mode = GIMBAL_GYRO_MODE;
// break;
// }
switch (rc_data[TEMP].key_count[KEY_PRESS][Key_Q] % 2) // Q键开关热控
{
case 0:
chassis_cmd_send.chassis_mode = CHASSIS_FOLLOW_GIMBAL_YAW;
gimbal_cmd_send.gimbal_mode = GIMBAL_FREE_MODE;
shoot_cmd_send.heat_mode = HEAT_OPEN;
break;
default:
chassis_cmd_send.chassis_mode = CHASSIS_ROTATE;
gimbal_cmd_send.gimbal_mode = GIMBAL_GYRO_MODE;
shoot_cmd_send.heat_mode = HEAT_CLOSE;
break;
}
switch (rc_data[TEMP].key_count[KEY_PRESS][Key_C] % 2) // C键侧向
{
case 0:
switch (rc_data[TEMP].key_count[KEY_PRESS][Key_E] % 2) // E键开关小陀螺
{
case 0:
chassis_cmd_send.chassis_mode = CHASSIS_FOLLOW_GIMBAL_YAW;
gimbal_cmd_send.gimbal_mode = GIMBAL_FREE_MODE;
break;
default:
chassis_cmd_send.chassis_mode = CHASSIS_ROTATE;
gimbal_cmd_send.gimbal_mode = GIMBAL_GYRO_MODE;
break;
}
break;
default:
chassis_cmd_send.chassis_mode = CHASSIS_SIDEWAYS;
switch (rc_data[TEMP].key_count[KEY_PRESS][Key_E] % 2) // E键开关小陀螺
{
case 0:
chassis_cmd_send.chassis_mode = CHASSIS_FOLLOW_GIMBAL_YAW;
gimbal_cmd_send.gimbal_mode = GIMBAL_FREE_MODE;
break;
default:
chassis_cmd_send.chassis_mode = CHASSIS_ROTATE;
gimbal_cmd_send.gimbal_mode = GIMBAL_GYRO_MODE;
break;
}
break;
}
switch (rc_data[TEMP].key_count[KEY_PRESS][Key_G] % 3) // G键切换发射模式
@ -483,7 +523,7 @@ static void VTMouseKeySet()
shoot_cmd_send.friction_mode = FRICTION_ON;
break;
}
switch (vt_data[TEMP].key_count[KEY_PRESS][Key_B] % 2) // Q键开关弹舱盖
switch (vt_data[TEMP].key_count[KEY_PRESS][Key_B] % 2) // B键开关弹舱盖
{
case 0:
shoot_cmd_send.lid_mode = LID_CLOSE;
@ -492,15 +532,63 @@ static void VTMouseKeySet()
shoot_cmd_send.lid_mode = LID_OPEN;
break;
}
switch (vt_data[TEMP].key_count[KEY_PRESS][Key_E] % 2) // E键开关小陀螺
// switch (vt_data[TEMP].key_count[KEY_PRESS][Key_E] % 2) // E键开关小陀螺
// {
// case 0:
// chassis_cmd_send.chassis_mode = CHASSIS_FOLLOW_GIMBAL_YAW;
// gimbal_cmd_send.gimbal_mode = GIMBAL_FREE_MODE;
// break;
// default:
// chassis_cmd_send.chassis_mode = CHASSIS_ROTATE;
// gimbal_cmd_send.gimbal_mode = GIMBAL_GYRO_MODE;
// break;
// }
switch (rc_data[TEMP].key_count[KEY_PRESS][Key_C] % 2) // C键侧向
{
case 0:
switch (rc_data[TEMP].key_count[KEY_PRESS][Key_E] % 2) // E键开关小陀螺
{
case 0:
chassis_cmd_send.chassis_mode = CHASSIS_FOLLOW_GIMBAL_YAW;
gimbal_cmd_send.gimbal_mode = GIMBAL_FREE_MODE;
break;
default:
chassis_cmd_send.chassis_mode = CHASSIS_ROTATE;
gimbal_cmd_send.gimbal_mode = GIMBAL_GYRO_MODE;
break;
}
break;
default:
chassis_cmd_send.chassis_mode = CHASSIS_SIDEWAYS;
switch (rc_data[TEMP].key_count[KEY_PRESS][Key_E] % 2) // E键开关小陀螺
{
case 0:
chassis_cmd_send.chassis_mode = CHASSIS_FOLLOW_GIMBAL_YAW;
gimbal_cmd_send.gimbal_mode = GIMBAL_FREE_MODE;
break;
default:
chassis_cmd_send.chassis_mode = CHASSIS_ROTATE;
gimbal_cmd_send.gimbal_mode = GIMBAL_GYRO_MODE;
break;
}
break;
}
switch (vt_data[TEMP].key_count[KEY_PRESS][Key_Q] % 2) // Q键开关热控
{
case 0:
shoot_cmd_send.heat_mode = HEAT_OPEN;
break;
default:
shoot_cmd_send.heat_mode = HEAT_CLOSE;
break;
}
switch (vt_data[TEMP].key_count[KEY_PRESS][Key_C] % 2) // C键侧向
{
case 0:
chassis_cmd_send.chassis_mode = CHASSIS_FOLLOW_GIMBAL_YAW;
gimbal_cmd_send.gimbal_mode = GIMBAL_FREE_MODE;
break;
default:
chassis_cmd_send.chassis_mode = CHASSIS_ROTATE;
gimbal_cmd_send.gimbal_mode = GIMBAL_GYRO_MODE;
chassis_cmd_send.chassis_mode = CHASSIS_SIDEWAYS;
break;
}
switch (rc_data[TEMP].key_count[KEY_PRESS][Key_G] % 3) // G键切换发射模式

View File

@ -26,7 +26,7 @@
/* 机器人重要参数定义,注意根据不同机器人进行修改,浮点数需要以.0或f结尾,无符号以u结尾 */
// 云台参数
#define YAW_CHASSIS_ALIGN_ECD 1443 // 云台和底盘对齐指向相同方向时的电机编码器值,若对云台有机械改动需要修改
#define YAW_CHASSIS_ALIGN_ECD 1443 // 小 1443 大2053 // 云台和底盘对齐指向相同方向时的电机编码器值,若对云台有机械改动需要修改
#define YAW_ECD_GREATER_THAN_4096 0 // ALIGN_ECD值是否大于4096,是为1,否为0;用于计算云台偏转角度
#define PITCH_HORIZON_ECD 4422 // 云台处于水平位置时编码器值,若对云台有机械改动需要修改
#define PITCH_MAX_ANGLE 25 // 云台竖直方向最大角度 (注意反馈如果是陀螺仪,则填写陀螺仪的角度)
@ -90,6 +90,7 @@ typedef enum
CHASSIS_ROTATE, // 小陀螺模式
CHASSIS_NO_FOLLOW, // 不跟随,允许全向平移
CHASSIS_FOLLOW_GIMBAL_YAW, // 跟随模式,底盘叠加角度环控制
CHASSIS_SIDEWAYS, // 侧向
} chassis_mode_e;
// 云台模式设置
@ -114,7 +115,7 @@ typedef enum
typedef enum
{
LID_OPEN = 0, // 弹舱盖打开
LID_OPEN , // 弹舱盖打开
LID_CLOSE, // 弹舱盖关闭
} lid_mode_e;
@ -126,7 +127,11 @@ typedef enum
LOAD_3_BULLET, // 三发
LOAD_BURSTFIRE, // 连发
} loader_mode_e;
typedef enum
{
HEAT_OPEN , // 热控打开
HEAT_CLOSE, // 热控关闭
}heat_mode_e;
// 功率限制,从裁判系统获取,是否有必要保留?
typedef struct
{
@ -179,6 +184,7 @@ typedef struct
loader_mode_e loader_mode;
lid_mode_e lid_mode;
friction_mode_e friction_mode;
heat_mode_e heat_mode;
Bullet_Speed_e bullet_speed; // 弹速枚举
float shoot_rate; // 连续发射的射频,unit per s,发/秒

View File

@ -28,16 +28,16 @@ void ShootInit()
},
.controller_param_init_config = {
.speed_PID = {
.Kp = 1.5f, // 20
.Ki = 0.2f, // 1
.Kp = 1.5f,
.Ki = 0.2f,
.Kd = 0,
.Improve = PID_Integral_Limit,
.IntegralLimit = 10000,
.MaxOut = 15000,
},
.current_PID = {
.Kp = 0, // 0.7
.Ki = 0, // 0.1
.Kp = 0,
.Ki = 0,
.Kd = 0,
.Improve = PID_Integral_Limit,
.IntegralLimit = 10000,
@ -49,11 +49,11 @@ void ShootInit()
.speed_feedback_source = MOTOR_FEED,
.outer_loop_type = SPEED_LOOP,
.close_loop_type = SPEED_LOOP,
.motor_reverse_flag = MOTOR_DIRECTION_NORMAL,
},
.motor_type = M3508};
friction_config.can_init_config.tx_id = 2,
friction_l = DJIMotorInit(&friction_config);
friction_config.controller_setting_init_config.motor_reverse_flag = MOTOR_DIRECTION_NORMAL;
friction_l = DJIMotorInit(&friction_config);
friction_config.can_init_config.tx_id = 3; // 右摩擦轮,改txid和方向就行
friction_config.controller_setting_init_config.motor_reverse_flag = MOTOR_DIRECTION_REVERSE;
@ -154,17 +154,17 @@ void stalled_detect()
}
// 热量控制
void Heat_control()
{
if(shoot_cmd_recv.heat>=(0.9*shoot_cmd_recv.heat_limit))
{
DJIMotorStop(loader);
}
else
{
DJIMotorEnable(loader);
}
}
//void Heat_control()
//{
// if(shoot_cmd_recv.heat>=(0.9*shoot_cmd_recv.heat_limit))
// {
// DJIMotorStop(loader);
// }
// else
// {
// DJIMotorEnable(loader);
// }
//}
/* 机器人发射机构控制核心任务 */
void ShootTask()
@ -274,10 +274,26 @@ void ShootTask()
{
Servo_Motor_FreeAngle_Set(lid,10);
}
// 开关热控
if(shoot_cmd_recv.heat_mode == HEAT_OPEN)
{
if(shoot_cmd_recv.heat>=(0.9*shoot_cmd_recv.heat_limit))
{
DJIMotorStop(loader);
}
else
{
DJIMotorEnable(loader);
}
}
else if(shoot_cmd_recv.heat_mode == HEAT_CLOSE) {
DJIMotorEnable(loader);
}
//卡弹检测
stalled_detect();
// 热量控制
Heat_control();
//Heat_control();
// 反馈数据,目前暂时没有要设定的反馈数据,后续可能增加应用离线监测以及卡弹反馈
PubPushMessage(shoot_pub, (void *)&shoot_feedback_data);

File diff suppressed because one or more lines are too long

View File

@ -47,19 +47,19 @@ cmake_force:
SHELL = cmd.exe
# The CMake executable.
CMAKE_COMMAND = D:\codeEditor\CLion\bin\cmake\win\x64\bin\cmake.exe
CMAKE_COMMAND = "D:\clion\CLion 2023.2.2\bin\cmake\win\x64\bin\cmake.exe"
# The command to remove a file.
RM = D:\codeEditor\CLion\bin\cmake\win\x64\bin\cmake.exe -E rm -f
RM = "D:\clion\CLion 2023.2.2\bin\cmake\win\x64\bin\cmake.exe" -E rm -f
# Escaping for special characters.
EQUALS = =
# The top-level source directory on which CMake was run.
CMAKE_SOURCE_DIR = C:\Users\sph\Desktop\xjcontrol\xiaojing
CMAKE_SOURCE_DIR = D:\zhandui\cqdm\xiaojing
# The top-level build directory on which CMake was run.
CMAKE_BINARY_DIR = C:\Users\sph\Desktop\xjcontrol\xiaojing\cmake-build-debug
CMAKE_BINARY_DIR = D:\zhandui\cqdm\xiaojing\cmake-build-debug
#=============================================================================
# Targets provided globally by CMake.
@ -67,7 +67,7 @@ CMAKE_BINARY_DIR = C:\Users\sph\Desktop\xjcontrol\xiaojing\cmake-build-debug
# Special rule for the target edit_cache
edit_cache:
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "No interactive CMake dialog available..."
D:\codeEditor\CLion\bin\cmake\win\x64\bin\cmake.exe -E echo "No interactive CMake dialog available."
"D:\clion\CLion 2023.2.2\bin\cmake\win\x64\bin\cmake.exe" -E echo "No interactive CMake dialog available."
.PHONY : edit_cache
# Special rule for the target edit_cache
@ -77,7 +77,7 @@ edit_cache/fast: edit_cache
# Special rule for the target rebuild_cache
rebuild_cache:
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..."
D:\codeEditor\CLion\bin\cmake\win\x64\bin\cmake.exe --regenerate-during-build -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
"D:\clion\CLion 2023.2.2\bin\cmake\win\x64\bin\cmake.exe" --regenerate-during-build -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
.PHONY : rebuild_cache
# Special rule for the target rebuild_cache
@ -86,9 +86,9 @@ rebuild_cache/fast: rebuild_cache
# The main all target
all: cmake_check_build_system
$(CMAKE_COMMAND) -E cmake_progress_start C:\Users\sph\Desktop\xjcontrol\xiaojing\cmake-build-debug\CMakeFiles C:\Users\sph\Desktop\xjcontrol\xiaojing\cmake-build-debug\\CMakeFiles\progress.marks
$(CMAKE_COMMAND) -E cmake_progress_start D:\zhandui\cqdm\xiaojing\cmake-build-debug\CMakeFiles D:\zhandui\cqdm\xiaojing\cmake-build-debug\\CMakeFiles\progress.marks
$(MAKE) $(MAKESILENT) -f CMakeFiles\Makefile2 all
$(CMAKE_COMMAND) -E cmake_progress_start C:\Users\sph\Desktop\xjcontrol\xiaojing\cmake-build-debug\CMakeFiles 0
$(CMAKE_COMMAND) -E cmake_progress_start D:\zhandui\cqdm\xiaojing\cmake-build-debug\CMakeFiles 0
.PHONY : all
# The main clean target

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
# Install script for directory: C:/Users/sph/Desktop/xjcontrol/xiaojing
# Install script for directory: D:/zhandui/cqdm/xiaojing
# Set the install prefix
if(NOT DEFINED CMAKE_INSTALL_PREFIX)
@ -45,5 +45,5 @@ endif()
string(REPLACE ";" "\n" CMAKE_INSTALL_MANIFEST_CONTENT
"${CMAKE_INSTALL_MANIFEST_FILES}")
file(WRITE "C:/Users/sph/Desktop/xjcontrol/xiaojing/cmake-build-debug/${CMAKE_INSTALL_MANIFEST}"
file(WRITE "D:/zhandui/cqdm/xiaojing/cmake-build-debug/${CMAKE_INSTALL_MANIFEST}"
"${CMAKE_INSTALL_MANIFEST_CONTENT}")

View File

@ -93,8 +93,12 @@ void MyUIInit()
// UICharRefresh(&referee_recv_info->referee_id, UI_State_sta[2]);
UICharDraw(&UI_State_sta[3], "ss3", UI_Graph_ADD, 8, UI_Color_Pink, 20, 2, 10, 700, "F.frict:");
UICharRefresh(&referee_recv_info->referee_id, UI_State_sta[3]);
UICharDraw(&UI_State_sta[4], "ss4", UI_Graph_ADD, 8, UI_Color_Pink, 20, 2, 10, 650, "B.lid:");
UICharDraw(&UI_State_sta[4], "ss4", UI_Graph_ADD, 8, UI_Color_Main, 20, 2, 10, 650, "B.lid:");
UICharRefresh(&referee_recv_info->referee_id, UI_State_sta[4]);
UICharDraw(&UI_State_sta[5], "ss5", UI_Graph_ADD, 8, UI_Color_Pink, 20, 2, 10, 600, "Q.heat:");
UICharRefresh(&referee_recv_info->referee_id, UI_State_sta[5]);
UICharDraw(&UI_State_sta[6], "ss6", UI_Graph_ADD, 8, UI_Color_Pink, 20, 2, 10, 800, "C.ce:");
UICharRefresh(&referee_recv_info->referee_id, UI_State_sta[6]);
// UICharDraw(&UI_State_sta[5], "ss5", UI_Graph_ADD, 8, UI_Color_Pink, 15, 2, 150, 800, "load:");
// UICharRefresh(&referee_recv_info->referee_id, UI_State_sta[5]);
@ -118,8 +122,12 @@ void MyUIInit()
// UICharRefresh(&referee_recv_info->referee_id, UI_State_dyn[2]);
UICharDraw(&UI_State_dyn[3], "sd3", UI_Graph_ADD, 8, UI_Color_Pink, 20, 2, 170, 700, "off");
UICharRefresh(&referee_recv_info->referee_id, UI_State_dyn[3]);
UICharDraw(&UI_State_dyn[4], "sd4", UI_Graph_ADD, 8, UI_Color_Pink, 20, 2, 170, 650, "on ");
UICharDraw(&UI_State_dyn[4], "sd4", UI_Graph_ADD, 8, UI_Color_Pink, 20, 2, 170, 650, "off");
UICharRefresh(&referee_recv_info->referee_id, UI_State_dyn[4]);
UICharDraw(&UI_State_dyn[5], "sd5", UI_Graph_ADD, 8, UI_Color_Pink, 20, 2, 170, 600, "on");
UICharRefresh(&referee_recv_info->referee_id, UI_State_dyn[5]);
UICharDraw(&UI_State_dyn[6], "sd6", UI_Graph_ADD, 8, UI_Color_Pink, 20, 2, 170, 800, "off");
UICharRefresh(&referee_recv_info->referee_id, UI_State_dyn[6]);
// UICharDraw(&UI_State_dyn[5], "sd5", UI_Graph_ADD, 8, UI_Color_Pink, 15, 2, 270, 800, "999");
// UICharRefresh(&referee_recv_info->referee_id, UI_State_dyn[5]);
@ -150,20 +158,23 @@ static void MyUIRefresh(referee_info_t *referee_recv_info, Referee_Interactive_i
if (_Interactive_data->Referee_Interactive_Flag.chassis_flag == 1)
{
switch (_Interactive_data->chassis_mode)
{
case CHASSIS_ZERO_FORCE:
UICharDraw(&UI_State_dyn[0], "sd0", UI_Graph_Change, 8, UI_Color_Main, 20, 2, 170, 750, "off");
break;
case CHASSIS_ROTATE:
UICharDraw(&UI_State_dyn[0], "sd0", UI_Graph_Change, 8, UI_Color_Main, 20, 2, 170, 750, "on ");
// 此处注意字数对齐问题,字数相同才能覆盖掉
break;
case CHASSIS_NO_FOLLOW:
UICharDraw(&UI_State_dyn[0], "sd0", UI_Graph_Change, 8, UI_Color_Main, 20, 2, 170, 750, "off");
break;
case CHASSIS_FOLLOW_GIMBAL_YAW:
UICharDraw(&UI_State_dyn[0], "sd0", UI_Graph_Change, 8, UI_Color_Main, 20, 2, 170, 750, "off");
break;
{
case CHASSIS_ZERO_FORCE:
UICharDraw(&UI_State_dyn[0], "sd0", UI_Graph_Change, 8, UI_Color_Main, 20, 2, 170, 750, "off");
break;
case CHASSIS_ROTATE:
UICharDraw(&UI_State_dyn[0], "sd0", UI_Graph_Change, 8, UI_Color_Main, 20, 2, 170, 750, "on ");
break;
case CHASSIS_SIDEWAYS:
UICharDraw(&UI_State_dyn[6], "sd6", UI_Graph_Change, 8, UI_Color_Pink, 20, 2, 170, 800, _Interactive_data->chassis_mode == CHASSIS_SIDEWAYS ? "on " : "off");
break;
case CHASSIS_NO_FOLLOW:
UICharDraw(&UI_State_dyn[0], "sd0", UI_Graph_Change, 8, UI_Color_Main, 20, 2, 170, 750, "off");
break;
case CHASSIS_FOLLOW_GIMBAL_YAW:
UICharDraw(&UI_State_dyn[0], "sd0", UI_Graph_Change, 8, UI_Color_Main, 20, 2, 170, 750, "off");
break;
}
UICharRefresh(&referee_recv_info->referee_id, UI_State_dyn[0]);
_Interactive_data->Referee_Interactive_Flag.chassis_flag = 0;
@ -213,6 +224,13 @@ static void MyUIRefresh(referee_info_t *referee_recv_info, Referee_Interactive_i
UICharRefresh(&referee_recv_info->referee_id, UI_State_dyn[4]);
_Interactive_data->Referee_Interactive_Flag.lid_flag = 0;
}
// heat
if (_Interactive_data->Referee_Interactive_Flag.heat_flag == 1)
{
UICharDraw(&UI_State_dyn[5], "sd5", UI_Graph_Change, 8, UI_Color_Pink, 20, 2, 170, 600, _Interactive_data->heat_mode == HEAT_OPEN ? "on " : "off");
UICharRefresh(&referee_recv_info->referee_id, UI_State_dyn[5]);
_Interactive_data->Referee_Interactive_Flag.heat_flag = 0;
}
// loader_mode
// if (_Interactive_data->Referee_Interactive_Flag.load_flag == 1)
// {
@ -294,6 +312,12 @@ static void UIChangeCheck(Referee_Interactive_info_t *_Interactive_data)
_Interactive_data->lid_last_mode = _Interactive_data->lid_mode;
}
if (_Interactive_data->heat_mode != _Interactive_data->heat_last_mode)
{
_Interactive_data->Referee_Interactive_Flag.heat_flag = 1;
_Interactive_data->heat_last_mode = _Interactive_data->heat_mode;
}
if (_Interactive_data->Chassis_Power_Data.chassis_power_mx != _Interactive_data->Chassis_last_Power_Data.chassis_power_mx)
{
_Interactive_data->Referee_Interactive_Flag.Power_flag = 1;

View File

@ -59,6 +59,7 @@ typedef struct
uint32_t aim_flag : 1;
uint32_t cap_flag : 1;
uint32_t load_flag : 1;
uint32_t heat_flag : 1;
} Referee_Interactive_Flag_t;
// 此结构体包含UI绘制与机器人车间通信的需要的其他非裁判系统数据
@ -74,6 +75,7 @@ typedef struct
Chassis_Power_Data_s Chassis_Power_Data; // 功率控制
uint8_t aim_fire; // 开火建议
loader_mode_e loader_mode; // 发射模式
heat_mode_e heat_mode; // 热量控制
Cap_Data_s Cap_Data; // 电容信息
// 上一次的模式用于flag判断
@ -85,6 +87,7 @@ typedef struct
Chassis_Power_Data_s Chassis_last_Power_Data;
uint8_t aim_last_fire;
loader_mode_e loader_last_mode;
heat_mode_e heat_last_mode;
Cap_Data_s Cap_last_Data;
} Referee_Interactive_info_t;

View File

@ -2,6 +2,7 @@
#define SUPER_CAP_H
#include "bsp_can.h"
#include "controller.h"
#pragma pack(1)
typedef struct
@ -18,12 +19,14 @@ typedef struct
{
CANInstance *can_ins; // CAN实例
SuperCap_Msg_s cap_msg; // 超级电容信息
PIDInstance buffer_pid; //
} SuperCapInstance;
/* 超级电容初始化配置 */
typedef struct
{
CAN_Init_Config_s can_config;
PID_Init_Config_s buffer_config_pid;
} SuperCap_Init_Config_s;
/**