绘制腿部五连杆

This commit is contained in:
kai
2024-05-24 22:05:40 +08:00
parent 03ae284fca
commit 346a0f4d70
3 changed files with 77 additions and 0 deletions

View File

@@ -453,6 +453,7 @@ static void CommNPower()
ui_data.chassis_mode = chassis_cmd_recv.chassis_mode;
ui_data.ui_mode = chassis_cmd_recv.ui_mode;
ui_data.vision_mode = chassis_cmd_recv.vision_mode;
memcpy(ui_data.coord, l_side.coord, sizeof(l_side.coord));
}
void BalanceTask()

View File

@@ -14,6 +14,7 @@
#include "referee_UI.h"
#include "string.h"
#include "cmsis_os.h"
#include "balance.h"
static Referee_Interactive_info_t *Interactive_data; // UI绘制需要的机器人状态数据
static referee_info_t *referee_recv_info; // 接收到的裁判系统数据
@@ -60,6 +61,13 @@ static String_Data_t UI_State_sta[6]; // 机器人状态,静态只需画一次
static String_Data_t UI_State_dyn[6]; // 机器人状态,动态先add才能change
static uint32_t shoot_line_location[10] = {540, 960, 600, 460, 420, 350};
#define Leg_X_Offset 1650
#define Leg_Y_Offset 500
#define Leg_Gain 500
static Graph_Data_t Leg_Graph_sta[2];
static Graph_Data_t Leg_Graph_dyn[6];
static uint32_t Processed_coord[6] = {1605, 455, 1695, 410, 1785, 455}; // Y坐标取反放大平移后的
void MyUIInit()
{
if (!referee_recv_info->init_flag)
@@ -120,6 +128,23 @@ void MyUIInit()
// 能量条初始状态
UILineDraw(&UI_Energy[2], "sd6", UI_Graph_ADD, 8, UI_Color_Pink, 30, 720, 160, 1020, 160);
UIGraphRefresh(&referee_recv_info->referee_id, 2, UI_Energy[1], UI_Energy[2]);
// 底盘方向--指示云台方向
UILineDraw(&Leg_Graph_sta[0], "ws0", UI_Graph_ADD, 9, UI_Color_Purplish_red, 4, 1700, 600, 1700, 705);
UIGraphRefresh(&referee_recv_info->referee_id, 1, Leg_Graph_sta[0]);
// 腿部运动,五连杆
UILineDraw(&Leg_Graph_dyn[1], "wd1", UI_Graph_ADD, 7, UI_Color_Yellow, 5,
0 + Leg_X_Offset, 0 + Leg_Y_Offset, (uint32_t)(JOINT_DISTANCE * Leg_Gain + Leg_X_Offset), 0 + Leg_Y_Offset); // 水平线
UILineDraw(&Leg_Graph_dyn[2], "wd2", UI_Graph_ADD, 7, UI_Color_Green, 5,
0 + Leg_X_Offset, 0 + Leg_Y_Offset, Processed_coord[0], Processed_coord[1]); // 左大腿
UILineDraw(&Leg_Graph_dyn[3], "wd3", UI_Graph_ADD, 7, UI_Color_Green, 5,
Processed_coord[0], Processed_coord[1], Processed_coord[2], Processed_coord[3]); // 左小腿
UILineDraw(&Leg_Graph_dyn[4], "wd4", UI_Graph_ADD, 7, UI_Color_Purplish_red, 5,
(uint32_t)(JOINT_DISTANCE * Leg_Gain + Leg_X_Offset), 0 + Leg_Y_Offset, Processed_coord[4], Processed_coord[5]); // 右大腿
UILineDraw(&Leg_Graph_dyn[5], "wd5", UI_Graph_ADD, 7, UI_Color_Purplish_red, 5,
Processed_coord[2], Processed_coord[3], Processed_coord[4], Processed_coord[5]); // 右小腿
UIGraphRefresh(&referee_recv_info->referee_id, 5, Leg_Graph_dyn[1], Leg_Graph_dyn[2], Leg_Graph_dyn[3], Leg_Graph_dyn[4], Leg_Graph_dyn[5]);
}
// 测试用函数,实现模式自动变化,用于检查该任务和裁判系统是否连接正常
@@ -262,6 +287,50 @@ static void MyUIRefresh(referee_info_t *referee_recv_info, Referee_Interactive_i
UIGraphRefresh(&referee_recv_info->referee_id, 2, UI_Energy[1], UI_Energy[2]);
_Interactive_data->Referee_Interactive_Flag.Power_flag = 0;
}
// 底盘方向
if (_Interactive_data->Referee_Interactive_Flag.direction_flag == 1)
{
switch (_Interactive_data->direction)
{
case CHASSIS_SIDLE:
{
UILineDraw(&Leg_Graph_dyn[0], "wd0", UI_Graph_Change, 9, UI_Color_Green, 7, 1700, 600, 1700, 700);
break;
}
case CHASSIS_ALIGN:
{
UILineDraw(&Leg_Graph_dyn[0], "wd0", UI_Graph_Change, 9, UI_Color_Green, 7, 1650, 600, 1750, 600);
break;
}
}
UIGraphRefresh(&referee_recv_info->referee_id, 1, Leg_Graph_dyn[0]);
_Interactive_data->Referee_Interactive_Flag.direction_flag = 0;
}
if (Processed_coord[0] != (uint32_t)(_Interactive_data->coord[0] * Leg_Gain + Leg_X_Offset))
{
Processed_coord[0] = (uint32_t)(_Interactive_data->coord[0] * Leg_Gain + Leg_X_Offset);
Processed_coord[1] = (uint32_t)(_Interactive_data->coord[1] * -Leg_Gain + Leg_Y_Offset);
Processed_coord[2] = (uint32_t)(_Interactive_data->coord[2] * Leg_Gain + Leg_X_Offset);
Processed_coord[3] = (uint32_t)(_Interactive_data->coord[3] * -Leg_Gain + Leg_Y_Offset);
Processed_coord[4] = (uint32_t)(_Interactive_data->coord[4] * Leg_Gain + Leg_X_Offset);
Processed_coord[5] = (uint32_t)(_Interactive_data->coord[5] * -Leg_Gain + Leg_Y_Offset);
// 腿部运动,五连杆,不需要检测变更,实时显示变化
UILineDraw(&Leg_Graph_dyn[2], "wd2", UI_Graph_Change, 7, UI_Color_Green, 5,
0 + Leg_X_Offset, 0 + Leg_Y_Offset, Processed_coord[0], Processed_coord[1]); // 左大腿
UILineDraw(&Leg_Graph_dyn[3], "wd3", UI_Graph_Change, 7, UI_Color_Green, 5,
Processed_coord[0], Processed_coord[1], Processed_coord[2], Processed_coord[3]); // 左小腿
UILineDraw(&Leg_Graph_dyn[4], "wd4", UI_Graph_Change, 7, UI_Color_Purplish_red, 5,
(uint32_t)(JOINT_DISTANCE * Leg_Gain + Leg_X_Offset), 0 + Leg_Y_Offset, Processed_coord[4], Processed_coord[5]); // 右大腿
UILineDraw(&Leg_Graph_dyn[5], "wd5", UI_Graph_Change, 7, UI_Color_Purplish_red, 5,
Processed_coord[2], Processed_coord[3], Processed_coord[4], Processed_coord[5]); // 右小腿
UIGraphRefresh(&referee_recv_info->referee_id, 5, Leg_Graph_dyn[1], Leg_Graph_dyn[2], Leg_Graph_dyn[3], Leg_Graph_dyn[4], Leg_Graph_dyn[5]);
}
}
/**
@@ -319,4 +388,10 @@ static void UIChangeCheck(Referee_Interactive_info_t *_Interactive_data)
_Interactive_data->Referee_Interactive_Flag.loader_flag = 1;
_Interactive_data->loader_last_mode = _Interactive_data->loader_mode;
}
if (_Interactive_data->direction != _Interactive_data->last_direction)
{
_Interactive_data->Referee_Interactive_Flag.direction_flag = 1;
_Interactive_data->last_direction = _Interactive_data->direction;
}
}

View File

@@ -74,6 +74,7 @@ typedef struct
vision_mode_e vision_mode; // 视觉状态
loader_mode_e loader_mode; // 拨盘模式
chassis_direction_e direction; // 对齐状态
float coord[6]; // 五连杆
// 上一次的模式用于flag判断
chassis_mode_e chassis_last_mode;