|
From: <sgv...@us...> - 2013-05-22 14:59:04
|
Revision: 351
http://sourceforge.net/p/simspark/svn/351
Author: sgvandijk
Date: 2013-05-22 14:59:02 +0000 (Wed, 22 May 2013)
Log Message:
-----------
- Rename fault to foul
- SoccerRuleAspect keeps list of fouls
- Created SoccerRuleItem; adds fouls to monitor protocol
Modified Paths:
--------------
trunk/rcssserver3d/plugin/soccer/CMakeLists.txt
trunk/rcssserver3d/plugin/soccer/export.cpp
trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.cpp
trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.h
trunk/rcssserver3d/rcssserver3d/naosoccersim.rb
Added Paths:
-----------
trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleitem.cpp
trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleitem.h
trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleitem_c.cpp
Modified: trunk/rcssserver3d/plugin/soccer/CMakeLists.txt
===================================================================
--- trunk/rcssserver3d/plugin/soccer/CMakeLists.txt 2013-05-20 11:28:53 UTC (rev 350)
+++ trunk/rcssserver3d/plugin/soccer/CMakeLists.txt 2013-05-22 14:59:02 UTC (rev 351)
@@ -37,6 +37,7 @@
soccercontrolaspect/soccercontrolaspect.h
soccernode/soccernode.h
soccerruleaspect/soccerruleaspect.h
+ soccerruleaspect/soccerruleitem.h
trainercommandparser/trainercommandparser.h
gametimeperceptor/gametimeperceptor.h
visionperceptor/visionperceptor.h
@@ -106,6 +107,8 @@
soccernode/soccernode_c.cpp
soccerruleaspect/soccerruleaspect.cpp
soccerruleaspect/soccerruleaspect_c.cpp
+ soccerruleaspect/soccerruleitem.cpp
+ soccerruleaspect/soccerruleitem_c.cpp
trainercommandparser/trainercommandparser.cpp
trainercommandparser/trainercommandparser_c.cpp
visionperceptor/visionperceptor.cpp
Modified: trunk/rcssserver3d/plugin/soccer/export.cpp
===================================================================
--- trunk/rcssserver3d/plugin/soccer/export.cpp 2013-05-20 11:28:53 UTC (rev 350)
+++ trunk/rcssserver3d/plugin/soccer/export.cpp 2013-05-22 14:59:02 UTC (rev 351)
@@ -36,6 +36,7 @@
#include "gamestateaspect/gamestateitem.h"
#include "ballstateaspect/ballstateaspect.h"
#include "soccerruleaspect/soccerruleaspect.h"
+#include "soccerruleaspect/soccerruleitem.h"
#include "agentstate/agentstate.h"
#include "sexpmonitor/sexpmonitor.h"
#include "internalsoccermonitor/internalsoccerrender.h"
@@ -63,6 +64,7 @@
ZEITGEIST_EXPORT(GameStateItem);
ZEITGEIST_EXPORT(BallStateAspect);
ZEITGEIST_EXPORT(SoccerRuleAspect);
+ ZEITGEIST_EXPORT(SoccerRuleItem);
ZEITGEIST_EXPORT(BeamEffector);
ZEITGEIST_EXPORT(CatchEffector);
ZEITGEIST_EXPORT(CreateEffector);
Modified: trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.cpp
===================================================================
--- trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.cpp 2013-05-20 11:28:53 UTC (rev 350)
+++ trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.cpp 2013-05-22 14:59:02 UTC (rev 351)
@@ -68,9 +68,9 @@
mMin2PlDistance(0), // min dist for second closest of team before being repositioned
mMin3PlDistance(0), // min dist for third closest of team before being repositioned
mMaxTouchGroupSize(1000),
- mMaxFaultTime(0.0), // maximum time allowed for a player to commit a positional fault before being repositioned
+ mMaxFoulTime(0.0), // maximum time allowed for a player to commit a positional foul before being repositioned
mLastKickOffKickTime(0),
- mCheckKickOffKickerFault(false)
+ mCheckKickOffKickerFoul(false)
{
mFreeKickPos = Vector3f(0.0,0.0,mBallRadius);
}
@@ -93,21 +93,21 @@
void
SoccerRuleAspect::AutomaticSimpleReferee(TPlayMode playMode)
{
- // Reset counters and do not consider players' faults when game is not
+ // Reset counters and do not consider players' fouls when game is not
// running
if (mGameState->IsPaused())
{
- ResetFaultCounter(TI_LEFT);
- ResetFaultCounter(TI_RIGHT);
+ ResetFoulCounter(TI_LEFT);
+ ResetFoulCounter(TI_RIGHT);
}
else
{
CalculateDistanceArrays(TI_LEFT); // Calculates distance arrays for left team
CalculateDistanceArrays(TI_RIGHT); // Calculates distance arrays for right team
- AnalyseFaults(TI_LEFT); // Analyzes simple faults for the left team
- AnalyseFaults(TI_RIGHT); // Analyzes simple faults for the right team
- AnalyseTouchGroups(TI_LEFT);
- AnalyseTouchGroups(TI_RIGHT);
+ AnalyseFouls(TI_LEFT); // Analyzes simple fouls for the left team
+ AnalyseFouls(TI_RIGHT); // Analyzes simple fouls for the right team
+ AnalyseTouchGroups(TI_LEFT); // Analyzes how many players are touching for the left team
+ AnalyseTouchGroups(TI_RIGHT); // Analyzes whether too many players are touching for the right team
ClearPlayersAutomatic(TI_LEFT); // enforce standing and not overcrowding rules for left team
ClearPlayersAutomatic(TI_RIGHT); // enforce standing and not overcrowding rules for right team
@@ -120,21 +120,21 @@
void
-SoccerRuleAspect::ResetFaultCounterPlayer(int unum, TTeamIndex idx)
+SoccerRuleAspect::ResetFoulCounterPlayer(int unum, TTeamIndex idx)
{
playerGround[unum][idx] = 0;
playerNotStanding[unum][idx] = 0;
playerStanding[unum][idx] = 5/0.02; // Considers player has been standing for some time in playoff
prevPlayerInsideOwnArea[unum][idx] = 0;
playerInsideOwnArea[unum][idx] = 0;
- playerFaultTime[unum][idx] = 0;
+ playerFoulTime[unum][idx] = 0;
}
void
-SoccerRuleAspect::ResetFaultCounter(TTeamIndex idx)
+SoccerRuleAspect::ResetFoulCounter(TTeamIndex idx)
{
for(int t=1; t<=11; t++) {
- ResetFaultCounterPlayer(t,idx);
+ ResetFoulCounterPlayer(t,idx);
}
}
@@ -301,7 +301,8 @@
if (pl[idx] >= touchGroup->size() - pl[idx])
{
- playerFaultTime[(*i)->GetUniformNumber()][idx]++;
+ playerFoulTime[(*i)->GetUniformNumber()][idx]++;
+ playerLastFoul[(*i)->GetUniformNumber()][idx] = FT_Touching;
// Remove player from touch group so no more agents are replaced
touchGroup->erase(*i);
}
@@ -309,7 +310,8 @@
{
// I am the last one to enter the group, but the number of
// opponents in the group are more than us
- playerFaultTime[(*oppIt)->GetUniformNumber()][oppIdx]++;
+ playerFoulTime[(*oppIt)->GetUniformNumber()][oppIdx]++;
+ playerLastFoul[(*oppIt)->GetUniformNumber()][oppIdx] = FT_Touching;
touchGroup->erase(*oppIt);
}
}
@@ -330,8 +332,8 @@
}
}
-// Analyse Faults and Creates Fault Time Array
-void SoccerRuleAspect::AnalyseFaults(TTeamIndex idx)
+// Analyse Fouls and Creates Foul Time Array
+void SoccerRuleAspect::AnalyseFouls(TTeamIndex idx)
{
TTeamIndex idx2;
if (idx == TI_LEFT)
@@ -345,13 +347,15 @@
if (unum != 1 && closestPlayerDist[idx2] < mMinOppDistance &&
(distArr[unum][idx] <= mMin3PlDistance + 0.01 && ordArr[unum][idx] == 3))
{
- playerFaultTime[unum][idx]++;
+ playerFoulTime[unum][idx]++;
+ playerLastFoul[unum][idx] = FT_Crowding;
}
// I am the second closest player but i am too near the ball (and not the goalie)
else if(unum != 1 && closestPlayerDist[idx2] < mMinOppDistance &&
distArr[unum][idx] <= mMin2PlDistance + 0.01 && ordArr[unum][idx] == 2 )
{
- playerFaultTime[unum][idx]++;
+ playerFoulTime[unum][idx]++;
+ playerLastFoul[unum][idx] = FT_Crowding;
}
// Too many players inside my own penalty area and Im am the last one to enter or
// the last one to enter was the goalie and I am the one further away from own goal
@@ -359,31 +363,36 @@
(prevPlayerInsideOwnArea[unum][idx] == 0 ||
(prevPlayerInsideOwnArea[1][idx] == 0 && playerInsideOwnArea[1][idx] == 1 && mMaxPlayersInsideOwnArea + 1 == ordGArr[unum][idx]))))
{
- playerFaultTime[unum][idx]++;
+ playerFoulTime[unum][idx]++;
+ playerLastFoul[unum][idx] = FT_IllegalDefence;
}
// I am a field player and on the ground for too much time
else if (unum != 1 && playerGround[unum][idx] > mGroundMaxTime / 0.02)
{
- playerFaultTime[unum][idx]++;
+ playerFoulTime[unum][idx]++;
+ playerLastFoul[unum][idx] = FT_Incapable;
}
// I am a field player and I am not standing for too much time
else if(unum!=1 && playerNotStanding[unum][idx] > mNotStandingMaxTime / 0.02)
{
- playerFaultTime[unum][idx]++;
+ playerFoulTime[unum][idx]++;
+ playerLastFoul[unum][idx] = FT_Incapable;
}
// I am the goalie and I am on the ground for too much time
else if (unum == 1 && playerGround[unum][idx] > mGoalieGroundMaxTime / 0.02)
{
- playerFaultTime[unum][idx]++;
+ playerFoulTime[unum][idx]++;
+ playerLastFoul[unum][idx] = FT_Incapable;
}
// I am the goalie and I and not standing for too much time
else if (unum == 1 && playerNotStanding[unum][idx] > mGoalieNotStandingMaxTime / 0.02)
{
- playerFaultTime[unum][idx]++;
+ playerFoulTime[unum][idx]++;
+ playerLastFoul[unum][idx] = FT_Incapable;
}
else
{
- playerFaultTime[unum][idx]=0;
+ playerFoulTime[unum][idx]=0;
}
}
}
@@ -424,14 +433,16 @@
SoccerBase::GetTransformParent(**i, agent_aspect);
Vector3f agentPos = agent_aspect->GetWorldTransform().Pos();
int unum = (*i)->GetUniformNumber();
- if (playerFaultTime[unum][idx] > mMaxFaultTime / 0.02)
+ if (playerFoulTime[unum][idx] > mMaxFoulTime / 0.02)
{
// I am not a very good soccer player... I am violating the rules...
salt::Vector3f new_pos = RepositionOutsidePos(ballPos, unum, idx);
//Calculate my Reposition pos outside of the field
SoccerBase::MoveAgent(agent_aspect, new_pos);
//Oh my God!! I am flying!! I am going outside of the field
- ResetFaultCounterPlayer(unum, idx);
+ ResetFoulCounterPlayer(unum, idx);
+ // Record faul
+ mFouls.push_back(Foul(mFouls.size() + 1, playerLastFoul[unum][idx], *i));
//cout << "*********Player Repos Num: " << unum << " Team: " << team << " Pos: " << new_pos << endl;
}
}
@@ -591,7 +602,7 @@
}
void
-SoccerRuleAspect::PunishKickOffFault(
+SoccerRuleAspect::PunishKickOffFoul(
boost::shared_ptr<oxygen::AgentAspect> agent)
{
boost::shared_ptr<AgentState> agentState;
@@ -666,6 +677,20 @@
}
}
+vector<SoccerRuleAspect::Foul>
+SoccerRuleAspect::GetFouls() const
+{
+ return mFouls;
+}
+
+vector<SoccerRuleAspect::Foul>
+SoccerRuleAspect::GetFoulsSince(unsigned index) const
+{
+ Foul f(index+1, (EFoulType)0, boost::shared_ptr<AgentState>());
+ vector<SoccerRuleAspect::Foul>::const_iterator low = lower_bound(mFouls.begin(), mFouls.end(), f);
+ return vector<Foul>(low, mFouls.end());
+}
+
void
SoccerRuleAspect::DropBall()
{
@@ -783,7 +808,7 @@
if (SoccerBase::GetGameControlServer(*this, game_control)
&& game_control->GetAgentCount() > 2) // todo: remove this when there is a "penalty" playmode
{
- mCheckKickOffKickerFault = true;
+ mCheckKickOffKickerFoul = true;
}
mLastKickOffKickTime = time;
mLastKickOffTaker = agent;
@@ -1177,7 +1202,7 @@
boost::shared_ptr<AgentAspect> agent;
if (WasLastKickFromKickOff(agent))
{
- PunishKickOffFault(agent);
+ PunishKickOffFoul(agent);
return false;
}
@@ -1189,18 +1214,18 @@
}
bool
-SoccerRuleAspect::CheckKickOffTakerFault()
+SoccerRuleAspect::CheckKickOffTakerFoul()
{
- if (!mCheckKickOffKickerFault)
+ if (!mCheckKickOffKickerFoul)
return false;
boost::shared_ptr<AgentAspect> agent;
if (!WasLastKickFromKickOff(agent)) // second kick
{
- mCheckKickOffKickerFault = false;
+ mCheckKickOffKickerFoul = false;
if (agent == mLastKickOffTaker)
{
- PunishKickOffFault(mLastKickOffTaker);
+ PunishKickOffFoul(mLastKickOffTaker);
return true;
}
}
@@ -1232,7 +1257,7 @@
}
#endif
- if (CheckKickOffTakerFault())
+ if (CheckKickOffTakerFoul())
{
return;
}
@@ -1488,7 +1513,7 @@
SoccerBase::GetSoccerVar(*this,"Min2PlDistance",mMin2PlDistance);
SoccerBase::GetSoccerVar(*this,"Min3PlDistance",mMin3PlDistance);
SoccerBase::GetSoccerVar(*this,"MaxTouchGroupSize",mMaxTouchGroupSize);
- //SoccerBase::GetSoccerVar(*this,"MaxFaultTime",mMaxFaultTime);
+ //SoccerBase::GetSoccerVar(*this,"MaxFoulTime",mMaxFoulTime);
// cout << "MaxInside " << mMaxPlayersInsideOwnArea << endl << endl;
Modified: trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.h
===================================================================
--- trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.h 2013-05-20 11:28:53 UTC (rev 350)
+++ trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.h 2013-05-22 14:59:02 UTC (rev 351)
@@ -46,6 +46,29 @@
public:
typedef std::list<boost::shared_ptr<AgentState> > TAgentStateList;
+ enum EFoulType
+ {
+ FT_Crowding,
+ FT_Touching,
+ FT_IllegalDefence,
+ FT_IllegalAttack,
+ FT_Incapable,
+ FT_KickOff
+ };
+
+ struct Foul
+ {
+ Foul(unsigned _index, EFoulType _type, boost::shared_ptr<AgentState> _agent)
+ : index(_index),
+ type(_type),
+ agent(_agent)
+ {}
+ int index;
+ EFoulType type;
+ boost::shared_ptr<AgentState> agent;
+ bool operator<(Foul const& other) const { return index < other.index; }
+ };
+
public:
SoccerRuleAspect();
virtual ~SoccerRuleAspect();
@@ -76,7 +99,7 @@
*/
//salt::Vector3f RepositionInsidePos(salt::Vector3f initPos, int unum, TTeamIndex idx, float distance);
- /** New rules for repositioning players that commit faults
+ /** New rules for repositioning players that commit fouls
*/
void ClearPlayersAutomatic(TTeamIndex idx);
@@ -91,17 +114,17 @@
*/
void ProcessAgentState(salt::Vector3f pos, int unum, TTeamIndex idx);
- /** Reset the fault time counter for all players and also other counters
+ /** Reset the foul time counter for all players and also other counters
*/
- void ResetFaultCounter(TTeamIndex idx);
+ void ResetFoulCounter(TTeamIndex idx);
- /** Reset the fault time counter for a given player
+ /** Reset the foul time counter for a given player
*/
- void ResetFaultCounterPlayer(int unum, TTeamIndex idx);
+ void ResetFoulCounterPlayer(int unum, TTeamIndex idx);
- /**Analyse Faults from players and increase fault counter of offending players
+ /**Analyse Fouls from players and increase foul counter of offending players
*/
- void AnalyseFaults(TTeamIndex idx);
+ void AnalyseFouls(TTeamIndex idx);
/** Check whether too many agents are touching
*/
@@ -146,7 +169,14 @@
*/
salt::Vector2f GetFieldSize() const;
+ /** Get the foul history
+ */
+ std::vector<Foul> GetFouls() const;
+ /** Get the foul history, starting from given foul index
+ */
+ std::vector<Foul> GetFoulsSince(unsigned index) const;
+
void ResetAgentSelection();
void SelectNextAgent();
@@ -212,7 +242,7 @@
bool CheckOffside();
/** checks if kickoff taker has kicked the ball again before other players */
- bool CheckKickOffTakerFault();
+ bool CheckKickOffTakerFoul();
/** moves the ball to pos setting its linear and angular velocity to 0 */
void MoveBall(const salt::Vector3f& pos);
@@ -257,9 +287,9 @@
void SwapTeamSides();
/**
- * Punish agent's fault committed during kickoff
+ * Punish agent's foul committed during kickoff
*/
- void PunishKickOffFault(boost::shared_ptr<oxygen::AgentAspect> agent);
+ void PunishKickOffFoul(boost::shared_ptr<oxygen::AgentAspect> agent);
/** returns true if last kick was happenned in kick off */
bool WasLastKickFromKickOff(
@@ -342,10 +372,10 @@
int mMaxPlayersInsideOwnArea;
/** maximum number of players that may be in a single touch group */
int mMaxTouchGroupSize;
- /** maximum time allowed for a player to commit a positional fault before being repositioned */
- int mMaxFaultTime;
+ /** maximum time allowed for a player to commit a positional foul before being repositioned */
+ int mMaxFoulTime;
- /* Useful arrays for dealing with agent state an faults */
+ /* Useful arrays for dealing with agent state an fouls */
salt::Vector3f playerPos[12][3]; //Players Positions - not used
int playerGround[12][3]; //Time Players are on the ground
int playerNotStanding[12][3]; //Time Players are not standing (head up for more than 0.5s)
@@ -356,7 +386,8 @@
int ordArr[12][3]; //Distance order of players (left/right team)
float distGArr[12][3]; //Distance array to own goal (left/right team)
int ordGArr[12][3]; //Distance order of players to own goal (left/right team)
- int playerFaultTime[12][3]; //Time player is commiting a positional fault
+ int playerFoulTime[12][3]; //Time player is commiting a positional foul
+ EFoulType playerLastFoul[12][3]; //Type of last foul committed by player
int numPlInsideOwnArea[3]; //Number of players inside own area
int closestPlayer[3]; //Closest Player from each team
float closestPlayerDist[3]; //Closest Player distance to ball from each team
@@ -399,7 +430,10 @@
/** the player which kicked in the last kick off mode */
boost::shared_ptr<oxygen::AgentAspect> mLastKickOffTaker;
/** if kickoff taker should be checked for single kick rule */
- bool mCheckKickOffKickerFault;
+ bool mCheckKickOffKickerFoul;
+
+ /** complete foul history */
+ std::vector<Foul> mFouls;
};
DECLARE_CLASS(SoccerRuleAspect);
Added: trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleitem.cpp
===================================================================
--- trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleitem.cpp (rev 0)
+++ trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleitem.cpp 2013-05-22 14:59:02 UTC (rev 351)
@@ -0,0 +1,78 @@
+/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*-
+
+ this file is part of rcssserver3D
+ Fri May 9 2003
+ Copyright (C) 2002,2003 Koblenz University
+ Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group
+ $Id: gamestateitem.cpp 259 2011-03-24 20:25:24Z hedayat $
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+#include "soccerruleitem.h"
+#include <soccerbase/soccerbase.h>
+#include <agentstate/agentstate.h>
+
+using namespace zeitgeist;
+using namespace oxygen;
+using namespace std;
+
+SoccerRuleItem::SoccerRuleItem()
+ : MonitorItem(),
+ mLastFoul(0)
+{
+}
+
+SoccerRuleItem::~SoccerRuleItem()
+{
+}
+
+void SoccerRuleItem::GetInitialPredicates(PredicateList& pList)
+{
+ GetPredicates(pList);
+}
+
+void SoccerRuleItem::AddFoul(SoccerRuleAspect::Foul const& foul, PredicateList& pList)
+{
+ Predicate& predicate = pList.AddPredicate();
+ predicate.name = "foul";
+ predicate.parameter.AddValue(foul.index);
+ predicate.parameter.AddValue((int)foul.type);
+ predicate.parameter.AddValue((int)foul.agent->GetTeamIndex());
+ predicate.parameter.AddValue((int)foul.agent->GetUniformNumber());
+}
+
+void SoccerRuleItem::GetPredicates(PredicateList& pList)
+{
+ if (mSoccerRule.get() == 0)
+ {
+ return;
+ }
+
+ vector<SoccerRuleAspect::Foul> newFouls = mSoccerRule->GetFoulsSince(mLastFoul);
+ for (unsigned i = 0; i < newFouls.size(); ++i)
+ {
+ AddFoul(newFouls[i], pList);
+ mLastFoul = newFouls[i].index;
+ }
+}
+
+void SoccerRuleItem::OnLink()
+{
+ SoccerBase::GetSoccerRuleAspect(*this, mSoccerRule);
+}
+
+void SoccerRuleItem::OnUnlink()
+{
+ mSoccerRule.reset();
+}
Added: trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleitem.h
===================================================================
--- trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleitem.h (rev 0)
+++ trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleitem.h 2013-05-22 14:59:02 UTC (rev 351)
@@ -0,0 +1,64 @@
+/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*-
+
+ this file is part of rcssserver3D
+ Fri May 9 2003
+ Copyright (C) 2002,2003 Koblenz University
+ Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group
+ $Id: gamestateitem.h 21 2009-01-14 14:38:57Z yxu $
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+#ifndef SOCCERRULEITEM_H
+#define SOCCERRULEITEM_H
+
+#include <oxygen/monitorserver/monitoritem.h>
+#include "soccerruleaspect.h"
+
+class SoccerRuleItem : public oxygen::MonitorItem
+{
+public:
+ SoccerRuleItem();
+ virtual ~SoccerRuleItem();
+
+ /** This function is called once for every MonitorSystem each time
+ * a new client connects. It should append predicates to a list
+ * that is sent using the active monitor
+ */
+ virtual void GetInitialPredicates(oxygen::PredicateList& pList);
+
+ /** This function will be called periodically to append predicates
+ to a list that is sent using the active monitor
+ */
+ virtual void GetPredicates(oxygen::PredicateList& pList);
+
+ /** sets the reference to the GameStateAspect */
+ virtual void OnLink();
+
+ /** resets the reference to the GameStateAspect */
+ virtual void OnUnlink();
+
+protected:
+ boost::shared_ptr<SoccerRuleAspect> mSoccerRule;
+
+ //! Last foul sent out to monitors
+ unsigned mLastFoul;
+
+ void AddFoul(SoccerRuleAspect::Foul const& foul, oxygen::PredicateList& pList);
+
+};
+
+DECLARE_CLASS(SoccerRuleItem)
+
+#endif // SOCCERRULEITEM_H
+
Added: trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleitem_c.cpp
===================================================================
--- trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleitem_c.cpp (rev 0)
+++ trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleitem_c.cpp 2013-05-22 14:59:02 UTC (rev 351)
@@ -0,0 +1,30 @@
+/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*-
+
+ this file is part of rcssserver3D
+ Fri May 9 2003
+ Copyright (C) 2002,2003 Koblenz University
+ Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group
+ $Id: gamestateitem_c.cpp 9 2008-11-24 02:39:02Z hedayat $
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "soccerruleitem.h"
+
+using namespace oxygen;
+
+void CLASS(SoccerRuleItem)::DefineClass()
+{
+ DEFINE_BASECLASS(MonitorItem);
+}
Modified: trunk/rcssserver3d/rcssserver3d/naosoccersim.rb
===================================================================
--- trunk/rcssserver3d/rcssserver3d/naosoccersim.rb 2013-05-20 11:28:53 UTC (rev 350)
+++ trunk/rcssserver3d/rcssserver3d/naosoccersim.rb 2013-05-22 14:59:02 UTC (rev 351)
@@ -124,6 +124,7 @@
monitorServer = get($serverPath+'monitor')
if (monitorServer != nil)
monitorServer.registerMonitorItem('GameStateItem')
+ monitorServer.registerMonitorItem('SoccerRuleItem')
end
# install the TrainerCommandParser to parse commands received from a
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|