From: Markus R. <rol...@us...> - 2005-12-13 21:49:05
|
Update of /cvsroot/simspark/simspark/spark/plugin/sparkagent In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv885/sparkagent Added Files: .cvsignore Makefile.am export.cpp hinge2action.h hinge2effector.cpp hinge2effector.h hinge2effector_c.cpp hinge2perceptor.cpp hinge2perceptor.h hinge2perceptor_c.cpp timeperceptor.cpp timeperceptor.h timeperceptor_c.cpp Log Message: - added spark specific plugins --- NEW FILE: .cvsignore --- *.la *.lo .deps .libs Makefile Makefile.in --- NEW FILE: hinge2effector_c.cpp --- /* -*- 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: hinge2effector_c.cpp,v 1.1 2005/12/13 21:48:50 rollmark Exp $ 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 "hinge2effector.h" void CLASS(Hinge2Effector)::DefineClass() { DEFINE_BASECLASS(oxygen/Effector); } --- NEW FILE: timeperceptor_c.cpp --- /* -*- 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: timeperceptor_c.cpp,v 1.1 2005/12/13 21:48:50 rollmark Exp $ 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 "timeperceptor.h" void CLASS(TimePerceptor)::DefineClass() { DEFINE_BASECLASS(oxygen/Perceptor); } --- NEW FILE: export.cpp --- /* -*- 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: export.cpp,v 1.1 2005/12/13 21:48:50 rollmark Exp $ 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 <zeitgeist/zeitgeist.h> #include "hinge2perceptor.h" #include "hinge2effector.h" #include "timeperceptor.h" ZEITGEIST_EXPORT_BEGIN() ZEITGEIST_EXPORT(Hinge2Effector); ZEITGEIST_EXPORT(Hinge2Perceptor); ZEITGEIST_EXPORT(TimePerceptor); ZEITGEIST_EXPORT_END() --- NEW FILE: timeperceptor.cpp --- /* -*- 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: timeperceptor.cpp,v 1.1 2005/12/13 21:48:50 rollmark Exp $ 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 "timeperceptor.h" #include <zeitgeist/logserver/logserver.h> using namespace oxygen; using namespace zeitgeist; using namespace boost; using namespace std; TimePerceptor::TimePerceptor() : Perceptor() { } TimePerceptor::~TimePerceptor() { } void TimePerceptor::OnLink() { mSimulationServer = shared_dynamic_cast<SimulationServer> (GetCore()->Get("/sys/server/simulation")); if (mSimulationServer.get() == 0) { GetLog()->Error() << "(TimePerceptor) ERROR: SimulationServer not found\n"; } } void TimePerceptor::OnUnlink() { mSimulationServer.reset(); } bool TimePerceptor::Percept(boost::shared_ptr<oxygen::PredicateList> predList) { if (mSimulationServer.get() == 0) { return false; } Predicate& predicate = predList->AddPredicate(); predicate.name = "time"; predicate.parameter.Clear(); ParameterList& nowElement = predicate.parameter.AddList(); nowElement.AddValue(string("now")); nowElement.AddValue(mSimulationServer->GetTime()); ParameterList& stepElement = predicate.parameter.AddList(); stepElement.AddValue(string("step")); stepElement.AddValue(mSimulationServer->GetSimStep()); return true; } --- NEW FILE: hinge2effector.cpp --- /* -*- 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: hinge2effector.cpp,v 1.1 2005/12/13 21:48:50 rollmark Exp $ 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 "hinge2effector.h" #include "hinge2action.h" using namespace oxygen; using namespace zeitgeist; using namespace boost; using namespace std; Hinge2Effector::Hinge2Effector() : Effector() { SetName("hinge2"); } Hinge2Effector::~Hinge2Effector() { } bool Hinge2Effector::Realize(boost::shared_ptr<ActionObject> action) { if (mJoint.get() == 0) { return false; } shared_ptr<Hinge2Action> hinge2Action = shared_dynamic_cast<Hinge2Action>(action); if (hinge2Action.get() == 0) { GetLog()->Error() << "ERROR: (Hinge2Effector) cannot realize an " << "unknown ActionObject\n"; return false; } mJoint->SetAngularMotorVelocity (Joint::AI_SECOND, hinge2Action->GetMotorVelocity()); return true; } shared_ptr<ActionObject> Hinge2Effector::GetActionObject(const Predicate& predicate) { for(;;) { if (mJoint.get() == 0) { break; } if (predicate.name != GetPredicate()) { GetLog()->Error() << "ERROR: (KickEffector) invalid predicate" << predicate.name << "\n"; break; } Predicate::Iterator iter = predicate.begin(); float velocity; if (! predicate.AdvanceValue(iter, velocity)) { GetLog()->Error() << "ERROR: (KickEffector) motor velocity expected\n"; break; } return shared_ptr<Hinge2Action>(new Hinge2Action(GetPredicate(),velocity)); } return shared_ptr<ActionObject>(); } void Hinge2Effector::OnLink() { mJoint = make_shared(FindParentSupportingClass<Hinge2Joint>()); if (mJoint.get() == 0) { GetLog()->Error() << "(Hinge2Effector) ERROR: found no Hinge2Joint parent\n"; } } void Hinge2Effector::OnUnlink() { mJoint.reset(); } --- NEW FILE: timeperceptor.h --- /* -*- 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: timeperceptor.h,v 1.1 2005/12/13 21:48:50 rollmark Exp $ 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 TIMEPERCEPTOR_H #define TIMEPERCEPTOR_H #include <oxygen/agentaspect/perceptor.h> #include <oxygen/simulationserver/simulationserver.h> class TimePerceptor : public oxygen::Perceptor { public: TimePerceptor(); virtual ~TimePerceptor(); //! \return true, if valid data is available and false otherwise. bool Percept(boost::shared_ptr<oxygen::PredicateList> predList); protected: virtual void OnLink(); virtual void OnUnlink(); protected: /** cached reference to the SimulationServer */ boost::shared_ptr<oxygen::SimulationServer> mSimulationServer; }; DECLARE_CLASS(TimePerceptor); #endif //TIMEPERCEPTOR_H --- NEW FILE: hinge2effector.h --- /* -*- 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: hinge2effector.h,v 1.1 2005/12/13 21:48:50 rollmark Exp $ 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 HINGE2EFFECTOR_H #define HINGE2EFFECTOR_H #include <oxygen/agentaspect/effector.h> #include <oxygen/physicsserver/hinge2joint.h> class Hinge2Effector : public oxygen::Effector { public: Hinge2Effector(); virtual ~Hinge2Effector(); /** realizes the action described by the ActionObject */ virtual bool Realize(boost::shared_ptr<oxygen::ActionObject> action); /** returns the name of the predicate this effector implements. */ virtual std::string GetPredicate() { return GetName(); } /** constructs an Actionobject, describing a predicate */ virtual boost::shared_ptr<oxygen::ActionObject> GetActionObject(const oxygen::Predicate& predicate); /** setup the reference to the ball body node */ virtual void OnLink(); /** remove the reference to the ball body node */ virtual void OnUnlink(); protected: /** cached reference to the monitor joint */ boost::shared_ptr<oxygen::Hinge2Joint> mJoint; }; DECLARE_CLASS(Hinge2Effector); #endif // HINGE2EFFECTOR_H --- NEW FILE: hinge2perceptor.h --- /* -*- 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: hinge2perceptor.h,v 1.1 2005/12/13 21:48:50 rollmark Exp $ 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 HINGE2PERCEPTOR_H #define HINGE2PERCEPTOR_H #include <oxygen/agentaspect/perceptor.h> #include <oxygen/physicsserver/hinge2joint.h> class Hinge2Perceptor : public oxygen::Perceptor { public: Hinge2Perceptor(); virtual ~Hinge2Perceptor(); //! \return true, if valid data is available and false otherwise. bool Percept(boost::shared_ptr<oxygen::PredicateList> predList); protected: virtual void OnLink(); virtual void OnUnlink(); void InsertAxisAngle(oxygen::Predicate& predicate, oxygen::Joint::EAxisIndex idx); void InsertAxisRate(oxygen::Predicate& predicate, oxygen::Joint::EAxisIndex idx); protected: /** cached reference to the monitor joint */ boost::shared_ptr<oxygen::Hinge2Joint> mJoint; }; DECLARE_CLASS(Hinge2Perceptor); #endif //HINGE2PERCEPTOR_H --- NEW FILE: hinge2perceptor_c.cpp --- /* -*- 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: hinge2perceptor_c.cpp,v 1.1 2005/12/13 21:48:50 rollmark Exp $ 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 "hinge2perceptor.h" void CLASS(Hinge2Perceptor)::DefineClass() { DEFINE_BASECLASS(oxygen/Perceptor); } --- NEW FILE: hinge2perceptor.cpp --- /* -*- 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: hinge2perceptor.cpp,v 1.1 2005/12/13 21:48:50 rollmark Exp $ 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 "hinge2perceptor.h" #include <zeitgeist/logserver/logserver.h> using namespace oxygen; using namespace zeitgeist; using namespace boost; using namespace std; Hinge2Perceptor::Hinge2Perceptor() : Perceptor() { } Hinge2Perceptor::~Hinge2Perceptor() { } void Hinge2Perceptor::OnLink() { mJoint = make_shared(FindParentSupportingClass<Hinge2Joint>()); if (mJoint.get() == 0) { GetLog()->Error() << "(Hinge2Perceptor) ERROR: found no Hinge2Joint parent\n"; } } void Hinge2Perceptor::OnUnlink() { mJoint.reset(); } void Hinge2Perceptor::InsertAxisAngle(Predicate& predicate, Joint::EAxisIndex idx) { ParameterList& axisElement = predicate.parameter.AddList(); axisElement.AddValue(string("axis")); axisElement.AddValue(static_cast<int>(idx)); axisElement.AddValue(mJoint->GetAngle(idx)); } void Hinge2Perceptor::InsertAxisRate(Predicate& predicate, Joint::EAxisIndex idx) { ParameterList& axisElement = predicate.parameter.AddList(); axisElement.AddValue(string("rate")); axisElement.AddValue(static_cast<int>(idx)); axisElement.AddValue(mJoint->GetAngleRate(idx)); } bool Hinge2Perceptor::Percept(boost::shared_ptr<oxygen::PredicateList> predList) { if (mJoint.get() == 0) { return false; } Predicate& predicate = predList->AddPredicate(); predicate.name = "hinge2"; predicate.parameter.Clear(); ParameterList& nameElement = predicate.parameter.AddList(); nameElement.AddValue(string("name")); nameElement.AddValue(GetName()); InsertAxisAngle(predicate,Joint::AI_FIRST); InsertAxisRate(predicate,Joint::AI_SECOND); return true; } --- NEW FILE: Makefile.am --- pkglib_LTLIBRARIES = sparkagent.la sparkagent_la_SOURCES = \ hinge2action.h \ hinge2perceptor.h \ hinge2perceptor.cpp \ hinge2perceptor_c.cpp \ hinge2effector.h \ hinge2effector.cpp \ hinge2effector_c.cpp \ timeperceptor.h \ timeperceptor.cpp \ timeperceptor_c.cpp \ export.cpp sparkagent_la_LDFLAGS = -module -version-info 0:0:0 AM_CPPFLAGS = -I${top_srcdir}/lib -I${top_srcdir}/utility @RUBY_CPPFLAGS@ --- NEW FILE: hinge2action.h --- /* -*- 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: hinge2action.h,v 1.1 2005/12/13 21:48:50 rollmark Exp $ 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 HINGE2ACTION_H #define HINGE2ACTION_H #include <oxygen/gamecontrolserver/actionobject.h> class Hinge2Action : public oxygen::ActionObject { public: Hinge2Action(const std::string& predicate, float velocity) : ActionObject(predicate), mVelocity(velocity) {}; virtual ~Hinge2Action() {} float GetMotorVelocity() { return mVelocity; } protected: float mVelocity; }; #endif // HINGE2ACTION_H |