00001 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- 00002 00003 this file is part of rcssserver3D 00004 Fri May 9 2003 00005 Copyright (C) 2002,2003 Koblenz University 00006 Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group 00007 00008 This program is free software; you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation; version 2 of the License. 00011 00012 This program is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with this program; if not, write to the Free Software 00019 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00020 */ 00021 #ifndef CATCHEFFECTOR_H 00022 #define CATCHEFFECTOR_H 00023 00024 #include <oxygen/agentaspect/effector.h> 00025 #include <oxygen/physicsserver/body.h> 00026 #include <soccer/ball/ball.h> 00027 #include <soccer/ballstateaspect/ballstateaspect.h> 00028 00029 namespace salt 00030 { 00031 class AABB2; 00032 } 00033 00034 namespace oxygen 00035 { 00036 class Body; 00037 class AgentAspect; 00038 } 00039 00040 class AgentState; 00041 00042 class SoccerRuleAspect; 00043 00044 class CatchEffector : public oxygen::Effector 00045 { 00046 public: 00047 CatchEffector(); 00048 virtual ~CatchEffector(); 00049 00051 virtual bool Realize(boost::shared_ptr<oxygen::ActionObject> action); 00052 00054 virtual std::string GetPredicate() { return "catch"; } 00055 00057 virtual boost::shared_ptr<oxygen::ActionObject> 00058 GetActionObject(const oxygen::Predicate& predicate); 00059 00061 virtual void OnLink(); 00062 00064 virtual void OnUnlink(); 00065 00067 void SetCatchMargin(float margin); 00068 00069 protected: 00071 void MoveBall(const salt::Vector3f& pos); 00073 boost::shared_ptr<SoccerRuleAspect> mSoccerRule; 00074 00075 protected: 00077 boost::shared_ptr<oxygen::Body> mBallBody; 00079 boost::shared_ptr<oxygen::AgentAspect> mAgent; 00081 boost::shared_ptr<AgentState> mAgentState; 00082 00084 salt::AABB2 mRightPenaltyArea; 00086 salt::AABB2 mLeftPenaltyArea; 00087 00089 float mFieldLength; 00091 float mGoalWidth; 00092 00093 private: 00095 float mCatchMargin; 00097 float mPlayerRadius; 00099 float mBallRadius; 00100 }; 00101 00102 DECLARE_CLASS(CatchEffector); 00103 00104 #endif // CATCHEFFECTOR_H