Auto Aim
This commit is contained in:
@@ -39,6 +39,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
EnergyPartParam energy_part_param_;
|
EnergyPartParam energy_part_param_;
|
||||||
|
LiftHeight lift_height_;
|
||||||
int fans_cnt;
|
int fans_cnt;
|
||||||
int armors_cnt;
|
int armors_cnt;
|
||||||
int count;
|
int count;
|
||||||
|
|||||||
@@ -49,6 +49,16 @@ struct EnergyPartParam {
|
|||||||
float TWIN_ANGEL_MAX;
|
float TWIN_ANGEL_MAX;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct LiftHeight{
|
||||||
|
float LIFT_0;
|
||||||
|
float LIFT_30;
|
||||||
|
float LIFT_60;
|
||||||
|
float LIFT_90;
|
||||||
|
float LIFT_minus_30;
|
||||||
|
float LIFT_minus_60;
|
||||||
|
float LIFT_minus_90;
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct GMAngle_t{
|
typedef struct GMAngle_t{
|
||||||
float yaw;
|
float yaw;
|
||||||
float pitch;
|
float pitch;
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ void Energy::gimbleRotation(){
|
|||||||
// yaw_rotation = static_cast<float>(180 / PI * atan2((ATTACK_DISTANCE*tan(YAW_ORIGIN_RAD)-real_hit_point.x), ATTACK_DISTANCE));
|
// yaw_rotation = static_cast<float>(180 / PI * atan2((ATTACK_DISTANCE*tan(YAW_ORIGIN_RAD)-real_hit_point.x), ATTACK_DISTANCE));
|
||||||
// pitch_rotation = static_cast<float>(180 / PI * atan2((ATTACK_DISTANCE*tan(PITCH_ORIGIN_RAD)-real_hit_point.y), ATTACK_DISTANCE));
|
// pitch_rotation = static_cast<float>(180 / PI * atan2((ATTACK_DISTANCE*tan(PITCH_ORIGIN_RAD)-real_hit_point.y), ATTACK_DISTANCE));
|
||||||
|
|
||||||
yaw_rotation = static_cast<float>(180 / PI * atan2((ATTACK_DISTANCE*tan(mark_yaw*PI/180)-real_hit_point.x), ATTACK_DISTANCE));
|
yaw_rotation = static_cast<float>(180 / PI * atan2((attack_distance*tan(mark_yaw*PI/180)-real_hit_point.x), attack_distance));
|
||||||
pitch_rotation = static_cast<float>(180 / PI * atan2((ATTACK_DISTANCE*tan(mark_pitch*PI/180)-real_hit_point.y), ATTACK_DISTANCE));
|
pitch_rotation = static_cast<float>(180 / PI * atan2((attack_distance*tan(mark_pitch*PI/180)-real_hit_point.y), attack_distance));
|
||||||
|
|
||||||
// yaw_rotation = static_cast<float>(180 / PI * atan2((ATTACK_DISTANCE*tan(3.5*PI/180)-STRETCH*(hit_point.x-cycle_center.x)), ATTACK_DISTANCE));
|
// yaw_rotation = static_cast<float>(180 / PI * atan2((ATTACK_DISTANCE*tan(3.5*PI/180)-STRETCH*(hit_point.x-cycle_center.x)), ATTACK_DISTANCE));
|
||||||
// pitch_rotation = static_cast<float>(180 / PI * atan2((ATTACK_DISTANCE*tan(9.1*PI/180)-STRETCH*(hit_point.y-cycle_center.y)), ATTACK_DISTANCE));
|
// pitch_rotation = static_cast<float>(180 / PI * atan2((ATTACK_DISTANCE*tan(9.1*PI/180)-STRETCH*(hit_point.y-cycle_center.y)), ATTACK_DISTANCE));
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ using std::vector;
|
|||||||
void Energy::initEnergyPartParam() {
|
void Energy::initEnergyPartParam() {
|
||||||
|
|
||||||
energy_part_param_.RPM = 10;
|
energy_part_param_.RPM = 10;
|
||||||
energy_part_param_.HIT_TIME = 1.0;
|
energy_part_param_.HIT_TIME = 1.5;
|
||||||
|
|
||||||
energy_part_param_.GRAY_THRESH = 240;
|
energy_part_param_.GRAY_THRESH = 240;
|
||||||
energy_part_param_.SPLIT_GRAY_THRESH = 80;
|
energy_part_param_.SPLIT_GRAY_THRESH = 80;
|
||||||
@@ -36,6 +36,13 @@ void Energy::initEnergyPartParam() {
|
|||||||
|
|
||||||
energy_part_param_.TWIN_ANGEL_MAX = 10;
|
energy_part_param_.TWIN_ANGEL_MAX = 10;
|
||||||
|
|
||||||
|
lift_height_.LIFT_0 = 0;
|
||||||
|
lift_height_.LIFT_30 = 0;
|
||||||
|
lift_height_.LIFT_60 = 0;
|
||||||
|
lift_height_.LIFT_90 = 10;
|
||||||
|
lift_height_.LIFT_minus_30 = 0;
|
||||||
|
lift_height_.LIFT_minus_60 = 0;
|
||||||
|
lift_height_.LIFT_minus_90 = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ extern float curr_yaw, curr_pitch, mark_yaw, mark_pitch;
|
|||||||
extern int mark;
|
extern int mark;
|
||||||
|
|
||||||
int Energy::run(cv::Mat &src){
|
int Energy::run(cv::Mat &src){
|
||||||
|
// imshow("src",src);
|
||||||
fans.clear();
|
fans.clear();
|
||||||
armors.clear();
|
armors.clear();
|
||||||
fanPosition.clear();
|
fanPosition.clear();
|
||||||
@@ -31,11 +32,11 @@ int Energy::run(cv::Mat &src){
|
|||||||
// imshow("bin",src);
|
// imshow("bin",src);
|
||||||
|
|
||||||
|
|
||||||
// fans_cnt = findFan(src, fans, last_fans_cnt);
|
fans_cnt = findFan(src, fans, last_fans_cnt);
|
||||||
// cout<<"fans_cnt: "<<fans_cnt<<endl;
|
// cout<<"fans_cnt: "<<fans_cnt<<endl;
|
||||||
// if(fans_cnt==-1) return 0;//滤去漏判的帧
|
if(fans_cnt==-1) return 0;//滤去漏判的帧
|
||||||
// if(fans_cnt>0)showFanContours("fan",src,fans);
|
// if(fans_cnt>0)showFanContours("fan",src,fans);
|
||||||
fans_cnt=0;
|
// fans_cnt=0;
|
||||||
|
|
||||||
armors_cnt = findArmor(src, armors, last_armors_cnt);
|
armors_cnt = findArmor(src, armors, last_armors_cnt);
|
||||||
// cout<<"armors_cnt: "<<armors_cnt<<endl;
|
// cout<<"armors_cnt: "<<armors_cnt<<endl;
|
||||||
@@ -61,8 +62,11 @@ int Energy::run(cv::Mat &src){
|
|||||||
cout<<"all_armor_centers.size(): "<<all_armor_centers.size()<<endl;
|
cout<<"all_armor_centers.size(): "<<all_armor_centers.size()<<endl;
|
||||||
cycleLeastFit();
|
cycleLeastFit();
|
||||||
|
|
||||||
cycle_center = cv::Point(414,227);
|
|
||||||
radius = 203.728;
|
cycle_center = cv::Point(332,233);
|
||||||
|
radius = 208.835;
|
||||||
|
attack_distance = ATTACK_DISTANCE * 203.728 / radius;
|
||||||
|
|
||||||
getFanPosition(fanPosition, fans, cycle_center, radius);
|
getFanPosition(fanPosition, fans, cycle_center, radius);
|
||||||
getArmorPosition(armorPosition, armors, cycle_center, radius);
|
getArmorPosition(armorPosition, armors, cycle_center, radius);
|
||||||
findTarget(fanPosition, armorPosition, target_armor);
|
findTarget(fanPosition, armorPosition, target_armor);
|
||||||
|
|||||||
Reference in New Issue
Block a user