This commit is contained in:
zyx 2024-05-18 04:51:00 +08:00
parent 019b4d07d3
commit dbb0042275
15 changed files with 10640 additions and 10743 deletions

View File

@ -91,7 +91,7 @@ void ChassisInit() {
.speed_feedback_source = MOTOR_FEED,
.outer_loop_type = SPEED_LOOP,
.close_loop_type = SPEED_LOOP, // CURRENT_LOOP,
.power_limit_flag = NO_POWER_LIMIT,
.power_limit_flag = POWER_LIMIT_ON,
},
.motor_type = M3508,
};
@ -194,7 +194,7 @@ static void OmniCalculate() {
static const float motor_power_K[3] = {1.6301e-6f,5.7501e-7f,2.5863e-7f};
float input;
float P_max;
float P_max = 0;
///依据3508电机功率模型预测电机输出功率
static float EstimatePower(DJIMotorInstance* chassis_motor)
@ -237,8 +237,8 @@ static void LimitChassisOutput()
}
float K = P_max / P_cmd;
if(chassis_cmd_recv.buffer_energy<5)//当缓冲功率过小时,限制功率给小;
K = (float)(chassis_cmd_recv.chassis_power_limit - 3) / P_cmd;
// if(chassis_cmd_recv.buffer_energy<5)//当缓冲功率过小时,限制功率给小;
// K = (float)(chassis_cmd_recv.chassis_power_limit - 3) / P_cmd;
motor_rf->motor_controller.motor_power_scale = K;
motor_rb->motor_controller.motor_power_scale = K;
motor_lf->motor_controller.motor_power_scale = K;
@ -253,14 +253,13 @@ static void LimitChassisOutput()
}
/**
* @brief
* @brief
*
*
*/
static void SuperCapSetUpdate()
{
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);

View File

@ -403,39 +403,28 @@ static void MouseKeySet() {
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键切换发射模式
{
case 0:
loader_flag = 0;
break;
case 1:
loader_flag = 1;
break;
default:
loader_flag = 3;
chassis_cmd_send.chassis_mode = CHASSIS_SIDEWAYS;
break;
}
// switch (rc_data[TEMP].key_count[KEY_PRESS][Key_G] % 3) // G键切换发射模式
// {
// case 0:
// loader_flag = 0;
// break;
// case 1:
// loader_flag = 1;
// break;
// default:
// loader_flag = 3;
// break;
// }
switch (rc_data[TEMP].key[KEY_PRESS].shift) //按shift允许消耗超级电容能量
{
case 0:
chassis_cmd_send.buffer_supercap = 0;
chassis_cmd_send.buffer_supercap = 5;
break;
default:
case 1:
chassis_cmd_send.buffer_supercap = 195;
break;
}
@ -454,7 +443,7 @@ static void MouseKeySet() {
*/
static void VTMouseKeySet()
{
chassis_cmd_send.vy = vt_data[TEMP].key[KEY_PRESS].w * 3000 - vt_data[TEMP].key[KEY_PRESS].s * 3000; // 系数待测
chassis_cmd_send.vy = vt_data[TEMP].key[KEY_PRESS].w * 6000 - vt_data[TEMP].key[KEY_PRESS].s * 6000; // 系数待测 小 3000 3000
chassis_cmd_send.vx = vt_data[TEMP].key[KEY_PRESS].a * 3000 - vt_data[TEMP].key[KEY_PRESS].d * 3000;
gimbal_cmd_send.yaw -= (float) vt_data[TEMP].mouse.x / 660 * 4; // 系数待测
@ -543,10 +532,10 @@ static void VTMouseKeySet()
// gimbal_cmd_send.gimbal_mode = GIMBAL_GYRO_MODE;
// break;
// }
switch (rc_data[TEMP].key_count[KEY_PRESS][Key_C] % 2) // C键侧向
switch (vt_data[TEMP].key_count[KEY_PRESS][Key_C] % 2) // C键侧向
{
case 0:
switch (rc_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;
@ -558,19 +547,8 @@ static void VTMouseKeySet()
break;
}
break;
default:
case 1:
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键开关热控
@ -582,33 +560,24 @@ static void VTMouseKeySet()
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;
break;
default:
chassis_cmd_send.chassis_mode = CHASSIS_SIDEWAYS;
break;
}
switch (rc_data[TEMP].key_count[KEY_PRESS][Key_G] % 3) // G键切换发射模式
{
case 0:
loader_flag = 0;
break;
case 1:
loader_flag = 1;
break;
default:
loader_flag = 3;
break;
}
// switch (rc_data[TEMP].key_count[KEY_PRESS][Key_G] % 3) // G键切换发射模式
// {
// case 0:
// loader_flag = 0;
// break;
// case 1:
// loader_flag = 1;
// break;
// default:
// loader_flag = 3;
// break;
// }
switch (vt_data[TEMP].key[KEY_PRESS].shift) //按shift允许消耗超级电容能量
{
case 0:
chassis_cmd_send.buffer_supercap = 0;
chassis_cmd_send.buffer_supercap = 5;
break;
default:
case 1:
chassis_cmd_send.buffer_supercap = 195;
break;
}

View File

@ -26,7 +26,7 @@
/* 机器人重要参数定义,注意根据不同机器人进行修改,浮点数需要以.0或f结尾,无符号以u结尾 */
// 云台参数
#define YAW_CHASSIS_ALIGN_ECD 1443 // 小 1443 大2053 // 云台和底盘对齐指向相同方向时的电机编码器值,若对云台有机械改动需要修改
#define YAW_CHASSIS_ALIGN_ECD 2053 // 小 1443 大2053 // 云台和底盘对齐指向相同方向时的电机编码器值,若对云台有机械改动需要修改
#define YAW_ECD_GREATER_THAN_4096 0 // ALIGN_ECD值是否大于4096,是为1,否为0;用于计算云台偏转角度
#define PITCH_HORIZON_ECD 4422 // 云台处于水平位置时编码器值,若对云台有机械改动需要修改
#define PITCH_MAX_ANGLE 25 // 云台竖直方向最大角度 (注意反馈如果是陀螺仪,则填写陀螺仪的角度)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -81,7 +81,7 @@ void MyUIInit()
UILineDraw(&UI_shoot_line[1], "sl1", UI_Graph_ADD, 7, UI_Color_White, 3, shoot_line_location[1], 340, shoot_line_location[1], 740);
UILineDraw(&UI_shoot_line[2], "sl2", UI_Graph_ADD, 7, UI_Color_Yellow, 2, 810, shoot_line_location[2], 1110, shoot_line_location[2]);
UILineDraw(&UI_shoot_line[3], "sl3", UI_Graph_ADD, 7, UI_Color_Orange, 2, 960, 200, 960, 600);
UICircleDraw(&UI_shoot_yuan[0],"sy0",UI_Graph_ADD,7,UI_Color_Yellow,2,960,540,10);
UICircleDraw(&UI_shoot_yuan[0],"sy0",UI_Graph_ADD,7,UI_Color_Yellow,2,960,540,80);
UIGraphRefresh(&referee_recv_info->referee_id, 5, UI_shoot_line[0], UI_shoot_line[1], UI_shoot_line[2], UI_shoot_line[3],UI_shoot_yuan[0]);
// 绘制车辆状态标志指示,静态
@ -109,7 +109,7 @@ void MyUIInit()
UICharRefresh(&referee_recv_info->referee_id, UI_prompt_sta[1]);
// 底盘功率显示,静态
UICharDraw(&UI_State_sta[6], "ss6", UI_Graph_ADD, 8, UI_Color_Green, 18, 2, 620, 230, "Power_MAX:");
UICharDraw(&UI_State_sta[6], "ss6", UI_Graph_ADD, 8, UI_Color_Green, 18, 2, 620, 230, "MAX:");
UICharRefresh(&referee_recv_info->referee_id, UI_State_sta[6]);
// 绘制车辆状态标志,动态
@ -132,8 +132,8 @@ void MyUIInit()
// UICharRefresh(&referee_recv_info->referee_id, UI_State_dyn[5]);
// 能量条框
UIRectangleDraw(&UI_Energy[0], "ss6", UI_Graph_ADD, 7, UI_Color_Green, 2, 720, 140, 1220, 180);
UIGraphRefresh(&referee_recv_info->referee_id, 1, UI_Energy[0]);
// UIRectangleDraw(&UI_Energy[0], "ss6", UI_Graph_ADD, 7, UI_Color_Green, 2, 720, 140, 1220, 180);
// UIGraphRefresh(&referee_recv_info->referee_id, 1, UI_Energy[0]);
// 底盘功率显示,动态
UIFloatDraw(&UI_Energy[1], "sd6", UI_Graph_ADD, 8, UI_Color_Green, 18, 2, 2, 850, 230, Interactive_data->Chassis_Power_Data.chassis_power_mx * 1000);
@ -143,8 +143,8 @@ void MyUIInit()
UIFloatDraw(&UI_Energy[2], "sd7", UI_Graph_ADD, 8, UI_Color_Pink, 18, 2,2, 850, 280,Interactive_data->Cap_Data.cap_vol);
UIGraphRefresh(&referee_recv_info->referee_id, 1, UI_Energy[2]);
// 电容能量条
UILineDraw(&UI_Energy[3], "sd8", UI_Graph_ADD, 8, UI_Color_Pink, 30, 720, 160, (uint32_t)(720 + (Interactive_data->Cap_Data.cap_vol-1200) * 0.416), 160);
UIGraphRefresh(&referee_recv_info->referee_id, 1, UI_Energy[3]);
// UILineDraw(&UI_Energy[3], "sd8", UI_Graph_ADD, 8, UI_Color_Pink, 30, 720, 160, (uint32_t)(720 + (Interactive_data->Cap_Data.cap_vol-1200) * 0.416), 160);
// UIGraphRefresh(&referee_recv_info->referee_id, 1, UI_Energy[3]);
// 发弹量条框
UILineDraw(&UI_Energy[4], "ss7", UI_Graph_ADD, 7, UI_Color_Pink, 2, 1325, 500, 1480, 500);
@ -264,11 +264,11 @@ static void MyUIRefresh(referee_info_t *referee_recv_info, Referee_Interactive_i
}
UIFloatDraw(&UI_Energy[2], "sd7", UI_Graph_Change, 8, UI_Color_Pink, 18, 2,2, 850, 280,Interactive_data->Cap_Data.cap_vol);
UIGraphRefresh(&referee_recv_info->referee_id, 1,UI_Energy[2]);
UILineDraw(&UI_Energy[3], "sd8", UI_Graph_Change, 8, UI_Color_Pink, 30, 720, 160, (uint32_t)(720 + (Interactive_data->Cap_Data.cap_vol-1200) * 0.416), 160);
UIGraphRefresh(&referee_recv_info->referee_id, 1, &UI_Energy[3]);
// UILineDraw(&UI_Energy[3], "sd8", UI_Graph_Change, 8, UI_Color_Pink, 30, 720, 160, (uint32_t)(720 + (Interactive_data->Cap_Data.cap_vol-1200) * 0.416), 160);
// UIGraphRefresh(&referee_recv_info->referee_id, 1, &UI_Energy[3]);
//绘制开火建议
if (_Interactive_data->Referee_Interactive_Flag.aim_flag == 1) {
UICircleDraw(&UI_shoot_yuan[0], "sy0", UI_Graph_Change, 7, _Interactive_data->aim_fire == 0 ? UI_Color_Yellow : UI_Color_Main, 2, 960, 540, 10);
UICircleDraw(&UI_shoot_yuan[0], "sy0", UI_Graph_Change, 7, _Interactive_data->aim_fire == 0 ? UI_Color_Yellow : UI_Color_Main, 2, 960, 540, 80);
UIGraphRefresh(&referee_recv_info->referee_id, 1, UI_shoot_yuan[0]);
_Interactive_data->Referee_Interactive_Flag.aim_flag = 0;
}

View File

@ -24,6 +24,8 @@ SuperCapInstance *SuperCapInit(SuperCap_Init_Config_s *supercap_config)
supercap_config->can_config.can_module_callback = SuperCapRxCallback;
super_cap_instance->can_ins = CANRegister(&supercap_config->can_config);
PIDInit(&super_cap_instance->buffer_pid, &supercap_config->buffer_config_pid);
return super_cap_instance;
}

View File

@ -17,9 +17,9 @@ typedef struct
/* 超级电容实例 */
typedef struct
{
CANInstance *can_ins; // CAN实例
CANInstance *can_ins; // CAN实例
SuperCap_Msg_s cap_msg; // 超级电容信息
PIDInstance buffer_pid; //
PIDInstance buffer_pid; // 对缓冲功率进行闭环
} SuperCapInstance;
/* 超级电容初始化配置 */

View File

@ -33,7 +33,7 @@ void OnProjectLoad (void) {
//
// User settings
//
Edit.SysVar (VAR_HSS_SPEED, FREQ_500_HZ);
Edit.SysVar (VAR_HSS_SPEED, FREQ_200_HZ);
Project.SetOSPlugin ("FreeRTOSPlugin_CM4");
File.Open ("$(ProjectDir)/cmake-build-debug/basic_framework.elf");
}

View File

@ -1,30 +1,25 @@
OpenDocument="main.c", FilePath="D:/zhandui/cqdm/bubing_9/Src/main.c", Line=65
OpenDocument="robot_cmd.c", FilePath="D:/zhandui/cqdm/bubing_9/application/cmd/robot_cmd.c", Line=120
OpenDocument="referee_task.c", FilePath="D:/zhandui/cqdm/bubing_9/modules/referee/referee_task.c", Line=251
OpenDocument="tasks.c", FilePath="D:/zhandui/cqdm/bubing_9/Middlewares/Third_Party/FreeRTOS/Source/tasks.c", Line=3418
OpenDocument="gimbal.c", FilePath="D:/zhandui/cqdm/bubing_9/application/gimbal/gimbal.c", Line=0
OpenDocument="chassis.c", FilePath="D:/zhandui/cqdm/bubing_9/application/chassis/chassis.c", Line=87
OpenDocument="shoot.c", FilePath="D:/zhandui/cqdm/bubing_9/application/shoot/shoot.c", Line=191
OpenDocument="super_cap.c", FilePath="D:/zhandui/cqdm/bubing_9/modules/super_cap/super_cap.c", Line=0
GraphedExpression="P_max", Color=#e56a6f, Show=0
OpenDocument="chassis.c", FilePath="D:/zhandui/cqdm/xiaojing/application/chassis/chassis.c", Line=243
OpenDocument="robot_cmd.c", FilePath="D:/zhandui/cqdm/xiaojing/application/cmd/robot_cmd.c", Line=396
OpenDocument="main.c", FilePath="D:/zhandui/cqdm/xiaojing/Src/main.c", Line=65
OpenToolbar="Debug", Floating=0, x=0, y=0
OpenWindow="Source Files", DockArea=LEFT, x=0, y=0, w=735, h=506, FilterBarShown=0, TotalValueBarShown=0, ToolBarShown=0
OpenWindow="Memory 1", DockArea=BOTTOM, x=3, y=0, w=490, h=384, FilterBarShown=0, TotalValueBarShown=0, ToolBarShown=0, EditorAddress=0x30A3D70C
OpenWindow="Watched Data 1", DockArea=LEFT, x=0, y=1, w=735, h=550, FilterBarShown=0, TotalValueBarShown=0, ToolBarShown=0
OpenWindow="Terminal", DockArea=BOTTOM, x=0, y=0, w=1023, h=384, FilterBarShown=0, TotalValueBarShown=0, ToolBarShown=0
OpenWindow="Data Sampling", DockArea=BOTTOM, x=2, y=0, w=1151, h=384, FilterBarShown=0, TotalValueBarShown=0, ToolBarShown=0, VisibleTab=0, UniformSampleSpacing=0
OpenWindow="Timeline", DockArea=RIGHT, x=0, y=0, w=1541, h=1057, FilterBarShown=0, TotalValueBarShown=0, ToolBarShown=1, DataPaneShown=1, PowerPaneShown=0, CodePaneShown=0, PinCursor="Cursor Movable", TimePerDiv="2 s / Div", TimeStampFormat="Time", DataGraphDrawAsPoints=0, DataGraphLegendShown=1, DataGraphUniformSampleSpacing=0, DataGraphLegendPosition="0;861", DataGraphShowNamesAtCursor=0, PowerGraphDrawAsPoints=0, PowerGraphLegendShown=0, PowerGraphAvgFilterTime=Off, PowerGraphAvgFilterLen=Off, PowerGraphUniformSampleSpacing=0, PowerGraphLegendPosition="1314;-69", CodeGraphLegendShown=0, CodeGraphLegendPosition="1330;0"
OpenWindow="Console", DockArea=BOTTOM, x=1, y=0, w=213, h=384, FilterBarShown=0, TotalValueBarShown=0, ToolBarShown=0
OpenWindow="Source Files", DockArea=LEFT, x=0, y=0, w=735, h=499, FilterBarShown=0, TotalValueBarShown=0, ToolBarShown=0
OpenWindow="Memory 1", DockArea=BOTTOM, x=3, y=0, w=435, h=384, FilterBarShown=0, TotalValueBarShown=0, ToolBarShown=0, EditorAddress=0x30A3D70C
OpenWindow="Watched Data 1", DockArea=LEFT, x=0, y=1, w=735, h=537, FilterBarShown=0, TotalValueBarShown=0, ToolBarShown=0
OpenWindow="Terminal", DockArea=BOTTOM, x=0, y=0, w=581, h=384, FilterBarShown=0, TotalValueBarShown=0, ToolBarShown=0
OpenWindow="Data Sampling", DockArea=BOTTOM, x=2, y=0, w=1023, h=384, FilterBarShown=0, TotalValueBarShown=0, ToolBarShown=0, VisibleTab=0, UniformSampleSpacing=0
OpenWindow="Timeline", DockArea=RIGHT, x=0, y=0, w=1123, h=1037, FilterBarShown=0, TotalValueBarShown=0, ToolBarShown=1, DataPaneShown=1, PowerPaneShown=0, CodePaneShown=0, PinCursor="Cursor Movable", TimePerDiv="2 s / Div", TimeStampFormat="Time", DataGraphDrawAsPoints=0, DataGraphLegendShown=1, DataGraphUniformSampleSpacing=0, DataGraphLegendPosition="0;822", DataGraphShowNamesAtCursor=0, PowerGraphDrawAsPoints=0, PowerGraphLegendShown=0, PowerGraphAvgFilterTime=Off, PowerGraphAvgFilterLen=Off, PowerGraphUniformSampleSpacing=0, PowerGraphLegendPosition="896;-69", CodeGraphLegendShown=0, CodeGraphLegendPosition="912;0"
OpenWindow="Console", DockArea=BOTTOM, x=1, y=0, w=518, h=384, FilterBarShown=0, TotalValueBarShown=0, ToolBarShown=0
SmartViewPlugin="", Page="", Toolbar="Hidden", Window="SmartView 1"
TableHeader="Source Files", SortCol="File", SortOrder="ASCENDING", VisibleCols=["File";"Status";"Size";"#Insts";"Path"], ColWidths=[263;100;100;100;950]
TableHeader="Data Sampling Table", SortCol="None", SortOrder="ASCENDING", VisibleCols=["Index";"Time"], ColWidths=[100;100]
TableHeader="Data Sampling Setup", SortCol="Expression", SortOrder="ASCENDING", VisibleCols=["Expression";"Type";"Value";"Min";"Max";"Average";"# Changes";"Min. Change";"Max. Change"], ColWidths=[438;100;100;100;100;100;110;126;126]
TableHeader="Data Sampling Table", SortCol="None", SortOrder="ASCENDING", VisibleCols=["Index";"Time";" P_max"], ColWidths=[100;100;100]
TableHeader="Data Sampling Setup", SortCol="Expression", SortOrder="ASCENDING", VisibleCols=["Expression";"Type";"Value";"Min";"Max";"Average";"# Changes";"Min. Change";"Max. Change"], ColWidths=[438;100;100;154;164;100;110;126;126]
TableHeader="Power Sampling", SortCol="None", SortOrder="ASCENDING", VisibleCols=["Index";"Time";"Ch 0"], ColWidths=[100;100;100]
TableHeader="Task List", SortCol="None", SortOrder="ASCENDING", VisibleCols=["Name";"Run Count";"Priority";"Status";"Timeout";"Stack Info";"ID";"Mutex Count";"Notified Value";"Notify State"], ColWidths=[110;110;110;110;110;110;110;110;110;110]
TableHeader="Watched Data 1", SortCol="Expression", SortOrder="ASCENDING", VisibleCols=["Expression";"Value";"Location";"Refresh"], ColWidths=[238;149;104;218]
TableHeader="Watched Data 1", SortCol="Expression", SortOrder="ASCENDING", VisibleCols=["Expression";"Value";"Location";"Refresh"], ColWidths=[238;149;104;244]
TableHeader="RegisterSelectionDialog", SortCol="None", SortOrder="ASCENDING", VisibleCols=[], ColWidths=[]
TableHeader="TargetExceptionDialog", SortCol="Name", SortOrder="ASCENDING", VisibleCols=["Name";"Value";"Address";"Description"], ColWidths=[27;27;27;26]
WatchedExpression="yaw_motor", RefreshRate=2, Window=Watched Data 1
WatchedExpression="pitch_motor", RefreshRate=2, Window=Watched Data 1
WatchedExpression="motor_rf", RefreshRate=2, Window=Watched Data 1
@ -42,4 +37,7 @@ WatchedExpression="shoot_cmd_recv", RefreshRate=5, Window=Watched Data 1
WatchedExpression="gimba_IMU_data", RefreshRate=2, Window=Watched Data 1
WatchedExpression="vt_data", RefreshRate=2, Window=Watched Data 1
WatchedExpression="ui_data", RefreshRate=2, Window=Watched Data 1
WatchedExpression="Interactive_data", RefreshRate=2, Window=Watched Data 1
WatchedExpression="Interactive_data", RefreshRate=2, Window=Watched Data 1
WatchedExpression="chassis_cmd_send", Window=Watched Data 1
WatchedExpression="P_max", RefreshRate=2, Window=Watched Data 1
WatchedExpression="cap", RefreshRate=2, Window=Watched Data 1