From: <pat...@us...> - 2014-02-19 17:46:51
|
Revision: 371 http://sourceforge.net/p/simspark/svn/371 Author: patmac369 Date: 2014-02-19 17:46:49 +0000 (Wed, 19 Feb 2014) Log Message: ----------- This commit includes the following changes for the 2014 competition: - labeling of hear messages with team names - Ex: (hear teamName 9 10 text) - score reporting - Ex: (GS (unum 8) (team left) (sl 1) (sr 2) (t 0.00) (pm BeforeKickOff)) - robot type checking to ensure that enough robot types (3) are used and that not too many of any one (7) or two (9) types is used - Allowed formations include (7-1-1-1-1), (4-4-3), (3-3-3-2), (3-2-2-2-2), etc. but not (7-3-1) - Updating naorobottypes.rb with robot types for the 2014 competition (the same ones that were used at the 2013 competition) For backwards compatibility the following options have been added to naosoccersim.rb to toggle on and off these changes. LabelMessages - Toggles on/off labeling of messages (default on) ReportScores - Toggles on/off score reporting (default on) MaxRobotTypeCount - Maximum number of any one robot type that may be used (default 7 and can be set to 11 to preserve 2013 competition behavior) MinRobotTypesCount - Minimum number of robot types that must be used for a full team (default 3 and can be set to 1 to preserve 2013 competition behavior) MaxSumTwoRobotTypes - The maximum sum of robots for any two robot types (default 9 but can be set to 11 to preserve 2013 competition behavior) Modified Paths: -------------- trunk/rcssserver3d/plugin/soccer/agentstate/agentstate.cpp trunk/rcssserver3d/plugin/soccer/agentstate/agentstate.h trunk/rcssserver3d/plugin/soccer/gamestateaspect/gamestateaspect.cpp trunk/rcssserver3d/plugin/soccer/gamestateaspect/gamestateaspect.h trunk/rcssserver3d/plugin/soccer/gamestateperceptor/gamestateperceptor.cpp trunk/rcssserver3d/plugin/soccer/gamestateperceptor/gamestateperceptor.h trunk/rcssserver3d/plugin/soccer/hearperceptor/hearperceptor.cpp trunk/rcssserver3d/plugin/soccer/hearperceptor/hearperceptor.h trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.cpp trunk/rcssserver3d/rcssserver3d/naorobottypes.rb trunk/rcssserver3d/rcssserver3d/naosoccersim.rb Modified: trunk/rcssserver3d/plugin/soccer/agentstate/agentstate.cpp =================================================================== --- trunk/rcssserver3d/plugin/soccer/agentstate/agentstate.cpp 2013-06-19 20:55:49 UTC (rev 370) +++ trunk/rcssserver3d/plugin/soccer/agentstate/agentstate.cpp 2014-02-19 17:46:49 UTC (rev 371) @@ -136,7 +136,7 @@ } void -AgentState::AddMessage(const string& msg, float direction, bool teamMate) +AgentState::AddMessage(const string& msg, const string& team, float direction, bool teamMate) { if (teamMate) { @@ -148,6 +148,7 @@ mHearMateCap -= mHearDecay; mMateMsg = msg; + mMateTeam = team; mMateMsgDir = direction; mIfMateMsg = true; } @@ -161,6 +162,7 @@ mHearOppCap -= mHearDecay; mOppMsg = msg; + mOppTeam = team; mOppMsgDir = direction; mIfOppMsg = true; } @@ -174,7 +176,7 @@ } bool -AgentState::GetMessage(string& msg, float& direction, bool teamMate) +AgentState::GetMessage(string& msg, string& team, float& direction, bool teamMate) { if (teamMate) { @@ -189,6 +191,7 @@ } msg = mMateMsg; + team = mMateTeam; direction = mMateMsgDir; mIfMateMsg = false; return true; @@ -206,6 +209,7 @@ } msg = mOppMsg; + team = mOppTeam; direction = mOppMsgDir; mIfOppMsg = false; return true; Modified: trunk/rcssserver3d/plugin/soccer/agentstate/agentstate.h =================================================================== --- trunk/rcssserver3d/plugin/soccer/agentstate/agentstate.h 2013-06-19 20:55:49 UTC (rev 370) +++ trunk/rcssserver3d/plugin/soccer/agentstate/agentstate.h 2014-02-19 17:46:49 UTC (rev 371) @@ -94,11 +94,11 @@ bool ReduceBattery(float consumption); /** Add a new message to the list */ - void AddMessage(const std::string& msg, float direction, bool teamMate); + void AddMessage(const std::string& msg, const std::string& team, float direction, bool teamMate); void AddSelfMessage(const std::string& msg); /** Get the first message from the list */ - bool GetMessage(std::string& msg, float& direction, bool teamMate); + bool GetMessage(std::string& msg, std::string& team, float& direction, bool teamMate); bool GetSelfMessage(std::string& msg); /** Whether agent is selected */ @@ -143,10 +143,12 @@ /** team-mate's message */ std::string mMateMsg; + std::string mMateTeam; float mMateMsgDir; /** opponent's message */ std::string mOppMsg; + std::string mOppTeam; float mOppMsgDir; /** max hear capacity units */ Modified: trunk/rcssserver3d/plugin/soccer/gamestateaspect/gamestateaspect.cpp =================================================================== --- trunk/rcssserver3d/plugin/soccer/gamestateaspect/gamestateaspect.cpp 2013-06-19 20:55:49 UTC (rev 370) +++ trunk/rcssserver3d/plugin/soccer/gamestateaspect/gamestateaspect.cpp 2014-02-19 17:46:49 UTC (rev 371) @@ -41,8 +41,6 @@ mGameHalf = GH_FIRST; mRobotTypeCount[0].push_back(0); // add count for type 0 (default type) mRobotTypeCount[1].push_back(0); - mHeteroCount[0] = 0; - mHeteroCount[1] = 0; mScore[0] = 0; mScore[1] = 0; mLastKickOffGameHalf = GH_NONE; @@ -52,8 +50,9 @@ mAgentRadius = 3.5; mFinished = false; mGamePaused = true; - mMaxHeteroTypeCount = 3; - mMaxTotalHeteroCount = 9; + mMaxRobotTypeCount = 7; + mMinRobotTypesCount = 3; + mMaxSumTwoRobotTypes = 9; mInternalIndex[TI_NONE] = -1; mInternalIndex[TI_LEFT] = 0; mInternalIndex[TI_RIGHT] = 1; @@ -258,26 +257,53 @@ if (i < 0) return false; - if (type) // heterogeneous player + int numRobots = 0; + int numRobotTypes = 0; + int maxSumTwoRobotTypes = 0; + + if (mRobotTypeCount[i].size() <= type) + mRobotTypeCount[i].resize(type+1); + + for (int j = 0; j < mRobotTypeCount[i].size(); j++) { - if (mHeteroCount[i] == mMaxTotalHeteroCount) + if (mRobotTypeCount[i][j] > 0) { - GetLog()->Error() - << "ERROR: (GameStateAspect::InsertRobotType) Hetero player" - " count limit reached.\n"; - return false; + numRobots += mRobotTypeCount[i][j]; + numRobotTypes++; } + int sumTwoRobotTypes = mRobotTypeCount[i][type]+1; + if (j != type) + sumTwoRobotTypes += mRobotTypeCount[i][j]; + + if (sumTwoRobotTypes > maxSumTwoRobotTypes) + maxSumTwoRobotTypes = sumTwoRobotTypes; + } - ++mHeteroCount[i]; + if (mRobotTypeCount[i][type] == mMaxRobotTypeCount) + { + GetLog()->Error() + << "ERROR: (GameStateAspect::InsertRobotType) No more robots " + "of type " << type << " are allowed.\n"; + return false; + } - if (mRobotTypeCount[i].size() <= type) - mRobotTypeCount[i].resize(type+1); - - if (mRobotTypeCount[i][type] == mMaxHeteroTypeCount) + if (maxSumTwoRobotTypes > mMaxSumTwoRobotTypes) + { + GetLog()->Error() + << "ERROR: (GameStateAspect::InsertRobotType) Maximum sum of " + "robots of two robot types limit reached. No more robots of " + "type " << type << " are allowed.\n"; + return false; + } + + if ((11-numRobots) <= (mMinRobotTypesCount-numRobotTypes)) + { + if (mRobotTypeCount[i][type] != 0) { GetLog()->Error() - << "ERROR: (GameStateAspect::InsertRobotType) No more robots " - "of type " << type << " are allowed.\n"; + << "ERROR: (GameStateAspect::InsertRobotType) Minimum number" + " of different robot types not reached. Only robots of a type" + " not yet used can be added.\n"; return false; } } @@ -299,9 +325,6 @@ return false; } - if (type) // heterogeneous player - --mHeteroCount[i]; - --mRobotTypeCount[i][type]; return true; @@ -496,8 +519,9 @@ if (!coinTossKickOff) mNextHalfKickOff = TI_LEFT; - SoccerBase::GetSoccerVar(*this, "MaxHeteroTypeCount", mMaxHeteroTypeCount); - SoccerBase::GetSoccerVar(*this, "MaxTotalHeteroCount", mMaxTotalHeteroCount); + SoccerBase::GetSoccerVar(*this, "MaxRobotTypeCount", mMaxRobotTypeCount); + SoccerBase::GetSoccerVar(*this, "MinRobotTypesCount", mMinRobotTypesCount); + SoccerBase::GetSoccerVar(*this, "MaxSumTwoRobotTypes", mMaxSumTwoRobotTypes); } int Modified: trunk/rcssserver3d/plugin/soccer/gamestateaspect/gamestateaspect.h =================================================================== --- trunk/rcssserver3d/plugin/soccer/gamestateaspect/gamestateaspect.h 2013-06-19 20:55:49 UTC (rev 370) +++ trunk/rcssserver3d/plugin/soccer/gamestateaspect/gamestateaspect.h 2014-02-19 17:46:49 UTC (rev 371) @@ -200,9 +200,6 @@ /** the array of robot type counts for each team */ std::vector<int> mRobotTypeCount[2]; - /** the number of heterogeneous players for each team */ - int mHeteroCount[2]; - /** the scores of two teams */ int mScore[2]; @@ -221,11 +218,14 @@ /** flag if the game is running or paused (e.g. in goal_left/right state) */ bool mGamePaused; - /** the maximum number of heterogeneous players of a single type per team */ - int mMaxHeteroTypeCount; + /** the maximum number of players of a single type per team */ + int mMaxRobotTypeCount; - /** the maximum number of total heterogeneous players for a team */ - int mMaxTotalHeteroCount; + /** the minimum number of different robot types per team */ + int mMinRobotTypesCount; + + /** the maximum sum of robots for any two robot types */ + int mMaxSumTwoRobotTypes; }; DECLARE_CLASS(GameStateAspect); Modified: trunk/rcssserver3d/plugin/soccer/gamestateperceptor/gamestateperceptor.cpp =================================================================== --- trunk/rcssserver3d/plugin/soccer/gamestateperceptor/gamestateperceptor.cpp 2013-06-19 20:55:49 UTC (rev 370) +++ trunk/rcssserver3d/plugin/soccer/gamestateperceptor/gamestateperceptor.cpp 2014-02-19 17:46:49 UTC (rev 371) @@ -33,6 +33,7 @@ GameStatePerceptor::GameStatePerceptor() : oxygen::Perceptor() { mFirstPercept = true; + mReportScore = true; } GameStatePerceptor::~GameStatePerceptor() @@ -127,6 +128,18 @@ InsertInitialPercept(predicate); } + if (mReportScore) { + // score left + ParameterList& slElement = predicate.parameter.AddList(); + slElement.AddValue(string("sl")); + slElement.AddValue(mGameState->GetScore(TI_LEFT)); + + // score right + ParameterList& srElement = predicate.parameter.AddList(); + srElement.AddValue(string("sr")); + srElement.AddValue(mGameState->GetScore(TI_RIGHT)); + } + // time ParameterList& timeElement = predicate.parameter.AddList(); timeElement.AddValue(string("t")); @@ -145,6 +158,7 @@ { SoccerBase::GetGameState(*this,mGameState); SoccerBase::GetAgentState(*this,mAgentState); + SoccerBase::GetSoccerVar(*this,"ReportScore",mReportScore); } void Modified: trunk/rcssserver3d/plugin/soccer/gamestateperceptor/gamestateperceptor.h =================================================================== --- trunk/rcssserver3d/plugin/soccer/gamestateperceptor/gamestateperceptor.h 2013-06-19 20:55:49 UTC (rev 370) +++ trunk/rcssserver3d/plugin/soccer/gamestateperceptor/gamestateperceptor.h 2014-02-19 17:46:49 UTC (rev 371) @@ -73,6 +73,9 @@ is assigned to a team with a successful init command */ bool mFirstPercept; + + /** report game score to agent */ + bool mReportScore; }; DECLARE_CLASS(GameStatePerceptor); Modified: trunk/rcssserver3d/plugin/soccer/hearperceptor/hearperceptor.cpp =================================================================== --- trunk/rcssserver3d/plugin/soccer/hearperceptor/hearperceptor.cpp 2013-06-19 20:55:49 UTC (rev 370) +++ trunk/rcssserver3d/plugin/soccer/hearperceptor/hearperceptor.cpp 2014-02-19 17:46:49 UTC (rev 371) @@ -30,6 +30,7 @@ HearPerceptor::HearPerceptor() : oxygen::Perceptor() { + mLabelMessages = true; } HearPerceptor::~HearPerceptor() @@ -50,6 +51,7 @@ bool result = false; string message; + string team; float direction; if (mAgentState->GetSelfMessage(message)) @@ -58,28 +60,37 @@ Predicate& predicate = predList->AddPredicate(); predicate.name = "hear"; predicate.parameter.Clear(); + if (mLabelMessages) { + predicate.parameter.AddValue(mAgentState->GetPerceptName(ObjectState::PT_Player)); + } predicate.parameter.AddValue(mGameState->GetTime()); predicate.parameter.AddValue(self); predicate.parameter.AddValue(message); result = true; } - if (mAgentState->GetMessage(message, direction, true)) + if (mAgentState->GetMessage(message, team, direction, true)) { Predicate& predicate = predList->AddPredicate(); predicate.name = "hear"; predicate.parameter.Clear(); + if (mLabelMessages) { + predicate.parameter.AddValue(team); + } predicate.parameter.AddValue(mGameState->GetTime()); predicate.parameter.AddValue(direction); predicate.parameter.AddValue(message); result = true; } - if (mAgentState->GetMessage(message, direction, false)) + if (mAgentState->GetMessage(message, team, direction, false)) { Predicate& predicate = predList->AddPredicate(); predicate.name = "hear"; predicate.parameter.Clear(); + if (mLabelMessages) { + predicate.parameter.AddValue(team); + } predicate.parameter.AddValue(mGameState->GetTime()); predicate.parameter.AddValue(direction); predicate.parameter.AddValue(message); @@ -94,6 +105,7 @@ { SoccerBase::GetAgentState(*this, mAgentState); SoccerBase::GetGameState(*this, mGameState); + SoccerBase::GetSoccerVar(*this, "LabelMessages", mLabelMessages); } void Modified: trunk/rcssserver3d/plugin/soccer/hearperceptor/hearperceptor.h =================================================================== --- trunk/rcssserver3d/plugin/soccer/hearperceptor/hearperceptor.h 2013-06-19 20:55:49 UTC (rev 370) +++ trunk/rcssserver3d/plugin/soccer/hearperceptor/hearperceptor.h 2014-02-19 17:46:49 UTC (rev 371) @@ -53,6 +53,11 @@ /** reference to the GameStateAspect */ boost::shared_ptr<GameStateAspect> mGameState; + + /** label agent messages with the team of the sender */ + bool mLabelMessages; + + }; DECLARE_CLASS(HearPerceptor); Modified: trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.cpp =================================================================== --- trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.cpp 2013-06-19 20:55:49 UTC (rev 370) +++ trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.cpp 2014-02-19 17:46:49 UTC (rev 371) @@ -1806,7 +1806,8 @@ Vector3f relPos = pos - new_pos; relPos = SoccerBase::FlipView(relPos, idx); float direction = salt::gRadToDeg(salt::gArcTan2(relPos[1], relPos[0])); - (*it)->AddMessage(message, direction, true); + std::string team = (*it)->GetPerceptName(ObjectState::PT_Player); + (*it)->AddMessage(message, team, direction, true); } } @@ -1828,7 +1829,8 @@ Vector3f relPos = pos - new_pos; relPos = SoccerBase::FlipView(relPos, SoccerBase::OpponentTeam(idx)); float direction = salt::gRadToDeg(salt::gArcTan2(relPos[1], relPos[0])); - (*it)->AddMessage(message, direction, false); + std::string team = (*it)->GetPerceptName(ObjectState::PT_Player); + (*it)->AddMessage(message, team, direction, false); } } } Modified: trunk/rcssserver3d/rcssserver3d/naorobottypes.rb =================================================================== --- trunk/rcssserver3d/rcssserver3d/naorobottypes.rb 2013-06-19 20:55:49 UTC (rev 370) +++ trunk/rcssserver3d/rcssserver3d/naorobottypes.rb 2014-02-19 17:46:49 UTC (rev 371) @@ -9,18 +9,18 @@ }, # Type 1 { - 'ThighRelHip2_Z' => -0.06, - 'AnkleRelShank_Z' => -0.075, + 'ThighRelHip2_Z' => -0.05832, + 'AnkleRelShank_Z' => -0.07332, 'lj5_max_abs_speed' => 6.1395, 'lj6_max_abs_speed' => 6.1395, - 'ElbowRelUpperArm_Y' => 0.11 + 'ElbowRelUpperArm_Y' => 0.10664 }, # Type 2 { 'ThighRelHip2_Z' => -0.04, 'AnkleRelShank_Z' => -0.055, - 'lj5_max_abs_speed' => 9.21, - 'lj6_max_abs_speed' => 4.605, + 'lj5_max_abs_speed' => 8.80667, + 'lj6_max_abs_speed' => 3.47234, 'ElbowRelUpperArm_Y' => 0.07 } Modified: trunk/rcssserver3d/rcssserver3d/naosoccersim.rb =================================================================== --- trunk/rcssserver3d/rcssserver3d/naosoccersim.rb 2013-06-19 20:55:49 UTC (rev 370) +++ trunk/rcssserver3d/rcssserver3d/naosoccersim.rb 2014-02-19 17:46:49 UTC (rev 371) @@ -60,8 +60,9 @@ # agent parameters addSoccerVar('AgentRadius', 0.4) -addSoccerVar('MaxHeteroTypeCount', 3) -addSoccerVar('MaxTotalHeteroCount', 9) +addSoccerVar('MaxRobotTypeCount', 7) +addSoccerVar('MinRobotTypesCount', 3) +addSoccerVar('MaxSumTwoRobotTypes', 9) # ball parameters addSoccerVar('BallRadius', 0.042) @@ -90,8 +91,12 @@ addSoccerVar('MaxPlayersInsideOwnArea',3) addSoccerVar('MinOppDistance',0.8) addSoccerVar('Min2PlDistance',0.4) -addSoccerVar('Min3PlDistance',1.0) +addSoccerVar('Min3PlDistance',1.0) +# 2014 server changes +addSoccerVar('ReportScore', true) +addSoccerVar('LabelMessages', true) + # auto ref parameters for testing (not for use in competition...) #addSoccerVar('NotStandingMaxTime',10) #addSoccerVar('GoalieNotStandingMaxTime',30) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |