diff --git a/Core/src/Algorithm/BallSpeedModel.cpp b/Core/src/Algorithm/BallSpeedModel.cpp index 7c00f89..95a0b54 100644 --- a/Core/src/Algorithm/BallSpeedModel.cpp +++ b/Core/src/Algorithm/BallSpeedModel.cpp @@ -40,9 +40,9 @@ std::tuple CBallSpeedModel::predictForDist(const double dist){ auto time = (v0 - v1) / _DEC; return {time, Utils::Polar2Vector(v1, _ballVel.dir())}; } -MobileVisionT CBallSpeedModel::poseForTime(const double time){ +ObjectPoseT CBallSpeedModel::poseForTime(const double time){ this->update(); - MobileVisionT predictPose; + ObjectPoseT predictPose; auto v0 = _ballVel.mod(); auto v1 = std::max(v0 - _DEC * time, 0.0); auto runtime = std::min(v0 / _DEC, time); diff --git a/Core/src/Algorithm/BallSpeedModel.h b/Core/src/Algorithm/BallSpeedModel.h index 9a33ce3..7b9a191 100644 --- a/Core/src/Algorithm/BallSpeedModel.h +++ b/Core/src/Algorithm/BallSpeedModel.h @@ -14,7 +14,7 @@ class CBallSpeedModel std::tuple predictForDist(const double dist); // 计算若干距离后的速度 double timeForDist(const double dist); //计算球运动若干距离的时间 CVector speedForDist(const double dist); // 计算球运动若干距离的速度 - MobileVisionT poseForTime(const double time); // 计算若干帧以后的绝对位置 + ObjectPoseT poseForTime(const double time); // 计算若干帧以后的绝对位置 private: void update(); CGeoPoint _ballPos; diff --git a/Core/src/Algorithm/BallStatus.cpp b/Core/src/Algorithm/BallStatus.cpp index 0b86cf6..5e6bbad 100644 --- a/Core/src/Algorithm/BallStatus.cpp +++ b/Core/src/Algorithm/BallStatus.cpp @@ -55,7 +55,7 @@ void CBallStatus::UpdateBallStatus(const CVisionModule* pVision) void CBallStatus::UpdateBallMoving(const CVisionModule* pVision) { - const MobileVisionT& ball = pVision->ball(); // 球 + const ObjectPoseT& ball = pVision->ball(); // 球 isNearPlayer = false; for (int i=0; iallPlayer(i).Valid() && pVision->allPlayer(i).Pos().dist(ball.Pos())< PARAM::Field::MAX_PLAYER_SIZE/2+5){ diff --git a/Core/src/Algorithm/ContactChecker.cpp b/Core/src/Algorithm/ContactChecker.cpp index f8950d2..4ad734a 100644 --- a/Core/src/Algorithm/ContactChecker.cpp +++ b/Core/src/Algorithm/ContactChecker.cpp @@ -33,7 +33,7 @@ bool isPointOutField(CGeoPoint pos) } void ContactChecker::OutFieldJudge(const CVisionModule* pVision) { - MobileVisionT last_ball=pVision->ball(pVision->getCycle()-4); + ObjectPoseT last_ball=pVision->ball(pVision->getCycle()-4); if (pVision->ball().Valid()&&isPointOutField(pVision->ball().Pos())){ _isBallOutField=true; } diff --git a/Core/src/Algorithm/ContactChecker.h b/Core/src/Algorithm/ContactChecker.h index 0ccc531..a338ac5 100644 --- a/Core/src/Algorithm/ContactChecker.h +++ b/Core/src/Algorithm/ContactChecker.h @@ -23,8 +23,8 @@ class ContactChecker { std::vector AllPlayer; Last_Contact _last_contact; - MobileVisionT _ball; - MobileVisionT _lastball; + ObjectPoseT _ball; + ObjectPoseT _lastball; CVector ball_direction_before; CVector ball_direction_after; double speed_before ; diff --git a/Core/src/LuaModule/ballspeedmodel.pkg b/Core/src/LuaModule/ballspeedmodel.pkg index 39ba87a..e4c7e6a 100644 --- a/Core/src/LuaModule/ballspeedmodel.pkg +++ b/Core/src/LuaModule/ballspeedmodel.pkg @@ -3,5 +3,5 @@ class CBallSpeedModel { double timeForDist(const double dist); CVector speedForDist(const double dist); - MobileVisionT poseForTime(const double time); + ObjectPoseT poseForTime(const double time); }; \ No newline at end of file diff --git a/Core/src/LuaModule/visionmodule.pkg b/Core/src/LuaModule/visionmodule.pkg index 6698928..abf17e7 100644 --- a/Core/src/LuaModule/visionmodule.pkg +++ b/Core/src/LuaModule/visionmodule.pkg @@ -17,10 +17,10 @@ class CVisionModule{ const PlayerVisionT& allPlayer(int num) const; const PlayerVisionT& ourPlayer(int num) const; const PlayerVisionT& theirPlayer(int num) const; - const MobileVisionT& ball() const; + const ObjectPoseT& ball() const; const PlayerVisionT& ourPlayer(int cycle, int num) const; const PlayerVisionT& theirPlayer(int cycle, int num) const; - const MobileVisionT& ball(int cycle) const; + const ObjectPoseT& ball(int cycle) const; const ObjectPoseT& rawBall() const; const CGeoPoint& getBallPlacementPosition() const; const RobotRawVisionData& ourRawPlayer(int num) const; diff --git a/Core/src/LuaModule/worlddefine.pkg b/Core/src/LuaModule/worlddefine.pkg index bf6beb3..a8a4d6a 100644 --- a/Core/src/LuaModule/worlddefine.pkg +++ b/Core/src/LuaModule/worlddefine.pkg @@ -16,18 +16,11 @@ class ObjectPoseT{ double VelY() const; void SetValid(bool v); bool Valid() const; -}; - -class VisionObjectT{ const CGeoPoint& RawPos() const; void SetRawPos(double x, double y); void SetRawPos(const CGeoPoint& pos); }; -class MobileVisionT : public ObjectPoseT, public VisionObjectT{ - -}; - struct PlayerPoseT : public ObjectPoseT{ PlayerPoseT(); double Dir() const; @@ -39,12 +32,12 @@ struct PlayerPoseT : public ObjectPoseT{ }; class PlayerTypeT{ - void SetType(int t); - int Type() const; -}; -class PlayerVisionT : public PlayerPoseT, public VisionObjectT, public PlayerTypeT{ +}; +class PlayerVisionT : public PlayerPoseT { + void SetType(int t); + int Type() const; }; struct PlayerCapabilityT{ diff --git a/Core/src/MotionControl/DynamicsSafetySearch.cpp b/Core/src/MotionControl/DynamicsSafetySearch.cpp index 2ba4131..8fba1b8 100644 --- a/Core/src/MotionControl/DynamicsSafetySearch.cpp +++ b/Core/src/MotionControl/DynamicsSafetySearch.cpp @@ -383,7 +383,7 @@ bool CDynamicSafetySearch::CheckAccel (const int player, vector2f acc, const CVi if(pVision->ball().Valid() && (_flag & PlayerStatus::DODGE_BALL)) { vector2f pj = vector2f(pVision->ball().Pos().x(), pVision->ball().Pos().y()); vector2f vj = vector2f(pVision->ball().VelX(), pVision->ball().VelY()); - const MobileVisionT& last_ball = pVision->ball(pVision->getLastCycle()); + const ObjectPoseT& last_ball = pVision->ball(pVision->getLastCycle()); vector2f Aj; Aj = (vj - vector2f(last_ball.VelX(), last_ball.VelY())) /_C; if(CheckRobot(player, _pos, _vel, acc, -1, pj, vj, Aj, type, limitTime) == UNSAFE) { diff --git a/Core/src/OtherLibs/cmu/obstacle.cpp b/Core/src/OtherLibs/cmu/obstacle.cpp index e0c0550..bf7a1aa 100644 --- a/Core/src/OtherLibs/cmu/obstacle.cpp +++ b/Core/src/OtherLibs/cmu/obstacle.cpp @@ -442,12 +442,12 @@ void obstacles::addObs(const CVisionModule *pVision, const TaskT &task, bool dra // ball if(flags & PlayerStatus::DODGE_BALL) { - const MobileVisionT& ball = pVision->ball(); + const ObjectPoseT& ball = pVision->ball(); add_circle(vector2f(ball.Pos().x(), ball.Pos().y()), vector2f(ball.Vel().x(), ball.Vel().y()), ballAvoidDist, 1, drawObs); } if(WorldModel::Instance()->CurrentRefereeMsg() == "GameStop") { - const MobileVisionT& ball = pVision->ball(); + const ObjectPoseT& ball = pVision->ball(); add_circle(vector2f(ball.Pos().x(), ball.Pos().y()), vector2f(0.0f, 0.0f), 50.0f, 1, drawObs); } diff --git a/Core/src/PathPlan/ObstacleNew.cpp b/Core/src/PathPlan/ObstacleNew.cpp index 45d4014..8d65eb7 100644 --- a/Core/src/PathPlan/ObstacleNew.cpp +++ b/Core/src/PathPlan/ObstacleNew.cpp @@ -486,13 +486,13 @@ void ObstaclesNew::addObs(const CVisionModule * pVision, const TaskT & task, boo // ball if (flags & PlayerStatus::DODGE_BALL) { - const MobileVisionT& ball = pVision->ball(); + const ObjectPoseT& ball = pVision->ball(); addCircle(ball.RawPos(), ball.Vel(), ballAvoidDist, OBS_CIRCLE_NEW); } if (WorldModel::Instance()->CurrentRefereeMsg() == "GameStop" || (flags & PlayerStatus::AVOID_STOP_BALL_CIRCLE)) { - const MobileVisionT& ball = pVision->ball(); + const ObjectPoseT& ball = pVision->ball(); addCircle(ball.RawPos(), CVector(0.0f, 0.0f), stopBallAvoidDist, OBS_CIRCLE_NEW); } diff --git a/Core/src/Vision/BallPredictor.cpp b/Core/src/Vision/BallPredictor.cpp index b6dff01..9208390 100644 --- a/Core/src/Vision/BallPredictor.cpp +++ b/Core/src/Vision/BallPredictor.cpp @@ -86,8 +86,8 @@ bool CBallPredictor::checkValid(int cycle) { return true; } -void CBallPredictor::setCollisionResult(int cycle, const MobileVisionT& ball) { - MobileVisionT& oldBall = _visionLogger.getVision(cycle); +void CBallPredictor::setCollisionResult(int cycle, const ObjectPoseT& ball) { + ObjectPoseT& oldBall = _visionLogger.getVision(cycle); oldBall = ball; _hasCollision = true; diff --git a/Core/src/Vision/BallPredictor.h b/Core/src/Vision/BallPredictor.h index 5dd21d6..af31c29 100644 --- a/Core/src/Vision/BallPredictor.h +++ b/Core/src/Vision/BallPredictor.h @@ -21,7 +21,7 @@ const double MAX_DIST = 1000.0 / PARAM::Vision::FRAME_RATE * 4; const int MAX_LOGS = 16; } -class BallVisionData : public MobileVisionT { +class BallVisionData : public ObjectPoseT { public: BallVisionData(): cycle(-1) {} int cycle; @@ -64,10 +64,10 @@ class CBallPredictor { BallVisionData& getData(int cycle) { return _visionLogger.getVision(cycle); } - const MobileVisionT& getResult(int cycle) const { + const ObjectPoseT& getResult(int cycle) const { return _visionLogger.getVision(cycle); } - void setCollisionResult(int cycle, const MobileVisionT& ball); + void setCollisionResult(int cycle, const ObjectPoseT& ball); int visibility() const { return _visibility; } @@ -91,7 +91,7 @@ class CBallPredictor { bool checkValid(int cycle); // 去掉不合理的情况 private: CBallVisionLogger _visionLogger; - MobileVisionT _ballLinePredictData[60]; + ObjectPoseT _ballLinePredictData[60]; int _ballLostTime; // 看不到球的次数 int _ballInvalidMovedCycle; // 球的信息不合理的周期数 int _visibility, _activity; // 可见度和活动度 diff --git a/Core/src/Vision/CollisionSimulator.h b/Core/src/Vision/CollisionSimulator.h index e720ee2..c8a5328 100644 --- a/Core/src/Vision/CollisionSimulator.h +++ b/Core/src/Vision/CollisionSimulator.h @@ -9,10 +9,10 @@ class CCollisionSimulator{ CCollisionSimulator() : _hasCollision(false){ } void reset(const CGeoPoint& ballRawPos, const CVector& ballVel); void simulate(PlayerVisionT robot, const double time); // 模拟一定时间 - const MobileVisionT& ball() const { return _ball; } + const ObjectPoseT& ball() const { return _ball; } bool hasCollision() const { return _hasCollision; } private: - MobileVisionT _ball; // 球的信息 + ObjectPoseT _ball; // 球的信息 CVector _ballRelToRobot; // 球在机器人局部坐标系中的位置 bool _hasCollision; // 是否碰撞 }; diff --git a/Core/src/Vision/RobotPredictor.cpp b/Core/src/Vision/RobotPredictor.cpp index 423d445..2d00ce0 100644 --- a/Core/src/Vision/RobotPredictor.cpp +++ b/Core/src/Vision/RobotPredictor.cpp @@ -34,7 +34,7 @@ CRobotPredictor::CRobotPredictor(bool isHasRotation) : _robotLostTime(0), _isHas // _robotFilter.initialize(PARAM::File::RobotPosFilterDir + "slowMatrices.txt", PARAM::File::RobotPosFilterDir + "fastMatrices.txt"); // } } -void CRobotPredictor::updateVision(int cycle, const VehicleInfoT& player, const MobileVisionT& ball, bool invert) { +void CRobotPredictor::updateVision(int cycle, const VehicleInfoT& player, const ObjectPoseT& ball, bool invert) { // !!!!这里好像有问题: // 如果是对手车也能识别朝向,就会调用updateOurVision, 但因为在该函数里取不到cmd(只有我方车才有cmd存下来), 结果就不对. // 这里需要一个辨别我方车与对方车的方式!! @@ -95,7 +95,7 @@ void CRobotPredictor::updateVision(int cycle, const VehicleInfoT& player, const } } -//void CRobotPredictor::updateOurVision(int cycle, const VehicleInfoT& player, const MobileVisionT& ball, bool invert, int realNum) { +//void CRobotPredictor::updateOurVision(int cycle, const VehicleInfoT& player, const ObjectPoseT& ball, bool invert, int realNum) { // const double x = invert ? -player.pos.x : player.pos.x; // const double y = invert ? -player.pos.y : player.pos.y; // double dir = 0; @@ -279,7 +279,7 @@ void CRobotPredictor::updateVision(int cycle, const VehicleInfoT& player, const // predictedVision.SetType(player.type); //} -//void CRobotPredictor::updateTheirVision(int cycle, const VehicleInfoT & player, const MobileVisionT & ball, bool invert, int realNum) { +//void CRobotPredictor::updateTheirVision(int cycle, const VehicleInfoT & player, const ObjectPoseT & ball, bool invert, int realNum) { // const double x = invert ? -player.pos.x : player.pos.x; // const double y = invert ? -player.pos.y : player.pos.y; // double dir = 0; @@ -435,7 +435,7 @@ bool CRobotPredictor::checkValid(int cycle, const CGeoPoint & pos) { } return true; } -void CRobotPredictor::predictLost(int cycle, const MobileVisionT & ball) { +void CRobotPredictor::predictLost(int cycle, const ObjectPoseT & ball) { //cout<ourPlayer(runner); const auto mouseVec = Utils::Polar2Vector(PARAM::Vehicle::V2::PLAYER_CENTER_TO_BALL_CENTER, me.Dir()); const auto mousePos = me.Pos() + mouseVec; - const MobileVisionT& ball = pVision->ball(); + const ObjectPoseT& ball = pVision->ball(); const double ballVelDir = ball.Vel().dir(); const CGeoPoint& ballPos = ball.RawPos(); const CGeoLine ballVelLine(ballPos, ballVelDir); diff --git a/ZBin/lua_scripts/worldmodel/player.lua b/ZBin/lua_scripts/worldmodel/player.lua index 533e962..fd42bbd 100644 --- a/ZBin/lua_scripts/worldmodel/player.lua +++ b/ZBin/lua_scripts/worldmodel/player.lua @@ -42,6 +42,10 @@ function posY(role) return instance(role):Y() end +function rawPos(role) + return instance(role):RawPos() +end + function dir(role) return instance(role):Dir() end