AnimatLab  2
Test
Structure.h
Go to the documentation of this file.
1 
7 #pragma once
8 
9 #include "ScriptProcessor.h"
10 #include "RobotInterface.h"
11 #include "RobotIOControl.h"
12 #include "RobotPartInterface.h"
13 
14 namespace AnimatSim
15 {
16 
23  namespace Environment
24  {
25 
38  class ANIMAT_PORT CollisionPair : public AnimatBase
39  {
40  public:
42  std::string m_strPart1ID;
44  std::string m_strPart2ID;
45 
53 
61  };
62 
63 
84  class ANIMAT_PORT Structure : public AnimatBase, public MovableItem
85  {
86  protected:
89 
95  CStdMap<std::string, RigidBody *> m_aryRigidBodies;
96 
102  CStdMap<std::string, Joint *> m_aryJoints;
103 
105  CStdPtrArray<CollisionPair> m_aryExcludeCollisionList;
106 
112 
114  float m_fltSize;
115 
118 
119  virtual void LoadLayout(CStdXml &oXml);
120  virtual void LoadCollisionPair(CStdXml &oXml);
121  virtual RigidBody *LoadRoot(CStdXml &oXml);
122 
123  virtual void AddRoot(std::string strXml);
124  virtual void RemoveRoot(std::string strID, bool bThrowError = true);
125 
126  virtual ScriptProcessor *LoadScript(CStdXml &oXml);
127  virtual void AddScript(std::string strXml);
128  virtual void RemoveScript(std::string strID, bool bThrowError = true);
129 
130  virtual void UpdateData();
131 
132  public:
133  Structure();
134  virtual ~Structure();
135 
136  static Structure *CastToDerived(AnimatBase *lpBase) {return static_cast<Structure*>(lpBase);}
137 
138  void Sim(Simulator *lpSim);
139 
140  virtual void Body(RigidBody *lpBody);
141  virtual RigidBody *Body();
142 
143  virtual CStdFPoint Position();
144  virtual void Position(CStdFPoint &oPoint, bool bUseScaling = true, bool bFireChangeEvent = false, bool bUpdateMatrix = true);
145 
146  virtual float Size();
147  virtual void Size(float fltVal, bool bUseScaling = true);
148 
149  virtual RobotInterface *GetRobotInterface() {return NULL;};
150 
151  virtual bool AllowTranslateDragX();
152  virtual bool AllowTranslateDragY();
153  virtual bool AllowTranslateDragZ();
154 
155  virtual bool AllowRotateDragX();
156  virtual bool AllowRotateDragY();
157  virtual bool AllowRotateDragZ();
158 
159  virtual CStdPtrArray<CollisionPair> ExclusionList();
160  virtual void AddCollisionPair(std::string strID1, std::string strID2);
161 
162  virtual void MinTimeStep(float &fltMin);
163 
164  virtual void Create();
165  virtual void StepPhysicsEngine();
166  virtual void ResetSimulation();
167 
168  void AddJoint(Joint *lpJoint);
169  void RemoveJoint(std::string strID);
170  void AddRigidBody(RigidBody *lpBody);
171  void RemoveRigidBody(std::string strID);
172 
173  virtual Joint *FindJoint(std::string strJointID, bool bThrowError = true);
174  virtual RigidBody *FindRigidBody(std::string strBodyID, bool bThrowError = true);
175  virtual Node *FindNode(std::string strID, bool bThrowError = true);
176  //virtual AnimatBase *FindCollisionPair(std::string strID, bool bThrowError = true);
177 
178  virtual void EnableMotor(std::string strJointID, bool bVal);
179  virtual void SetMotorInput(std::string strJointID, float fltInput);
180 
181  virtual void EnableCollision(RigidBody *lpCollisionBody);
182  virtual void DisableCollision(RigidBody *lpCollisionBody);
183 
184  virtual void Selected(bool bValue, bool bSelectMultiple);
185  virtual void UpdatePhysicsPosFromGraphics();
186 
187  virtual void Script(ScriptProcessor *lpScript);
188  virtual ScriptProcessor *Script();
189 
190 #pragma region DataAccesMethods
191 
192  virtual void SetSystemPointers(Simulator *lpSim, Structure *lpStructure, NeuralModule *lpModule, Node *lpNode, bool bVerify);
193  virtual float *GetDataPointer(const std::string &strDataType);
194  virtual bool SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError = true);
195  virtual void QueryProperties(CStdPtrArray<TypeProperty> &aryProperties);
196  virtual bool AddItem(const std::string &strItemType, const std::string &strXml, bool bThrowError = true, bool bDoNotInit = false);
197  virtual bool RemoveItem(const std::string &strItemType, const std::string &strID, bool bThrowError = true);
198 
199 #pragma endregion
200 
201 #pragma region SnapshotMethods
202  virtual long CalculateSnapshotByteSize();
203  virtual void SaveKeyFrameSnapshot(byte *aryBytes, long &lIndex);
204  virtual void LoadKeyFrameSnapshot(byte *aryBytes, long &lIndex);
205 #pragma endregion
206 
207  virtual void Initialize();
208  virtual void Kill(bool bState = true);
209  virtual void SimStarting();
210  virtual void SimPausing();
211  virtual void SimStopping();
212 
213  virtual void Load(CStdXml &oXml);
214  };
215 
216  } // Environment
217 } //AnimatSim
IMovableItemCallback * m_lpCallback
Definition: Structure.h:111
Movable Item callback to the GUI.
Declares the Robot IO control interface base class.
Simulates the entire environment.
Definition: Simulator.h:31
Root namespace for the base simulation library for AnimatLab.
CollisionPair()
Default constructor.
Definition: Structure.h:52
CStdMap< std::string, RigidBody * > m_aryRigidBodies
Definition: Structure.h:95
std::string m_strPart2ID
GUID ID of the second part of the collision pair.
Definition: Structure.h:44
RigidBody * m_lpBody
The root rigid body object of this structure.
Definition: Structure.h:88
Baes class for all items that can be moved/roated within the environment.
Definition: MovableItem.h:19
CStdPtrArray< CollisionPair > m_aryExcludeCollisionList
This is the list of other body part ID's to exclude from collision tests.
Definition: Structure.h:105
A "static" structure in the simulation.
Definition: Structure.h:84
float m_fltSize
The radius of the graphical sphere shown for the structure position.
Definition: Structure.h:114
Animat base class.
Definition: AnimatBase.h:36
ScriptProcessor * m_lpScript
Script processor for running python or other scripting systems related to this structure.
Definition: Structure.h:117
Base class for body parts and neural network nodes.
Definition: Node.h:25
CStdMap< std::string, Joint * > m_aryJoints
Definition: Structure.h:102
std::string m_strPart1ID
GUID ID of the first part of the collision pair.
Definition: Structure.h:42
Declares the robotics inerface for animatlab.
The base class for all of the basic rigid body type of objects.
Definition: RigidBody.h:66