| 
      
      
      From: <sgv...@us...> - 2010-05-19 14:58:23
      
     | 
| Revision: 201
          http://simspark.svn.sourceforge.net/simspark/?rev=201&view=rev
Author:   sgvandijk
Date:     2010-05-19 14:58:17 +0000 (Wed, 19 May 2010)
Log Message:
-----------
- clear selection, clear selected agent, monitorinput controls
Modified Paths:
--------------
    branches/agentselection/rcssserver3d/data/rsg/agent/nao/nao.rsg
    branches/agentselection/rcssserver3d/plugin/soccer/agentstate/agentstate.cpp
    branches/agentselection/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.cpp
    branches/agentselection/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.h
    branches/agentselection/rcssserver3d/plugin/soccer/trainercommandparser/trainercommandparser.cpp
    branches/agentselection/rcssserver3d/plugin/soccer/trainercommandparser/trainercommandparser.h
    branches/agentselection/rcssserver3d/plugin/soccermonitor/soccerinput.cpp
    branches/agentselection/rcssserver3d/plugin/soccermonitor/soccerinput.h
    branches/agentselection/rcssserver3d/rcssmonitor3d/soccerbindings.rb
    branches/agentselection/spark/data/scripts/materials.rb
Modified: branches/agentselection/rcssserver3d/data/rsg/agent/nao/nao.rsg
===================================================================
--- branches/agentselection/rcssserver3d/data/rsg/agent/nao/nao.rsg	2010-05-18 16:16:23 UTC (rev 200)
+++ branches/agentselection/rcssserver3d/data/rsg/agent/nao/nao.rsg	2010-05-19 14:58:17 UTC (rev 201)
@@ -69,9 +69,10 @@
             (nd GameStatePerceptor)
             (nd HearPerceptor)
             (nd Transform
-              (nd Sphere
+              (nd Cylinder
                 (setName SelectionMarker)
-                (setRadius 0.4)
+                (setParams 1.0 1.0)
+                (setScale 0.2 0.2 0.02)
                 (setMaterial matSelect)
                 (setTransparent)
               )
Modified: branches/agentselection/rcssserver3d/plugin/soccer/agentstate/agentstate.cpp
===================================================================
--- branches/agentselection/rcssserver3d/plugin/soccer/agentstate/agentstate.cpp	2010-05-18 16:16:23 UTC (rev 200)
+++ branches/agentselection/rcssserver3d/plugin/soccer/agentstate/agentstate.cpp	2010-05-19 14:58:17 UTC (rev 201)
@@ -250,7 +250,6 @@
 void
 AgentState::Select(bool s)
 {
-    cerr << "Selecting " << mUniformNumber << endl;
     mSelected = s;
 }
 
Modified: branches/agentselection/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.cpp
===================================================================
--- branches/agentselection/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.cpp	2010-05-18 16:16:23 UTC (rev 200)
+++ branches/agentselection/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.cpp	2010-05-19 14:58:17 UTC (rev 201)
@@ -212,8 +212,9 @@
 }
 
 void
-SoccerRuleAspect::ClearSelectedPlayers(float min_dist)
+SoccerRuleAspect::ClearSelectedPlayers()
 {
+    float min_dist = mFreeKickMoveDist;
     std::list<boost::shared_ptr<AgentState> > agent_states;
     if (! SoccerBase::GetAgentStates(*mBallState.get(), agent_states, TI_NONE))
         return;
Modified: branches/agentselection/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.h
===================================================================
--- branches/agentselection/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.h	2010-05-18 16:16:23 UTC (rev 200)
+++ branches/agentselection/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.h	2010-05-19 14:58:17 UTC (rev 201)
@@ -100,6 +100,8 @@
     
     void SelectNextAgent();
     
+    void ClearSelectedPlayers();
+
 protected:
     /** rereads the current soccer script values */
     virtual void UpdateCachedInternal();
@@ -194,8 +196,6 @@
      * @param idx the team which kick off
      */
     void ClearPlayersBeforeKickOff(TTeamIndex idx);
-
-    void ClearSelectedPlayers(float min_dist);
                       
 protected:
     /** reference to the body node of the Ball */
Modified: branches/agentselection/rcssserver3d/plugin/soccer/trainercommandparser/trainercommandparser.cpp
===================================================================
--- branches/agentselection/rcssserver3d/plugin/soccer/trainercommandparser/trainercommandparser.cpp	2010-05-18 16:16:23 UTC (rev 200)
+++ branches/agentselection/rcssserver3d/plugin/soccer/trainercommandparser/trainercommandparser.cpp	2010-05-19 14:58:17 UTC (rev 201)
@@ -47,6 +47,7 @@
     mCommandMap["kickOff"] = CT_KICK_OFF;
     mCommandMap["getAck"] = CT_ACK;
     mCommandMap["select"] = CT_SELECT;
+    mCommandMap["kill"] = CT_KILL;
     
     // setup team index map
     // Originally  team sides were "L","R" and "N"
@@ -203,6 +204,9 @@
     case CT_SELECT:
         ParseSelectCommand(predicate);
         break;
+    case CT_KILL:
+        ParseKillCommand(predicate);
+        break;
     default:
         return false;
     }
@@ -240,6 +244,12 @@
     else
       specified = false;
 
+    if (!specified)
+    {
+      mSoccerRule->ClearSelectedPlayers();
+      return;
+    }
+    
     SoccerBase::TAgentStateList agentStates;
     SoccerBase::GetAgentStates(*this, agentStates, (specified ? idx : TI_NONE)); 
     SoccerBase::TAgentStateList::iterator iter = agentStates.begin();
@@ -247,7 +257,7 @@
 
     while (iter != agentStates.end() && !found)
         {   
-            if ((specified && (*iter)->GetUniformNumber() == unum) ||
+            if ((specified && (*iter)->GetUniformNumber() == unum && (*iter)->GetTeamIndex() == idx) ||
                 (!specified && (*iter)->IsSelected()))
                 found = true;                     
             else
@@ -319,31 +329,6 @@
         }
     }
 
-    Predicate::Iterator killParam(predicate);
-    if (predicate.FindParameter(killParam, "kill"))
-    {
-        GameControlServer::TAgentAspectList agentAspects;
-        mGameControl->GetAgentAspectList(agentAspects);
-
-        GameControlServer::TAgentAspectList::iterator aaiter;
-        for (
-              aaiter = agentAspects.begin();
-              aaiter != agentAspects.end();
-              ++aaiter
-            )
-        {
-            // search for the first agent of the left/right side
-            boost::shared_ptr<AgentState> agentState =
-                shared_dynamic_cast<AgentState>((*aaiter)->GetChild("AgentState", true));
-
-            if (agentState == *iter)
-            {
-                mGameControl->pushDisappearedAgent((*aaiter)->ID());
-                break;
-            }
-        }
-    }
-    
     // Joschka: I removed the part to set a velocity because it doesn't really  
     // seem to have a meaning for agents that have more than just a single body
 
@@ -534,6 +519,12 @@
     else
       specified = false;
     
+    if (specified && unum == -1)
+    {
+        soccerRuleAspect->ResetAgentSelection();
+        return;
+    }
+      
     string team;
     TTeamIndex idx;
     Predicate::Iterator teamParam(predicate);
@@ -578,3 +569,64 @@
 
     (*iter)->Select();
 }
+
+void TrainerCommandParser::ParseKillCommand(const oxygen::Predicate & predicate)
+{    
+    Predicate::Iterator unumParam(predicate);
+    int                 unum;
+    bool specified = true;
+    
+    shared_ptr<SoccerRuleAspect> soccerRuleAspect;
+    if (!SoccerBase::GetSoccerRuleAspect(*this, soccerRuleAspect))
+    {
+        GetLog()->Error() << "(TrainerCommandParser) ERROR: can't get soccer rule aspect\n";
+        return;
+    }
+
+    // extract unum
+    if (predicate.FindParameter(unumParam, "unum"))
+    {
+        if (! predicate.GetValue(unumParam, unum))
+          specified = false;
+    }
+    else
+      specified = false;
+    
+    string team;
+    TTeamIndex idx;
+    Predicate::Iterator teamParam(predicate);
+
+    // extract side
+    if (predicate.FindParameter(teamParam, "team"))
+    {
+        if (! predicate.GetValue(teamParam, team))
+          specified = false;
+        else
+            idx = mTeamIndexMap[team];
+    }    
+    else
+      specified = false;
+    
+    GameControlServer::TAgentAspectList agentAspects;
+    mGameControl->GetAgentAspectList(agentAspects);
+    GameControlServer::TAgentAspectList::iterator aaiter;
+    for (
+          aaiter = agentAspects.begin();
+          aaiter != agentAspects.end();
+          ++aaiter
+        )
+    {
+        // search for the first agent of the left/right side
+        boost::shared_ptr<AgentState> agentState =
+            shared_dynamic_cast<AgentState>((*aaiter)->GetChild("AgentState", true));
+
+        if ((specified && agentState->GetUniformNumber() == unum && agentState->GetTeamIndex() == idx) ||
+            (!specified && agentState->IsSelected()))
+        {
+            mGameControl->pushDisappearedAgent((*aaiter)->ID());
+            break;
+        }
+    }
+}
+
+    
Modified: branches/agentselection/rcssserver3d/plugin/soccer/trainercommandparser/trainercommandparser.h
===================================================================
--- branches/agentselection/rcssserver3d/plugin/soccer/trainercommandparser/trainercommandparser.h	2010-05-18 16:16:23 UTC (rev 200)
+++ branches/agentselection/rcssserver3d/plugin/soccer/trainercommandparser/trainercommandparser.h	2010-05-19 14:58:17 UTC (rev 201)
@@ -50,7 +50,8 @@
         CT_DROP_BALL,
         CT_KICK_OFF,
         CT_ACK,
-        CT_SELECT
+        CT_SELECT,
+        CT_KILL
     };
 
     typedef std::map<std::string, ECommandType>  TCommandMap;
@@ -112,6 +113,10 @@
     */
     void ParseSelectCommand(const oxygen::Predicate & predicate);
 
+    /** parses and executes the kill command contained in the given
+        predicate
+    */
+    void ParseKillCommand(const oxygen::Predicate & predicate);
 protected:
     TCommandMap    mCommandMap;
 
Modified: branches/agentselection/rcssserver3d/plugin/soccermonitor/soccerinput.cpp
===================================================================
--- branches/agentselection/rcssserver3d/plugin/soccermonitor/soccerinput.cpp	2010-05-18 16:16:23 UTC (rev 200)
+++ branches/agentselection/rcssserver3d/plugin/soccermonitor/soccerinput.cpp	2010-05-19 14:58:17 UTC (rev 201)
@@ -62,6 +62,7 @@
     
     scriptServer->CreateVariable("Command.NextMode", CmdNextMode);
     scriptServer->CreateVariable("Command.SelectNextAgent", CmdSelectNextAgent);
+    scriptServer->CreateVariable("Command.ResetSelection", CmdResetSelection);
     scriptServer->CreateVariable("Command.KillSelection", CmdKillSelection);
     
     mMonitorClient = shared_dynamic_cast<NetClient>
@@ -148,10 +149,17 @@
                 }
             break;
         
+        case CmdResetSelection:
+            if (input.GetKeyPress())
+                {
+                    SendCommand("(select (unum -1))");
+                }
+            break;
+            
         case CmdKillSelection:
             if (input.GetKeyPress())
                 {
-                    SendCommand("(agent (kill 1))");
+                    SendCommand("(kill)");
                 }
             break;
             
@@ -171,7 +179,7 @@
         case CmdMoveAgent:
             if (input.GetKeyPress())
                 {
-                    //SendCommand("(agent (team Left)(unum 1)(pos -2.0 1.0 3.5))");
+                    SendCommand("(agent)");
                 }
             break;
         case CmdDropBall:
Modified: branches/agentselection/rcssserver3d/plugin/soccermonitor/soccerinput.h
===================================================================
--- branches/agentselection/rcssserver3d/plugin/soccermonitor/soccerinput.h	2010-05-18 16:16:23 UTC (rev 200)
+++ branches/agentselection/rcssserver3d/plugin/soccermonitor/soccerinput.h	2010-05-19 14:58:17 UTC (rev 201)
@@ -55,7 +55,8 @@
             
             CmdNextMode = CmdFreeKickRight + 1,
             CmdSelectNextAgent = CmdNextMode + 1,
-            CmdKillSelection = CmdSelectNextAgent + 1
+            CmdResetSelection = CmdSelectNextAgent + 1,
+            CmdKillSelection = CmdResetSelection + 1
         };
         
     enum ECmdMode
Modified: branches/agentselection/rcssserver3d/rcssmonitor3d/soccerbindings.rb
===================================================================
--- branches/agentselection/rcssserver3d/rcssmonitor3d/soccerbindings.rb	2010-05-18 16:16:23 UTC (rev 200)
+++ branches/agentselection/rcssserver3d/rcssmonitor3d/soccerbindings.rb	2010-05-19 14:58:17 UTC (rev 201)
@@ -27,7 +27,7 @@
     inputServer.bindCommand('k',      Command.KickOff);
     inputServer.bindCommand('j',      Command.KickOffRight);
     inputServer.bindCommand('b',      Command.DropBall);
-    #inputServer.bindCommand('m',      Command.MoveAgent);
+    inputServer.bindCommand('m',      Command.MoveAgent);
     #inputServer.bindCommand('n',      Command.ShootBall);
     #inputServer.bindCommand('x',      Command.MoveBall);
     inputServer.bindCommand('1',      Command.CameraLeftGoal);
@@ -41,6 +41,7 @@
     inputServer.bindCommand('r',      Command.FreeKickRight);
     inputServer.bindCommand('lctrl y',      Command.NextMode);
     inputServer.bindCommand('n',      Command.SelectNextAgent);
+    inputServer.bindCommand('e',      Command.ResetSelection);
     inputServer.bindCommand('x',      Command.KillSelection);
   end
 end
Modified: branches/agentselection/spark/data/scripts/materials.rb
===================================================================
--- branches/agentselection/spark/data/scripts/materials.rb	2010-05-18 16:16:23 UTC (rev 200)
+++ branches/agentselection/spark/data/scripts/materials.rb	2010-05-19 14:58:17 UTC (rev 201)
@@ -36,9 +36,9 @@
 
 # selection marker
 material = sparkCreate('kerosin/MaterialSolid', $serverPath+'material/matSelect');
-material.setDiffuse(1.0,0.0,0.0,0.4)
-material.setAmbient(1.0,0.0,0.0,1.0)
-material.setSpecular(1.0,0.5,0.5,1.0);
+material.setDiffuse(1.0,0.0,0.0,0.5)
+material.setAmbient(1.0,0.0,0.0,0.5)
+material.setSpecular(1.0,0.2,0.2,0.5);
 
 # shades of grey
 material = sparkCreate('kerosin/MaterialSolid', $serverPath+'material/matWhite');
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 |