8 #include "IMotorizedJoint.h"
9 #include "IMovableItemCallback.h"
10 #include "ISimGUICallback.h"
15 #include "IPhysicsMovableItem.h"
16 #include "IPhysicsBody.h"
18 #include "MovableItem.h"
21 #include "MotorizedJoint.h"
80 {
Std_TraceMsg(0,
"Caught Error in desctructor of Structure\r\n",
"", -1,
false,
true);}
129 else if(bFireChangeEvent)
165 MovableItem::Selected(bValue, bSelectMultiple);
229 void Structure::UpdatePhysicsPosFromGraphics()
235 void Structure::Create()
270 void Structure::MinTimeStep(
float &fltMin) {}
347 THROW_PARAM_ERROR(Al_Err_lJointNotDefined, Al_Err_strJointNotDefined,
"StructureID",
m_strName);
403 THROW_PARAM_ERROR(Al_Err_lBodyNotDefined, Al_Err_strBodyNotDefined,
"StructureID",
m_strName);
459 Joint *lpJoint = NULL;
460 CStdMap<std::string, Joint *>::iterator oPos;
464 lpJoint = oPos->second;
466 THROW_TEXT_ERROR(Al_Err_lJointIDNotFound, Al_Err_strJointIDNotFound,
" StructureID: " +
m_strName +
" JointID: " + strJointID);
492 CStdMap<std::string, RigidBody *>::iterator oPos;
496 lpBody = oPos->second;
498 THROW_TEXT_ERROR(Al_Err_lRigidBodyIDNotFound, Al_Err_strRigidBodyIDNotFound,
" StructureID: " +
m_strName +
" BodyID: " + strBodyID);
528 THROW_TEXT_ERROR(Al_Err_lRigidBodyIDNotFound, Al_Err_strRigidBodyIDNotFound,
" StructureID: " +
m_strName +
" BodyID: " + strID);
533 #pragma region DataAccesMethods
546 lpData = MovableItem::GetDataPointer(strDataType);
550 THROW_TEXT_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType,
"Simulator DataType: " + strDataType);
555 bool Structure::SetData(
const std::string &strDataType,
const std::string &strValue,
bool bThrowError)
562 if(MovableItem::SetData(strDataType, strValue,
false))
567 THROW_PARAM_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType,
"Data Type", strDataType);
575 MovableItem::QueryProperties(aryProperties);
578 bool Structure::AddItem(
const std::string &strItemType,
const std::string &strXml,
bool bThrowError,
bool bDoNotInit)
582 if(strType ==
"RIGIDBODY")
588 if(strType ==
"SCRIPT")
596 THROW_PARAM_ERROR(Al_Err_lInvalidItemType, Al_Err_strInvalidItemType,
"Item Type", strItemType);
605 if(strType ==
"RIGIDBODY")
611 if(strType ==
"SCRIPT")
619 THROW_PARAM_ERROR(Al_Err_lInvalidItemType, Al_Err_strInvalidItemType,
"Item Type", strItemType);
678 m_lpSim->NotifyRigidBodyRemoved(strID);
681 THROW_PARAM_ERROR(Al_Err_lRigidBodyIDNotFound, Al_Err_strRigidBodyIDNotFound,
"ID", strID);
712 if(lpScript)
delete lpScript;
718 if(lpScript)
delete lpScript;
720 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
746 THROW_PARAM_ERROR(Al_Err_lRigidBodyIDNotFound, Al_Err_strRigidBodyIDNotFound,
"ID", strID);
766 THROW_PARAM_ERROR(Al_Err_lJointNotMotorized, Al_Err_strJointNotMotorized,
"ID", strJointID);
788 THROW_PARAM_ERROR(Al_Err_lJointNotMotorized, Al_Err_strJointNotMotorized,
"ID", strJointID);
804 CStdMap<std::string, RigidBody *>::iterator oPos;
808 lpBody = oPos->second;
827 CStdMap<std::string, RigidBody *>::iterator oPos;
831 lpBody = oPos->second;
888 void Structure::Load(
CStdXml &oXml)
892 MovableItem::Load(oXml);
934 std::string strID1, strID2;
951 if(lpPair)
delete lpPair;
956 if(lpPair)
delete lpPair;
957 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
977 std::string strModule;
996 for(
int iIndex=0; iIndex<iChildCount; iIndex++)
1022 std::string strModule;
1023 std::string strType;
1034 THROW_TEXT_ERROR(Al_Err_lConvertingClassToType, Al_Err_strConvertingClassToType,
"RigidBody");
1049 RELAY_ERROR(oError);
1056 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
1074 std::string strModule;
1075 std::string strType;
1087 THROW_TEXT_ERROR(Al_Err_lConvertingClassToType, Al_Err_strConvertingClassToType,
"Script");
1091 lpScript->
Load(oXml);
1097 if(lpScript)
delete lpScript;
1099 RELAY_ERROR(oError);
1104 if(lpScript)
delete lpScript;
1106 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
void Sim(Simulator *lpSim)
Sets the simulator object.
virtual void ResetSimulation()
Resets the simulation back to time 0.
virtual void SimPausing()
Called just before the simulation pauses.
virtual void Deserialize(std::string &strXml)
Deserializes a string into an xml document.
The base class for all of the joint type of objects.
void AddRigidBody(RigidBody *lpBody)
Adds a new rigid body to the list of all bodies for this structure.
Base class file for all Animat simulation objects.
Declares the nervous system class.
virtual float * GetDataPointer(const std::string &strDataType)
Returns a float pointer to a data item of interest in this object.
virtual void Initialize()
Initializes this object.
Declares the simulation recorder class.
virtual void QueryProperties(CStdPtrArray< TypeProperty > &aryProperties)
Queries this object for a list of properties that can be changed using SetData.
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 void SetSystemPointers(Simulator *lpSim, Structure *lpStructure, NeuralModule *lpModule, Node *lpNode, bool bVerify)
Sets the system pointers.
virtual Node * FindNode(std::string strID, bool bThrowError=true)
Searches for a Node with the given ID.
Simulates the entire environment.
virtual void DisableCollision(RigidBody *lpBody)
Disables collision between the past-in object and this object.
virtual bool FindChildElement(std::string strElementName, bool fThrowError=true)
Finds a child element by name.
Simulator * m_lpMovableSim
The pointer to a Simulation.
virtual void CreateParts()
Allows the rigid body to create its parts using the chosen physics engine.
Root namespace for the base simulation library for AnimatLab.
virtual void EnableCollision(RigidBody *lpBody)
Enables collision between the past-in object and this object.
CStdMap< std::string, RigidBody * > m_aryRigidBodies
virtual bool AllowTranslateDragY()
Gets whether this body part can be translated along the y-axis by the user with the drag handlers...
virtual bool AllowRotateDragZ()
Gets whether this body part can be rotated along the z-axis by the user with the drag handlers...
virtual void SimStarting()
Called just before the simulation starts.
Declares the body part class.
void RemoveRigidBody(std::string strID)
Removes the rigid body with the specified ID.
virtual void Kill(bool bState=true)
Kills.
std::string m_strError
The error message.
virtual void ResetSimulation()
Resets the simulation back to time 0.
virtual bool FindElement(std::string strElementName, bool fThrowError=true)
Finds an element with the specified name.
Simulator * m_lpSim
The pointer to a Simulation.
virtual float Size()
Gets the size of the graphical representation of this joint.
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.
void AddJoint(Joint *lpJoint)
Adds a new joint to the list of all joints for this structure.
virtual ~Structure()
Destructor.
std::string m_strPart2ID
GUID ID of the second part of the collision pair.
virtual bool AllowTranslateDragX()
Gets whether this body part can be translated along the x-axis by the user with the drag handlers...
void RemoveJoint(std::string strID)
Removes the joint with the specified ID.
virtual void SimStopping()
Called just before the simulation stops.
virtual void LoadCollisionPair(CStdXml &oXml)
Loads a collision pair.
long m_lError
The error number.
virtual void Initialize()
Initializes this object.
virtual RigidBody * LoadRoot(CStdXml &oXml)
Loads the root rigid body.
Declares the link base class.
Declares the key frame class.
virtual void Initialize()
Initializes this object.
virtual void SetMotorInput(std::string strJointID, float fltInput)
Sets the velocity for the specified joint.
RigidBody * m_lpBody
The root rigid body object of this structure.
Declares the joint class.
Declares the organism class.
virtual void PositionChanged()=0
Called to signal to the GUI that the position of the body part changed.
virtual RigidBody * Body()
Gets the root body.
virtual bool AllowTranslateDragZ()
Gets whether this body part can be translated along the z-axis by the user with the drag handlers...
virtual bool RemoveItem(const std::string &strItemType, const std::string &strID, bool bThrowError=true)
Removes a child item from this parent.
bool Std_IsAboveMin(int iMinVal, int iVal, bool bThrowError, std::string strParamName, bool bInclusiveLimit)
Tests if a number is above a minimum value.
Declares the activated item class.
CStdPtrArray< CollisionPair > m_aryExcludeCollisionList
This is the list of other body part ID's to exclude from collision tests.
virtual CStdSerialize * CreateObject(std::string strModule, std::string strClassName, std::string strType, bool bThrowError=true)
Creates an object using a class factory.
virtual void UpdatePhysicsPosFromGraphics()
Updates the physics position from graphics.
Declares a light manager object.
IPhysicsMovableItem * m_lpPhysicsMovableItem
Declares the bounding box class.
virtual std::string Name()
Gets the name of this object.
virtual IMovableItemCallback * Callback()
Gets the callback interface pointer. This is an interface pointer to a callback class that allows us ...
virtual void LoadKeyFrameSnapshot(byte *aryBytes, long &lIndex)
Loads a key frame snapshot.
virtual CStdFPoint Position()
Gets the local position. (m_oPosition)
virtual void ResetSimulation()
Resets the simulation back to time 0.
virtual long CalculateSnapshotByteSize()
Calculates the snapshot byte size.
A standard xml manipulation class.
virtual bool Selected()
Tells if this items is selected or not.
A "static" structure in the simulation.
virtual void CreateJoints()
Allows the rigid body to create its joints using the chosen physics engine.
virtual bool EnableMotor()
Tells if the motor is enabled.
virtual void DisableCollision(RigidBody *lpCollisionBody)
Disables collision between the past-in object and all rigid bodies of this structure.
virtual IPhysicsMovableItem * PhysicsMovableItem()
Gets the physics body interface pointer. This is an interface reference to the Vs version of this obj...
virtual void QueryProperties(CStdPtrArray< TypeProperty > &aryProperties)
Queries this object for a list of properties that can be changed using SetData.
virtual std::string GetChildString(std::string strElementName)
Gets a string value from the element with the specified name.
float m_fltSize
The radius of the graphical sphere shown for the structure position.
virtual Joint * FindJoint(std::string strJointID, bool bThrowError=true)
Finds a joint with a specified ID within this structure.
virtual void AddCollisionPair(std::string strID1, std::string strID2)
Adds a collision pair to m_aryExcludeCollisionList.
RigidBody * Parent()
Gets the parent RigidBody of this part.
virtual void EnableCollision(RigidBody *lpCollisionBody)
Enables collision between the past-in object and all rigid bodies of this structure.
virtual void StepPhysicsEngine()
Allows the organism and its parts to update at each time slice.
virtual void Load(StdUtils::CStdXml &oXml)
Loads the item using an XML data packet.
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 CStdFPoint Position()
Gets the local position. (m_oPosition)
Structure()
Default constructor.
virtual bool AllowRotateDragX()
Gets whether this body part can be rotated along the x-axis by the user with the drag handlers...
virtual void Kill(bool bState=true)
Kills.
virtual void AddRoot(std::string strXml)
Creates and adds a root body part.
ScriptProcessor * m_lpScript
Script processor for running python or other scripting systems related to this structure.
virtual int NumberOfChildren()
Gets the number of children of the current element.
virtual bool SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError=true)
Set a variable based on a string data type name.
Base class for body parts and neural network nodes.
virtual void LoadLayout(CStdXml &oXml)
Loads the layout for this structure from an asl configuration file.
virtual void RemoveScript(std::string strID, bool bThrowError=true)
Removes the script based on ID.
CStdMap< std::string, Joint * > m_aryJoints
virtual bool OutOfElem()
Goes out of the element where the cursor is located.
virtual void RemoveRoot(std::string strID, bool bThrowError=true)
Removes the root based on ID.
Declares the data chart manager class.
virtual bool AllowRotateDragY()
Gets whether this body part can be rotated along the y-axis by the user with the drag handlers...
std::string m_strPart1ID
GUID ID of the first part of the collision pair.
Declares the rigid body class.
virtual void StepSimulation()
Step the simulation for this object.
std::string Std_CheckString(std::string strVal)
Converts a string to upper case and trims it.
Declares the structure class.
Declares the odor type class.
virtual void UpdateData()
Collects reporting data for the structure at each time step.
virtual float InverseDistanceUnits()
Gets the inverse distance units.
virtual ScriptProcessor * LoadScript(CStdXml &oXml)
Loads the script.
virtual void EnableMotor(std::string strJointID, bool bVal)
Enables the given joints motor.
Declares the simulator class.
Declares the neural module class.
virtual bool FindChildByIndex(int iIndex, bool bThrowError=true)
Finds a child element by index.
virtual CStdPtrArray< CollisionPair > ExclusionList()
Gets the collision exclusion list as an array.
Declares the activated item manager class.
virtual void MotorInput(float fltInput)
Sets the desired velocity.
virtual void SaveKeyFrameSnapshot(byte *aryBytes, long &lIndex)
Saves a key frame snapshot.
Declares the external stimuli manager class.
virtual RigidBody * FindRigidBody(std::string strBodyID, bool bThrowError=true)
Finds a rigid body with a specified ID within this structure.
virtual bool SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError=true)
Set a variable based on a string data type name.
The base class for all of the basic rigid body type of objects.
virtual void AddScript(std::string strXml)
Creates and adds a scripting object to this structure.
Declares the receptive field class.
virtual void AfterResetSimulation()
Called after a simulation reset for some objects.
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.