From: <sgv...@us...> - 2011-06-23 18:00:56
|
Revision: 285 http://simspark.svn.sourceforge.net/simspark/?rev=285&view=rev Author: sgvandijk Date: 2011-06-23 18:00:49 +0000 (Thu, 23 Jun 2011) Log Message: ----------- - Can requast full monitor frame from MonitorControl - Trainer command to request full monitor frame - Start of RCS3DMonitor (to be able to add RCS3D specific data to monitor data) - Option in vision perceptor to request ball ground truth Modified Paths: -------------- trunk/rcssserver3d/data/rsg/agent/nao/naoneckhead.rsg trunk/rcssserver3d/plugin/soccer/CMakeLists.txt trunk/rcssserver3d/plugin/soccer/export.cpp trunk/rcssserver3d/plugin/soccer/restrictedvisionperceptor/restrictedvisionperceptor.cpp trunk/rcssserver3d/plugin/soccer/restrictedvisionperceptor/restrictedvisionperceptor.h trunk/rcssserver3d/plugin/soccer/restrictedvisionperceptor/restrictedvisionperceptor_c.cpp trunk/rcssserver3d/plugin/soccer/trainercommandparser/trainercommandparser.cpp trunk/rcssserver3d/plugin/soccer/trainercommandparser/trainercommandparser.h trunk/rcssserver3d/rcssmonitor3d/main.cpp trunk/spark/lib/oxygen/simulationserver/monitorcontrol.cpp trunk/spark/lib/oxygen/simulationserver/monitorcontrol.h Added Paths: ----------- trunk/rcssserver3d/plugin/soccer/rcs3dmonitor/ trunk/rcssserver3d/plugin/soccer/rcs3dmonitor/rcs3dmonitor.cpp trunk/rcssserver3d/plugin/soccer/rcs3dmonitor/rcs3dmonitor.h trunk/rcssserver3d/plugin/soccer/rcs3dmonitor/rcs3dmonitor_c.cpp Modified: trunk/rcssserver3d/data/rsg/agent/nao/naoneckhead.rsg =================================================================== --- trunk/rcssserver3d/data/rsg/agent/nao/naoneckhead.rsg 2011-06-06 10:23:16 UTC (rev 284) +++ trunk/rcssserver3d/data/rsg/agent/nao/naoneckhead.rsg 2011-06-23 18:00:49 UTC (rev 285) @@ -89,6 +89,7 @@ (nd RestrictedVisionPerceptor (setViewCones 120 120) (setSenseMyPos false) + (setSenseBallPos false) (setStaticSenseAxis false) (addNoise true) (setInterval 3) Modified: trunk/rcssserver3d/plugin/soccer/CMakeLists.txt =================================================================== --- trunk/rcssserver3d/plugin/soccer/CMakeLists.txt 2011-06-06 10:23:16 UTC (rev 284) +++ trunk/rcssserver3d/plugin/soccer/CMakeLists.txt 2011-06-23 18:00:49 UTC (rev 285) @@ -47,6 +47,7 @@ hmdp_effector/naospecific.h line/line.h agentcollisionhandler/agentcollisionhandler.h + rcs3dmonitor/rcs3dmonitor.h ) set(soccer_LIB_SRCS @@ -123,6 +124,8 @@ line/line_c.cpp agentcollisionhandler/agentcollisionhandler.cpp agentcollisionhandler/agentcollisionhandler_c.cpp + rcs3dmonitor/rcs3dmonitor.cpp + rcs3dmonitor/rcs3dmonitor_c.cpp ) include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${FREETYPE_INCLUDE_DIRS} Modified: trunk/rcssserver3d/plugin/soccer/export.cpp =================================================================== --- trunk/rcssserver3d/plugin/soccer/export.cpp 2011-06-06 10:23:16 UTC (rev 284) +++ trunk/rcssserver3d/plugin/soccer/export.cpp 2011-06-23 18:00:49 UTC (rev 285) @@ -55,6 +55,7 @@ #include "hmdp_effector/hmdpperceptor.h" #include "line/line.h" #include "agentcollisionhandler/agentcollisionhandler.h" +#include "rcs3dmonitor/rcs3dmonitor.h" ZEITGEIST_EXPORT_BEGIN() ZEITGEIST_EXPORT(SoccerControlAspect); @@ -92,5 +93,6 @@ ZEITGEIST_EXPORT(HMDPEffector); ZEITGEIST_EXPORT(Line); ZEITGEIST_EXPORT(AgentCollisionHandler); + ZEITGEIST_EXPORT(RCS3DMonitor); ZEITGEIST_EXPORT_END() Added: trunk/rcssserver3d/plugin/soccer/rcs3dmonitor/rcs3dmonitor.cpp =================================================================== --- trunk/rcssserver3d/plugin/soccer/rcs3dmonitor/rcs3dmonitor.cpp (rev 0) +++ trunk/rcssserver3d/plugin/soccer/rcs3dmonitor/rcs3dmonitor.cpp 2011-06-23 18:00:49 UTC (rev 285) @@ -0,0 +1,459 @@ +/* -*- 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: RCS3DMonitor.cpp 246 2011-02-18 18:44:14Z sgvandijk $ + + 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 "rcs3dmonitor.h" +#include <zeitgeist/logserver/logserver.h> +#include <kerosin/sceneserver/singlematnode.h> +#include <kerosin/materialserver/material.h> +#include <oxygen/monitorserver/monitorcmdparser.h> +#include <oxygen/sceneserver/sceneserver.h> +#include <sstream> + +using namespace kerosin; +using namespace oxygen; +using namespace zeitgeist; +using namespace boost; +using namespace salt; +using namespace std; + +RCS3DMonitor::RCS3DMonitor() : oxygen::MonitorSystem() +{ + mFullState = true; +} + +RCS3DMonitor::~RCS3DMonitor() +{ +} + +void RCS3DMonitor::ClearNodeCache() +{ + mNodeCache.clear(); +} + +void RCS3DMonitor::UpdateCached() +{ + MonitorSystem::UpdateCached(); + ClearNodeCache(); +} + +void RCS3DMonitor::OnLink() +{ + // setup SceneServer reference + mSceneServer = shared_dynamic_cast<SceneServer> + (GetCore()->Get("/sys/server/scene")); + + if (mSceneServer.get() == 0) + { + GetLog()->Error() + << "(RCS3DMonitor) ERROR: SceneServer not found\n"; + } +} + +void RCS3DMonitor::OnUnlink() +{ + mSceneServer.reset(); + mActiveScene.reset(); + ClearNodeCache(); +} + +void RCS3DMonitor::ParseMonitorMessage(const std::string& data) +{ + // pass the received string on to all installed CommandParsers + TLeafList items; + ListChildrenSupportingClass<MonitorCmdParser>(items); + + for ( + TLeafList::iterator iter = items.begin(); + iter != items.end(); + ++iter + ) + { + shared_static_cast<MonitorCmdParser>(*iter) + ->ParseMonitorMessage(data); + } +} + +string RCS3DMonitor::GetMonitorInfo(const PredicateList& pList) +{ + stringstream ss; + mFullState = false; + DescribeCustomPredicates(ss,pList); + DescribeActiveScene(ss); + + return ss.str(); +} + +string RCS3DMonitor::GetMonitorHeaderInfo(const PredicateList& pList) +{ + stringstream ss; + mFullState = true; + ClearNodeCache(); + DescribeCustomPredicates(ss,pList); + DescribeActiveScene(ss); + + return ss.str(); +} + +void RCS3DMonitor::DescribeCustomPredicates(stringstream& ss,const PredicateList& pList) +{ + ss << "("; + + for ( + PredicateList::TList::const_iterator iter = pList.begin(); + iter != pList.end(); + ++iter + ) + { + const Predicate& pred = (*iter); + + ss << "("; + ss << pred.name; + + const ParameterList& paramList = pred.parameter; + ParameterList::TVector::const_iterator pIter = paramList.begin(); + + std::string param; + while ( + (pIter != paramList.end()) && + (paramList.AdvanceValue(pIter, param)) + ) + { + ss << " "; + ss << param; + } + + ss << ")"; + } + + ss << ")"; +} + +void RCS3DMonitor::DescribeBall(stringstream& ss, NodeCache& entry, boost::shared_ptr<Ball> ball) +{ + if (mFullState) + { + ss << "(nd Ball"; + } else + { + ss << "(nd"; + } + + DescribeTransform(ss, entry, boost::shared_static_cast<Transform>(ball), false); +} + +void RCS3DMonitor::DescribeBaseNode(stringstream& ss) +{ + if (mFullState) + { + ss << "(nd BN"; + } else + { + ss << "(nd"; + } +} + +void RCS3DMonitor::DescribeLight(stringstream& ss, boost::shared_ptr<Light> light) +{ + if (! mFullState) + { + return DescribeBaseNode(ss); + } + + ss << "(nd Light "; + + const RGBA& diff = light->GetDiffuse(); + ss << "(setDiffuse " << diff.r() << " " << diff.g() << " " + << diff.b() << " " << diff.a() << ") "; + + const RGBA& amb = light->GetAmbient(); + ss << "(setAmbient " << amb.r() << " " << amb.g() << " " + << amb.b() << " " << amb.a() << ") "; + + const RGBA& spec = light->GetSpecular(); + ss << "(setSpecular " << spec.r() << " " << spec.g() << " " + << spec.b() << " " << spec.a() << ")"; +} + +void RCS3DMonitor::DescribeTransform(stringstream& ss, NodeCache& entry, boost::shared_ptr<Transform> transform, bool prefix) +{ + if (prefix) + if (mFullState) + { + ss << "(nd TRF"; + } else + { + ss << "(nd"; + } + + // include transform data only for fullstate or a modified + // transform node + const float precision = 0.005f; + const Matrix& mat = transform->GetLocalTransform(); + + bool update = false; + + if (mFullState) + { + update = true; + } else + { + const salt::Matrix& old = entry.transform; + + for (int i=0;i<16;++i) + { + const float d = fabs(old.m[i] - mat.m[i]); + + if (d > precision) + { + update = true; + break; + } + } + } + + if (update) + { + ss << " (SLT"; + + for (int i=0;i<16;++i) + { + ss << " " << mat.m[i]; + } + + ss << ")"; + + // update cache + entry.transform = mat; + } +} + +void RCS3DMonitor::DescribeMesh(stringstream& ss, boost::shared_ptr<StaticMesh> mesh) +{ + boost::shared_ptr<SingleMatNode> singleMat = + shared_dynamic_cast<SingleMatNode>(mesh); + + if (singleMat.get() != 0) + { + ss << "(nd SMN"; + } else + { + ss << "(nd StaticMesh"; + } + + if (mFullState || mesh->VisibleToggled()) + if (mesh->IsVisible()) + ss << " (setVisible 1)"; + else + ss << " (setVisible 0)"; + + if (! mFullState) + return; + + if (mesh->IsTransparent()) + { + ss << " (setTransparent)"; + } + + ss << " (load " << mesh->GetMeshName(); + + const ParameterList& params = mesh->GetMeshParameter(); + for ( + ParameterList::TVector::const_iterator iter = params.begin(); + iter != params.end(); + ++iter + ) + { + string str; + params.GetValue(iter,str); + ss << " " << str; + } + + ss << ")"; + + const Vector3f& scale = mesh->GetScale(); + + ss << " (sSc " + << scale[0] << " " + << scale[1] << " " + << scale[2] << ")"; + + if (singleMat.get() != 0) + { + boost::shared_ptr<Material> mat = singleMat->GetMaterial(); + if (mat.get() != 0) + { + ss << " (sMat " << mat->GetName() << ")"; + } + } + else{ + std::vector<std::string> mats = mesh->GetMaterialNames(); + if ( !mats.empty() ){ + ss<<"(resetMaterials"; + for(std::vector<std::string>::const_iterator iter = mats.begin(); + mats.end() != iter; ++iter){ + ss<<' '<<*iter; + } + ss<<')'; + } + } +} + +RCS3DMonitor::NodeCache* RCS3DMonitor::LookupNode(boost::shared_ptr<BaseNode> node) +{ + if (node.get() == 0) + { + assert(false); + return 0; + } + + // Check whether we already have this node in cache + TNodeCacheMap::iterator iter = mNodeCache.find(node); + if (iter != mNodeCache.end()) + { + return &((*iter).second); + } + + // Ball + boost::shared_ptr<Ball> ball + = shared_dynamic_cast<Ball>(node); + if (ball.get() != 0) + { + mNodeCache[node] + = NodeCache(NT_BALL, ball->GetLocalTransform()); + + return &(mNodeCache[node]); + } + + // Transform + boost::shared_ptr<Transform> transform + = shared_dynamic_cast<Transform>(node); + if (transform.get() != 0) + { + mNodeCache[node] + = NodeCache(NT_TRANSFORM, transform->GetLocalTransform()); + + return &(mNodeCache[node]); + } + + boost::shared_ptr<StaticMesh> mesh + = shared_dynamic_cast<StaticMesh>(node); + if (mesh.get() != 0) + { + mNodeCache[node] = NodeCache(NT_STATICMESH); + return &(mNodeCache[node]); + } + + boost::shared_ptr<Light> light + = shared_dynamic_cast<Light>(node); + if (light.get() != 0) + { + mNodeCache[node] = NodeCache(NT_LIGHT); + return &(mNodeCache[node]); + } + + // treat every other node type as a BaseNode + mNodeCache[node] = NodeCache(NT_BASE); + + return &(mNodeCache[node]); +} + +bool RCS3DMonitor::DescribeNode(stringstream& ss, boost::shared_ptr<BaseNode> node) +{ + NodeCache* entry = LookupNode(node); + if (entry == 0) + { + // skip node + assert(false); + return false; + } + + switch (entry->type) + { + default: + assert(false); + // fall through + + case NT_BASE: + // skip node + return false; + + case NT_BALL: + DescribeBall + (ss, (*entry), shared_static_cast<Ball>(node)); + + case NT_TRANSFORM: + DescribeTransform + (ss, (*entry), shared_static_cast<Transform>(node)); + return true; + + case NT_STATICMESH: + DescribeMesh + (ss, shared_static_cast<StaticMesh>(node)); + return true; + + case NT_LIGHT: + DescribeLight + (ss, shared_static_cast<Light>(node)); + return true; + } +} + +void RCS3DMonitor::DescribeActiveScene(stringstream& ss) +{ + if (mSceneServer.get() == 0) + { + return; + } + + mActiveScene = mSceneServer->GetActiveScene(); + + if (mActiveScene.get() != 0) + { + if (mFullState) + { + ss << "(RSG 0 1)"; + } else + { + ss << "(RDS 0 1)"; + } + + ss << "("; + DescribeScene(ss,mActiveScene); + ss << ")"; + } +} + +void RCS3DMonitor::DescribeScene(stringstream& ss, boost::shared_ptr<BaseNode> node) +{ + bool closeParen = DescribeNode(ss, node); + + TLeafList baseNodes = node->GetBaseNodeChildren(); + for (TLeafList::iterator i = baseNodes.begin(); i!= baseNodes.end(); ++i) + { + boost::shared_ptr<BaseNode> baseNode = shared_dynamic_cast<BaseNode>(*i); + DescribeScene(ss,baseNode); + } + + if (closeParen) + { + ss << ")"; + } +} Added: trunk/rcssserver3d/plugin/soccer/rcs3dmonitor/rcs3dmonitor.h =================================================================== --- trunk/rcssserver3d/plugin/soccer/rcs3dmonitor/rcs3dmonitor.h (rev 0) +++ trunk/rcssserver3d/plugin/soccer/rcs3dmonitor/rcs3dmonitor.h 2011-06-23 18:00:49 UTC (rev 285) @@ -0,0 +1,150 @@ +/* -*- 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: sparkmonitor.h 3 2008-11-21 02:38:08Z 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. +*/ +#ifndef RCS3DMONITOR_H__ +#define RCS3DMONITOR_H__ + +#include <oxygen/monitorserver/monitorsystem.h> +#include <oxygen/sceneserver/sceneserver.h> +#include <oxygen/sceneserver/scene.h> +#include <oxygen/sceneserver/transform.h> +#include <kerosin/sceneserver/staticmesh.h> +#include <kerosin/sceneserver/light.h> +#include <oxygen/physicsserver/body.h> +#include "../ball/ball.h" + +class RCS3DMonitor : public oxygen::MonitorSystem +{ +public: + enum ENodeType + { + NT_BASE = 0, + NT_TRANSFORM, + NT_STATICMESH, + NT_LIGHT, + NT_BALL + }; + + struct NodeCache + { + public: + ENodeType type; + + /** the last local transform matrix sent to the client */ + salt::Matrix transform; + + public: + NodeCache(ENodeType nt = NT_BASE) + : type(nt) + { + } + + NodeCache(ENodeType nt, const salt::Matrix& t) + : type(nt), transform(t) + { + } + }; + + typedef std::map<boost::shared_ptr<oxygen::BaseNode>, NodeCache> TNodeCacheMap; + +public: + RCS3DMonitor(); + virtual ~RCS3DMonitor(); + + /** If a monitor sends information to the world model, this + * function is called to process it. + * @param data data sent from monitor to monitorsystem via SPADES. + */ + void ParseMonitorMessage(const std::string& data); + + /** This function will be called periodically to get information + * about the current state of the world. + * \param items holds a list of additional name value pairs. These + * predicates are collected from MonitorItem objects registered to + * the MonitorServer. The monitor should transfer them to the + * client if possible. + */ + virtual std::string GetMonitorInfo(const oxygen::PredicateList& pList); + + /** This function is called once for every MonitorSystem each time + * a new client connects. It should return any header/setup + * information that is needed. + * \param items holds a list of additional name value + * pairs. These predicates are collected from MonitorItem objects + * registered to the MonitorServer. The monitor should transfer + * them to the client if possible. + */ + virtual std::string GetMonitorHeaderInfo(const oxygen::PredicateList& pList); + + /** update variables from a script */ + virtual void UpdateCached(); + +protected: + virtual void OnLink(); + virtual void OnUnlink(); + + void ClearNodeCache(); + + /** This function looks the cached node entry in the node + cache. The entry is added to the cache if it does not exist + */ + NodeCache* LookupNode(boost::shared_ptr<oxygen::BaseNode> node); + + void DescribeCustomPredicates(std::stringstream& ss,const oxygen::PredicateList& pList); + void DescribeActiveScene(std::stringstream& ss); + void DescribeScene(std::stringstream& ss, + boost::shared_ptr<oxygen::BaseNode> node); + + /** This function writes the s-expression for the given node to + the given strinstream, omitting the closing parentheses. It + returns false if the node is skipped and no description is + created. Skipped nodes are invisible scene graph nodes. + */ + bool DescribeNode(std::stringstream& ss, + boost::shared_ptr<oxygen::BaseNode> node); + void DescribeBaseNode(std::stringstream& ss); + void DescribeBall(std::stringstream& ss, NodeCache& entry, + boost::shared_ptr<Ball> ball); + void DescribeTransform(std::stringstream& ss, NodeCache& entry, + boost::shared_ptr<oxygen::Transform> transform, bool prefix = true); + void DescribeMesh(std::stringstream& ss, + boost::shared_ptr<kerosin::StaticMesh> mesh); + void DescribeLight(std::stringstream& ss, + boost::shared_ptr<kerosin::Light> light); + +protected: + /** cached reference to the SceneServer */ + boost::shared_ptr<oxygen::SceneServer> mSceneServer; + + /** cached reference to the current active scene */ + boost::shared_ptr<oxygen::Scene> mActiveScene; + + /** true, if the full state is generated */ + bool mFullState; + + /** cached node type and state */ + TNodeCacheMap mNodeCache; +}; + +DECLARE_CLASS(RCS3DMonitor); + +#endif // RCS3DMONITOR_H__ + Added: trunk/rcssserver3d/plugin/soccer/rcs3dmonitor/rcs3dmonitor_c.cpp =================================================================== --- trunk/rcssserver3d/plugin/soccer/rcs3dmonitor/rcs3dmonitor_c.cpp (rev 0) +++ trunk/rcssserver3d/plugin/soccer/rcs3dmonitor/rcs3dmonitor_c.cpp 2011-06-23 18:00:49 UTC (rev 285) @@ -0,0 +1,29 @@ +/* -*- 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: sparkmonitor_c.cpp 3 2008-11-21 02:38:08Z 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 "rcs3dmonitor.h" + +void +CLASS(RCS3DMonitor)::DefineClass() +{ + DEFINE_BASECLASS(oxygen/BaseParser); +} + Modified: trunk/rcssserver3d/plugin/soccer/restrictedvisionperceptor/restrictedvisionperceptor.cpp =================================================================== --- trunk/rcssserver3d/plugin/soccer/restrictedvisionperceptor/restrictedvisionperceptor.cpp 2011-06-06 10:23:16 UTC (rev 284) +++ trunk/rcssserver3d/plugin/soccer/restrictedvisionperceptor/restrictedvisionperceptor.cpp 2011-06-23 18:00:49 UTC (rev 285) @@ -38,6 +38,7 @@ RestrictedVisionPerceptor::RestrictedVisionPerceptor() : Perceptor(), mSenseMyPos(false), + mSenseBallPos(false), mAddNoise(true), mStaticSenseAxis(true), mSenseLine(false) @@ -460,6 +461,21 @@ element.AddValue(sensedMyPos[2]); } + if (mSenseBallPos) + { + TTeamIndex ti = mAgentState->GetTeamIndex(); + boost::shared_ptr<Ball> ball; + SoccerBase::GetBall(*this, ball); + Vector3f sensedBallPos = SoccerBase::FlipView(ball->GetWorldTransform().Pos(), ti); + + ParameterList& element = predicate.parameter.AddList(); + element.AddValue(std::string("ballpos")); + element.AddValue(sensedBallPos[0]); + element.AddValue(sensedBallPos[1]); + element.AddValue(sensedBallPos[2]); + + } + if (mSenseLine) { SenseLine(predicate); @@ -562,6 +578,21 @@ element.AddValue(sensedMyPos[2]); } + if (mSenseBallPos) + { + TTeamIndex ti = mAgentState->GetTeamIndex(); + boost::shared_ptr<Ball> ball; + SoccerBase::GetBall(*this, ball); + Vector3f sensedBallPos = SoccerBase::FlipView(ball->GetWorldTransform().Pos(), ti); + + ParameterList& element = predicate.parameter.AddList(); + element.AddValue(std::string("ballpos")); + element.AddValue(sensedBallPos[0]); + element.AddValue(sensedBallPos[1]); + element.AddValue(sensedBallPos[2]); + + } + if (mSenseLine) { SenseLine(predicate); @@ -633,6 +664,12 @@ mSenseMyPos = sense; } +void +RestrictedVisionPerceptor::SetSenseBallPos(bool sense) +{ + mSenseBallPos = sense; +} + bool RestrictedVisionPerceptor::CheckVisuable(RestrictedVisionPerceptor::ObjectData& od) const { // theta is the angle in horizontal plane, with fwAngle as 0 degree Modified: trunk/rcssserver3d/plugin/soccer/restrictedvisionperceptor/restrictedvisionperceptor.h =================================================================== --- trunk/rcssserver3d/plugin/soccer/restrictedvisionperceptor/restrictedvisionperceptor.h 2011-06-06 10:23:16 UTC (rev 284) +++ trunk/rcssserver3d/plugin/soccer/restrictedvisionperceptor/restrictedvisionperceptor.h 2011-06-23 18:00:49 UTC (rev 285) @@ -30,6 +30,7 @@ #include <oxygen/agentaspect/agentaspect.h> #include <agentstate/agentstate.h> #include "../line/line.h" +#include "../ball/ball.h" class RestrictedVisionPerceptor : public oxygen::Perceptor { @@ -104,6 +105,9 @@ //! Turn sensing of agent position on/off void SetSenseMyPos(bool sense); + //! Turn sensing of agent position on/off + void SetSenseBallPos(bool sense); + // turn sensing of lines on/off void SetSenseLine(bool sense); @@ -207,6 +211,9 @@ //! true, if the absolute position of the agent is sensed. bool mSenseMyPos; + + //! true, if the absolute position of the ball is sensed. + bool mSenseBallPos; //! sigma for random measurement error (distance) float mSigmaDist; Modified: trunk/rcssserver3d/plugin/soccer/restrictedvisionperceptor/restrictedvisionperceptor_c.cpp =================================================================== --- trunk/rcssserver3d/plugin/soccer/restrictedvisionperceptor/restrictedvisionperceptor_c.cpp 2011-06-06 10:23:16 UTC (rev 284) +++ trunk/rcssserver3d/plugin/soccer/restrictedvisionperceptor/restrictedvisionperceptor_c.cpp 2011-06-23 18:00:49 UTC (rev 285) @@ -80,6 +80,22 @@ return true; } +FUNCTION(RestrictedVisionPerceptor,setSenseBallPos) +{ + bool inSenseBallPos; + + if ( + (in.GetSize() != 1) || + (! in.GetValue(in.begin(),inSenseBallPos)) + ) + { + return false; + } + + obj->SetSenseBallPos(inSenseBallPos); + return true; +} + FUNCTION(RestrictedVisionPerceptor,setStaticSenseAxis) { bool inStaticAxis; @@ -172,6 +188,7 @@ DEFINE_FUNCTION(setNoiseParams); DEFINE_FUNCTION(addNoise); DEFINE_FUNCTION(setSenseMyPos); + DEFINE_FUNCTION(setSenseBallPos); DEFINE_FUNCTION(setStaticSenseAxis); DEFINE_FUNCTION(setViewCones); DEFINE_FUNCTION(setPanRange); Modified: trunk/rcssserver3d/plugin/soccer/trainercommandparser/trainercommandparser.cpp =================================================================== --- trunk/rcssserver3d/plugin/soccer/trainercommandparser/trainercommandparser.cpp 2011-06-06 10:23:16 UTC (rev 284) +++ trunk/rcssserver3d/plugin/soccer/trainercommandparser/trainercommandparser.cpp 2011-06-23 18:00:49 UTC (rev 285) @@ -51,6 +51,8 @@ mCommandMap["kill"] = CT_KILL; mCommandMap["repos"] = CT_REPOS; mCommandMap["killsim"] = CT_KILLSIM; + mCommandMap["reqfullstate"] = CT_REQFULLSTATE; + // setup team index map // Originally team sides were "L","R" and "N" // But this seems to be unused @@ -128,7 +130,13 @@ GetLog()->Error() << "ERROR: (TrainerCommandParser) Unable to get SimulationServer\n"; } - + mMonitorControl = shared_dynamic_cast<MonitorControl> + (mSimServer->GetControlNode("MonitorControl")); + + if (mMonitorControl.get() == 0) + { + GetLog()->Error() << "ERROR: (TrainerCommandParser) Unable to get MonitorControl\n"; + } } void TrainerCommandParser::OnUnlink() @@ -224,6 +232,10 @@ case CT_KILLSIM: ParseKillSimCommand(predicate); break; + case CT_REQFULLSTATE: + mMonitorControl->RequestFullState(); + break; + default: return false; } Modified: trunk/rcssserver3d/plugin/soccer/trainercommandparser/trainercommandparser.h =================================================================== --- trunk/rcssserver3d/plugin/soccer/trainercommandparser/trainercommandparser.h 2011-06-06 10:23:16 UTC (rev 284) +++ trunk/rcssserver3d/plugin/soccer/trainercommandparser/trainercommandparser.h 2011-06-23 18:00:49 UTC (rev 285) @@ -33,6 +33,7 @@ #include <soccertypes.h> #include <soccerruleaspect/soccerruleaspect.h> #include <oxygen/simulationserver/simulationserver.h> +#include <oxygen/simulationserver/monitorcontrol.h> namespace oxygen { @@ -54,7 +55,8 @@ CT_SELECT, CT_KILL, CT_REPOS, - CT_KILLSIM + CT_KILLSIM, + CT_REQFULLSTATE }; typedef std::map<std::string, ECommandType> TCommandMap; @@ -148,6 +150,8 @@ boost::shared_ptr<oxygen::GameControlServer> mGameControl; //! cached reference to the simulation server boost::shared_ptr<oxygen::SimulationServer> mSimServer; + //! cahced reference to the monitor control node + boost::shared_ptr<oxygen::MonitorControl> mMonitorControl; bool mGetAck; std::string mAckString; Modified: trunk/rcssserver3d/rcssmonitor3d/main.cpp =================================================================== --- trunk/rcssserver3d/rcssmonitor3d/main.cpp 2011-06-06 10:23:16 UTC (rev 284) +++ trunk/rcssserver3d/rcssmonitor3d/main.cpp 2011-06-23 18:00:49 UTC (rev 285) @@ -121,6 +121,17 @@ GetScriptServer()->Eval(serverIPStr); } } + else if (strcmp(argv[i], "--server-port") == 0) + { + i++; + if (i < argc) + GetScriptServer()->Eval(string("$monitorPort = ") + argv[i]); + else + { + PrintHelp(); + return false; + } + } } return true; Modified: trunk/spark/lib/oxygen/simulationserver/monitorcontrol.cpp =================================================================== --- trunk/spark/lib/oxygen/simulationserver/monitorcontrol.cpp 2011-06-06 10:23:16 UTC (rev 284) +++ trunk/spark/lib/oxygen/simulationserver/monitorcontrol.cpp 2011-06-23 18:00:49 UTC (rev 285) @@ -158,3 +158,8 @@ } } } + +void MonitorControl::RequestFullState() +{ + mFullStateLogged--; +} Modified: trunk/spark/lib/oxygen/simulationserver/monitorcontrol.h =================================================================== --- trunk/spark/lib/oxygen/simulationserver/monitorcontrol.h 2011-06-06 10:23:16 UTC (rev 284) +++ trunk/spark/lib/oxygen/simulationserver/monitorcontrol.h 2011-06-23 18:00:49 UTC (rev 285) @@ -54,6 +54,9 @@ /** sets the monitor update interval in cycles */ void SetMonitorInterval(int i); + /** Request that next update gives the full state */ + void RequestFullState(); + protected: virtual void OnLink(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |