mirror of
https://gitee.com/dlmu-cone/bf_original_balance_chassis
synced 2026-07-23 19:25:09 +08:00
添加裁判系统串口,修复关节复位bug
This commit is contained in:
@@ -45,11 +45,14 @@ static PIDInstance anti_crash_pid; // 抗劈叉,将输出以相
|
|||||||
// 底盘状态
|
// 底盘状态
|
||||||
static Robot_Status_e chassis_status;
|
static Robot_Status_e chassis_status;
|
||||||
|
|
||||||
|
static referee_info_t* referee_data; // 用于获取裁判系统的数据
|
||||||
|
static Referee_Interactive_info_t ui_data; // UI数据,将底盘中的数据传入此结构体的对应变量中,UI会自动检测是否变化,对应显示UI
|
||||||
|
|
||||||
void BalanceInit()
|
void BalanceInit()
|
||||||
{
|
{
|
||||||
rc_data = RemoteControlInit(&huart3);
|
rc_data = RemoteControlInit(&huart3);
|
||||||
Chassis_IMU_data = INS_Init();
|
Chassis_IMU_data = INS_Init();
|
||||||
|
referee_data = UITaskInit(&huart6, &ui_data); // 裁判系统初始化,会同时初始化UI
|
||||||
|
|
||||||
// 关节电机
|
// 关节电机
|
||||||
Motor_Init_Config_s joint_conf = {
|
Motor_Init_Config_s joint_conf = {
|
||||||
@@ -197,7 +200,7 @@ static void ControlSwitch()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
chassis_cmd_recv.chassis_mode = CHASSIS_FREE_DEBUG; // 自由转动&前后
|
chassis_cmd_recv.chassis_mode = CHASSIS_FREE_DEBUG; // 自由转动&前后
|
||||||
chassis_cmd_recv.vx = 0.004 * (float)rc_data[TEMP].rc.rocker_r1; // speed x, unit m/s
|
chassis_cmd_recv.vx = 0.003 * (float)rc_data[TEMP].rc.rocker_r1; // speed x, unit m/s
|
||||||
chassis_cmd_recv.delta_leglen = -0.000001f * (float)rc_data[TEMP].rc.dial;
|
chassis_cmd_recv.delta_leglen = -0.000001f * (float)rc_data[TEMP].rc.dial;
|
||||||
chassis_cmd_recv.offset_angle -= 0.000005 * (float)rc_data[TEMP].rc.rocker_r_;
|
chassis_cmd_recv.offset_angle -= 0.000005 * (float)rc_data[TEMP].rc.rocker_r_;
|
||||||
}
|
}
|
||||||
@@ -219,14 +222,14 @@ static void ResetChassis()
|
|||||||
chassis_cmd_recv.offset_angle = chassis.target_yaw = chassis.yaw;
|
chassis_cmd_recv.offset_angle = chassis.target_yaw = chassis.yaw;
|
||||||
|
|
||||||
// 撞墙时前后移动保证能重新站立,执行速度输入
|
// 撞墙时前后移动保证能重新站立,执行速度输入
|
||||||
LKMotorSetRef(l_driven, chassis_cmd_recv.vx * 2);
|
LKMotorSetRef(l_driven, chassis_cmd_recv.vx + chassis_cmd_recv.rotate_w);
|
||||||
LKMotorSetRef(r_driven, -chassis_cmd_recv.vx * 2);
|
LKMotorSetRef(r_driven, -chassis_cmd_recv.vx + chassis_cmd_recv.rotate_w);
|
||||||
|
|
||||||
// 若关节完成复位,进入ready态
|
// 若关节完成复位,进入ready态
|
||||||
if (abs(lf->measure.total_angle) < 0.05 && abs(lf->measure.total_angle) > 0.03 &&
|
if (abs(lf->measure.total_angle) < 0.05 &&
|
||||||
abs(lb->measure.total_angle) < 0.05 && abs(lb->measure.total_angle) > 0.03 &&
|
abs(lb->measure.total_angle) < 0.05 &&
|
||||||
abs(rf->measure.total_angle) < 0.05 && abs(rf->measure.total_angle) > 0.03 &&
|
abs(rf->measure.total_angle) < 0.05 &&
|
||||||
abs(rb->measure.total_angle) < 0.05 && abs(rb->measure.total_angle) > 0.03)
|
abs(rb->measure.total_angle) < 0.05)
|
||||||
{
|
{
|
||||||
chassis_status = ROBOT_READY; // 底盘已经准备好重新站立
|
chassis_status = ROBOT_READY; // 底盘已经准备好重新站立
|
||||||
}
|
}
|
||||||
@@ -303,7 +306,6 @@ static void WokingStateSet()
|
|||||||
// TODO 最大dist误差限幅
|
// TODO 最大dist误差限幅
|
||||||
|
|
||||||
// TODO 最大速度误差限幅
|
// TODO 最大速度误差限幅
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
#define LIMIT_LINK_RAD 0.220039368 // 初始限位角度,见ParamAssemble
|
#define LIMIT_LINK_RAD 0.220039368 // 初始限位角度,见ParamAssemble
|
||||||
#define BALANCE_GRAVITY_BIAS 0
|
#define BALANCE_GRAVITY_BIAS 0
|
||||||
#define ROLL_GRAVITY_BIAS 0
|
#define ROLL_GRAVITY_BIAS 0
|
||||||
#define MAX_ACC_REF 0.8f
|
#define MAX_ACC_REF 0.9f
|
||||||
#define MAX_DIST_TRACK 1.0f
|
#define MAX_DIST_TRACK 1.0f
|
||||||
#define MAX_VEL_TRACK 0.5f
|
#define MAX_VEL_TRACK 0.5f
|
||||||
|
|
||||||
|
|||||||
@@ -88,16 +88,16 @@ typedef enum
|
|||||||
/* 命令码数据段长,根据官方协议来定义长度,还有自定义数据长度 */
|
/* 命令码数据段长,根据官方协议来定义长度,还有自定义数据长度 */
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
LEN_game_state = 3, // 0x0001
|
LEN_game_state = 11, // 0x0001
|
||||||
LEN_game_result = 1, // 0x0002
|
LEN_game_result = 1, // 0x0002
|
||||||
LEN_game_robot_HP = 2, // 0x0003
|
LEN_game_robot_HP = 32, // 0x0003
|
||||||
LEN_event_data = 4, // 0x0101
|
LEN_event_data = 4, // 0x0101
|
||||||
LEN_supply_projectile_action = 4, // 0x0102
|
LEN_supply_projectile_action = 4, // 0x0102
|
||||||
LEN_game_robot_state = 27, // 0x0201
|
LEN_game_robot_state = 13, // 0x0201
|
||||||
LEN_power_heat_data = 14, // 0x0202
|
LEN_power_heat_data = 16, // 0x0202
|
||||||
LEN_game_robot_pos = 16, // 0x0203
|
LEN_game_robot_pos = 16, // 0x0203
|
||||||
LEN_buff_musk = 1, // 0x0204
|
LEN_buff_musk = 6, // 0x0204
|
||||||
LEN_aerial_robot_energy = 1, // 0x0205
|
LEN_aerial_robot_energy = 2, // 0x0205
|
||||||
LEN_robot_hurt = 1, // 0x0206
|
LEN_robot_hurt = 1, // 0x0206
|
||||||
LEN_shoot_data = 7, // 0x0207
|
LEN_shoot_data = 7, // 0x0207
|
||||||
LEN_receive_data = 6 + Communicate_Data_LEN, // 0x0301
|
LEN_receive_data = 6 + Communicate_Data_LEN, // 0x0301
|
||||||
@@ -107,12 +107,13 @@ typedef enum
|
|||||||
/****************************接收数据的详细说明****************************/
|
/****************************接收数据的详细说明****************************/
|
||||||
/****************************接收数据的详细说明****************************/
|
/****************************接收数据的详细说明****************************/
|
||||||
|
|
||||||
/* ID: 0x0001 Byte: 3 比赛状态数据 */
|
/* ID: 0x0001 Byte: 11 比赛状态数据 */
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
uint8_t game_type : 4;
|
uint8_t game_type : 4;
|
||||||
uint8_t game_progress : 4;
|
uint8_t game_progress : 4;
|
||||||
uint16_t stage_remain_time;
|
uint16_t stage_remain_time;
|
||||||
|
uint64_t SyncTimeStamp;
|
||||||
} ext_game_state_t;
|
} ext_game_state_t;
|
||||||
|
|
||||||
/* ID: 0x0002 Byte: 1 比赛结果数据 */
|
/* ID: 0x0002 Byte: 1 比赛结果数据 */
|
||||||
@@ -157,37 +158,31 @@ typedef struct
|
|||||||
uint8_t supply_projectile_num;
|
uint8_t supply_projectile_num;
|
||||||
} ext_supply_projectile_action_t;
|
} ext_supply_projectile_action_t;
|
||||||
|
|
||||||
/* ID: 0X0201 Byte: 27 机器人状态数据 */
|
/* ID: 0X0201 Byte: 13 机器人状态数据 */
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
uint8_t robot_id;
|
uint8_t robot_id;
|
||||||
uint8_t robot_level;
|
uint8_t robot_level;
|
||||||
uint16_t remain_HP;
|
uint16_t current_HP;
|
||||||
uint16_t max_HP;
|
uint16_t maximum_HP;
|
||||||
uint16_t shooter_id1_17mm_cooling_rate;
|
uint16_t shooter_barrel_cooling_value;
|
||||||
uint16_t shooter_id1_17mm_cooling_limit;
|
uint16_t shooter_barrel_heat_limit;
|
||||||
uint16_t shooter_id1_17mm_speed_limit;
|
uint16_t chassis_power_limit;
|
||||||
uint16_t shooter_id2_17mm_cooling_rate;
|
uint8_t power_management_gimbal_output : 1;
|
||||||
uint16_t shooter_id2_17mm_cooling_limit;
|
uint8_t power_management_chassis_output : 1;
|
||||||
uint16_t shooter_id2_17mm_speed_limit;
|
uint8_t power_management_shooter_output : 1;
|
||||||
uint16_t shooter_id1_42mm_cooling_rate;
|
|
||||||
uint16_t shooter_id1_42mm_cooling_limit;
|
|
||||||
uint16_t shooter_id1_42mm_speed_limit;
|
|
||||||
uint16_t chassis_power_limit;
|
|
||||||
uint8_t mains_power_gimbal_output : 1;
|
|
||||||
uint8_t mains_power_chassis_output : 1;
|
|
||||||
uint8_t mains_power_shooter_output : 1;
|
|
||||||
} ext_game_robot_state_t;
|
} ext_game_robot_state_t;
|
||||||
|
|
||||||
/* ID: 0X0202 Byte: 14 实时功率热量数据 */
|
/* ID: 0X0202 Byte: 16 实时功率热量数据 */
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
uint16_t chassis_volt;
|
uint16_t chassis_voltage;
|
||||||
uint16_t chassis_current;
|
uint16_t chassis_current;
|
||||||
float chassis_power; // 瞬时功率
|
float chassis_power;
|
||||||
uint16_t chassis_power_buffer; // 60焦耳缓冲能量
|
uint16_t buffer_energy;
|
||||||
uint16_t shooter_heat0; // 17mm
|
uint16_t shooter_17mm_1_barrel_heat;
|
||||||
uint16_t shooter_heat1;
|
uint16_t shooter_17mm_2_barrel_heat;
|
||||||
|
uint16_t shooter_42mm_barrel_heat;
|
||||||
} ext_power_heat_data_t;
|
} ext_power_heat_data_t;
|
||||||
|
|
||||||
/* ID: 0x0203 Byte: 16 机器人位置数据 */
|
/* ID: 0x0203 Byte: 16 机器人位置数据 */
|
||||||
@@ -199,16 +194,21 @@ typedef struct
|
|||||||
float yaw;
|
float yaw;
|
||||||
} ext_game_robot_pos_t;
|
} ext_game_robot_pos_t;
|
||||||
|
|
||||||
/* ID: 0x0204 Byte: 1 机器人增益数据 */
|
/* ID: 0x0204 Byte: 6 机器人增益数据 */
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
uint8_t power_rune_buff;
|
uint8_t recovery_buff;
|
||||||
|
uint8_t cooling_buff;
|
||||||
|
uint8_t defence_buff;
|
||||||
|
uint8_t vulnerability_buff;
|
||||||
|
uint16_t attack_buff;
|
||||||
} ext_buff_musk_t;
|
} ext_buff_musk_t;
|
||||||
|
|
||||||
/* ID: 0x0205 Byte: 1 空中机器人能量状态数据 */
|
/* ID: 0x0205 Byte: 2 空中机器人能量状态数据 */
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
uint8_t attack_time;
|
uint8_t airforce_status;
|
||||||
|
uint8_t time_remain;
|
||||||
} aerial_robot_energy_t;
|
} aerial_robot_energy_t;
|
||||||
|
|
||||||
/* ID: 0x0206 Byte: 1 伤害状态数据 */
|
/* ID: 0x0206 Byte: 1 伤害状态数据 */
|
||||||
|
|||||||
Reference in New Issue
Block a user