|
From: <sgv...@us...> - 2010-05-18 16:16:29
|
Revision: 200
http://simspark.svn.sourceforge.net/simspark/?rev=200&view=rev
Author: sgvandijk
Date: 2010-05-18 16:16:23 +0000 (Tue, 18 May 2010)
Log Message:
-----------
- kill command kills selected agent
Modified Paths:
--------------
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/rcssserver3d/rcssserver3d/simspark.rb
branches/agentselection/spark/data/scripts/materials.rb
branches/agentselection/spark/lib/kerosin/inputserver/inputcontrol.cpp
branches/agentselection/spark/lib/kerosin/inputserver/inputserver.cpp
branches/agentselection/spark/plugin/inputsdl/keyboardsdl.cpp
branches/agentselection/spark/plugin/inputsdl/mousesdl.cpp
Modified: branches/agentselection/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.cpp
===================================================================
--- branches/agentselection/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.cpp 2010-05-17 18:50:22 UTC (rev 199)
+++ branches/agentselection/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.cpp 2010-05-18 16:16:23 UTC (rev 200)
@@ -1411,8 +1411,6 @@
void
SoccerRuleAspect::SelectNextAgent()
{
- cerr << "Selecting Next Agent..." << endl;
-
std::list<boost::shared_ptr<AgentState> > agent_states;
bool selectNext = false;
if (SoccerBase::GetAgentStates(*mBallState.get(), agent_states, TI_NONE) && agent_states.size() > 0)
Modified: branches/agentselection/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.h
===================================================================
--- branches/agentselection/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.h 2010-05-17 18:50:22 UTC (rev 199)
+++ branches/agentselection/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.h 2010-05-18 16:16:23 UTC (rev 200)
@@ -45,7 +45,6 @@
{
public:
typedef std::list<boost::shared_ptr<AgentState> > TAgentStateList;
- typedef std::pair<TTeamIndex, int> TAgentSelection;
public:
SoccerRuleAspect();
Modified: branches/agentselection/rcssserver3d/plugin/soccer/trainercommandparser/trainercommandparser.cpp
===================================================================
--- branches/agentselection/rcssserver3d/plugin/soccer/trainercommandparser/trainercommandparser.cpp 2010-05-17 18:50:22 UTC (rev 199)
+++ branches/agentselection/rcssserver3d/plugin/soccer/trainercommandparser/trainercommandparser.cpp 2010-05-18 16:16:23 UTC (rev 200)
@@ -29,6 +29,7 @@
#include <agentstate/agentstate.h>
#include <soccertypes.h>
#include <gamestateaspect/gamestateaspect.h>
+#include <oxygen/agentaspect/agentaspect.h>
#include "trainercommandparser.h"
using namespace std;
@@ -107,6 +108,15 @@
GetLog()->Error() << "ERROR: (TrainerCommnadParser) failed to create SexpParser\n";
return;
}
+
+ mGameControl = shared_dynamic_cast<GameControlServer>
+ (GetCore()->Get("/sys/server/gamecontrol"));
+
+ if (mGameControl.get() == 0)
+ {
+ GetLog()->Error() << "ERROR: (TrainerCommandParser) Unable to get GameControlServer\n";
+ }
+
}
void TrainerCommandParser::OnUnlink()
@@ -152,8 +162,6 @@
// lookup the command type corresponding to the predicate name
TCommandMap::iterator iter = mCommandMap.find(predicate.name);
- cerr << "Trainer command: " << predicate.name << endl;
-
if (iter == mCommandMap.end())
{
return false;
@@ -206,17 +214,17 @@
{
Predicate::Iterator unumParam(predicate);
int unum;
+ bool specified = true;
// extract unum
if (predicate.FindParameter(unumParam, "unum"))
{
if (! predicate.GetValue(unumParam, unum))
- {
- GetLog()->Error() << "(TrainerCommandParser) ERROR: can't get unum\n";
- return;
- }
+ specified = false;
}
-
+ else
+ specified = false;
+
string team;
TTeamIndex idx;
Predicate::Iterator teamParam(predicate);
@@ -225,26 +233,23 @@
if (predicate.FindParameter(teamParam, "team"))
{
if (! predicate.GetValue(teamParam, team))
- {
- GetLog()->Error() << "(TrainerCommandParser) ERROR: can't get team name\n";
- return;
- }
-
- idx = mTeamIndexMap[team];
+ specified = false;
+ else
+ idx = mTeamIndexMap[team];
}
+ else
+ specified = false;
-
SoccerBase::TAgentStateList agentStates;
- SoccerBase::GetAgentStates(*this, agentStates, idx);
+ SoccerBase::GetAgentStates(*this, agentStates, (specified ? idx : TI_NONE));
SoccerBase::TAgentStateList::iterator iter = agentStates.begin();
bool found = false;
while (iter != agentStates.end() && !found)
{
- if ((*iter)->GetUniformNumber() == unum)
- {
- found = true;
- }
+ if ((specified && (*iter)->GetUniformNumber() == unum) ||
+ (!specified && (*iter)->IsSelected()))
+ found = true;
else
++iter;
}
@@ -256,7 +261,6 @@
}
Predicate::Iterator posParam(predicate);
-
if (predicate.FindParameter(posParam, "pos"))
{
salt::Vector3f pos;
@@ -315,6 +319,31 @@
}
}
+ 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
@@ -489,12 +518,9 @@
int unum;
bool specified = true;
- cerr << "Parsing Select Command..." << endl;
-
shared_ptr<SoccerRuleAspect> soccerRuleAspect;
if (!SoccerBase::GetSoccerRuleAspect(*this, soccerRuleAspect))
{
- cerr << "(TrainerCommandParser) ERROR: can't get soccer rule aspect\n" << endl;
GetLog()->Error() << "(TrainerCommandParser) ERROR: can't get soccer rule aspect\n";
return;
}
Modified: branches/agentselection/rcssserver3d/plugin/soccer/trainercommandparser/trainercommandparser.h
===================================================================
--- branches/agentselection/rcssserver3d/plugin/soccer/trainercommandparser/trainercommandparser.h 2010-05-17 18:50:22 UTC (rev 199)
+++ branches/agentselection/rcssserver3d/plugin/soccer/trainercommandparser/trainercommandparser.h 2010-05-18 16:16:23 UTC (rev 200)
@@ -33,6 +33,11 @@
#include <soccertypes.h>
#include <soccerruleaspect/soccerruleaspect.h>
+namespace oxygen
+{
+ class GameControlServer;
+}
+
class TrainerCommandParser : public oxygen::MonitorCmdParser
{
public:
@@ -120,6 +125,8 @@
boost::shared_ptr<SoccerRuleAspect> mSoccerRule;
//! the parser used to create the PredicateList
boost::shared_ptr<oxygen::BaseParser> mSexpParser;
+ //! cached reference to the game control server
+ boost::shared_ptr<oxygen::GameControlServer> mGameControl;
bool mGetAck;
std::string mAckString;
Modified: branches/agentselection/rcssserver3d/plugin/soccermonitor/soccerinput.cpp
===================================================================
--- branches/agentselection/rcssserver3d/plugin/soccermonitor/soccerinput.cpp 2010-05-17 18:50:22 UTC (rev 199)
+++ branches/agentselection/rcssserver3d/plugin/soccermonitor/soccerinput.cpp 2010-05-18 16:16:23 UTC (rev 200)
@@ -62,7 +62,7 @@
scriptServer->CreateVariable("Command.NextMode", CmdNextMode);
scriptServer->CreateVariable("Command.SelectNextAgent", CmdSelectNextAgent);
-
+ scriptServer->CreateVariable("Command.KillSelection", CmdKillSelection);
mMonitorClient = shared_dynamic_cast<NetClient>
(GetCore()->Get("/sys/server/simulation/SparkMonitorClient"));
@@ -147,6 +147,13 @@
SendCommand("(select)");
}
break;
+
+ case CmdKillSelection:
+ if (input.GetKeyPress())
+ {
+ SendCommand("(agent (kill 1))");
+ }
+ break;
case CmdKickOff:
if (input.GetKeyPress())
Modified: branches/agentselection/rcssserver3d/plugin/soccermonitor/soccerinput.h
===================================================================
--- branches/agentselection/rcssserver3d/plugin/soccermonitor/soccerinput.h 2010-05-17 18:50:22 UTC (rev 199)
+++ branches/agentselection/rcssserver3d/plugin/soccermonitor/soccerinput.h 2010-05-18 16:16:23 UTC (rev 200)
@@ -54,7 +54,8 @@
CmdFreeKickRight = CmdFreeKickLeft + 1,
CmdNextMode = CmdFreeKickRight + 1,
- CmdSelectNextAgent = CmdNextMode + 1
+ CmdSelectNextAgent = CmdNextMode + 1,
+ CmdKillSelection = CmdSelectNextAgent + 1
};
enum ECmdMode
Modified: branches/agentselection/rcssserver3d/rcssmonitor3d/soccerbindings.rb
===================================================================
--- branches/agentselection/rcssserver3d/rcssmonitor3d/soccerbindings.rb 2010-05-17 18:50:22 UTC (rev 199)
+++ branches/agentselection/rcssserver3d/rcssmonitor3d/soccerbindings.rb 2010-05-18 16:16:23 UTC (rev 200)
@@ -41,5 +41,6 @@
inputServer.bindCommand('r', Command.FreeKickRight);
inputServer.bindCommand('lctrl y', Command.NextMode);
inputServer.bindCommand('n', Command.SelectNextAgent);
+ inputServer.bindCommand('x', Command.KillSelection);
end
end
Modified: branches/agentselection/rcssserver3d/rcssserver3d/simspark.rb
===================================================================
--- branches/agentselection/rcssserver3d/rcssserver3d/simspark.rb 2010-05-17 18:50:22 UTC (rev 199)
+++ branches/agentselection/rcssserver3d/rcssserver3d/simspark.rb 2010-05-18 16:16:23 UTC (rev 200)
@@ -48,7 +48,7 @@
sparkLogErrorToCerr()
#sparkLogAllToCerr()
#sparkLogAllToFile('spark.txt')
-sparkLogDebugToCerr()
+#sparkLogDebugToCerr()
#
# uncomment any of the following to run a simulation
Modified: branches/agentselection/spark/data/scripts/materials.rb
===================================================================
--- branches/agentselection/spark/data/scripts/materials.rb 2010-05-17 18:50:22 UTC (rev 199)
+++ branches/agentselection/spark/data/scripts/materials.rb 2010-05-18 16:16:23 UTC (rev 200)
@@ -36,8 +36,9 @@
# selection marker
material = sparkCreate('kerosin/MaterialSolid', $serverPath+'material/matSelect');
-material.setDiffuse(1.0,0.0,0.0,0.2)
-material.setAmbient(1.0,0.0,0.0,0.2)
+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);
# shades of grey
material = sparkCreate('kerosin/MaterialSolid', $serverPath+'material/matWhite');
Modified: branches/agentselection/spark/lib/kerosin/inputserver/inputcontrol.cpp
===================================================================
--- branches/agentselection/spark/lib/kerosin/inputserver/inputcontrol.cpp 2010-05-17 18:50:22 UTC (rev 199)
+++ branches/agentselection/spark/lib/kerosin/inputserver/inputcontrol.cpp 2010-05-18 16:16:23 UTC (rev 200)
@@ -212,21 +212,21 @@
break;
default:
+ // pass unknown events on to the registered InputItems
+ TLeafList items;
+ ListChildrenSupportingClass<InputItem>(items);
+
+ for (
+ TLeafList::iterator iter = items.begin();
+ iter != items.end();
+ ++iter
+ )
+ {
+ shared_static_cast<InputItem>(*iter)
+ ->ProcessInput(input);
+ }
break;
}
- // pass unknown events on to the registered InputItems
- TLeafList items;
- ListChildrenSupportingClass<InputItem>(items);
-
- for (
- TLeafList::iterator iter = items.begin();
- iter != items.end();
- ++iter
- )
- {
- shared_static_cast<InputItem>(*iter)
- ->ProcessInput(input);
- }
}
if (mAdvanceTime)
Modified: branches/agentselection/spark/lib/kerosin/inputserver/inputserver.cpp
===================================================================
--- branches/agentselection/spark/lib/kerosin/inputserver/inputserver.cpp 2010-05-17 18:50:22 UTC (rev 199)
+++ branches/agentselection/spark/lib/kerosin/inputserver/inputserver.cpp 2010-05-18 16:16:23 UTC (rev 200)
@@ -288,6 +288,7 @@
// return Input::eUser input
return true;
}
+
// translate raw input to binding
TBindMap::iterator bindListIter = mBindings.find(input.mCode);
if (bindListIter == mBindings.end())
@@ -322,13 +323,13 @@
#else
const Bind& bind = (*bindIter);
- //printf("Looking at: %d %d %d", (*bind).mCode, (*bind).cmd, (*bind).modifier);
if (
(bind.modifier == 0 && input.mModState == 0) ||
(bind.modifier & input.mModState)
)
#endif
{
+
input.mId = bind.cmd;
return true;
}
Modified: branches/agentselection/spark/plugin/inputsdl/keyboardsdl.cpp
===================================================================
--- branches/agentselection/spark/plugin/inputsdl/keyboardsdl.cpp 2010-05-17 18:50:22 UTC (rev 199)
+++ branches/agentselection/spark/plugin/inputsdl/keyboardsdl.cpp 2010-05-18 16:16:23 UTC (rev 200)
@@ -265,7 +265,7 @@
Input input(Input::eButton, sym);
input.mData.l = (event->type == SDL_KEYDOWN);
input.mModState = modState;
- mInputSystem->AddInput(input);
+ mInputSystem->AddInputInternal(input);
return 0;
}
Modified: branches/agentselection/spark/plugin/inputsdl/mousesdl.cpp
===================================================================
--- branches/agentselection/spark/plugin/inputsdl/mousesdl.cpp 2010-05-17 18:50:22 UTC (rev 199)
+++ branches/agentselection/spark/plugin/inputsdl/mousesdl.cpp 2010-05-18 16:16:23 UTC (rev 200)
@@ -69,6 +69,7 @@
}
input.mData.l = (event->type == SDL_MOUSEBUTTONDOWN);
+ input.mModState = 0;
mInputSystem->AddInputInternal(input);
return 0;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|