Update of /cvsroot/simspark/simspark/spark/plugin/sparkagent In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21881 Modified Files: 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 Added Files: hingeaction.h hingeeffector.cpp hingeeffector.h hingeeffector_c.cpp hingeperceptor.cpp hingeperceptor.h hingeperceptor_c.cpp Log Message: - added Joschka's hingeeffector implementation - sync with rcssserver3d CVS --- NEW FILE: hingeperceptor_c.cpp --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Thu Nov 8 2005 Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group 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 "hingeperceptor.h" void CLASS(HingePerceptor)::DefineClass() { DEFINE_BASECLASS(oxygen/Perceptor); } --- NEW FILE: hingeaction.h --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Thu Nov 9 2005 Copyright (C) 2005 RoboCup Soccer Server 3D Maintenance Group 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 HINGEACTION_H #define HINGEACTION_H #include <oxygen/gamecontrolserver/actionobject.h> class HingeAction : public oxygen::ActionObject { public: HingeAction(const std::string& predicate, float velocity) : ActionObject(predicate), mVelocity(velocity) {}; virtual ~HingeAction() {} float GetMotorVelocity() { return mVelocity; } protected: float mVelocity; }; #endif // HINGEACTION_H Index: Makefile.am =================================================================== RCS file: /cvsroot/simspark/simspark/spark/plugin/sparkagent/Makefile.am,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Makefile.am 13 Dec 2005 21:48:50 -0000 1.1 --- Makefile.am 2 Jan 2006 18:11:33 -0000 1.2 *************** *** 12,16 **** timeperceptor.cpp \ timeperceptor_c.cpp \ ! export.cpp sparkagent_la_LDFLAGS = -module -version-info 0:0:0 --- 12,23 ---- timeperceptor.cpp \ timeperceptor_c.cpp \ ! export.cpp \ ! hingeaction.h \ ! hingeeffector.h \ ! hingeeffector.cpp \ ! hingeeffector_c.cpp \ ! hingeperceptor.h \ ! hingeperceptor.cpp \ ! hingeperceptor_c.cpp sparkagent_la_LDFLAGS = -module -version-info 0:0:0 Index: export.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/plugin/sparkagent/export.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** export.cpp 13 Dec 2005 21:48:50 -0000 1.1 --- export.cpp 2 Jan 2006 18:11:33 -0000 1.2 *************** *** 21,24 **** --- 21,26 ---- */ #include <zeitgeist/zeitgeist.h> + #include "hingeperceptor.h" + #include "hingeeffector.h" #include "hinge2perceptor.h" #include "hinge2effector.h" *************** *** 29,31 **** --- 31,35 ---- ZEITGEIST_EXPORT(Hinge2Perceptor); ZEITGEIST_EXPORT(TimePerceptor); + ZEITGEIST_EXPORT(HingeEffector); + ZEITGEIST_EXPORT(HingePerceptor); ZEITGEIST_EXPORT_END() --- NEW FILE: hingeeffector.h --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Wed Nov 9 2005 Copyright (C) 2005 RoboCup Soccer Server 3D Maintenance Group 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 HINGEEFFECTOR_H #define HINGEEFFECTOR_H #include <oxygen/agentaspect/effector.h> #include <oxygen/physicsserver/hingejoint.h> class HingeEffector : public oxygen::Effector { public: HingeEffector(); virtual ~HingeEffector(); /** 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); protected: /** setup the reference to the HingeJoint parent node */ virtual void OnLink(); /** remove the reference to the HingeJoint parent node */ virtual void OnUnlink(); protected: /** cached reference to the monitor joint */ boost::shared_ptr<oxygen::HingeJoint> mJoint; }; DECLARE_CLASS(HingeEffector); #endif // HINGEEFFECTOR_H Index: hinge2effector.h =================================================================== RCS file: /cvsroot/simspark/simspark/spark/plugin/sparkagent/hinge2effector.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** hinge2effector.h 13 Dec 2005 21:48:50 -0000 1.1 --- hinge2effector.h 2 Jan 2006 18:11:33 -0000 1.2 *************** *** 42,49 **** 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(); --- 42,50 ---- GetActionObject(const oxygen::Predicate& predicate); ! protected: ! /** setup the reference to the Hinge2Joint parent node */ virtual void OnLink(); ! /** remove the reference to the Hinge2Joint parent node */ virtual void OnUnlink(); --- NEW FILE: hingeperceptor.cpp --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Thu Nov 8 2005 Copyright (C) 2005 RoboCup Soccer Server 3D Maintenance Group 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 "hingeperceptor.h" #include <zeitgeist/logserver/logserver.h> using namespace oxygen; using namespace zeitgeist; using namespace boost; using namespace std; HingePerceptor::HingePerceptor() : Perceptor() { } HingePerceptor::~HingePerceptor() { } void HingePerceptor::OnLink() { mJoint = make_shared(FindParentSupportingClass<HingeJoint>()); if (mJoint.get() == 0) { GetLog()->Error() << "(HingePerceptor) ERROR: found no HingeJoint parent\n"; } } void HingePerceptor::OnUnlink() { mJoint.reset(); } void HingePerceptor::InsertAxisAngle(Predicate& predicate) { ParameterList& axisElement = predicate.parameter.AddList(); axisElement.AddValue(string("axis")); axisElement.AddValue(mJoint->GetAngle()); } void HingePerceptor::InsertAxisRate(Predicate& predicate) { ParameterList& axisElement = predicate.parameter.AddList(); axisElement.AddValue(string("rate")); axisElement.AddValue(mJoint->GetAngleRate()); } bool HingePerceptor::Percept(boost::shared_ptr<oxygen::PredicateList> predList) { if (mJoint.get() == 0) { return false; } Predicate& predicate = predList->AddPredicate(); predicate.name = "HJ"; predicate.parameter.Clear(); ParameterList& nameElement = predicate.parameter.AddList(); nameElement.AddValue(string("name")); nameElement.AddValue(GetName()); InsertAxisAngle(predicate); InsertAxisRate(predicate); return true; } --- NEW FILE: hingeeffector.cpp --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Wed Nov 9 2005 Copyright (C) 2005 RoboCup Soccer Server 3D Maintenance Group 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 "hingeeffector.h" #include "hingeaction.h" using namespace oxygen; using namespace zeitgeist; using namespace salt; using namespace boost; using namespace std; HingeEffector::HingeEffector() : Effector() { SetName("hinge"); } HingeEffector::~HingeEffector() { } bool HingeEffector::Realize(boost::shared_ptr<ActionObject> action) { if (mJoint.get() == 0) { return false; } shared_ptr<HingeAction> hingeAction = shared_dynamic_cast<HingeAction>(action); if (hingeAction.get() == 0) { GetLog()->Error() << "ERROR: (HingeEffector) cannot realize an " << "unknown ActionObject\n"; return false; } /* Vector3f axis = mJoint->GetAxis(); GetLog()->Error() << "(HingeEffector) axis is (" << axis[0] << "," << axis[1] << "," << axis[2] << ")\n"; GetLog()->Error() << "(HingeEffector) current vel = " << mJoint->GetAngularMotorVelocity(Joint::AI_FIRST) << "\n"; GetLog()->Error() << "(HingeEffector) set vel to " << hingeAction->GetMotorVelocity() << "\n"; */ mJoint->SetParameter(dParamVel, hingeAction->GetMotorVelocity()); return true; } shared_ptr<ActionObject> HingeEffector::GetActionObject(const Predicate& predicate) { for(;;) { if (mJoint.get() == 0) { break; } if (predicate.name != GetPredicate()) { GetLog()->Error() << "ERROR: (HingeEffector) invalid predicate" << predicate.name << "\n"; break; } Predicate::Iterator iter = predicate.begin(); float velocity; if (! predicate.AdvanceValue(iter, velocity)) { GetLog()->Error() << "ERROR: (HingeEffector) motor velocity expected\n"; break; } return shared_ptr<HingeAction>(new HingeAction(GetPredicate(),velocity)); } return shared_ptr<ActionObject>(); } void HingeEffector::OnLink() { mJoint = make_shared(FindParentSupportingClass<HingeJoint>()); if (mJoint.get() == 0) { GetLog()->Error() << "(HingeEffector) ERROR: found no HingeJoint parent\n"; } } void HingeEffector::OnUnlink() { mJoint.reset(); } --- NEW FILE: hingeperceptor.h --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Thu Nov 8 2005 Copyright (C) 2005 RoboCup Soccer Server 3D Maintenance Group 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 HINGEPERCEPTOR_H #define HINGEPERCEPTOR_H #include <oxygen/agentaspect/perceptor.h> #include <oxygen/physicsserver/hingejoint.h> class HingePerceptor : public oxygen::Perceptor { public: HingePerceptor(); virtual ~HingePerceptor(); //! \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); void InsertAxisRate(oxygen::Predicate& predicate); protected: /** cached reference to the monitor joint */ boost::shared_ptr<oxygen::HingeJoint> mJoint; }; DECLARE_CLASS(HingePerceptor); #endif //HINGEPERCEPTOR_H --- NEW FILE: hingeeffector_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: hingeeffector_c.cpp,v 1.1 2006/01/02 18:11:33 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 "hingeeffector.h" void CLASS(HingeEffector)::DefineClass() { DEFINE_BASECLASS(oxygen/Effector); } |