改用单维及二维数组的写法
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

96 lines
2.2 KiB

/*
* swing_action.c
*
* Created on: Mar 4, 2026
* Author: 42961
*/
#include "swing_action.h"
#include "Handset_Status_Setting.h"
#include "fsm_state.h"
#include "BHBF_ROBOT.h"
#define TT_One_Deg_Count 11014///32768*121/360(减速比121)=11014
#define LEFT_LIMIT 1
#define RIGHT_LIMIT 2
float Swing_Speed_Deg_Sencond=201.7;//HJ32-121
int middle_position=-944334;
//int center_angle;
//int offset_angle;
//int center_position; //中间位置-944334
int limit_record=0;
float left_compare_value;
float right_compare_value;
int lef_positon=-569580;
int Right_positon=-1230420;
void Robot_Swing_Operation_Function()
{
if(P_MK32->CH0_RY_H>300)
{
GV.SwingMotor.Position_immediately1_Lag2=1;
GV.SwingMotor.Tar_Position_angle=90;
GV.SwingMotor.Tar_Position_Velcity_Degree_S=GV.PV.Robot_Swing_Speed;
}
else if(P_MK32->CH0_RY_H<-300)
{
GV.SwingMotor.Position_immediately1_Lag2=1;
GV.SwingMotor.Tar_Position_angle=-90;
GV.SwingMotor.Tar_Position_Velcity_Degree_S=GV.PV.Robot_Swing_Speed;
}
else
{
Move_Swing_Halt_Func_Do();
}
}
//摆臂电机左转延时生效
void Move_Swing_Left_Func_Do_lay(void)
{
GV.SwingMotor.Position_immediately1_Lag2=2;
GV.SwingMotor.Tar_Position_angle=left_compare_value;
GV.SwingMotor.Tar_Position_Velcity_Degree_S=GV.PV.Robot_Swing_Speed;
}
//摆臂电机右转延时生效
void Move_Swing_Right_Func_Do_lay(void)
{
GV.SwingMotor.Position_immediately1_Lag2=2;
GV.SwingMotor.Tar_Position_angle=right_compare_value;
GV.SwingMotor.Tar_Position_Velcity_Degree_S=GV.PV.Robot_Swing_Speed;
}
//摆臂电机左转立即执行
void Move_Swing_Left_Func_Do_imm(void)
{
GV.SwingMotor.Position_immediately1_Lag2=1;
GV.SwingMotor.Tar_Position_angle=left_compare_value;
GV.SwingMotor.Tar_Position_Velcity_Degree_S=GV.PV.Robot_Swing_Speed;
}
//摆臂电机右转立即执行
void Move_Swing_Right_Func_Do_imm(void)
{
GV.SwingMotor.Position_immediately1_Lag2=1;
GV.SwingMotor.Tar_Position_angle=right_compare_value;
GV.SwingMotor.Tar_Position_Velcity_Degree_S=GV.PV.Robot_Swing_Speed;
}
void Move_Swing_Halt_Func_Do(void)
{
GV.SwingMotor.Position_immediately1_Lag2=1;
GV.SwingMotor.Tar_Position_count=0;
GV.SwingMotor.Tar_Position_Velcity_Degree_S=0;
}