8 #include "IMovableItemCallback.h"
9 #include "ISimGUICallback.h"
14 #include "IPhysicsMovableItem.h"
15 #include "IPhysicsBody.h"
17 #include "MovableItem.h"
27 #include "PhysicsNeuralModule.h"
71 {
Std_TraceMsg(0,
"Caught Error in desctructor of PhysicsNeuralModule\r\n",
"", -1,
false,
true);}
91 for(
int iIndex=0; iIndex<iCount; iIndex++)
99 for(
int iIndex=0; iIndex<iCount; iIndex++)
110 THROW_TEXT_ERROR(Al_Err_lConvertingClassToType, Al_Err_strConvertingClassToType,
"Organism");
113 for(
int iIndex=0; iIndex<iCount; iIndex++)
118 #pragma region DataAccesMethods
127 if(strType ==
"TIMESTEP")
129 TimeStep((
float) atof(strValue.c_str()));
135 THROW_PARAM_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType,
"Data Type", strDataType);
144 aryProperties.Add(
new TypeProperty(
"TimeStep", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
147 void PhysicsNeuralModule::AddAdapter(std::string strXml,
bool bDoNotInit)
154 Adapter *lpAdapter = LoadAdapter(oXml);
159 void PhysicsNeuralModule::RemoveAdapter(std::string strID)
161 int iIdx = FindAdapterListPos(strID);
166 int PhysicsNeuralModule::FindAdapterListPos(std::string strID,
bool bThrowError)
171 for(
int iIndex=0; iIndex<iCount; iIndex++)
176 THROW_PARAM_ERROR(Al_Err_lAdapterIDNotFound, Al_Err_strAdapterIDNotFound,
"ID",
m_strID);
185 if(strType ==
"ADAPTER")
189 AddAdapter(strXml, bDoNotInit);
202 THROW_PARAM_ERROR(Al_Err_lInvalidItemType, Al_Err_strInvalidItemType,
"Item Type", strItemType);
211 if(strType ==
"ADAPTER")
213 RemoveAdapter(strID);
221 THROW_PARAM_ERROR(Al_Err_lInvalidItemType, Al_Err_strInvalidItemType,
"Item Type", strItemType);
232 for(
int iIndex=0; iIndex<iCount; iIndex++)
234 lByteSize +=
m_aryAdapters[iIndex]->CalculateSnapshotByteSize();
242 for(
int iIndex=0; iIndex<iCount; iIndex++)
244 m_aryAdapters[iIndex]->SaveKeyFrameSnapshot(aryBytes, lIndex);
250 for(
int iIndex=0; iIndex<iCount; iIndex++)
252 m_aryAdapters[iIndex]->LoadKeyFrameSnapshot(aryBytes, lIndex);
255 void PhysicsNeuralModule::Load(
CStdXml &oXml)
281 for(
int iIndex=0; iIndex<iCount; iIndex++)
291 TRACE_DEBUG(
"Finished loading nervous system config file.");
314 std::string strModuleName, strType;
325 THROW_TEXT_ERROR(Al_Err_lConvertingClassToType, Al_Err_strConvertingClassToType,
"Adapter");
328 lpAdapter->Load(oXml);
336 if(lpAdapter)
delete lpAdapter;
342 if(lpAdapter)
delete lpAdapter;
343 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
virtual void SetSystemPointers(Simulator *lpSim, Structure *lpStructure, NeuralModule *lpModule, Node *lpNode, bool bVerify)
Sets the system pointers.
virtual void QueryProperties(CStdPtrArray< TypeProperty > &aryProperties)
Queries this object for a list of properties that can be changed using SetData.
virtual void Deserialize(std::string &strXml)
Deserializes a string into an xml document.
CStdArray< Adapter * > m_arySourceAdapters
An array of source adapters for this module.
Base class file for all Animat simulation objects.
Declares the nervous system class.
virtual void PhysicsTimeStep(float fltVal)
Sets the integration time step for the physics engine.
Declares the simulation recorder class.
virtual bool FindChildElement(std::string strElementName, bool fThrowError=true)
Finds a child element by name.
Root namespace for the base simulation library for AnimatLab.
virtual void ResetSimulation()
Resets the simulation back to time 0.
virtual float TimeStep()
Gets the time step for this moudle in time units.
virtual void Initialize()
Initializes this object.
Declares the body part class.
virtual std::string Type()
returns the string type name of this object.
virtual void Kill(bool bState=true)
Kills.
virtual void Initialize()
Initializes this object.
virtual bool FindElement(std::string strElementName, bool fThrowError=true)
Finds an element with the specified name.
Simulator * m_lpSim
The pointer to a Simulation.
Information about the standard error.
virtual std::string ID()
Gets the unique GUID ID of this object.
virtual bool IntoElem()
Goes into the next element where the cursor is located.
Class that stores information about types for QueryProperty information.
Declares the link base class.
Declares the key frame class.
virtual void Initialize()
Initializes this object.
virtual void LoadKeyFrameSnapshot(byte *aryBytes, long &lIndex)
Loads a key frame snapshot.
virtual bool RemoveItem(const std::string &strItemType, const std::string &strID, bool bThrowError=true)
Removes a child item from this parent.
Declares the joint class.
Declares the organism class.
AnimatSim::Environment::Structure * m_lpStructure
The pointer to this items parent Structure. If this is not relevant for this object then this is NULL...
std::string m_strID
The unique Id for this object.
std::string Std_Trim(std::string strVal)
Trims a string.
CStdPtrArray< Adapter > m_aryAdapters
The array of adapters in this module.
virtual ~PhysicsNeuralModule()
Destructor.
Declares the activated item class.
virtual CStdSerialize * CreateObject(std::string strModule, std::string strClassName, std::string strType, bool bThrowError=true)
Creates an object using a class factory.
Declares a light manager object.
virtual bool SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError=true)
Set a variable based on a string data type name.
virtual float TimeStep()
Gets the time step for this moudle in time units.
Declares the bounding box class.
CStdArray< Adapter * > m_aryTargetAdapters
An array of target adapters for this module.
virtual std::string Name()
Gets the name of this object.
Declares the gain base class.
A standard xml manipulation class.
virtual void QueryProperties(CStdPtrArray< TypeProperty > &aryProperties)
Queries this object for a list of properties that can be changed using SetData.
virtual long CalculateSnapshotByteSize()
Calculates the snapshot byte size.
virtual std::string GetChildString(std::string strElementName)
Gets a string value from the element with the specified name.
void Std_TraceMsg(const int iLevel, std::string strMessage, std::string strSourceFile, int iSourceLine, bool bLogToFile, bool bPrintHeader)
Traces a message to the debugger window.
virtual bool AddItem(const std::string &strItemType, const std::string &strXml, bool bThrowError=true, bool bDoNotInit=false)
Adds a new object to this parent.
virtual int NumberOfChildren()
Gets the number of children of the current element.
A dynamic organism that is controlled by a neural network.
virtual bool OutOfElem()
Goes out of the element where the cursor is located.
PhysicsNeuralModule()
Default constructor.
Declares the data chart manager class.
Declares the rigid body class.
std::string Std_CheckString(std::string strVal)
Converts a string to upper case and trims it.
virtual void VerifySystemPointers()
Verify that system pointers have been set correctly.
Declares the structure class.
Declares the odor type class.
float m_fltTimeStep
The DT time step for this neural module in seconds.
Declares the simulator class.
Declares the neural module class.
virtual bool FindChildByIndex(int iIndex, bool bThrowError=true)
Finds a child element by index.
std::string Std_ToUpper(std::string strVal)
Converts a string to upper case.
Declares the activated item manager class.
Declares the external stimuli manager class.
std::string m_strType
The type for this object. Examples are Box, Plane, Neuron, etc..
virtual void AddToObjectList(AnimatBase *lpItem)
Adds an object to the list of all simulation objects.
virtual bool SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError=true)
Set a variable based on a string data type name.
virtual void SaveKeyFrameSnapshot(byte *aryBytes, long &lIndex)
Saves a key frame snapshot.
Declares the receptive field class.
std::string m_strName
The name for this object.
virtual float GetChildFloat(std::string strElementName)
Gets a float value from the element with the specified name.