|
From: <sgv...@us...> - 2011-02-18 18:44:21
|
Revision: 246
http://simspark.svn.sourceforge.net/simspark/?rev=246&view=rev
Author: sgvandijk
Date: 2011-02-18 18:44:14 +0000 (Fri, 18 Feb 2011)
Log Message:
-----------
- spark.rb possible to be loaded locally
- Taken out confusing output, output errors that are warnings with Warning
- BaseNode keeps cache of BoseNode children (takes out loads of fynamic casting)
- HingePerceptor can report torque
- Fix multithreaded mode
Modified Paths:
--------------
trunk/rcssserver3d/plugin/soccer/restrictedvisionperceptor/restrictedvisionperceptor.cpp
trunk/spark/lib/oxygen/agentaspect/agentaspect.cpp
trunk/spark/lib/oxygen/agentaspect/agentaspect.h
trunk/spark/lib/oxygen/gamecontrolserver/gamecontrolserver.cpp
trunk/spark/lib/oxygen/geometryserver/geometryserver.cpp
trunk/spark/lib/oxygen/monitorserver/monitorserver.cpp
trunk/spark/lib/oxygen/physicsserver/hingejoint.cpp
trunk/spark/lib/oxygen/physicsserver/hingejoint.h
trunk/spark/lib/oxygen/physicsserver/int/hingejointint.h
trunk/spark/lib/oxygen/sceneserver/basenode.cpp
trunk/spark/lib/oxygen/sceneserver/basenode.h
trunk/spark/lib/oxygen/sceneserver/scene.cpp
trunk/spark/lib/oxygen/sceneserver/scene.h
trunk/spark/lib/oxygen/sceneserver/sceneserver.cpp
trunk/spark/lib/oxygen/simulationserver/monitorcontrol.cpp
trunk/spark/lib/oxygen/simulationserver/simulationserver.cpp
trunk/spark/lib/zeitgeist/scriptserver/scriptserver.cpp
trunk/spark/plugin/odeimps/odehingejoint.cpp
trunk/spark/plugin/odeimps/odehingejoint.h
trunk/spark/plugin/sparkagent/hingeperceptor.cpp
trunk/spark/plugin/sparkagent/hingeperceptor.h
trunk/spark/plugin/sparkmonitor/sparkmonitor.cpp
trunk/spark/plugin/sparkmonitor/sparkmonitorclient.cpp
trunk/spark/spark/spark.cpp
trunk/spark/spark/spark.rb
Modified: trunk/rcssserver3d/plugin/soccer/restrictedvisionperceptor/restrictedvisionperceptor.cpp
===================================================================
--- trunk/rcssserver3d/plugin/soccer/restrictedvisionperceptor/restrictedvisionperceptor.cpp 2011-02-11 22:53:50 UTC (rev 245)
+++ trunk/rcssserver3d/plugin/soccer/restrictedvisionperceptor/restrictedvisionperceptor.cpp 2011-02-18 18:44:14 UTC (rev 246)
@@ -861,4 +861,4 @@
void RestrictedVisionPerceptor::SetSenseLine(bool sense)
{
mSenseLine = sense;
-}
\ No newline at end of file
+}
Modified: trunk/spark/lib/oxygen/agentaspect/agentaspect.cpp
===================================================================
--- trunk/spark/lib/oxygen/agentaspect/agentaspect.cpp 2011-02-11 22:53:50 UTC (rev 245)
+++ trunk/spark/lib/oxygen/agentaspect/agentaspect.cpp 2011-02-18 18:44:14 UTC (rev 246)
@@ -21,6 +21,7 @@
*/
#include "agentaspect.h"
#include <zeitgeist/logserver/logserver.h>
+#include <oxygen/sceneserver/scene.h>
using namespace boost;
using namespace oxygen;
@@ -38,11 +39,20 @@
{
}
+void
+AgentAspect::UpdateCacheInternal()
+{
+ GetLog()->Debug() << "(AgentAspect) Updating cache\n";
+
+ UpdateEffectorMap();
+
+ mPerceptors.clear();
+ ListChildrenSupportingClass<Perceptor>(mPerceptors,true);
+}
+
bool
AgentAspect::RealizeActions(boost::shared_ptr<ActionObject::TList> actions)
{
- UpdateEffectorMap();
-
for (
ActionObject::TList::iterator iter = actions->begin();
iter != actions->end();
@@ -79,15 +89,13 @@
{
mPerceptorCycle++;
// build list of perceptors, searching recursively
- TLeafList perceptors;
- ListChildrenSupportingClass<Perceptor>(perceptors,true);
boost::shared_ptr<PredicateList> predList(new PredicateList());
// query the perceptors for new data
for (
- TLeafList::iterator iter = perceptors.begin();
- iter != perceptors.end();
+ TLeafList::iterator iter = mPerceptors.begin();
+ iter != mPerceptors.end();
++iter
)
{
@@ -167,6 +175,7 @@
}
return added;
+
}
bool AgentAspect::IsSynced() const
Modified: trunk/spark/lib/oxygen/agentaspect/agentaspect.h
===================================================================
--- trunk/spark/lib/oxygen/agentaspect/agentaspect.h 2011-02-11 22:53:50 UTC (rev 245)
+++ trunk/spark/lib/oxygen/agentaspect/agentaspect.h 2011-02-18 18:44:14 UTC (rev 246)
@@ -65,6 +65,8 @@
/** looks up the effector corresponding to a predicate */
virtual boost::shared_ptr<Effector> GetEffector(const std::string predicate) const;
+ void UpdateCacheInternal();
+
//! @return the unique ID for the agent aspect
inline int ID() const { return mID; }
@@ -83,6 +85,9 @@
private:
int mID;
+ /** cache of the agent's effectors */
+ TLeafList mPerceptors;
+
/** indicates how many times the QueryPerceptors be called */
unsigned int mPerceptorCycle;
Modified: trunk/spark/lib/oxygen/gamecontrolserver/gamecontrolserver.cpp
===================================================================
--- trunk/spark/lib/oxygen/gamecontrolserver/gamecontrolserver.cpp 2011-02-11 22:53:50 UTC (rev 245)
+++ trunk/spark/lib/oxygen/gamecontrolserver/gamecontrolserver.cpp 2011-02-18 18:44:14 UTC (rev 246)
@@ -155,12 +155,20 @@
aspect->SetName(name.str());
scene->AddChildReference(aspect);
+
mAgentMap[id] = aspect;
+ bool ok = aspect->Init(mCreateEffector,id);
+ if (ok)
+ {
+ aspect->UpdateCache();
+ scene->UpdateCache(false);
+ }
+
// mark the scene as modified
scene->SetModified(true);
- return aspect->Init(mCreateEffector,id);
+ return ok;
}
bool GameControlServer::AgentDisappear(int id)
@@ -178,13 +186,12 @@
// remove the AgentAspect from the Scene and our map. The
// AgentAspect does all the necessary cleanup
boost::shared_ptr<Scene> scene = GetActiveScene();
+
if (scene.get() != 0)
{
(*iter).second->UnlinkChildren();
(*iter).second->Unlink();
- // mark the scene as modified
- scene->SetModified(true);
} else
{
GetLog()->Error()
@@ -194,6 +201,9 @@
mAgentMap.erase(id);
+ // mark the scene as modified
+ scene->SetModified(true);
+
GetLog()->Debug() << "(GameControlServer) An agent disconnected (id: "
<< id << ")\n";
@@ -257,9 +267,7 @@
// construct an ActionList using the registered effectors
boost::shared_ptr<ActionObject::TList> actionList(new ActionObject::TList());
- // update the map of effectors below the agentaspect
boost::shared_ptr<AgentAspect> aspect = (*iter).second;
- aspect->UpdateEffectorMap();
for
(
Modified: trunk/spark/lib/oxygen/geometryserver/geometryserver.cpp
===================================================================
--- trunk/spark/lib/oxygen/geometryserver/geometryserver.cpp 2011-02-11 22:53:50 UTC (rev 245)
+++ trunk/spark/lib/oxygen/geometryserver/geometryserver.cpp 2011-02-18 18:44:14 UTC (rev 246)
@@ -63,7 +63,7 @@
importer->SetName(importerName);
AddChildReference(importer);
- GetLog()->Normal()
+ GetLog()->Debug()
<< "(GeometryServer) MeshImporter '" << importerName << "' registered\n";
return true;
@@ -139,7 +139,7 @@
mesh->SetName(name);
}
- GetLog()->Normal() << "(GeometryServer) imported mesh '" << meshName
+ GetLog()->Debug() << "(GeometryServer) imported mesh '" << meshName
<< " with '" << importer->GetName() << "'\n";
if (mesh.get() == 0 || mesh->GetVertexCount() == 0)
@@ -183,14 +183,14 @@
}
mMeshMap[name] = mesh;
- GetLog()->Normal() << "(GeometryServer) mesh " << name << " registered\n";
+ GetLog()->Debug() << "(GeometryServer) mesh " << name << " registered\n";
TLeafList exporters;
ListChildrenSupportingClass<MeshExporter>(exporters);
for (TLeafList::const_iterator bi = exporters.begin(); bi != exporters.end(); ++bi)
{
- GetLog()->Normal() << "(GeometryServer) additionally registered mesh "
+ GetLog()->Debug() << "(GeometryServer) additionally registered mesh "
<< name << " via MeshExporter '" << (*bi)->GetName() << "'\n";
boost::shared_ptr<MeshExporter> mb = shared_static_cast<MeshExporter>(*bi);
mb->RegisterMesh(mesh);
@@ -213,7 +213,7 @@
exporter->SetName(name);
AddChildReference(exporter);
- GetLog()->Normal() << "(GeometryServer) MeshExporter '" << name << "' registered\n";
+ GetLog()->Debug() << "(GeometryServer) MeshExporter '" << name << "' registered\n";
return true;
}
Modified: trunk/spark/lib/oxygen/monitorserver/monitorserver.cpp
===================================================================
--- trunk/spark/lib/oxygen/monitorserver/monitorserver.cpp 2011-02-11 22:53:50 UTC (rev 245)
+++ trunk/spark/lib/oxygen/monitorserver/monitorserver.cpp 2011-02-18 18:44:14 UTC (rev 246)
@@ -44,8 +44,8 @@
if (mSimulationServer.expired())
{
- GetLog()->Error()
- << "(MonitorServer) ERROR: SimulationServer not found.\n";
+ GetLog()->Warning()
+ << "(MonitorServer) WARNING: SimulationServer not found.\n";
}
}
Modified: trunk/spark/lib/oxygen/physicsserver/hingejoint.cpp
===================================================================
--- trunk/spark/lib/oxygen/physicsserver/hingejoint.cpp 2011-02-11 22:53:50 UTC (rev 245)
+++ trunk/spark/lib/oxygen/physicsserver/hingejoint.cpp 2011-02-18 18:44:14 UTC (rev 246)
@@ -134,6 +134,11 @@
return mHingeJointImp->GetAngleRate(mJointID);
}
+float HingeJoint::GetTorque() const
+{
+ return mHingeJointImp->GetTorque(mJointID);
+}
+
void HingeJoint::SetParameter(int parameter, float value){
mJointImp->SetParameter(parameter, value, mJointID);
}
Modified: trunk/spark/lib/oxygen/physicsserver/hingejoint.h
===================================================================
--- trunk/spark/lib/oxygen/physicsserver/hingejoint.h 2011-02-11 22:53:50 UTC (rev 245)
+++ trunk/spark/lib/oxygen/physicsserver/hingejoint.h 2011-02-18 18:44:14 UTC (rev 246)
@@ -69,6 +69,9 @@
/** returns the time derivate of the hinge angle */
float GetAngleRate() const;
+ /** returns the torque on the joint */
+ float GetTorque() const;
+
/** Sets a parameter value of this joint*/
void SetParameter(int parameter, float value);
Modified: trunk/spark/lib/oxygen/physicsserver/int/hingejointint.h
===================================================================
--- trunk/spark/lib/oxygen/physicsserver/int/hingejointint.h 2011-02-11 22:53:50 UTC (rev 245)
+++ trunk/spark/lib/oxygen/physicsserver/int/hingejointint.h 2011-02-18 18:44:14 UTC (rev 246)
@@ -67,6 +67,9 @@
/** returns the time derivate of the hinge angle */
virtual float GetAngleRate(long jointID) const = 0;
+
+ /** returns the torque on the joint */
+ virtual float GetTorque(long jointID) const = 0;
};
} //namespace oxygen
Modified: trunk/spark/lib/oxygen/sceneserver/basenode.cpp
===================================================================
--- trunk/spark/lib/oxygen/sceneserver/basenode.cpp 2011-02-11 22:53:50 UTC (rev 245)
+++ trunk/spark/lib/oxygen/sceneserver/basenode.cpp 2011-02-18 18:44:14 UTC (rev 246)
@@ -84,12 +84,30 @@
{
}
+Leaf::TLeafList BaseNode::GetBaseNodeChildren()
+{
+ return mBaseNodeChildren;
+}
+
+void BaseNode::UpdateCache(bool recursive)
+{
+ UpdateBaseNodeChildren();
+ UpdateCacheInternal();
+
+ if (recursive)
+ {
+ // perform update on hierarchy
+ for (TLeafList::iterator i = mBaseNodeChildren.begin(); i!= mBaseNodeChildren.end(); ++i)
+ {
+ shared_static_cast<BaseNode>(*i)->UpdateCache();
+ }
+ }
+}
+
void BaseNode::PrePhysicsUpdate(float deltaTime)
{
// perform update on hierarchy
- TLeafList baseNodes;
- ListChildrenSupportingClass<BaseNode>(baseNodes);
- for (TLeafList::iterator i = baseNodes.begin(); i!= baseNodes.end(); ++i)
+ for (TLeafList::iterator i = mBaseNodeChildren.begin(); i!= mBaseNodeChildren.end(); ++i)
{
shared_static_cast<BaseNode>(*i)->PrePhysicsUpdate(deltaTime);
}
@@ -104,9 +122,7 @@
void BaseNode::PostPhysicsUpdate()
{
// perform update on hierarchy
- TLeafList baseNodes;
- ListChildrenSupportingClass<BaseNode>(baseNodes);
- for (TLeafList::iterator i = baseNodes.begin(); i!= baseNodes.end(); ++i)
+ for (TLeafList::iterator i = mBaseNodeChildren.begin(); i!= mBaseNodeChildren.end(); ++i)
{
shared_static_cast<BaseNode>(*i)->PostPhysicsUpdate();
}
@@ -128,9 +144,7 @@
mWorldBoundingBox.TransformBy(worldTransform);
// perform update on hierarchy
- TLeafList baseNodes;
- ListChildrenSupportingClass<BaseNode>(baseNodes);
- for (TLeafList::iterator i = baseNodes.begin(); i!= baseNodes.end(); ++i)
+ for (TLeafList::iterator i = mBaseNodeChildren.begin(); i!= mBaseNodeChildren.end(); ++i)
{
boost::shared_ptr<BaseNode> node = shared_static_cast<BaseNode>(*i);
node->UpdateHierarchy();
@@ -178,6 +192,12 @@
{
}
+void BaseNode::UpdateBaseNodeChildren()
+{
+ mBaseNodeChildren.clear();
+ ListChildrenSupportingClass<BaseNode>(mBaseNodeChildren);
+}
+
const salt::AABB3& BaseNode::GetWorldBoundingBox() const
{
return mWorldBoundingBox;
Modified: trunk/spark/lib/oxygen/sceneserver/basenode.h
===================================================================
--- trunk/spark/lib/oxygen/sceneserver/basenode.h 2011-02-11 22:53:50 UTC (rev 245)
+++ trunk/spark/lib/oxygen/sceneserver/basenode.h 2011-02-18 18:44:14 UTC (rev 246)
@@ -83,8 +83,14 @@
/** returns the world bounding box of this node */
const salt::AABB3& GetWorldBoundingBox() const;
+ /** get the cached BaseNode children of this node */
+ TLeafList GetBaseNodeChildren();
+
// scene graph update passes
+ /** updates internal cache */
+ virtual void UpdateCache(bool recursive = true);
+
/** updates internal state before physics calculation */
void PrePhysicsUpdate(float deltaTime);
@@ -123,6 +129,9 @@
etc..) */
virtual void UpdateHierarchyInternal();
+ virtual void UpdateCacheInternal() {}
+
+ void UpdateBaseNodeChildren();
//
// Members
//
@@ -138,6 +147,8 @@
/** world bounding box */
salt::AABB3 mWorldBoundingBox;
+
+ TLeafList mBaseNodeChildren;
};
DECLARE_CLASS(BaseNode);
Modified: trunk/spark/lib/oxygen/sceneserver/scene.cpp
===================================================================
--- trunk/spark/lib/oxygen/sceneserver/scene.cpp 2011-02-11 22:53:50 UTC (rev 245)
+++ trunk/spark/lib/oxygen/sceneserver/scene.cpp 2011-02-18 18:44:14 UTC (rev 246)
@@ -34,6 +34,16 @@
{
}
+void Scene::UpdateCacheInternal()
+{
+ mLastCacheUpdate = mModifiedNum;
+}
+
+int Scene::GetLastCacheUpdate()
+{
+ return mLastCacheUpdate;
+}
+
const salt::Matrix& Scene::GetWorldTransform() const
{
return mIdentityMatrix;
@@ -58,4 +68,3 @@
{
return mModifiedNum;
}
-
Modified: trunk/spark/lib/oxygen/sceneserver/scene.h
===================================================================
--- trunk/spark/lib/oxygen/sceneserver/scene.h 2011-02-11 22:53:50 UTC (rev 245)
+++ trunk/spark/lib/oxygen/sceneserver/scene.h 2011-02-18 18:44:14 UTC (rev 246)
@@ -69,12 +69,19 @@
/** return how many times the scene was modified */
int GetModifiedNum();
+ /** return he modification count at the last update */
+ int GetLastCacheUpdate();
protected:
+ void UpdateCacheInternal();
+
/** true, if the scene is modified */
bool mModified;
/** how many times the scene was modified */
int mModifiedNum;
+
+ /** the modification count at the last update */
+ int mLastCacheUpdate;
};
DECLARE_CLASS(Scene);
Modified: trunk/spark/lib/oxygen/sceneserver/sceneserver.cpp
===================================================================
--- trunk/spark/lib/oxygen/sceneserver/sceneserver.cpp 2011-02-11 22:53:50 UTC (rev 245)
+++ trunk/spark/lib/oxygen/sceneserver/sceneserver.cpp 2011-02-18 18:44:14 UTC (rev 246)
@@ -41,7 +41,7 @@
int SceneServer::mTransformMark = 0;
SceneServer::SceneServer() : Node()
-{
+{
}
SceneServer::~SceneServer()
@@ -95,6 +95,9 @@
}
mPhysicsServer->UpdateCache(mActiveScene.get());
+
+ if (mActiveScene->GetLastCacheUpdate() != mActiveScene->GetModifiedNum())
+ mActiveScene->UpdateCache();
}
void SceneServer::OnUnlink()
@@ -181,6 +184,7 @@
}
UpdateCache();
+
++mTransformMark;
mActiveScene->PrePhysicsUpdate(deltaTime);
@@ -257,7 +261,7 @@
if (importer->ImportScene(file,root,parameter))
{
- GetLog()->Normal()
+ GetLog()->Debug()
<< "(SceneServer) imported scene file '"
<< file << " with '"
<< importer->GetName()
@@ -378,7 +382,7 @@
importer->SetName(importerName);
AddChildReference(importer);
- GetLog()->Normal()
+ GetLog()->Debug()
<< "(SceneServer) SceneImporter '" << importerName << "' registered\n";
return true;
Modified: trunk/spark/lib/oxygen/simulationserver/monitorcontrol.cpp
===================================================================
--- trunk/spark/lib/oxygen/simulationserver/monitorcontrol.cpp 2011-02-11 22:53:50 UTC (rev 245)
+++ trunk/spark/lib/oxygen/simulationserver/monitorcontrol.cpp 2011-02-18 18:44:14 UTC (rev 246)
@@ -62,6 +62,7 @@
}
string header = mMonitorServer->GetMonitorHeaderInfo();
+
mNetMessage->PrepareToSend(header);
SendClientMessage(client->addr,header);
@@ -90,10 +91,19 @@
string info;
boost::shared_ptr<Scene> scene = GetActiveScene();
if (scene.get() != 0
- && scene->GetModifiedNum() > mFullStateLogged )
+ && scene->GetModifiedNum() > mFullStateLogged)
{
- mFullStateLogged = scene->GetModifiedNum();
- info = mMonitorServer->GetMonitorHeaderInfo();
+ if (scene->GetLastCacheUpdate() == scene->GetModifiedNum())
+ {
+ mFullStateLogged = scene->GetModifiedNum();
+ info = mMonitorServer->GetMonitorHeaderInfo();
+ }
+ else
+ {
+ GetLog()->Debug()
+ << "(MonitorControl) Scene is modified, but hasn't updated cache yet. Doing nothing.\n";
+ return;
+ }
}
else
{
Modified: trunk/spark/lib/oxygen/simulationserver/simulationserver.cpp
===================================================================
--- trunk/spark/lib/oxygen/simulationserver/simulationserver.cpp 2011-02-11 22:53:50 UTC (rev 245)
+++ trunk/spark/lib/oxygen/simulationserver/simulationserver.cpp 2011-02-18 18:44:14 UTC (rev 246)
@@ -427,10 +427,12 @@
while (!mExitThreads)
{
++mCycle;
+
mThreadBarrier->wait();
if (mExit)
mExitThreads = true;
// Wait for SimControlNodes' acts at the begining of a cycle
+
mThreadBarrier->wait();
finalDelta = initDelta = mSumDeltaTime;
@@ -480,6 +482,7 @@
while (!mExitThreads)
{
mThreadBarrier->wait();
+
newCycle = false;
if ( controlNode->GetTime() - mSimTime <= 0.005f )
{
@@ -489,14 +492,9 @@
controlNode->ActAgent();
controlNode->SetSimTime(mSimTime);
}
+
mThreadBarrier->wait();
- if (isInputControl)
- {
- while (int(mSumDeltaTime*100) < int(mSimStep*100))
- controlNode->StartCycle(); // advance the time
- }
-
// wait for physics update
mThreadBarrier->wait();
if (!isRenderControl && newCycle)
Modified: trunk/spark/lib/zeitgeist/scriptserver/scriptserver.cpp
===================================================================
--- trunk/spark/lib/zeitgeist/scriptserver/scriptserver.cpp 2011-02-11 22:53:50 UTC (rev 245)
+++ trunk/spark/lib/zeitgeist/scriptserver/scriptserver.cpp 2011-02-18 18:44:14 UTC (rev 246)
@@ -258,7 +258,7 @@
void
ScriptServer::UpdateCachedAllNodes()
{
- GetLog()->Normal() << "(ScriptServer) updating cached script variables\n";
+ GetLog()->Debug() << "(ScriptServer) updating cached script variables\n";
GetCore()->GetRoot()->UpdateCached();
}
@@ -480,7 +480,7 @@
{
// run the init script in the sourceDir
string sourcePath = sourceDir + salt::RFile::Sep() + name;
- GetLog()->Normal() << "(ScriptServer) Running " << sourcePath << "... " << endl;
+ GetLog()->Debug() << "(ScriptServer) Running " << sourcePath << "... " << endl;
boost::shared_ptr<salt::StdFile> file(new(salt::StdFile));
if (! file->Open(sourcePath.c_str()))
@@ -493,7 +493,7 @@
return eError;
} else
{
- GetLog()->Normal() << "(ScriptServer) Script ended OK " << sourcePath << endl;
+ GetLog()->Debug() << "(ScriptServer) Script ended OK " << sourcePath << endl;
}
// copy it to the destDir
@@ -504,7 +504,7 @@
string destPath = destDir + salt::RFile::Sep() + name;
- GetLog()->Normal() << "Copying " << sourcePath
+ GetLog()->Debug() << "Copying " << sourcePath
<< " to " << destPath << endl;
stringstream s;
@@ -579,7 +579,7 @@
return false;
}
- GetLog()->Normal() << "(ScriptServer) Created Directory '"
+ GetLog()->Debug() << "(ScriptServer) Created Directory '"
<< dotDir << "'\n";
return true;
@@ -589,6 +589,9 @@
ScriptServer::RunInitScript(const string &fileName, const string &relPath,
EInitScriptType type)
{
+ GetLog()->Debug() << "(ScriptServer) Attempting to run init script '"
+ << fileName << "'\n";
+
string dotDir;
bool validDotDir =
(type == IS_USERLOCAL) &&
@@ -607,56 +610,52 @@
if (validDotDir)
{
+ // Trying dot-dir in home directory
result = RunInitScriptInternal(dotDir, fileName, false);
- }
+ if (result == eOK)
+ {
+ GetLog()->Debug() << "(ScriptServer) : Ran init script '"
+ << dotDir << salt::RFile::Sep() << fileName << "'\n";
+ return true;
+ }
+ else if (result == eError)
+ {
+ GetLog()->Error() << "(ScriptServer) ERROR: Found error in init script '"
+ << dotDir << salt::RFile::Sep() << fileName << "'\n";
+ return false;
+ }
- if (result == eOK)
- {
- GetLog()->Debug() << "(ScriptServer) : Ran init script '"
- << dotDir << salt::RFile::Sep() << fileName << "'\n";
- return true;
- }
-
- if (result == eNotFound)
- {
GetLog()->Debug() << "(ScriptServer) : Did not find init script '"
- << dotDir << salt::RFile::Sep() << fileName << "'\n";
+ << dotDir << salt::RFile::Sep() << fileName << "'\n";
}
- else if (result == eError)
- {
- GetLog()->Error() << "(ScriptServer) ERROR: Found error in init script '"
- << dotDir << salt::RFile::Sep() << fileName << "'\n";
- return false;
- }
- //
+
+ // Trying package data directory
result = RunInitScriptInternal(pkgdatadir, fileName, validDotDir, dotDir);
-
if (result == eOK)
{
GetLog()->Debug() << "(ScriptServer) : Ran init script '"
<< pkgdatadir << salt::RFile::Sep() << fileName << "'\n";
return true;
}
-
- if (result == eNotFound)
- {
- GetLog()->Debug() << "(ScriptServer) : Did not find init script '"
- << pkgdatadir << salt::RFile::Sep() << fileName << "'\n";
- }
else if (result == eError)
{
GetLog()->Error() << "(ScriptServer) ERROR: Found error in init script '"
<< pkgdatadir << salt::RFile::Sep() << fileName << "'\n";
+ return false;
}
+ GetLog()->Debug() << "(ScriptServer) : Did not find init script '"
+ << pkgdatadir << salt::RFile::Sep() << fileName << "'\n";
+ // Trying relative path to cwd
result = RunInitScriptInternal(mRelPathPrefix+relPath, fileName, validDotDir, dotDir);
- if (result == eNotFound)
+ if (result == eOK)
{
- GetLog()->Error() << "(ScriptServer) ERROR: Cannot locate init script '"
- << fileName << "'\n";
+ GetLog()->Debug() << "(ScriptServer) : Ran init script '"
+ << mRelPathPrefix+relPath << salt::RFile::Sep() << fileName << "'\n";
+ return true;
}
else if (result == eError)
{
@@ -664,5 +663,7 @@
<< mRelPathPrefix+relPath << salt::RFile::Sep() << fileName << "'\n";
}
+ GetLog()->Error() << "(ScriptServer) ERROR: Cannot locate init script '"
+ << fileName << "'\n";
return (result == eOK);
}
Modified: trunk/spark/plugin/odeimps/odehingejoint.cpp
===================================================================
--- trunk/spark/plugin/odeimps/odehingejoint.cpp 2011-02-11 22:53:50 UTC (rev 245)
+++ trunk/spark/plugin/odeimps/odehingejoint.cpp 2011-02-18 18:44:14 UTC (rev 246)
@@ -32,6 +32,7 @@
{
dWorldID ODEWorld = (dWorldID) worldID;
dJointID ODEJoint = dJointCreateHinge(ODEWorld, 0);
+ dJointSetFeedback( ODEJoint, &mFeedback );
return (long) ODEJoint;
}
@@ -86,3 +87,10 @@
dJointID ODEJoint = (dJointID) jointID;
return gRadToDeg(dJointGetHingeAngleRate(ODEJoint));
}
+
+float HingeJointImp::GetTorque(long jointID) const
+{
+ dJointID ODEJoint = (dJointID) jointID;
+ dJointFeedback* fb = dJointGetFeedback(ODEJoint);
+ return dLENGTH(fb->t1) + dLENGTH(fb->t2);
+}
Modified: trunk/spark/plugin/odeimps/odehingejoint.h
===================================================================
--- trunk/spark/plugin/odeimps/odehingejoint.h 2011-02-11 22:53:50 UTC (rev 245)
+++ trunk/spark/plugin/odeimps/odehingejoint.h 2011-02-18 18:44:14 UTC (rev 246)
@@ -38,6 +38,10 @@
salt::Vector3f GetAxis(long jointID);
float GetAngle(long jointID) const;
float GetAngleRate(long jointID) const;
+ float GetTorque(long jointID) const;
+private:
+ dJointFeedback mFeedback;
+
};
DECLARE_CLASS(HingeJointImp);
Modified: trunk/spark/plugin/sparkagent/hingeperceptor.cpp
===================================================================
--- trunk/spark/plugin/sparkagent/hingeperceptor.cpp 2011-02-11 22:53:50 UTC (rev 245)
+++ trunk/spark/plugin/sparkagent/hingeperceptor.cpp 2011-02-18 18:44:14 UTC (rev 246)
@@ -48,6 +48,13 @@
axisElement.AddValue(mJoint->GetAngleRate());
}
+void HingePerceptor::InsertAxisTorque(Predicate& predicate)
+{
+ ParameterList& axisElement = predicate.parameter.AddList();
+ axisElement.AddValue(string("tq"));
+ axisElement.AddValue(mJoint->GetTorque());
+}
+
bool HingePerceptor::Percept(boost::shared_ptr<oxygen::PredicateList> predList)
{
if (mJoint.get() == 0)
@@ -65,6 +72,7 @@
InsertAxisAngle(predicate);
//InsertAxisRate(predicate);
-
+ //InsertAxisTorque(predicate);
+
return true;
}
Modified: trunk/spark/plugin/sparkagent/hingeperceptor.h
===================================================================
--- trunk/spark/plugin/sparkagent/hingeperceptor.h 2011-02-11 22:53:50 UTC (rev 245)
+++ trunk/spark/plugin/sparkagent/hingeperceptor.h 2011-02-18 18:44:14 UTC (rev 246)
@@ -35,6 +35,7 @@
protected:
void InsertAxisAngle(oxygen::Predicate& predicate);
void InsertAxisRate(oxygen::Predicate& predicate);
+ void InsertAxisTorque(oxygen::Predicate& predicate);
};
DECLARE_CLASS(HingePerceptor);
Modified: trunk/spark/plugin/sparkmonitor/sparkmonitor.cpp
===================================================================
--- trunk/spark/plugin/sparkmonitor/sparkmonitor.cpp 2011-02-11 22:53:50 UTC (rev 245)
+++ trunk/spark/plugin/sparkmonitor/sparkmonitor.cpp 2011-02-18 18:44:14 UTC (rev 246)
@@ -415,17 +415,13 @@
{
bool closeParen = DescribeNode(ss, node);
- for (TLeafList::iterator i = node->begin(); i!= node->end(); ++i)
+ TLeafList baseNodes = node->GetBaseNodeChildren();
+ for (TLeafList::iterator i = baseNodes.begin(); i!= baseNodes.end(); ++i)
{
boost::shared_ptr<BaseNode> baseNode = shared_dynamic_cast<BaseNode>(*i);
- if (baseNode.get() == 0)
- {
- continue;
- }
-
DescribeScene(ss,baseNode);
}
-
+
if (closeParen)
{
ss << ")";
Modified: trunk/spark/plugin/sparkmonitor/sparkmonitorclient.cpp
===================================================================
--- trunk/spark/plugin/sparkmonitor/sparkmonitorclient.cpp 2011-02-11 22:53:50 UTC (rev 245)
+++ trunk/spark/plugin/sparkmonitor/sparkmonitorclient.cpp 2011-02-18 18:44:14 UTC (rev 246)
@@ -191,7 +191,8 @@
}
mActiveScene = mSceneServer->GetActiveScene();
-
+ mActiveScene->UpdateCache();
+
if (mActiveScene.get() == 0)
{
return;
@@ -233,6 +234,8 @@
mSceneImporter->ParseScene(string(pcont->lastPos),
mManagedScene,
boost::shared_ptr<ParameterList>());
+
+ mActiveScene->SetModified(true);
destroy_sexp(sexp_custom);
destroy_continuation(pcont);
Modified: trunk/spark/spark/spark.cpp
===================================================================
--- trunk/spark/spark/spark.cpp 2011-02-11 22:53:50 UTC (rev 245)
+++ trunk/spark/spark/spark.cpp 2011-02-18 18:44:14 UTC (rev 246)
@@ -109,7 +109,7 @@
(
"spark.rb",
"lib/spark",
- ScriptServer::IS_COMMON
+ ScriptServer::IS_USERLOCAL
);
UpdateCached();
Modified: trunk/spark/spark/spark.rb
===================================================================
--- trunk/spark/spark/spark.rb 2011-02-11 22:53:50 UTC (rev 245)
+++ trunk/spark/spark/spark.rb 2011-02-18 18:44:14 UTC (rev 246)
@@ -188,8 +188,6 @@
end
def sparkSetupMonitor
- print "(spark.rb) sparkSetupMonitor\n"
-
# add the agent control node
simulationServer = sparkGetSimulationServer()
if (simulationServer != nil)
@@ -205,7 +203,8 @@
else if ($monitorType == 'tcp')
monitorClient.setClientTypeTCP()
else
- print "(spark.rb) unknown monitor socket type "
+ print "(spark.rb) sparkSetupMonitor\n"
+ print "(spark.rb) ERROR: unknown monitor socket type "
print $monitorType
print "\n"
end
@@ -218,7 +217,7 @@
end
def sparkSetupMonitorLogPlayer
- print "(spark.rb) sparkSetupMonitorLogPlayer\n"
+ #print "(spark.rb) sparkSetupMonitorLogPlayer\n"
simulationServer = sparkGetSimulationServer()
if (simulationServer != nil)
@@ -241,7 +240,7 @@
# simulation specific monitor processing
#
def sparkRegisterCustomMonitor(className)
- print "(spark.rb) sparkRegisterCustomMonitor " + className + "\n"
+ #print "(spark.rb) sparkRegisterCustomMonitor " + className + "\n"
sparkGetSimulationServer()
sparkCreate(className, $serverPath+'simulation/SparkMonitorClient/'+className)
end
@@ -251,7 +250,7 @@
# application specific render logic
#
def sparkRegisterCustomRender(className)
- print "(spark.rb) sparkRegisterCustomRender " + className + "\n"
+ #print "(spark.rb) sparkRegisterCustomRender " + className + "\n"
sparkGetSimulationServer()
sparkCreate(className, $serverPath+'simulation/RenderControl/'+className)
end
@@ -261,7 +260,7 @@
# application specific input processing
#
def sparkRegisterCustomInput(className)
- print "(spark.rb) sparkRegisterCustomInput " + className + "\n"
+ #print "(spark.rb) sparkRegisterCustomInput " + className + "\n"
sparkGetSimulationServer()
sparkCreate(className, $serverPath+'simulation/InputControl/'+className)
end
@@ -271,13 +270,12 @@
# commands received from a monitor client
#
def sparkRegisterMonitorCmdParser(className)
- print "(spark.rb) sparkRegisterMonitorCmdParser " + className + "\n"
+ #print "(spark.rb) sparkRegisterMonitorCmdParser " + className + "\n"
sparkGetMonitorServer()
sparkCreate(className, $serverPath+'monitor/SparkMonitor/'+className)
end
def sparkSetupServer
- print "(spark.rb) sparkSetupServer\n"
# add the agent control node
simulationServer = sparkGetSimulationServer()
@@ -306,7 +304,8 @@
else if ($agentType == 'tcp')
agentControl.setServerTypeTCP()
else
- print "(spark.rb) unknown agent socket type "
+ print "(spark.rb) sparkSetupServer\n"
+ print "(spark.rb) ERROR: unknown agent socket type "
print $agentType
print "\n"
end
@@ -321,7 +320,8 @@
else if ($serverType == 'tcp')
monitorControl.setServerTypeTCP()
else
- print "(spark.rb) unknown monitor socket type "
+ print "(spark.rb) sparkSetupServer\n"
+ print "(spark.rb) ERROR: unknown monitor socket type "
print $serverType
print "\n"
end
@@ -416,7 +416,7 @@
end
def sparkSetupTrain()
- print "(spark.rb) sparkSetupTrain\n"
+ #print "(spark.rb) sparkSetupTrain\n"
#
# register train control node to the simulation server
@@ -504,7 +504,7 @@
# deregisters all output stream
def sparkResetLogging()
- print "(spark.rb) sparkResetLogging removing all log targets\n";
+ #print "(spark.rb) sparkResetLogging removing all log targets\n";
logServer = get($serverPath+'log')
if (logServer != nil)
@@ -513,11 +513,21 @@
end
+# logs all normal output to cout
+def sparkLogNormalToCout()
+ sparkEnableLog(':cout', 'eNormal')
+end
+
# logs all error output to cerr
def sparkLogErrorToCerr()
sparkEnableLog(':cerr', 'eError')
end
+# logs all warning output to cerr
+def sparkLogWarningToCerr()
+ sparkEnableLog(':cerr', 'eWarning')
+end
+
# logs all debug output to cerr
def sparkLogDebugToCerr()
sparkEnableLog(':cerr', 'eDebug')
@@ -552,12 +562,12 @@
# setup spark
#
-print "(spark.rb) setup\n"
+#print "(spark.rb) setup\n"
#import the implementations of the desired physics engine
#currently supported: odeimps (uses Open Dynamics Engine)
importBundle 'odeimps'
-print "(spark.rb) using ODE, to change the physics engine go to line 559 in spark.rb\n"
+#print "(spark.rb) using ODE, to change the physics engine go to line 559 in spark.rb\n"
#
# set up logging
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|