细化UI,回退pitch限位为不可上坡的
This commit is contained in:
parent
7a85fdf4c2
commit
202afc84bb
|
@ -189,7 +189,7 @@ static void LimitChassisOutput()
|
||||||
// motor_rb->motor_controller.motor_power_predict +
|
// motor_rb->motor_controller.motor_power_predict +
|
||||||
// motor_lb->motor_controller.motor_power_predict +
|
// motor_lb->motor_controller.motor_power_predict +
|
||||||
// motor_lf->motor_controller.motor_power_predict + 3.6f;
|
// motor_lf->motor_controller.motor_power_predict + 3.6f;
|
||||||
float P_max = 60 - 10;
|
float P_max = 55;
|
||||||
float K = P_max/P_cmdall;
|
float K = P_max/P_cmdall;
|
||||||
|
|
||||||
|
|
||||||
|
@ -261,7 +261,7 @@ void ChassisTask()
|
||||||
chassis_cmd_recv.wz = -2000;
|
chassis_cmd_recv.wz = -2000;
|
||||||
break;
|
break;
|
||||||
case CHASSIS_ROTATE: // 自旋,同时保持全向机动;当前wz维持定值,后续增加不规则的变速策略
|
case CHASSIS_ROTATE: // 自旋,同时保持全向机动;当前wz维持定值,后续增加不规则的变速策略
|
||||||
chassis_cmd_recv.wz = 1600;
|
chassis_cmd_recv.wz = 2300;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -129,10 +129,12 @@ static void update_ui_data()
|
||||||
}
|
}
|
||||||
static void pitch_limit()
|
static void pitch_limit()
|
||||||
{
|
{
|
||||||
if(gimbal_fetch_data.pitch_motor_total_angle > horizontal_angle + 1500)
|
// if(gimbal_fetch_data.pitch_motor_total_angle > horizontal_angle + 1500)
|
||||||
gimbal_cmd_send.pitch -= 0.1f;
|
// gimbal_cmd_send.pitch -= 0.1f;
|
||||||
if(gimbal_fetch_data.pitch_motor_total_angle < horizontal_angle - 4000)
|
// if(gimbal_fetch_data.pitch_motor_total_angle < horizontal_angle - 4000)
|
||||||
gimbal_cmd_send.pitch += 0.1f;
|
// gimbal_cmd_send.pitch += 0.1f;
|
||||||
|
if(gimbal_cmd_send.pitch>18) gimbal_cmd_send.pitch = 18;
|
||||||
|
if(gimbal_cmd_send.pitch<-38) gimbal_cmd_send.pitch = -38;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief 控制输入为遥控器(调试时)的模式和控制量设置
|
* @brief 控制输入为遥控器(调试时)的模式和控制量设置
|
||||||
|
@ -149,7 +151,7 @@ static void RemoteControlSet()
|
||||||
}
|
}
|
||||||
else if (switch_is_mid(rc_data[TEMP].rc.switch_right)) // 右侧开关状态[中],底盘跟随云台
|
else if (switch_is_mid(rc_data[TEMP].rc.switch_right)) // 右侧开关状态[中],底盘跟随云台
|
||||||
{
|
{
|
||||||
chassis_cmd_send.chassis_mode = CHASSIS_FOLLOW_GIMBAL_YAW;
|
chassis_cmd_send.chassis_mode = CHASSIS_NO_FOLLOW;
|
||||||
gimbal_cmd_send.gimbal_mode = GIMBAL_FREE_MODE;
|
gimbal_cmd_send.gimbal_mode = GIMBAL_FREE_MODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,6 +233,7 @@ static void RemoteControlSet()
|
||||||
else
|
else
|
||||||
shoot_cmd_send.load_mode = LOAD_STOP;
|
shoot_cmd_send.load_mode = LOAD_STOP;
|
||||||
// 射频控制,固定每秒1发,后续可以根据左侧拨轮的值大小切换射频,
|
// 射频控制,固定每秒1发,后续可以根据左侧拨轮的值大小切换射频,
|
||||||
|
shoot_cmd_send.shoot_rate = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -260,7 +263,10 @@ static void MouseKeySet()
|
||||||
switch (rc_data[TEMP].mouse.press_l) // 左键发射模式
|
switch (rc_data[TEMP].mouse.press_l) // 左键发射模式
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
|
if(shoot_cmd_send.friction_mode == FRICTION_ON)
|
||||||
shoot_cmd_send.load_mode = LOAD_1_BULLET;
|
shoot_cmd_send.load_mode = LOAD_1_BULLET;
|
||||||
|
else
|
||||||
|
shoot_cmd_send.load_mode = LOAD_STOP;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
shoot_cmd_send.load_mode = LOAD_STOP;
|
shoot_cmd_send.load_mode = LOAD_STOP;
|
||||||
|
@ -284,6 +290,17 @@ static void MouseKeySet()
|
||||||
shoot_cmd_send.friction_mode = FRICTION_ON;
|
shoot_cmd_send.friction_mode = FRICTION_ON;
|
||||||
break;
|
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;
|
||||||
|
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] % 4) // C键设置底盘速度
|
switch (rc_data[TEMP].key_count[KEY_PRESS][Key_C] % 4) // C键设置底盘速度
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
|
|
|
@ -36,8 +36,8 @@
|
||||||
#define REDUCTION_RATIO_LOADER 19.0f // 拨盘电机的减速比,英雄需要修改为3508的19.0f//初始是49
|
#define REDUCTION_RATIO_LOADER 19.0f // 拨盘电机的减速比,英雄需要修改为3508的19.0f//初始是49
|
||||||
#define NUM_PER_CIRCLE 5 // 拨盘一圈的装载量
|
#define NUM_PER_CIRCLE 5 // 拨盘一圈的装载量
|
||||||
// 机器人底盘修改的参数,单位为mm(毫米)
|
// 机器人底盘修改的参数,单位为mm(毫米)
|
||||||
#define WHEEL_BASE 420 // 纵向轴距(前进后退方向)
|
#define WHEEL_BASE 433.86 // 纵向轴距(前进后退方向)
|
||||||
#define TRACK_WIDTH 450 // 横向轮距(左右平移方向)
|
#define TRACK_WIDTH 463.92 // 横向轮距(左右平移方向)
|
||||||
#define CENTER_GIMBAL_OFFSET_X 0 // 云台旋转中心距底盘几何中心的距离,前后方向,云台位于正中心时默认设为0
|
#define CENTER_GIMBAL_OFFSET_X 0 // 云台旋转中心距底盘几何中心的距离,前后方向,云台位于正中心时默认设为0
|
||||||
#define CENTER_GIMBAL_OFFSET_Y 0 // 云台旋转中心距底盘几何中心的距离,左右方向,云台位于正中心时默认设为0
|
#define CENTER_GIMBAL_OFFSET_Y 0 // 云台旋转中心距底盘几何中心的距离,左右方向,云台位于正中心时默认设为0
|
||||||
#define RADIUS_WHEEL 75 // 轮子半径
|
#define RADIUS_WHEEL 75 // 轮子半径
|
||||||
|
|
|
@ -23,6 +23,7 @@ static float hibernate_time = 0, dead_time = 0;
|
||||||
|
|
||||||
static uint16_t locked_time;
|
static uint16_t locked_time;
|
||||||
|
|
||||||
|
|
||||||
void ShootInit()
|
void ShootInit()
|
||||||
{
|
{
|
||||||
// 摩擦轮
|
// 摩擦轮
|
||||||
|
@ -32,12 +33,12 @@ void ShootInit()
|
||||||
},
|
},
|
||||||
.controller_param_init_config = {
|
.controller_param_init_config = {
|
||||||
.speed_PID = {
|
.speed_PID = {
|
||||||
.Kp = 1.5f, // 20
|
.Kp = 2, // 20
|
||||||
.Ki = 0.2f, // 1
|
.Ki = 1, // 1
|
||||||
.Kd = 0,
|
.Kd = 0,
|
||||||
.Improve = PID_Integral_Limit,
|
.Improve = PID_Integral_Limit,
|
||||||
.IntegralLimit = 10000,
|
.IntegralLimit = 10000,
|
||||||
.MaxOut = 15000,
|
.MaxOut = 28000,
|
||||||
},
|
},
|
||||||
.current_PID = {
|
.current_PID = {
|
||||||
.Kp = 0, // 0.7
|
.Kp = 0, // 0.7
|
||||||
|
@ -164,7 +165,7 @@ void ShootTask()
|
||||||
stop_location = loader->measure.total_angle;
|
stop_location = loader->measure.total_angle;
|
||||||
DJIMotorSetRef(loader, loader->measure.total_angle + ONE_BULLET_DELTA_ANGLE); // 控制量增加一发弹丸的角度
|
DJIMotorSetRef(loader, loader->measure.total_angle + ONE_BULLET_DELTA_ANGLE); // 控制量增加一发弹丸的角度
|
||||||
hibernate_time = DWT_GetTimeline_ms(); // 记录触发指令的时间
|
hibernate_time = DWT_GetTimeline_ms(); // 记录触发指令的时间
|
||||||
dead_time = 2000; // 完成1发弹丸发射的时间
|
dead_time = 300; // 完成1发弹丸发射的时间
|
||||||
break;
|
break;
|
||||||
// 三连发,如果不需要后续可能删除
|
// 三连发,如果不需要后续可能删除
|
||||||
case LOAD_3_BULLET:
|
case LOAD_3_BULLET:
|
||||||
|
@ -176,7 +177,7 @@ void ShootTask()
|
||||||
// 连发模式,对速度闭环,射频后续修改为可变,目前固定为1Hz
|
// 连发模式,对速度闭环,射频后续修改为可变,目前固定为1Hz
|
||||||
case LOAD_BURSTFIRE:
|
case LOAD_BURSTFIRE:
|
||||||
DJIMotorOuterLoop(loader, SPEED_LOOP);
|
DJIMotorOuterLoop(loader, SPEED_LOOP);
|
||||||
DJIMotorSetRef(loader, shoot_cmd_recv.shoot_rate * 360 * REDUCTION_RATIO_LOADER / 5);
|
DJIMotorSetRef(loader, shoot_cmd_recv.shoot_rate * 360 * REDUCTION_RATIO_LOADER);
|
||||||
// x颗/秒换算成速度: 已知一圈的载弹量,由此计算出1s需要转的角度,注意换算角速度(DJIMotor的速度单位是)
|
// x颗/秒换算成速度: 已知一圈的载弹量,由此计算出1s需要转的角度,注意换算角速度(DJIMotor的速度单位是)
|
||||||
break;
|
break;
|
||||||
// 拨盘反转,对速度闭环,后续增加卡弹检测(通过裁判系统剩余热量反馈和电机电流)
|
// 拨盘反转,对速度闭环,后续增加卡弹检测(通过裁判系统剩余热量反馈和电机电流)
|
||||||
|
@ -194,7 +195,7 @@ void ShootTask()
|
||||||
{
|
{
|
||||||
DJIMotorSetRef(friction_l, 39000);
|
DJIMotorSetRef(friction_l, 39000);
|
||||||
DJIMotorSetRef(friction_r, 39000);
|
DJIMotorSetRef(friction_r, 39000);
|
||||||
DJIMotorSetRef(friction_z, 39000);
|
DJIMotorSetRef(friction_z, 39000);//39000/6 = 6500
|
||||||
}
|
}
|
||||||
else // 关闭摩擦轮
|
else // 关闭摩擦轮
|
||||||
{
|
{
|
||||||
|
@ -216,7 +217,6 @@ void ShootTask()
|
||||||
// 反馈数据,目前暂时没有要设定的反馈数据,后续可能增加应用离线监测以及卡弹反馈
|
// 反馈数据,目前暂时没有要设定的反馈数据,后续可能增加应用离线监测以及卡弹反馈
|
||||||
|
|
||||||
//推送消息
|
//推送消息
|
||||||
//ui_data.friction_mode = shoot_cmd_recv.friction_mode;
|
|
||||||
PubPushMessage(shoot_pub, (void *)&shoot_feedback_data);
|
PubPushMessage(shoot_pub, (void *)&shoot_feedback_data);
|
||||||
|
|
||||||
}
|
}
|
|
@ -62,8 +62,8 @@ static uint32_t shoot_line_location[10] = {540, 960, 490, 515, 565};
|
||||||
|
|
||||||
void MyUIInit()
|
void MyUIInit()
|
||||||
{
|
{
|
||||||
if (!referee_recv_info->init_flag)
|
// if (!referee_recv_info->init_flag)
|
||||||
vTaskDelete(NULL); // 如果没有初始化裁判系统则直接删除ui任务
|
// vTaskDelete(NULL); // 如果没有初始化裁判系统则直接删除ui任务
|
||||||
while (referee_recv_info->GameRobotState.robot_id == 0)
|
while (referee_recv_info->GameRobotState.robot_id == 0)
|
||||||
osDelay(100); // 若还未收到裁判系统数据,等待一段时间后再检查
|
osDelay(100); // 若还未收到裁判系统数据,等待一段时间后再检查
|
||||||
|
|
||||||
|
@ -89,8 +89,8 @@ void MyUIInit()
|
||||||
UICharRefresh(&referee_recv_info->referee_id, UI_State_sta[2]);
|
UICharRefresh(&referee_recv_info->referee_id, UI_State_sta[2]);
|
||||||
UICharDraw(&UI_State_sta[3], "ss3", UI_Graph_ADD, 8, UI_Color_Pink, 15, 2, 150, 600, "frict:");
|
UICharDraw(&UI_State_sta[3], "ss3", UI_Graph_ADD, 8, UI_Color_Pink, 15, 2, 150, 600, "frict:");
|
||||||
UICharRefresh(&referee_recv_info->referee_id, UI_State_sta[3]);
|
UICharRefresh(&referee_recv_info->referee_id, UI_State_sta[3]);
|
||||||
UICharDraw(&UI_State_sta[4], "ss4", UI_Graph_ADD, 8, UI_Color_Pink, 15, 2, 150, 550, "lid:");
|
// UICharDraw(&UI_State_sta[4], "ss4", UI_Graph_ADD, 8, UI_Color_Pink, 15, 2, 150, 550, "lid:");
|
||||||
UICharRefresh(&referee_recv_info->referee_id, UI_State_sta[4]);
|
// UICharRefresh(&referee_recv_info->referee_id, UI_State_sta[4]);
|
||||||
|
|
||||||
// 绘制车辆状态标志,动态
|
// 绘制车辆状态标志,动态
|
||||||
// 由于初始化时xxx_last_mode默认为0,所以此处对应UI也应该设为0时对应的UI,防止模式不变的情况下无法置位flag,导致UI无法刷新
|
// 由于初始化时xxx_last_mode默认为0,所以此处对应UI也应该设为0时对应的UI,防止模式不变的情况下无法置位flag,导致UI无法刷新
|
||||||
|
@ -102,8 +102,8 @@ void MyUIInit()
|
||||||
UICharRefresh(&referee_recv_info->referee_id, UI_State_dyn[2]);
|
UICharRefresh(&referee_recv_info->referee_id, UI_State_dyn[2]);
|
||||||
UICharDraw(&UI_State_dyn[3], "sd3", UI_Graph_ADD, 8, UI_Color_Pink, 15, 2, 270, 600, "off");
|
UICharDraw(&UI_State_dyn[3], "sd3", UI_Graph_ADD, 8, UI_Color_Pink, 15, 2, 270, 600, "off");
|
||||||
UICharRefresh(&referee_recv_info->referee_id, UI_State_dyn[3]);
|
UICharRefresh(&referee_recv_info->referee_id, UI_State_dyn[3]);
|
||||||
UICharDraw(&UI_State_dyn[4], "sd4", UI_Graph_ADD, 8, UI_Color_Pink, 15, 2, 270, 550, "open ");
|
// UICharDraw(&UI_State_dyn[4], "sd4", UI_Graph_ADD, 8, UI_Color_Pink, 15, 2, 270, 550, "open ");
|
||||||
UICharRefresh(&referee_recv_info->referee_id, UI_State_dyn[4]);
|
// UICharRefresh(&referee_recv_info->referee_id, UI_State_dyn[4]);
|
||||||
|
|
||||||
// 底盘功率显示,静态
|
// 底盘功率显示,静态
|
||||||
UICharDraw(&UI_State_sta[5], "ss5", UI_Graph_ADD, 7, UI_Color_Green, 18, 2, 620, 230, "Power:");
|
UICharDraw(&UI_State_sta[5], "ss5", UI_Graph_ADD, 7, UI_Color_Green, 18, 2, 620, 230, "Power:");
|
||||||
|
@ -240,12 +240,12 @@ static void MyUIRefresh(referee_info_t *referee_recv_info, Referee_Interactive_i
|
||||||
_Interactive_data->Referee_Interactive_Flag.friction_flag = 0;
|
_Interactive_data->Referee_Interactive_Flag.friction_flag = 0;
|
||||||
}
|
}
|
||||||
// lid
|
// lid
|
||||||
if (_Interactive_data->Referee_Interactive_Flag.lid_flag == 1)
|
// if (_Interactive_data->Referee_Interactive_Flag.lid_flag == 1)
|
||||||
{
|
// {
|
||||||
UICharDraw(&UI_State_dyn[4], "sd4", UI_Graph_Change, 8, UI_Color_Pink, 15, 2, 270, 550, _Interactive_data->lid_mode == LID_OPEN ? "open " : "close");
|
// UICharDraw(&UI_State_dyn[4], "sd4", UI_Graph_Change, 8, UI_Color_Pink, 15, 2, 270, 550, _Interactive_data->lid_mode == LID_OPEN ? "open " : "close");
|
||||||
UICharRefresh(&referee_recv_info->referee_id, UI_State_dyn[4]);
|
// UICharRefresh(&referee_recv_info->referee_id, UI_State_dyn[4]);
|
||||||
_Interactive_data->Referee_Interactive_Flag.lid_flag = 0;
|
// _Interactive_data->Referee_Interactive_Flag.lid_flag = 0;
|
||||||
}
|
// }
|
||||||
// power
|
// power
|
||||||
if (_Interactive_data->Referee_Interactive_Flag.Power_flag == 1)
|
if (_Interactive_data->Referee_Interactive_Flag.Power_flag == 1)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue