⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ballprediction.h

📁 该文件是包含了机器人足球比赛中的整个系统的代码
💻 H
字号:
#ifndef BALL_PREDICTION_H
#define BALL_PREDICTION_H

#include "../Common/VisionObject.h"

#define MAX_FRAMES 8


struct BallInfo 
{
  double x;
  double y;
};

class BallPrediction {  
  public: 
    enum {
      BP_STRAIGHT,
      BP_RIGHT,
      BP_LEFT
    };

    struct Ball {
      double x;
      double y;
      double distance;
      double heading;
    };


    class Graham {  
      public: 
        Graham();
        void LoadParameters(char* filename);
        void ProcessFrame();
        bool ShouldIDive();
        void Clear();

      private:
        bool IsBallValid();
        void AddBallToArray();
        void DetermineAction();

        // Variables
        bool doBallPrediction;
        bool debug;
        bool firstArray;
        bool shouldDive;
        int firstCount;
        int diveDelayCount;
        double deltaX;
        int currentIndex;
        BallInfo current[MAX_FRAMES];
        BallInfo* currentBall;

        // Config file variables
        double diveBound;
        double diveAtTime;
        int diveDelay;
        double normalBallSpeed;
        double fastBallSpeed;
        int ignoreFrames;
        double minDiveBound;

      public: 
        double ballSpeed;
        double time;
        double xIntercept;
        double diveTime;
      };
  
    Graham gMoney;
    BallPrediction();
    void LoadParameters(char* filename);
    void ProcessFrame();
    bool CanPredict();
    bool ShouldIDive();
    void Clear() { gMoney.Clear(); }

    bool DoPrediction(int frameAhead);
    void AddBallToArray();
    void DetermineAction();

    int framesBallSeen_;
    bool isMovingAway_;
  
    Ball prevBall_[5];
    Ball predictedBall_;

    bool hadOutlier;
    bool shouldDive;
    double diveDelay;

};

#endif // BALL_PREDICTION_H

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -