From 877e1baa0dfae5e4c571fc809632e700ddd31955 Mon Sep 17 00:00:00 2001 From: Lizongdi <1210855344@qq.com> Date: Thu, 30 Apr 2026 09:53:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=99=90=E4=BD=8D=E5=BC=80?= =?UTF-8?q?=E5=85=B3=E5=88=A4=E6=96=AD=E5=88=B0=E8=BE=BE=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../.settings/language.settings.xml | 4 +- .../BHBF_Robot_Lifting_Lug Debug.launch | 6 +-- .../BHBF_Robot_Lifting_Lug/Core/Src/FSM.c | 23 +++++++----- .../Core/Src/robot_state.c | 37 +++++++++++++++---- 4 files changed, 48 insertions(+), 22 deletions(-) diff --git a/diaoerqiege/BHBF_Robot_Lifting_Lug/.settings/language.settings.xml b/diaoerqiege/BHBF_Robot_Lifting_Lug/.settings/language.settings.xml index 07f8dd5..15fa460 100644 --- a/diaoerqiege/BHBF_Robot_Lifting_Lug/.settings/language.settings.xml +++ b/diaoerqiege/BHBF_Robot_Lifting_Lug/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -16,7 +16,7 @@ - + diff --git a/diaoerqiege/BHBF_Robot_Lifting_Lug/BHBF_Robot_Lifting_Lug Debug.launch b/diaoerqiege/BHBF_Robot_Lifting_Lug/BHBF_Robot_Lifting_Lug Debug.launch index 6578262..72a57fa 100644 --- a/diaoerqiege/BHBF_Robot_Lifting_Lug/BHBF_Robot_Lifting_Lug Debug.launch +++ b/diaoerqiege/BHBF_Robot_Lifting_Lug/BHBF_Robot_Lifting_Lug Debug.launch @@ -7,7 +7,7 @@ - + @@ -60,12 +60,12 @@ - + - + diff --git a/diaoerqiege/BHBF_Robot_Lifting_Lug/Core/Src/FSM.c b/diaoerqiege/BHBF_Robot_Lifting_Lug/Core/Src/FSM.c index d399277..ef2c2d0 100644 --- a/diaoerqiege/BHBF_Robot_Lifting_Lug/Core/Src/FSM.c +++ b/diaoerqiege/BHBF_Robot_Lifting_Lug/Core/Src/FSM.c @@ -139,6 +139,10 @@ void Mode_Control() } +extern uint8_t Pin2; +extern uint8_t Pin3; + + void IO_Control() { GF_BSP_GPIO_SetIO(4, 1); @@ -155,16 +159,17 @@ void IO_Control() } + Pin2 = GF_BSP_GPIO_ReadIO(2); + Pin3 = GF_BSP_GPIO_ReadIO(3); + } -uint8_t IsAllowRotation_AutoMode = 0; -int32_t knife_descent_height = 0; -// 自动作业停止后默认上升高度为5mm -int32_t knife_rising_height = 500; -int32_t knife_current_altitude = 0; -uint16_t delay_counts = 0; +uint8_t IsAllowRotation_AutoMode = 0; // 是否允许转刀 +int32_t knife_descent_height = 0; // 屏幕配置值转换后 +int32_t knife_rising_height = 500; // 自动作业停止后默认上升高度为5mm +int32_t knife_current_altitude = 0; // 激光1读数 uint8_t auto_work_mode_states = 5; -uint8_t auto_work_halt_states = 10; +uint8_t auto_work_halt_states = 10; void Automatic_Operation() { @@ -174,12 +179,12 @@ void Automatic_Operation() { switch(auto_work_mode_states) { - case 5: + case 5: // 读一下激光高度 knife_current_altitude = GV.ZHR29_200_measure_results.laser_sensor_1_measure_distance; auto_work_mode_states = 10; auto_work_halt_states = 10; break; - case 10: + case 10: // 下刀 IsAllowRotation_AutoMode = Knife_Detection(); if(IsAllowRotation_AutoMode == 1) { diff --git a/diaoerqiege/BHBF_Robot_Lifting_Lug/Core/Src/robot_state.c b/diaoerqiege/BHBF_Robot_Lifting_Lug/Core/Src/robot_state.c index 85127c0..f99f151 100644 --- a/diaoerqiege/BHBF_Robot_Lifting_Lug/Core/Src/robot_state.c +++ b/diaoerqiege/BHBF_Robot_Lifting_Lug/Core/Src/robot_state.c @@ -228,18 +228,26 @@ static const int32_t SliderSpeed = 50; const uint32_t up_limit = 6200; const uint8_t down_limit = 0; +uint8_t Pin2 = -1; //上限位,为0表示限位触发 +uint8_t Pin3 = -1; //下限位,为0表示限位触发 + void Manual_Up_State_Do(void) { int32_t SliderSpeed_PPS = SliderSpeed_mmps_2_pps(SliderSpeed); GV.LS_FrontEnd_Motor.Target_Position = -10000000; GV.LS_FrontEnd_Motor.Target_Velcity = SliderSpeed_PPS; - if((GV.ZHR29_200_measure_results.laser_sensor_1_measure_distance >= up_limit) + /*if((GV.ZHR29_200_measure_results.laser_sensor_1_measure_distance >= up_limit) || (GV.ZHR29_200_measure_results.laser_sensor_2_measure_distance >= up_limit) || (GV.ZHR29_200_measure_results.laser_sensor_3_measure_distance >= up_limit)) { GV.LS_FrontEnd_Motor.Target_Velcity = 0; - } + }*/ + + if (!Pin2) + { + GV.LS_FrontEnd_Motor.Target_Velcity = 0; + } } void Manual_Down_State_Do(void) @@ -248,13 +256,17 @@ void Manual_Down_State_Do(void) GV.LS_FrontEnd_Motor.Target_Position = 10000000; GV.LS_FrontEnd_Motor.Target_Velcity = SliderSpeed_PPS; - if((GV.ZHR29_200_measure_results.laser_sensor_1_measure_distance <= down_limit) + /*if((GV.ZHR29_200_measure_results.laser_sensor_1_measure_distance <= down_limit) || (GV.ZHR29_200_measure_results.laser_sensor_2_measure_distance <= down_limit) || (GV.ZHR29_200_measure_results.laser_sensor_3_measure_distance <= down_limit)) { GV.LS_FrontEnd_Motor.Target_Velcity = 0; - } + }*/ + if (!Pin3) + { + GV.LS_FrontEnd_Motor.Target_Velcity = 0; + } } // 定义前端升降电机速度,单位0.1mm/s @@ -266,12 +278,17 @@ void Manual_Low_Speed_Up_State_Do(void) GV.LS_FrontEnd_Motor.Target_Position = -10000000; GV.LS_FrontEnd_Motor.Target_Velcity = SliderSpeed_PPS; - if((GV.ZHR29_200_measure_results.laser_sensor_1_measure_distance >= up_limit) + /*if((GV.ZHR29_200_measure_results.laser_sensor_1_measure_distance >= up_limit) || (GV.ZHR29_200_measure_results.laser_sensor_2_measure_distance >= up_limit) || (GV.ZHR29_200_measure_results.laser_sensor_3_measure_distance >= up_limit)) { GV.LS_FrontEnd_Motor.Target_Velcity = 0; - } + }*/ + + if (!Pin2) + { + GV.LS_FrontEnd_Motor.Target_Velcity = 0; + } } void Manual_low_speed_Down_State_Do(void) @@ -280,13 +297,17 @@ void Manual_low_speed_Down_State_Do(void) GV.LS_FrontEnd_Motor.Target_Position = 10000000; GV.LS_FrontEnd_Motor.Target_Velcity = SliderSpeed_PPS; - if((GV.ZHR29_200_measure_results.laser_sensor_1_measure_distance <= down_limit) + /*if((GV.ZHR29_200_measure_results.laser_sensor_1_measure_distance <= down_limit) || (GV.ZHR29_200_measure_results.laser_sensor_2_measure_distance <= down_limit) || (GV.ZHR29_200_measure_results.laser_sensor_3_measure_distance <= down_limit)) { GV.LS_FrontEnd_Motor.Target_Velcity = 0; - } + }*/ + if (!Pin3) + { + GV.LS_FrontEnd_Motor.Target_Velcity = 0; + } }