Merge remote-tracking branch 'origin/master'

# Conflicts:
#	.vscode/launch.json
#	application/gimbal/gimbal.c
#	application/robot.c
#	bsp/usart/bsp_usart.c
#	bsp/usart/bsp_usart.h
#	modules/master_machine/master_process.c
#	modules/master_machine/seasky_protocol.c
This commit is contained in:
chenfu
2023-03-22 16:49:56 +08:00
44 changed files with 1877 additions and 602 deletions

View File

@@ -1,4 +1,10 @@
// app
#include "balance.h"
#include "vmc_project.h"
#include "gain_table.h"
#include "robot_def.h"
#include "general_def.h"
// module
#include "HT04.h"
#include "LK9025.h"
#include "bmi088.h"
@@ -6,9 +12,8 @@
#include "super_cap.h"
#include "controller.h"
#include "can_comm.h"
// standard
#include "stdint.h"
#include "robot_def.h"
#include "general_def.h"
#include "arm_math.h" // 需要用到较多三角函数
/* 底盘拥有的模块实例 */
@@ -47,7 +52,7 @@ static float T_leg_left, T_leg_right; // 左右驱动电机力矩
*
*/
static void CalcLQR()
{
{
}
/**
@@ -55,15 +60,15 @@ static void CalcLQR()
*
*/
static void VMCProject()
{
{ // 拟将功能封装到vmc_project.h中
}
/**
* @brief 腿部角度控制:转向和抗劈叉
*
*/
static PIDInstance swerving_pid;
static PIDInstance anti_crash_pid;
static PIDInstance swerving_pid; // 转向PID,有转向指令时使用IMU的加速度反馈积分以获取速度和位置状态量
static PIDInstance anti_crash_pid; // 抗劈叉,将输出以相反的方向叠加到左右腿的上
static void SynthesizeMotion()
{
@@ -73,15 +78,16 @@ static void SynthesizeMotion()
* @brief 腿长控制:长度 + roll轴补偿(保持机体水平),用PD模拟弹簧的传递函数
*
*/
static PIDInstance leg_length_pid;
static PIDInstance roll_compensate_pid;
static PIDInstance leg_length_pid; // 用PD模拟弹簧的传递函数,不需要积分项(弹簧是一个无积分的二阶系统),增益不可过大否则抗外界冲击响应时太"硬"
static PIDInstance roll_compensate_pid; // roll轴补偿,用于保持机体水平
static void LegControl()
{
}
/**
* @brief 离地监测和?跳跃控制
* @brief 离地监测和?跳跃控制?
* 通过模型解算地面的支持力完成离地检测
*
*/
static void FlyDetect()
@@ -89,7 +95,7 @@ static void FlyDetect()
}
/**
* @brief 功率限制
* @brief 功率限制,一般不需要
*
*/
static void WattLimit()
@@ -134,7 +140,7 @@ void BalanceInit()
.cali_mode = BMI088_CALIBRATE_ONLINE_MODE,
.work_mode = BMI088_BLOCK_PERIODIC_MODE,
};
imu = BMI088Register(&imu_config);
// imu = BMI088Register(&imu_config);
SuperCap_Init_Config_s cap_conf = {
// 超级电容初始化
@@ -162,10 +168,28 @@ void BalanceInit()
Motor_Init_Config_s driven_conf = {
// 写一个,剩下的修改方向和id即可
.can_init_config.can_handle = &hcan1,
.controller_param_init_config = {
.current_PID = {
.Kp = 1,
.Ki = 0,
.Kd = 0,
.MaxOut = 500,
},
},
.controller_setting_init_config = {
.angle_feedback_source = MOTOR_FEED,
.speed_feedback_source = MOTOR_FEED,
.outer_loop_type = CURRENT_LOOP,
.close_loop_type = CURRENT_LOOP,
},
.motor_type = LK9025,
};
driven_conf.can_init_config.tx_id=1;
l_driven = LKMotorInit(&driven_conf);
driven_conf.can_init_config.tx_id=2;
r_driven = LKMotorInit(&driven_conf);
CANComm_Init_Config_s chassis_comm_conf = {
@@ -224,6 +248,7 @@ void BalanceInit()
PIDInit(&roll_compensate_pid, &roll_compensate_pid_conf);
}
/* balanceTask可能需要以更高频率运行,以提高线性化的精确程度 */
void BalanceTask()
{
}

View File

@@ -2,13 +2,14 @@
#pragma once
#include "stdint.h"
#include "stm32f407xx.h"
#include "arm_math.h"
#include "math.h"
#define GAIN_TABLE_SIZE 100 // 增益表大小
// K 2x6,6个状态变量2个输出(Tp关节电机和T驱动轮电机)
static float leglen2gain [GAIN_TABLE_SIZE][2][6] = {};
static float leglen2gain [GAIN_TABLE_SIZE][2][6] = {0};
static interpolation_flag = 0; // 插值方式:1 线性插值 0 关闭插值

View File

@@ -0,0 +1,14 @@
#ifndef VMC_PROJECT_H
#define VMC_PROJECT_H
#include "stm32f407xx.h"
#include "arm_math.h"
#include "math.h"
#include "general_def.h"
// 将五连杆和直杆的vmc映射放在此处,方便修改和调试,balance.c不会太长
#endif // !VMC_PROJECT_H

View File

@@ -16,10 +16,16 @@
#include "dji_motor.h"
#include "super_cap.h"
#include "message_center.h"
// referee需要移动到module层
/////////////////////////
#include "referee.h"
#include "rm_referee.h"
/////////////////////////
#include "general_def.h"
#include "bsp_dwt.h"
#include "referee_UI.h"
#include "arm_math.h"
/* 根据robot_def.h中的macro自动计算的参数 */
@@ -41,7 +47,7 @@ static Subscriber_t *chassis_sub; // 用于订阅底盘的控
static Chassis_Ctrl_Cmd_s chassis_cmd_recv; // 底盘接收到的控制命令
static Chassis_Upload_Data_s chassis_feedback_data; // 底盘回传的反馈数据
static referee_info_t *referee_data; // 裁判系统数据
// static referee_info_t *referee_data; // 裁判系统相关数据
static SuperCapInstance *cap; // 超级电容
static DJIMotorInstance *motor_lf; // left right forward back
static DJIMotorInstance *motor_rf;
@@ -103,7 +109,11 @@ void ChassisInit()
chassis_motor_config.controller_setting_init_config.motor_reverse_flag = MOTOR_DIRECTION_REVERSE;
motor_rb = DJIMotorInit(&chassis_motor_config);
referee_data = RefereeInit(&huart6); // 裁判系统初始化
// referee_data = RefereeInit(&huart6); // 裁判系统初始化
// while (referee_data->GameRobotState.robot_id ==0);
// Referee_Interactive_init(referee_data);
SuperCap_Init_Config_s cap_conf = {
.can_config = {
@@ -240,12 +250,12 @@ void ChassisTask()
// 根据电机的反馈速度和IMU(如果有)计算真实速度
EstimateSpeed();
// 获取裁判系统数据
// 我方颜色id小于7是红色,大于7是蓝色,注意这里发送的是对方的颜色, 0:blue , 1:red
chassis_feedback_data.enemy_color = referee_data->GameRobotStat.robot_id > 7 ? 1 : 0;
// 当前只做了17mm热量的数据获取,后续根据robot_def中的宏切换双枪管和英雄42mm的情况
chassis_feedback_data.bullet_speed = referee_data->GameRobotStat.shooter_id1_17mm_speed_limit;
chassis_feedback_data.rest_heat = referee_data->PowerHeatData.shooter_heat0;
// // 获取裁判系统数据 建议将裁判系统与底盘分离,所以此处数据应使用消息中心发送
// // 我方颜色id小于7是红色,大于7是蓝色,注意这里发送的是对方的颜色, 0:blue , 1:red
// chassis_feedback_data.enemy_color = referee_data->GameRobotState.robot_id > 7 ? 1 : 0;
// // 当前只做了17mm热量的数据获取,后续根据robot_def中的宏切换双枪管和英雄42mm的情况
// chassis_feedback_data.bullet_speed = referee_data->GameRobotState.shooter_id1_17mm_speed_limit;
// chassis_feedback_data.rest_heat = referee_data->PowerHeatData.shooter_heat0;
// 推送反馈消息
#ifdef ONE_BOARD

View File

@@ -1,5 +1,7 @@
// app
#include "robot_def.h"
#include "robot_cmd.h"
// module
#include "remote_control.h"
#include "ins_task.h"
#include "master_process.h"

View File

@@ -70,7 +70,7 @@ void GimbalInit()
.DeadBand = 0.1,
.Improve = PID_Trapezoid_Intergral | PID_Integral_Limit |PID_Derivative_On_Measurement,
.IntegralLimit = 100,
.MaxOut = 500,
},
.speed_PID = {
@@ -144,6 +144,7 @@ void GimbalTask()
// 后续增加未收到数据的处理
SubGetMessage(gimbal_sub, &gimbal_cmd_recv);
// @todo:现在已不再需要电机反馈,实际上可以始终使用IMU的姿态数据来作为云台的反馈,yaw电机的offset只是用来跟随底盘
// 根据控制模式进行电机反馈切换和过渡,视觉模式在robot_cmd模块就已经设置好,gimbal只看yaw_ref和pitch_ref
switch (gimbal_cmd_recv.gimbal_mode)
{
@@ -153,7 +154,7 @@ void GimbalTask()
DJIMotorStop(pitch_motor);
break;
// 使用陀螺仪的反馈,底盘根据yaw电机的offset跟随云台或视觉模式采用
case GIMBAL_GYRO_MODE: // 后续只保留此模式
case GIMBAL_GYRO_MODE: // 后续只保留此模式
DJIMotorEnable(yaw_motor);
DJIMotorEnable(pitch_motor);
DJIMotorChangeFeed(yaw_motor, ANGLE_LOOP, OTHER_FEED);
@@ -178,6 +179,10 @@ void GimbalTask()
break;
}
// 在合适的地方添加pitch重力补偿前馈力矩
// 根据IMU姿态/pitch电机角度反馈计算出当前配重下的重力矩
// ...
// 设置反馈数据,主要是imu和yaw的ecd
gimbal_feedback_data.gimbal_imu_data = *gimba_IMU_data;
gimbal_feedback_data.yaw_motor_single_round_angle = yaw_motor->motor_measure.angle_single_round;

View File

@@ -0,0 +1,385 @@
/**
* @file referee.C
* @author kidneygood (you@domain.com)
* @brief
* @version 0.1
* @date 2022-11-18
*
* @copyright Copyright (c) 2022
*
*/
#include "referee.h"
#include "robot_def.h"
#include "rm_referee.h"
#include "referee_UI.h"
#include "referee_communication.h"
static Referee_Interactive_info_t Interactive_data; // 非裁判系统数据
static referee_info_t *referee_data; // 裁判系统相关数据
static robot_interactive_data_t *SendData;
static void determine_ID(referee_info_t *_referee_info);
static void My_UI_init(referee_info_t *_referee_info);
static void My_UI_Refresh(referee_info_t *_referee_info, Referee_Interactive_info_t *_Interactive_data);
static void Mode_Change_Check(Referee_Interactive_info_t *_Interactive_data); // 模式切换检测
//syhtod 正式上车后需删除
static void robot_mode_change(Referee_Interactive_info_t *_Interactive_data); // 测试用函数,实现模式自动变化
static void UI_test_init(referee_info_t *_referee_info);//UI测试函数
void Referee_Interactive_init()
{
referee_data = RefereeInit(&huart6); // 裁判系统初始化
while (referee_data->GameRobotState.robot_id == 0)
;
determine_ID(referee_data);
My_UI_init(referee_data);
//UI_test_init(referee_data);
for (int i=0;i<Communicate_Data_LEN;i++)
{
SendData->data[i]=i+1;
}
referee_data->referee_id.Receiver_Robot_ID = RobotID_BEngineer; // 机器人车间通信时接收者的ID暂时发给蓝色2
Communicate_SendData(&referee_data->referee_id,SendData);
}
void Referee_Interactive_task()
{
robot_mode_change(&Interactive_data); // 测试用函数,实现模式自动变化
My_UI_Refresh(referee_data, &Interactive_data);
}
static Graph_Data_t UI_shoot_line[10]; // 射击准线
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, 490, 515, 565};
static void My_UI_init(referee_info_t *_referee_info)
{
UI_Delete(&_referee_info->referee_id, UI_Data_Del_ALL, 0);
// 绘制发射基准线
Line_Draw(&UI_shoot_line[0], "sl0", UI_Graph_ADD, 7, UI_Color_White, 3, 710, shoot_line_location[0], 1210, shoot_line_location[0]);
Line_Draw(&UI_shoot_line[1], "sl1", UI_Graph_ADD, 7, UI_Color_White, 3, shoot_line_location[1], 340, shoot_line_location[1], 740);
Line_Draw(&UI_shoot_line[2], "sl2", UI_Graph_ADD, 7, UI_Color_Yellow, 2, 810, shoot_line_location[2], 1110, shoot_line_location[2]);
Line_Draw(&UI_shoot_line[3], "sl3", UI_Graph_ADD, 7, UI_Color_Yellow, 2, 810, shoot_line_location[3], 1110, shoot_line_location[3]);
Line_Draw(&UI_shoot_line[4], "sl4", UI_Graph_ADD, 7, UI_Color_Yellow, 2, 810, shoot_line_location[4], 1110, shoot_line_location[4]);
UI_ReFresh(&_referee_info->referee_id, 5, UI_shoot_line[0], UI_shoot_line[1], UI_shoot_line[2], UI_shoot_line[3], UI_shoot_line[4]);
// 绘制车辆状态标志,静态
Char_Draw(&UI_State_sta[0], "ss0", UI_Graph_ADD, 8, UI_Color_Main, 15, 2, 150, 750);
Char_Write(&UI_State_sta[0], "chassis:");
Char_ReFresh(&_referee_info->referee_id, UI_State_sta[0]);
Char_Draw(&UI_State_sta[1], "ss1", UI_Graph_ADD, 8, UI_Color_Yellow, 15, 2, 150, 700);
Char_Write(&UI_State_sta[1], "gimbal:");
Char_ReFresh(&_referee_info->referee_id, UI_State_sta[1]);
Char_Draw(&UI_State_sta[2], "ss2", UI_Graph_ADD, 8, UI_Color_Orange, 15, 2, 150, 650);
Char_Write(&UI_State_sta[2], "shoot:");
Char_ReFresh(&_referee_info->referee_id, UI_State_sta[2]);
Char_Draw(&UI_State_sta[3], "ss3", UI_Graph_ADD, 8, UI_Color_Pink, 15, 2, 150, 600);
Char_Write(&UI_State_sta[3], "frict:");
Char_ReFresh(&_referee_info->referee_id, UI_State_sta[3]);
Char_Draw(&UI_State_sta[4], "ss4", UI_Graph_ADD, 8, UI_Color_Pink, 15, 2, 150, 550);
Char_Write(&UI_State_sta[4], "lid:");
Char_ReFresh(&_referee_info->referee_id, UI_State_sta[4]);
// 底盘功率显示,静态
Char_Draw(&UI_State_sta[5], "ss5", UI_Graph_ADD, 8, UI_Color_Green, 18, 2, 720, 210);
Char_Write(&UI_State_sta[5], "Power:");
Char_ReFresh(&_referee_info->referee_id, UI_State_sta[5]);
// 绘制车辆状态标志,动态
// 由于初始化时xxx_last_mode默认为0所以此处对应UI也应该设为0时对应的UI防止模式不变的情况下无法置位flag导致UI无法刷新
Char_Draw(&UI_State_dyn[0], "sd0", UI_Graph_ADD, 8, UI_Color_Main, 15, 2, 270, 750);
Char_Write(&UI_State_dyn[0], "zeroforce");
Char_ReFresh(&_referee_info->referee_id, UI_State_dyn[0]);
Char_Draw(&UI_State_dyn[1], "sd1", UI_Graph_ADD, 8, UI_Color_Yellow, 15, 2, 270, 700);
Char_Write(&UI_State_dyn[1], "zeroforce");
Char_ReFresh(&_referee_info->referee_id, UI_State_dyn[1]);
Char_Draw(&UI_State_dyn[2], "sd2", UI_Graph_ADD, 8, UI_Color_Orange, 15, 2, 270, 650);
Char_Write(&UI_State_dyn[2], "off");
Char_ReFresh(&_referee_info->referee_id, UI_State_dyn[2]);
Char_Draw(&UI_State_dyn[3], "sd3", UI_Graph_ADD, 8, UI_Color_Pink, 15, 2, 270, 600);
Char_Write(&UI_State_dyn[3], "off");
Char_ReFresh(&_referee_info->referee_id, UI_State_dyn[3]);
Char_Draw(&UI_State_dyn[4], "sd4", UI_Graph_ADD, 8, UI_Color_Pink, 15, 2, 270, 550);
Char_Write(&UI_State_dyn[4], "open ");
Char_ReFresh(&_referee_info->referee_id, UI_State_dyn[4]);
// 底盘功率显示,动态
Char_Draw(&UI_State_dyn[5], "sd5", UI_Graph_ADD, 8, UI_Color_Green, 18, 2, 840, 210);
Char_Write(&UI_State_dyn[5], "0000");
Char_ReFresh(&_referee_info->referee_id, UI_State_dyn[5]);
}
static uint8_t count = 0;
static uint16_t count1 = 0;
static void robot_mode_change(Referee_Interactive_info_t *_Interactive_data) // 测试用函数,实现模式自动变化
{
count++;
if (count >= 50)
{
count = 0;
count1++;
}
switch (count1 % 4)
{
case 0:
{
_Interactive_data->chassis_mode = CHASSIS_ZERO_FORCE;
_Interactive_data->gimbal_mode = GIMBAL_ZERO_FORCE;
_Interactive_data->shoot_mode = SHOOT_ON;
_Interactive_data->friction_mode = FRICTION_ON;
_Interactive_data->lid_mode = LID_OPEN;
break;
}
case 1:
{
;
_Interactive_data->chassis_mode = CHASSIS_ROTATE;
_Interactive_data->gimbal_mode = GIMBAL_FREE_MODE;
_Interactive_data->shoot_mode = SHOOT_OFF;
_Interactive_data->friction_mode = FRICTION_OFF;
_Interactive_data->lid_mode = LID_CLOSE;
break;
}
case 2:
{
_Interactive_data->chassis_mode = CHASSIS_NO_FOLLOW;
_Interactive_data->gimbal_mode = GIMBAL_GYRO_MODE;
_Interactive_data->shoot_mode = SHOOT_ON;
_Interactive_data->friction_mode = FRICTION_ON;
_Interactive_data->lid_mode = LID_OPEN;
break;
}
case 3:
{
_Interactive_data->chassis_mode = CHASSIS_FOLLOW_GIMBAL_YAW;
_Interactive_data->gimbal_mode = GIMBAL_ZERO_FORCE;
_Interactive_data->shoot_mode = SHOOT_OFF;
_Interactive_data->friction_mode = FRICTION_OFF;
_Interactive_data->lid_mode = LID_CLOSE;
break;
}
default:
break;
}
}
static void My_UI_Refresh(referee_info_t *_referee_info, Referee_Interactive_info_t *_Interactive_data)
{
Mode_Change_Check(_Interactive_data);
// chassis
if (_Interactive_data->Referee_Interactive_Flag.chassis_flag == 1)
{
switch (_Interactive_data->chassis_mode)
{
case CHASSIS_ZERO_FORCE:
{
Char_Draw(&UI_State_dyn[0], "sd0", UI_Graph_Change, 8, UI_Color_Main, 15, 2, 270, 750);
Char_Write(&UI_State_dyn[0], "zeroforce");
break;
}
case CHASSIS_ROTATE:
{
Char_Draw(&UI_State_dyn[0], "sd0", UI_Graph_Change, 8, UI_Color_Main, 15, 2, 270, 750);
Char_Write(&UI_State_dyn[0], "rotate "); // 此处注意字数对齐问题,字数相同才能覆盖掉
break;
}
case CHASSIS_NO_FOLLOW:
{
Char_Draw(&UI_State_dyn[0], "sd0", UI_Graph_Change, 8, UI_Color_Main, 15, 2, 270, 750);
Char_Write(&UI_State_dyn[0], "nofollow ");
break;
}
case CHASSIS_FOLLOW_GIMBAL_YAW:
{
Char_Draw(&UI_State_dyn[0], "sd0", UI_Graph_Change, 8, UI_Color_Main, 15, 2, 270, 750);
Char_Write(&UI_State_dyn[0], "follow ");
break;
}
}
Char_ReFresh(&_referee_info->referee_id, UI_State_dyn[0]);
_Interactive_data->Referee_Interactive_Flag.chassis_flag = 0;
}
// gimbal
if (_Interactive_data->Referee_Interactive_Flag.gimbal_flag == 1)
{
switch (_Interactive_data->gimbal_mode)
{
case GIMBAL_ZERO_FORCE:
{
Char_Draw(&UI_State_dyn[1], "sd1", UI_Graph_Change, 8, UI_Color_Yellow, 15, 2, 270, 700);
Char_Write(&UI_State_dyn[1], "zeroforce");
break;
}
case GIMBAL_FREE_MODE:
{
Char_Draw(&UI_State_dyn[1], "sd1", UI_Graph_Change, 8, UI_Color_Yellow, 15, 2, 270, 700);
Char_Write(&UI_State_dyn[1], "free ");
break;
}
case GIMBAL_GYRO_MODE:
{
Char_Draw(&UI_State_dyn[1], "sd1", UI_Graph_Change, 8, UI_Color_Yellow, 15, 2, 270, 700);
Char_Write(&UI_State_dyn[1], "gyro ");
break;
}
}
Char_ReFresh(&_referee_info->referee_id, UI_State_dyn[1]);
_Interactive_data->Referee_Interactive_Flag.gimbal_flag = 0;
}
// shoot
if (_Interactive_data->Referee_Interactive_Flag.shoot_flag == 1)
{
switch (_Interactive_data->shoot_mode)
{
case SHOOT_OFF:
{
Char_Draw(&UI_State_dyn[2], "sd2", UI_Graph_Change, 8, UI_Color_Orange, 15, 2, 270, 650);
Char_Write(&UI_State_dyn[2], "off");
break;
}
case SHOOT_ON:
{
Char_Draw(&UI_State_dyn[2], "sd2", UI_Graph_Change, 8, UI_Color_Orange, 15, 2, 270, 650);
Char_Write(&UI_State_dyn[2], "on ");
break;
}
}
Char_ReFresh(&_referee_info->referee_id, UI_State_dyn[2]);
_Interactive_data->Referee_Interactive_Flag.shoot_flag = 0;
}
// friction
if (_Interactive_data->Referee_Interactive_Flag.friction_flag == 1)
{
switch (_Interactive_data->friction_mode)
{
case FRICTION_OFF:
{
Char_Draw(&UI_State_dyn[3], "sd3", UI_Graph_Change, 8, UI_Color_Pink, 15, 2, 270, 600);
Char_Write(&UI_State_dyn[3], "off");
break;
}
case FRICTION_ON:
{
Char_Draw(&UI_State_dyn[3], "sd3", UI_Graph_Change, 8, UI_Color_Pink, 15, 2, 270, 600);
Char_Write(&UI_State_dyn[3], "on ");
break;
}
}
Char_ReFresh(&_referee_info->referee_id, UI_State_dyn[3]);
_Interactive_data->Referee_Interactive_Flag.friction_flag = 0;
}
// lid
if (_Interactive_data->Referee_Interactive_Flag.lid_flag == 1)
{
switch (_Interactive_data->lid_mode)
{
case LID_CLOSE:
{
Char_Draw(&UI_State_dyn[4], "sd4", UI_Graph_Change, 8, UI_Color_Pink, 15, 2, 270, 550);
Char_Write(&UI_State_dyn[4], "close");
break;
}
case LID_OPEN:
{
Char_Draw(&UI_State_dyn[4], "sd4", UI_Graph_Change, 8, UI_Color_Pink, 15, 2, 270, 550);
Char_Write(&UI_State_dyn[4], "open ");
break;
}
}
Char_ReFresh(&_referee_info->referee_id, UI_State_dyn[4]);
_Interactive_data->Referee_Interactive_Flag.lid_flag = 0;
}
}
/**
* @brief 模式切换检测,模式发生切换时对flag置位
* @param Referee_Interactive_info_t *_Interactive_data
* @retval none
* @attention
*/
static void Mode_Change_Check(Referee_Interactive_info_t *_Interactive_data)
{
if (_Interactive_data->chassis_mode != _Interactive_data->chassis_last_mode)
{
_Interactive_data->Referee_Interactive_Flag.chassis_flag = 1;
_Interactive_data->chassis_last_mode = _Interactive_data->chassis_mode;
}
if (_Interactive_data->gimbal_mode != _Interactive_data->gimbal_last_mode)
{
_Interactive_data->Referee_Interactive_Flag.gimbal_flag = 1;
_Interactive_data->gimbal_last_mode = _Interactive_data->gimbal_mode;
}
if (_Interactive_data->shoot_mode != _Interactive_data->shoot_last_mode)
{
_Interactive_data->Referee_Interactive_Flag.shoot_flag = 1;
_Interactive_data->shoot_last_mode = _Interactive_data->shoot_mode;
}
if (_Interactive_data->friction_mode != _Interactive_data->friction_last_mode)
{
_Interactive_data->Referee_Interactive_Flag.friction_flag = 1;
_Interactive_data->friction_last_mode = _Interactive_data->friction_mode;
}
if (_Interactive_data->lid_mode != _Interactive_data->lid_last_mode)
{
_Interactive_data->Referee_Interactive_Flag.lid_flag = 1;
_Interactive_data->lid_last_mode = _Interactive_data->lid_mode;
}
}
/**
* @brief 判断各种ID选择客户端ID
* @param referee_info_t *_referee_info
* @retval none
* @attention
*/
static void determine_ID(referee_info_t *_referee_info)
{
// id小于7是红色,大于7是蓝色,0为红色1为蓝色 #define Robot_Red 0 #define Robot_Blue 1
_referee_info->referee_id.Robot_Color = _referee_info->GameRobotState.robot_id > 7 ? Robot_Blue : Robot_Red;
_referee_info->referee_id.Robot_ID = _referee_info->GameRobotState.robot_id;
_referee_info->referee_id.Cilent_ID = 0x0100 + _referee_info->referee_id.Robot_ID; // 计算客户端ID
_referee_info->referee_id.Receiver_Robot_ID = 0;
}
/* 测试用函数 */
static void UI_test_init(referee_info_t *_referee_info)
{
Graph_Data_t graph[5];
Graph_Data_t num[2];
String_Data_t sdata[1];
UI_Delete(&_referee_info->referee_id, UI_Data_Del_ALL, 0);
Line_Draw(&graph[0],"s0",UI_Graph_ADD,0,UI_Color_White,3,710,540,1210,540);
Rectangle_Draw(&graph[1],"s1",UI_Graph_ADD,0,UI_Color_Yellow,4,600,200,800,500);
Circle_Draw(&graph[2],"s2",UI_Graph_ADD,0,UI_Color_Green,5,960,540,100);
Elliptical_Draw(&graph[3],"s3",UI_Graph_ADD,0,UI_Color_Orange,3,960,540,100,20);
Arc_Draw(&graph[4],"s4",UI_Graph_ADD,0,UI_Color_Purplish_red,30,160,3,1200,550,50,100);
Float_Draw(&num[0],"s5",UI_Graph_ADD,0,UI_Color_Pink,50,3,5,1050,660,1245545);
Integer_Draw(&num[1],"s6",UI_Graph_ADD,0,UI_Color_Cyan,50,5,1050,460,12345);
UI_ReFresh(&_referee_info->referee_id,7,graph[0],graph[1],graph[2],graph[3],graph[4],num[0],num[1]);
Char_Draw(&sdata[0],"s7",UI_Graph_ADD,0,UI_Color_Green,20,2,620,710);
Char_Write(&sdata[0],"number:%d",123);
Char_ReFresh(&_referee_info->referee_id,sdata[0]);
}

View File

@@ -0,0 +1,50 @@
#ifndef REFEREE_H
#define REFEREE_H
#include "rm_referee.h"
#include "robot_def.h"
#pragma pack(1)
//模式是否切换标志位0为未切换1为切换static定义默认为0
typedef struct
{
uint32_t chassis_flag : 1;
uint32_t gimbal_flag : 1;
uint32_t shoot_flag : 1;
uint32_t lid_flag : 1;
uint32_t friction_flag : 1;
uint32_t Power_flag : 1;
} Referee_Interactive_Flag_t;
// 此结构体包含UI绘制与机器人车间通信的需要的其他非裁判系统数据
typedef struct
{
Referee_Interactive_Flag_t Referee_Interactive_Flag;
//为UI绘制以及交互数据所用
Robot_Status_e Robot_Status;// 机器人状态
App_Status_e App_Status;// 应用状态
chassis_mode_e chassis_mode;//底盘模式
gimbal_mode_e gimbal_mode;//云台模式
shoot_mode_e shoot_mode;//发射模式设置
friction_mode_e friction_mode;//摩擦轮关闭
lid_mode_e lid_mode;//弹舱盖打开
loader_mode_e loader_mode;//单发...连发
Chassis_Power_Data_s Chassis_Power_Data;// 功率控制
chassis_mode_e chassis_last_mode;//底盘模式
gimbal_mode_e gimbal_last_mode;//云台模式
shoot_mode_e shoot_last_mode;//发射模式设置
friction_mode_e friction_last_mode;//摩擦轮关闭
lid_mode_e lid_last_mode;//弹舱盖打开
} Referee_Interactive_info_t;
#pragma pack()
void Referee_Interactive_init(void);
void Referee_Interactive_task(void);
#endif // REFEREE_H

View File

@@ -0,0 +1,3 @@
# referee
需要将此模块移动到module层并新建一个rtos任务以一定频率运行用于ui刷新和多机通信

View File

@@ -10,6 +10,7 @@
#if defined(ONE_BOARD) || defined(CHASSIS_BOARD)
#include "chassis.h"
#include "referee.h"
#endif
#if defined(ONE_BOARD) || defined(GIMBAL_BOARD)
@@ -34,7 +35,8 @@ void RobotInit()
#endif
#if defined(ONE_BOARD) || defined(CHASSIS_BOARD)
ChassisInit();
// Referee_Interactive_init();
ChassisInit();
#endif
// 初始化完成,开启中断
__enable_irq();
@@ -50,5 +52,6 @@ void RobotTask()
#if defined(ONE_BOARD) || defined(CHASSIS_BOARD)
ChassisTask();
// Referee_Interactive_task();
#endif
}

View File

@@ -132,7 +132,6 @@ typedef enum
// 功率限制,从裁判系统获取
typedef struct
{ // 功率控制
} Chassis_Power_Data_s;
/* ----------------CMD应用发布的控制数据,应当由gimbal/chassis/shoot订阅---------------- */

View File

@@ -1,5 +1,6 @@
#include "shoot.h"
#include "robot_def.h"
#include "dji_motor.h"
#include "message_center.h"
#include "bsp_dwt.h"