energy changed a lot
This commit is contained in:
@@ -27,47 +27,31 @@ public:
|
||||
Energy(Serial &u, uint8_t &color);//构造函数,参数为串口和敌方颜色
|
||||
~Energy();//默认析构函数
|
||||
|
||||
void runBig(cv::Mat &gimbal_src, cv::Mat &chassis_src);
|
||||
void runBig(cv::Mat &gimbal_src);
|
||||
void runSmall(cv::Mat &gimbal_src);
|
||||
bool is_big;//大符模式为true
|
||||
bool is_small;//小符模式为true
|
||||
|
||||
void run(cv::Mat &src);
|
||||
|
||||
Serial &serial;//串口
|
||||
void setEnergyInit();//设置能量机关初始化
|
||||
void setBigEnergyInit();//设置大能量机关初始化
|
||||
void setSmallEnergyInit();//设置小能量机关初始化
|
||||
void sendEnergy();//发送能量机关数据
|
||||
void sendTarget(Serial& serial, float x, float y, float z);//发送数据
|
||||
void sendTarget(Serial& serial, float x, float y, float z, uint16_t u);//发送数据
|
||||
|
||||
|
||||
private:
|
||||
EnergyPartParam energy_part_param_;//能量机关的参数设置
|
||||
EnergyPartParam gimbal_energy_part_param_;//云台摄像头能量机关的参数设置
|
||||
EnergyPartParam chassis_energy_part_param_;//底盘摄像头能量机关的参数设置
|
||||
|
||||
bool is_mark;//若操作手正在手动标定,则为true
|
||||
bool is_big;//大符模式为true
|
||||
bool is_small;//小符模式为true
|
||||
bool is_gimbal;//同时具有底盘和云台摄像头时,处于云台摄像头对心过程
|
||||
bool is_chassis;//同时具有底盘和云台摄像头时,处于底盘摄像头击打过程
|
||||
bool is_guessing;//当前处于发弹到新目标出现的过程,则为true,此时猜测下一个目标
|
||||
bool is_predicting;//当前处于新目标出现到发弹的过程,则为true,此时正常击打
|
||||
bool is_find_target;//判断当前是否找到了目标
|
||||
bool energy_mode_init;//正在进行大小符判断
|
||||
bool energy_mode_init;//大小符状态判断
|
||||
bool energy_rotation_init;//若仍在判断风车旋转方向,则为true
|
||||
bool manual_mark;//若操作手进行过手动标定,则为true
|
||||
bool auto_mark;//云台完成自动对心,则置为true
|
||||
bool start_guess;//进入猜测状态的标志
|
||||
bool change_target;//目标切换的标志
|
||||
|
||||
uint8_t last_mark;//用于记录上一帧操作手是否进行标定
|
||||
uint8_t &ally_color;//我方颜色
|
||||
|
||||
double radius;//大风车半径
|
||||
|
||||
int curr_fps;//帧率
|
||||
int send_cnt;//向主控板发送的数据总次数
|
||||
int camera_cnt;//摄像头数量
|
||||
int fans_cnt;//扇叶个数
|
||||
int last_fans_cnt;//上一帧的扇叶个数
|
||||
int guess_devide;//刚进入猜测状态时,猜测目标点在极坐标中的分区
|
||||
@@ -79,7 +63,8 @@ private:
|
||||
int extra_delta_x, extra_delta_y;//在风车运动到最高点附近的额外补偿量
|
||||
|
||||
float target_polar_angle;//待击打装甲板的极坐标角度
|
||||
float last_target_polar_angle;//上一帧待击打装甲板的极坐标角度
|
||||
float last_target_polar_angle_judge_change;//上一帧待击打装甲板的极坐标角度(用于判断目标切换)
|
||||
float last_target_polar_angle_judge_rotation;//上一帧待击打装甲板的极坐标角度(用于判断旋向)
|
||||
float guess_polar_angle;//猜测的下一个目标装甲板极坐标角度
|
||||
float last_base_angle;//上一帧的各扇叶在0区(0°~72°)的基础角度
|
||||
float predict_rad;//预测提前角
|
||||
@@ -87,12 +72,11 @@ private:
|
||||
float attack_distance;//步兵与风车平面距离
|
||||
float center_delta_yaw, center_delta_pitch;//对心时相差的角度
|
||||
float yaw_rotation, pitch_rotation;//云台yaw轴和pitch轴应该转到的角度
|
||||
float origin_yaw, origin_pitch;//初始的云台角度设定值
|
||||
float shoot;//若为2,则要求主控板发弹
|
||||
float shoot;//给主控板的指令,1表示跟随,2表示发射,3表示目标切换,4表示猜测模式
|
||||
float last_yaw, last_pitch;//PID中微分项
|
||||
float sum_yaw, sum_pitch;//yaw和pitch的累计误差,即PID中积分项
|
||||
|
||||
systime time_start_guess;
|
||||
systime time_start_guess;//进入猜测模式的时间
|
||||
|
||||
cv::RotatedRect centerR;//风车中心字母R的可能候选区
|
||||
cv::RotatedRect flow_strip;//图像中所有流动条(理论上只有一个)
|
||||
@@ -102,7 +86,6 @@ private:
|
||||
|
||||
cv::Point circle_center_point;//风车圆心坐标
|
||||
cv::Point target_point;//目标装甲板中心坐标
|
||||
cv::Point last_target_point;//上一帧目标装甲板中心坐标
|
||||
cv::Point guess_point;
|
||||
cv::Point predict_point;//预测的击打点坐标
|
||||
|
||||
@@ -125,17 +108,16 @@ private:
|
||||
void clearAll();//清空各vector
|
||||
void initImage(cv::Mat &src);//图像预处理
|
||||
|
||||
void startChassis();//从云台摄像头对心状态进入底盘摄像头击打状态
|
||||
bool stayGuessing();//保持在猜测模式
|
||||
|
||||
int findFans(const cv::Mat src);//寻找图中所有扇叶
|
||||
int findArmors(const cv::Mat src);//寻找图中所有装甲板
|
||||
bool findCenterR(const cv::Mat src);//寻找图中可能的风车中心字母R
|
||||
bool findFlowStrip(const cv::Mat src);//寻找图中的流动条
|
||||
bool findFlowStripSub(const cv::Mat src);//寻找图中的流动条
|
||||
bool findCenterROI(const cv::Mat src);//框取中心R候选区
|
||||
bool findFlowStripFan(const cv::Mat src);//寻找图中的流动条所在扇叶
|
||||
bool findFlowStripWeak(const cv::Mat src);//弱识别寻找图中的流动条
|
||||
int findFans(const cv::Mat &src);//寻找图中所有扇叶
|
||||
int findArmors(const cv::Mat &src);//寻找图中所有装甲板
|
||||
bool findCenterR(const cv::Mat &src);//寻找图中可能的风车中心字母R
|
||||
bool findFlowStrip(const cv::Mat &src);//寻找图中的流动条
|
||||
bool findCenterROI(const cv::Mat &src);//框取中心R候选区
|
||||
bool findFlowStripFan(const cv::Mat &src);//寻找图中的流动条所在扇叶
|
||||
bool findFlowStripWeak(const cv::Mat &src);//弱识别寻找图中的流动条
|
||||
bool findTargetInFlowStripFan();//在已发现的流动条区域中寻找待击打装甲板
|
||||
|
||||
bool isValidFanContour(cv::Mat &src, const vector<cv::Point> &fan_contour);//扇叶矩形尺寸要求
|
||||
bool isValidArmorContour(const vector<cv::Point> &armor_contour);//装甲板矩形尺寸要求
|
||||
@@ -143,57 +125,41 @@ private:
|
||||
bool isValidFlowStripContour(const vector<cv::Point> &flow_strip_contour);//流动条扇叶矩形尺寸要求
|
||||
bool isValidFlowStripFanContour(cv::Mat &src, const vector<cv::Point> &flow_strip_fan_contour);//流动条扇叶矩形尺寸要求
|
||||
|
||||
void showFans(std::string windows_name, const cv::Mat src);//显示扇叶
|
||||
void showArmors(std::string windows_name, const cv::Mat src);//显示装甲板
|
||||
void showBoth(std::string windows_name, const cv::Mat src);//显示扇叶和装甲板
|
||||
void showTarget(std::string windows_name, const cv::Mat src);//显示目标装甲板
|
||||
void showCenterR(std::string windows_name, const cv::Mat src);//显示风车中心候选区R
|
||||
void showFlowStrip(std::string windows_name, const cv::Mat src);//显示流动条
|
||||
void showFlowStripFan(std::string windows_name, const cv::Mat src);//显示流动条所在扇叶
|
||||
void showGuessTarget(std::string windows_name, const cv::Mat src);//显示猜测点位
|
||||
|
||||
void circleLeastFit();//利用所有记录的装甲板中心最小二乘法计算圆心和半径
|
||||
|
||||
void findTargetByIntersection();//通过面积重合度匹配获取目标装甲板的极坐标角度和装甲板中心坐标
|
||||
bool findTargetInFlowStripFan();//在已发现的流动条区域中寻找待击打装甲板
|
||||
void showFans(std::string windows_name, const cv::Mat &src);//显示扇叶
|
||||
void showArmors(std::string windows_name, const cv::Mat &src);//显示装甲板
|
||||
void showCenterR(std::string windows_name, const cv::Mat &src);//显示风车中心候选区R
|
||||
void showFlowStrip(std::string windows_name, const cv::Mat &src);//显示流动条
|
||||
void showFlowStripFan(std::string windows_name, const cv::Mat &src);//显示流动条所在扇叶
|
||||
void showGuessTarget(std::string windows_name, const cv::Mat &src);//显示猜测点位
|
||||
|
||||
int devide(float angle);//将极坐标分为五个区域,判断一个角度处于哪个区域
|
||||
int linePointX(const cv::Point2f &p1, const cv::Point2f &p2, int y);//计算直线上一点横坐标
|
||||
void rotate(cv::Point target_point);//获取预测点位
|
||||
void stretch(cv::Point point_1, cv::Point2f &point_2);//将像素差转换为实际距离差
|
||||
double pointDistance(cv::Point point_1, cv::Point point_2);//计算两点距离
|
||||
double nonZeroRateOfRotateRect(cv::Mat &bin, const cv::RotatedRect &rotatedRect);//计算旋转矩形内亮点占比
|
||||
|
||||
void writeDownSlightChange(cv::Mat &src);//记录操作手的手动微调
|
||||
void writeDownMark(cv::Mat &src);//记录操作手标定的云台对心初始角度
|
||||
void writeDownMark(cv::Mat &src);//记录操作手的手动微调
|
||||
|
||||
bool guessTarget();//获得猜测击打点位
|
||||
bool getOrigin();//获得云台对心所需角度
|
||||
void changeTarget();//判断目标是否改变
|
||||
void getCenter();//对心
|
||||
void multipleMode(cv::Mat &src);//多模式切换
|
||||
void getTargetPolarAngle();//获得目标装甲板极坐标角度
|
||||
void getPredictPoint(cv::Point target_point);//获取预测点位
|
||||
void getAimPoint(cv::Point target_point);//通过自瞄逻辑计算点位
|
||||
void changeMark();//操作手手动修改标定值
|
||||
void gimbalRotation();//计算云台旋转角度
|
||||
void getAllTargetArmorCenters();//记录所有目标装甲板中心坐标
|
||||
void getRecentTargetArmorCenters();//记录近30帧目标装甲板中心坐标
|
||||
|
||||
void judgeMode();//判断大符还是小符
|
||||
void judgeShootInGimbal();//在云台坐标系中判断是否可以发弹
|
||||
void judgeShootInWorld();//在世界坐标系中判断是否可以发弹
|
||||
void judgeShoot();//判断是否可以发弹
|
||||
bool isGuessingTimeout();//判断猜测模式是否超时(没打中)
|
||||
|
||||
void splitBayerBG(cv::Mat src, cv::Mat &blue, cv::Mat &red);//拜耳阵列分离
|
||||
void imagePreprocess(cv::Mat &src);//图像通道分离
|
||||
void hsvFilter(cv::Mat &src);//此函数通过HSV颜色空间对图像纯度进行限制,进行滤光
|
||||
|
||||
void FanStruct(cv::Mat &src);//腐蚀和膨胀
|
||||
void ArmorStruct(cv::Mat &src);//腐蚀和膨胀
|
||||
void FlowStripFanStruct(cv::Mat &src);//腐蚀和膨胀
|
||||
void FlowStripStruct(cv::Mat &src);//腐蚀和膨胀
|
||||
void FlowStripStructSub(cv::Mat &src);//腐蚀和膨胀
|
||||
void CenterRStruct(cv::Mat &src);//腐蚀和膨胀
|
||||
};
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ using std::vector;
|
||||
// 此结构体包括能量机关参数
|
||||
// ---------------------------------------------------------------------------------------------------------------------
|
||||
struct EnergyPartParam {
|
||||
int GRAY_THRESH;//二值化阈值
|
||||
int RED_GRAY_THRESH;//红方二值化阈值
|
||||
int BLUE_GRAY_THRESH;//蓝方二值化阈值
|
||||
int SPLIT_GRAY_THRESH;//通道分离二值化阈值
|
||||
@@ -30,8 +29,6 @@ struct EnergyPartParam {
|
||||
float FAN_CONTOUR_HW_RATIO_MAX;//扇叶长宽比最大值
|
||||
float FAN_CONTOUR_HW_RATIO_MIN;//扇叶长宽比最小值
|
||||
float FAN_CONTOUR_AREA_RATIO_MIN;//装甲板轮廓占旋转矩形面积比最小值
|
||||
double FAN_NON_ZERO_RATE_MAX;//流动条扇叶中亮点占旋转矩形的比值最大值
|
||||
double FAN_NON_ZERO_RATE_MIN;//流动条扇叶中亮点占旋转矩形的比值最大值
|
||||
|
||||
long ARMOR_CONTOUR_AREA_MAX;//装甲板面积最大值
|
||||
long ARMOR_CONTOUR_AREA_MIN;//装甲板面积最小值
|
||||
@@ -64,8 +61,6 @@ struct EnergyPartParam {
|
||||
float FLOW_STRIP_FAN_CONTOUR_HW_RATIO_MIN;//流动条扇叶(待击打)长宽比最小值
|
||||
float FLOW_STRIP_FAN_CONTOUR_AREA_RATIO_MAX;//流动条扇叶轮廓占旋转矩形面积比最小值
|
||||
float FLOW_STRIP_FAN_CONTOUR_AREA_RATIO_MIN;//流动条扇叶占旋转矩形面积比最小值
|
||||
double FLOW_STRIP_FAN_NON_ZERO_RATE_MAX;//流动条扇叶中亮点占旋转矩形的比值最大值
|
||||
double FLOW_STRIP_FAN_NON_ZERO_RATE_MIN;//流动条扇叶中亮点占旋转矩形的比值最大值
|
||||
|
||||
long FLOW_STRIP_CONTOUR_AREA_MAX;//流动条(待击打)面积最大值
|
||||
long FLOW_STRIP_CONTOUR_AREA_MIN;//流动条(待击打)面积最小值
|
||||
@@ -81,7 +76,6 @@ struct EnergyPartParam {
|
||||
float TWIN_ANGEL_MAX;//两个理论上相等的角度在计算时具有的可能最大差值
|
||||
long TARGET_INTERSETION_CONTOUR_AREA_MIN;//扇叶与装甲板匹配时的最小重合面积
|
||||
|
||||
long TARGET_CHANGE_DISTANCE_MAX;//目标未更改时,目标装甲板中心与原目标装甲板中心的距离变化最大值
|
||||
long TWIN_POINT_MAX;//两个点相同时距离最大值
|
||||
|
||||
long STRIP_ARMOR_DISTANCE_MIN;//流动条中心和目标装甲板中心距离最小值
|
||||
|
||||
Reference in New Issue
Block a user