AnimatLab  2
Test
Adapter.cpp
Go to the documentation of this file.
1 
7 #include "StdAfx.h"
8 #include "IMovableItemCallback.h"
9 #include "ISimGUICallback.h"
10 #include "AnimatBase.h"
11 
12 #include "Node.h"
13 #include "Link.h"
14 #include "IPhysicsMovableItem.h"
15 #include "IPhysicsBody.h"
16 #include "BoundingBox.h"
17 #include "MovableItem.h"
18 #include "BodyPart.h"
19 #include "Gain.h"
20 #include "Adapter.h"
21 #include "Joint.h"
22 #include "ReceptiveField.h"
23 #include "ContactSensor.h"
24 #include "RigidBody.h"
25 #include "Structure.h"
26 #include "NeuralModule.h"
27 #include "NervousSystem.h"
28 #include "Organism.h"
29 #include "ActivatedItem.h"
30 #include "ActivatedItemMgr.h"
31 #include "DataChartMgr.h"
32 #include "ExternalStimuliMgr.h"
33 #include "KeyFrame.h"
34 #include "SimulationRecorder.h"
35 #include "OdorType.h"
36 #include "Odor.h"
37 #include "Light.h"
38 #include "LightManager.h"
39 #include "Simulator.h"
40 
41 
42 namespace AnimatSim
43 {
44  namespace Adapters
45  {
53 {
54  m_lpGain = NULL;
55  m_lpSourceNode = NULL;
56  m_lpSourceData = NULL;
57  m_lpTargetNode = NULL;
58  m_bConnectedToPhysics = false;
59  m_fltNextVal = 0;
61  m_fltDelayBufferInterval = 0;
62  m_eDelayBufferMode = NoDelayBuffer;
66  m_bSynchWithRobot = false;
71  m_iSynchCount = 0;
72  m_iSynchTarget = -1;
74 }
75 
83 {
84 
85 try
86 {
87  m_lpSourceNode = NULL;
88  m_lpSourceData = NULL;
89  m_lpTargetNode = NULL;
90  if(m_lpGain) delete m_lpGain;
91 }
92 catch(...)
93 {Std_TraceMsg(0, "Caught Error in desctructor of Adapter\r\n", "", -1, false, true);}
94 }
95 
105 
114 void Adapter::SourceModule(std::string strName)
115 {
116  if(Std_IsBlank(strName))
117  THROW_TEXT_ERROR(Al_Err_lModuleNameBlank, Al_Err_strModuleNameBlank, ". Source Module. ID: " + strName);
118  m_strSourceModule = strName;
119 }
120 
129 std::string Adapter::SourceID() {return m_strSourceID;}
130 
139 void Adapter::SourceID(std::string strID)
140 {
141  if(Std_IsBlank(strID))
142  THROW_TEXT_ERROR(Al_Err_lDataTypeBlank, Al_Err_strDataTypeBlank, " Source ID");
143  m_strSourceID = strID;
144 }
145 
155 
164 void Adapter::SourceDataType(std::string strType)
165 {
166  if(Std_IsBlank(strType))
167  THROW_TEXT_ERROR(Al_Err_lDataTypeBlank, Al_Err_strDataTypeBlank, " Source DataType");
168  m_strSourceDataType = strType;
169 }
170 
180 
190 
199 void Adapter::TargetModule(std::string strName)
200 {
201  if(Std_IsBlank(strName))
202  THROW_TEXT_ERROR(Al_Err_lModuleNameBlank, Al_Err_strModuleNameBlank, ". Target Module. ID: " + strName);
203  m_strTargetModule = strName;
204 }
205 
214 std::string Adapter::TargetID() {return m_strTargetID;}
215 
216 
225 void Adapter::TargetID(std::string strID)
226 {
227  if(Std_IsBlank(strID))
228  THROW_TEXT_ERROR(Al_Err_lDataTypeBlank, Al_Err_strDataTypeBlank, " Target ID");
229  m_strTargetID = strID;
230 }
231 
241 
250 void Adapter::TargetDataType(std::string strType)
251 {
252  m_strTargetDataType = strType;
253 }
254 
264 
274 
275 void Adapter::SetGain(Gain *lpGain)
276 {
277  if(m_lpGain)
278  {
279  delete m_lpGain;
280  m_lpGain = NULL;
281  }
282 
283  m_lpGain = lpGain;
285 }
286 
296 
308 {
309  return m_eDelayBufferMode;
310 }
311 
323 {
324  m_eDelayBufferMode = eMode;
325  SetDelayBufferSize();
326 }
327 
336 float Adapter::DelayBufferInterval() {return m_fltDelayBufferInterval;}
337 
347 {
348  Std_IsAboveMin((float) 0, fltVal, true, "DelayBufferInterval", true);
349  m_fltDelayBufferInterval = fltVal;
350  SetDelayBufferSize();
351 }
352 
368 
383 void Adapter::RobotIOScale(float fltVal)
384 {
385  Std_IsAboveMin((float) 0, fltVal, true, "RobotIOScale");
386  m_fltRobotIOScale = fltVal;
387 }
388 
402 
412 
424 
434 {
435  Std_IsAboveMin((float) 0, fltVal, true, "SynchUpdateInterval", true);
436  m_fltSynchUpdateInterval = fltVal;
437 
438  if(m_lpSim)
439  {
440  float fltTimeStep = m_lpSim->PhysicsTimeStep();
441  if(m_lpModule)
442  fltTimeStep = m_lpModule->TimeStep();
443 
444  if(fltTimeStep > 0)
445  m_iSynchUpdateInterval = (int) ((m_fltSynchUpdateInterval/fltTimeStep) + 0.5);
446  else
448  }
449 }
450 
465 
480 {
481  Std_IsAboveMin((float) 0, fltVal, true, "SynchUpdateStartInterval", true);
483 
484  if(m_lpSim)
485  {
486  float fltTimeStep = m_lpSim->PhysicsTimeStep();
487  if(m_lpModule)
488  fltTimeStep = m_lpModule->TimeStep();
489 
490  if(fltTimeStep > 0)
491  m_iSynchUpdateStartInterval = (int) ((m_fltSynchUpdateStartInterval/fltTimeStep) + 0.5);
492  else
494  }
495 }
496 
509 {
511 }
512 
525 {
526  Std_IsAboveMin((float) 0, fltVal, true, "InitIODisableDuration", true);
528 }
529 
530 void Adapter::DetachAdaptersFromSimulation()
531 {
532  if(m_lpSim)
533  {
534  m_lpSim->RemoveSourceAdapter(m_lpStructure, this);
535  m_lpSim->RemoveTargetAdapter(m_lpStructure, this);
536  }
537 }
538 
539 void Adapter::AddExternalNodeInput(int iTargetDataType, float fltInput)
540 {
541  THROW_TEXT_ERROR(Al_Err_lOpNotDefinedForAdapter, Al_Err_strOpNotDefinedForAdapter, "AddExternalNodeInput");
542 }
543 
544 float *Adapter::GetDataPointer(const std::string &strDataType)
545 {
546  std::string strType = Std_CheckString(strDataType);
547 
548  float *lpData = NULL;
549 
550  if(strType == "ENABLE")
551  return &m_fltEnabled;
552  else if(strType == "CALCULATEDVAL")
553  return &m_fltCalculatedVal;
554  else if(strType == "NEXTVAL")
555  return &m_fltNextVal;
556  else if(strType == "UPDATEDVALUE")
557  return &m_fltUpdatedValue;
558 
559  return AnimatBase::GetDataPointer(strDataType);
560 }
561 
570 void Adapter::AddGain(std::string strXml)
571 {
572  CStdXml oXml;
573  oXml.Deserialize(strXml);
574  oXml.FindElement("Root");
575  oXml.FindChildElement("Gain");
576 
577  SetGain(LoadGain(m_lpSim, "Gain", oXml));
578 }
579 
580 void Adapter::SetOriginID(std::string strXml)
581 {
582  CStdXml oXml;
583  oXml.Deserialize(strXml);
584  oXml.FindElement("Root");
585  oXml.FindChildElement("Adapter");
586 
587  oXml.IntoElem(); //Into Adapter Element
588 
589  //Load Source Data
590  SourceModule(oXml.GetChildString("SourceModule"));
591  SourceID(oXml.GetChildString("SourceID"));
592  SourceDataType(oXml.GetChildString("SourceDataType"));
593 
594  oXml.OutOfElem(); //OutOf Adapter Element
595 
596  //Remove the adatper settings.
597  m_lpSim->RemoveSourceAdapter(m_lpStructure, this);
598  m_lpSim->RemoveTargetAdapter(m_lpStructure, this);
599 
600  Initialize();
601 }
602 
603 void Adapter::SetDestinationID(std::string strXml)
604 {
605  CStdXml oXml;
606  oXml.Deserialize(strXml);
607  oXml.FindElement("Root");
608  oXml.FindChildElement("Adapter");
609 
610  oXml.IntoElem(); //Into Adapter Element
611 
612  //Load Source Data
613  TargetModule(oXml.GetChildString("TargetModule"));
614  TargetID(oXml.GetChildString("TargetID"));
615  TargetDataType(oXml.GetChildString("TargetDataType"));
616 
617  oXml.OutOfElem(); //OutOf Adapter Element
618 
619  //Remove the adatper settings.
620  m_lpSim->RemoveSourceAdapter(m_lpStructure, this);
621  m_lpSim->RemoveTargetAdapter(m_lpStructure, this);
622 
623  Initialize();
624 }
625 
626 bool Adapter::SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError)
627 {
628  std::string strType = Std_CheckString(strDataType);
629 
630  if(Node::SetData(strDataType, strValue, false))
631  return true;
632 
633  if(strType == "GAIN")
634  {
635  AddGain(strValue);
636  return true;
637  }
638 
639  if(strType == "ORIGINID")
640  {
641  SetOriginID(strValue);
642  return true;
643  }
644 
645  if(strType == "DESTINATIONID")
646  {
647  SetDestinationID(strValue);
648  return true;
649  }
650 
651  if(strType == "DELAYBUFFERMODE")
652  {
653  DelayBufferMode((eDelayBufferMode) atoi(strValue.c_str()));
654  return true;
655  }
656 
657  if(strType == "DELAYBUFFERINTERVAL")
658  {
659  DelayBufferInterval(atof(strValue.c_str()));
660  return true;
661  }
662 
663  if(strType == "ROBOTIOSCALE")
664  {
665  RobotIOScale(atof(strValue.c_str()));
666  return true;
667  }
668 
669  if(strType == "SYNCHWITHROBOT")
670  {
671  SynchWithRobot(Std_ToBool(strValue));
672  return true;
673  }
674 
675  if(strType == "SYNCHUPDATEINTERVAL")
676  {
677  SynchUpdateInterval(atof(strValue.c_str()));
678  return true;
679  }
680 
681  if(strType == "SYNCHUPDATESTARTINTERVAL")
682  {
683  SynchUpdateStartInterval(atof(strValue.c_str()));
684  return true;
685  }
686 
687  if(strType == "INITIODISABLEDURATION")
688  {
689  InitIODisableDuration(atof(strValue.c_str()));
690  return true;
691  }
692 
693  //If it was not one of those above then we have a problem.
694  if(bThrowError)
695  THROW_PARAM_ERROR(Al_Err_lInvalidItemType, Al_Err_strInvalidItemType, "Data Type", strDataType);
696 
697  return false;
698 }
699 
700 void Adapter::QueryProperties(CStdPtrArray<TypeProperty> &aryProperties)
701 {
702  Node::QueryProperties(aryProperties);
703 
704  aryProperties.Add(new TypeProperty("Enable", AnimatPropertyType::Boolean, AnimatPropertyDirection::Get));
705  aryProperties.Add(new TypeProperty("CalculatedVal", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
706  aryProperties.Add(new TypeProperty("NextVal", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
707  aryProperties.Add(new TypeProperty("UpdatedValue", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
708 
709  aryProperties.Add(new TypeProperty("Gain", AnimatPropertyType::Xml, AnimatPropertyDirection::Set));
710  aryProperties.Add(new TypeProperty("DelayBufferMode", AnimatPropertyType::Integer, AnimatPropertyDirection::Set));
711  aryProperties.Add(new TypeProperty("DelayBufferInterval", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
712  aryProperties.Add(new TypeProperty("RobotIOScale", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
713  aryProperties.Add(new TypeProperty("SynchWithRobot", AnimatPropertyType::Boolean, AnimatPropertyDirection::Set));
714  aryProperties.Add(new TypeProperty("SynchUpdateInterval", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
715  aryProperties.Add(new TypeProperty("SynchUpdateStartInterval", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
716  aryProperties.Add(new TypeProperty("InitIODisableDuration", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
717 }
718 
730 {
732 
733  SetDelayBufferSize();
736 }
737 
738 bool Adapter::NeedsRobotSynch()
739 {
741  return true;
742 
744  {
746  m_iSynchCount = 0;
747  return true;
748  }
749  else
750  return false;
751 }
752 
754 {
756 
757  m_fltNextVal = 0;
758  m_fltCalculatedVal = 0;
759  m_iSynchCount = 0;
760  m_iSynchTarget = -1;
761  m_fltUpdatedValue = 0;
762  int iSize = m_aryDelayBuffer.GetSize();
763  for(int iIdx=0; iIdx<iSize; iIdx++)
764  m_aryDelayBuffer[iIdx] = 0;
765 }
766 
767 void Adapter::SetDelayBufferSize()
768 {
769  if(m_eDelayBufferMode == eDelayBufferMode::DelayBufferAlwaysOn ||
770  (m_eDelayBufferMode == eDelayBufferMode::DelayBufferInSimOnly && m_lpSim->InSimulation()))
771  {
772  float fltTimeStep = m_lpSim->PhysicsTimeStep();
773  if(m_lpModule)
774  fltTimeStep = m_lpModule->TimeStep();
775 
776  if(fltTimeStep > 0)
777  {
778  int iLength = (int) (m_fltDelayBufferInterval/fltTimeStep);
779  m_aryDelayBuffer.SetSize(iLength);
780  }
781  }
782  else
783  m_aryDelayBuffer.RemoveAll();
784 }
785 
787 {
789 
790  m_lpSourceNode = dynamic_cast<Node *>(m_lpSim->FindByID(m_strSourceID));
791  if(!m_lpSourceNode)
792  THROW_PARAM_ERROR(Al_Err_lNodeNotFound, Al_Err_strNodeNotFound, "ID: ", m_strSourceID);
793 
795 
796  if(!m_lpSourceData)
797  THROW_TEXT_ERROR(Al_Err_lDataPointNotFound, Al_Err_strDataPointNotFound,
798  ("Adapter: " + m_strID + " StructureID: " + m_lpStructure->ID() + "SourceID: " + m_strSourceID + " DataType: " + m_strSourceDataType));
799 
800  m_lpTargetNode = dynamic_cast<Node *>(m_lpSim->FindByID(m_strTargetID));
801  if(!m_lpTargetNode)
802  THROW_PARAM_ERROR(Al_Err_lNodeNotFound, Al_Err_strNodeNotFound, "ID: ", m_strTargetID);
803 
804  //Get the integer of the target data type we should use when calling AddExternalNodeInput. Zero is the default and only one most
805  //systems use.
807 
808  m_lpSim->AttachSourceAdapter(m_lpStructure, this);
809  m_lpSim->AttachTargetAdapter(m_lpStructure, this);
810 
811  m_bConnectedToPhysics = m_lpSim->IsPhysicsAdapter(this);
812 
813  //Reset times now that we are initialized
814  SetDelayBufferSize();
817 }
818 
819 void Adapter::ApplyExternalNodeInput(int iTargetDataType, float fltNextVal)
820 {
821  if(m_lpTargetNode)
822  m_lpTargetNode->AddExternalNodeInput(iTargetDataType, fltNextVal);
823 }
824 
826 {
827  m_fltUpdatedValue = 0;
828 
830  //int i=5;
831  //if(Std_ToLower(m_strID) == "8a07c86e-3972-43f8-b91d-9b4b58605a82" && m_lpSim->Time() > 0.2) //
832  // i=6;
833 
835  {
836  //If this is the first time we are coming in here then setup the first update correctly
839 
840  //If we are trying to synch the adapters to match the IO charachteristics of a robot then we should only
841  //calcualte the value from the source data based on the robot synch interval. Otherwise, use the value we calculated last time.
842  if(!m_lpSim->RobotAdpaterSynch() || !m_bSynchWithRobot || (m_lpSim->RobotAdpaterSynch() && m_bSynchWithRobot && NeedsRobotSynch()))
843  {
845  m_fltUpdatedValue = 1;
846 
848  //int i=5;
849  //if(Std_ToLower(m_strID) == "3953f16f-99aa-41e7-adaf-e0ca153d65ec" && m_fltCalculatedVal > 0.6 ) // && m_lpSim->Time() > 1
850  // i=6;
851 
852  //Scale the calculated value for robot performance matching if we are in simulation mode only.
853  if(m_lpSim->InSimulation())
855  }
856 
857  //If we 5are configured to use a delay buffer then use it.
858  if(m_eDelayBufferMode == eDelayBufferMode::DelayBufferAlwaysOn ||
859  (m_eDelayBufferMode == eDelayBufferMode::DelayBufferInSimOnly && m_lpSim->InSimulation()))
860  {
861  //First get the head element off the buffer.
862  float fltNextVal = m_aryDelayBuffer.GetHead();
863  //Now set the current value into the buffer.
865 
866  //Now reset the next val with the one from the buffer
867  m_fltNextVal = fltNextVal;
868  }
869  else
871 
872  ApplyExternalNodeInput(m_iTargetDataType, m_fltNextVal);
873 
874  m_iSynchCount++;
875  }
876 }
877 
878 void Adapter::Load(CStdXml &oXml)
879 {
880  Node::Load(oXml);
881 
882  oXml.IntoElem(); //Into Adapter Element
883 
884  //Load Source Data
885  SourceModule(oXml.GetChildString("SourceModule"));
886  SourceID(oXml.GetChildString("SourceID"));
887  SourceDataType(oXml.GetChildString("SourceDataType"));
888 
889  //Load Target Data
890  TargetModule(oXml.GetChildString("TargetModule"));
891  TargetID(oXml.GetChildString("TargetID"));
892  TargetDataType(oXml.GetChildString("TargetDataType", ""));
893 
894  SetGain(LoadGain(m_lpSim, "Gain", oXml));
895 
896  Enabled(oXml.GetChildBool("Enabled"));
897 
898  DelayBufferMode((eDelayBufferMode) oXml.GetChildInt("DelayBufferMode", m_eDelayBufferMode));
899  DelayBufferInterval(oXml.GetChildFloat("DelayBufferInterval", m_fltDelayBufferInterval));
900 
901  RobotIOScale(oXml.GetChildFloat("RobotIOScale", m_fltRobotIOScale));
902  SynchWithRobot(oXml.GetChildBool("SynchWithRobot", m_bSynchWithRobot));
903  SynchUpdateInterval(oXml.GetChildFloat("SynchUpdateInterval", m_fltSynchUpdateInterval));
904  SynchUpdateStartInterval(oXml.GetChildFloat("SynchUpdateStartInterval", m_fltSynchUpdateStartInterval));
905  InitIODisableDuration(oXml.GetChildFloat("InitIODisableDuration", m_fltInitIODisableDuration));
906 
907  oXml.OutOfElem(); //OutOf Adapter Element
908 }
909 
910 
911  } //Adapters
912 } //AnimatSim
virtual void Deserialize(std::string &strXml)
Deserializes a string into an xml document.
Definition: StdXml.cpp:162
Base class file for all Animat simulation objects.
Declares the nervous system class.
Gain * m_lpGain
Pointer to the Gain that will be used to convert the source value into the target value...
Definition: Adapter.h:75
virtual void PhysicsTimeStep(float fltVal)
Sets the integration time step for the physics engine.
Definition: Simulator.cpp:1126
Declares the simulation recorder class.
virtual std::string TargetModule()
Gets the name of the target NeuralModule.
Definition: Adapter.cpp:189
virtual void SetSystemPointers(Simulator *lpSim, Structure *lpStructure, NeuralModule *lpModule, Node *lpNode, bool bVerify)
Sets the system pointers.
Adapter()
Default constructor.
Definition: Adapter.cpp:52
virtual bool FindChildElement(std::string strElementName, bool fThrowError=true)
Finds a child element by name.
Definition: StdXml.cpp:256
virtual bool InSimulation()
Used to determine if we are running in a simulation, or in a real control mode.
Definition: Simulator.cpp:1673
virtual std::string SourceModule()
Gets the name of the source NeuralModule.
Definition: Adapter.cpp:104
Root namespace for the base simulation library for AnimatLab.
AnimatSim::Behavior::NeuralModule * m_lpModule
The pointer to this items parentNeuralModule. If this is not relevant for this object then this is NU...
Definition: AnimatBase.h:49
virtual float TimeStep()
Gets the time step for this moudle in time units.
virtual float SynchUpdateStartInterval()
This is the interval that this adapter waits the first time before doing its update.
Definition: Adapter.cpp:464
virtual eDelayBufferMode DelayBufferMode()
Returns the mode for the delay buffer.
Definition: Adapter.cpp:307
Declares the body part class.
virtual bool ConnectedToPhysics()
Returns whether or not this adpater is connected to a physics object or not.
Definition: Adapter.cpp:295
std::string m_strSourceModule
Name of the source NeuralModule.
Definition: Adapter.h:43
virtual void StepSimulation()
Step the simulation for this object.
Definition: Adapter.cpp:825
virtual void AddExternalNodeInput(int iTargetDataType, float fltInput)=0
Adds an external node input.
virtual Node * TargetNode()
Gets the target node.
Definition: Adapter.cpp:263
virtual bool FindElement(std::string strElementName, bool fThrowError=true)
Finds an element with the specified name.
Definition: StdXml.cpp:179
float m_fltUpdatedValue
Set to 1 each time the adapter was updated and 0 otherwise. Use to chart when the adpater was updated...
Definition: Adapter.h:134
Simulator * m_lpSim
The pointer to a Simulation.
Definition: AnimatBase.h:43
float m_fltEnabled
This is used for reporting the enabled state in a GetDataPointer call.
Definition: Node.h:35
float m_fltCalculatedVal
This is the value that will was calculated for this adpater. If you are using a delay buffer this may...
Definition: Adapter.h:82
virtual std::string ID()
Gets the unique GUID ID of this object.
Definition: AnimatBase.cpp:167
virtual bool IntoElem()
Goes into the next element where the cursor is located.
Definition: StdXml.cpp:42
virtual int GetTargetDataTypeIndex(const std::string &strDataType)
Used to convert a string target data type into an integer index.
Definition: Node.cpp:157
virtual float * GetDataPointer(const std::string &strDataType)
Returns a float pointer to a data item of interest in this object.
Definition: AnimatBase.cpp:340
Class that stores information about types for QueryProperty information.
Definition: TypeProperty.h:35
virtual void TimeStepModified()
Notification method that the time step modified has been modified. Objects should recalculate any sli...
Definition: AnimatBase.cpp:685
The Gain base class.
Definition: Gain.h:35
virtual void Initialize()
Initializes this object.
Definition: AnimatBase.cpp:573
CStdCircularArray< float > m_aryDelayBuffer
Definition: Adapter.h:95
std::string m_strSourceDataType
DateType of the source variable that will be converted. This is retrieved using the GetDataPointer me...
Definition: Adapter.h:49
Declares the key frame class.
virtual void Initialize()
Initializes this object.
Definition: Adapter.cpp:786
std::string m_strTargetDataType
Definition: Adapter.h:66
Node * m_lpSourceNode
Pointer to the source node.
Definition: Adapter.h:52
Declares the joint class.
std::string m_strTargetModule
Name of the target NeuralModule.
Definition: Adapter.h:58
Declares the organism class.
virtual int GetChildInt(std::string strElementName)
Gets an integer value from the element with the specified name.
Definition: StdXml.cpp:456
bool Std_IsAboveMin(int iMinVal, int iVal, bool bThrowError, std::string strParamName, bool bInclusiveLimit)
Tests if a number is above a minimum value.
AnimatSim::Environment::Structure * m_lpStructure
The pointer to this items parent Structure. If this is not relevant for this object then this is NULL...
Definition: AnimatBase.h:46
virtual bool Enabled()
Tells whether this node is enabled.
Definition: Node.cpp:84
std::string m_strID
The unique Id for this object.
Definition: AnimatBase.h:55
virtual bool SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError=true)
Set a variable based on a string data type name.
Definition: Adapter.cpp:626
std::string m_strSourceID
GUID ID of the source node.
Definition: Adapter.h:46
std::string m_strTargetID
GUID ID of the target node.
Definition: Adapter.h:61
Declares a light object.
Node * m_lpTargetNode
Pointer to the target node.
Definition: Adapter.h:72
virtual void TimeStepModified()
If the time step is modified then we need to recalculate the length of the delay buffer.
Definition: Adapter.cpp:729
Declares the activated item class.
virtual float * GetDataPointer(const std::string &strDataType)
Returns a float pointer to a data item of interest in this object.
Definition: Adapter.cpp:544
virtual void QueryProperties(CStdPtrArray< TypeProperty > &aryProperties)
Queries this object for a list of properties that can be changed using SetData.
Definition: Node.cpp:199
Declares a light manager object.
int m_iSynchTarget
The target count for synching.
Definition: Adapter.h:117
virtual bool RobotAdpaterSynch()
Gets whether we need to synch the physics adapters in a simulation to the robot physics time step...
Definition: Simulator.cpp:1645
Declares the bounding box class.
Declares the gain base class.
A standard xml manipulation class.
Definition: StdXml.h:19
virtual Gain * GetGain()
Gets the poitner to the gain function.
Definition: Adapter.cpp:273
Declares the node class.
int m_iSynchUpdateStartInterval
The number of ticks between the first call to update for this adapter till the next update time...
Definition: Adapter.h:114
virtual float RobotIOScale()
Gets the scale value used for calculated values for this adapter during simulation mode only...
Definition: Adapter.cpp:367
virtual void ResetSimulation()
Resets the simulation back to time 0.
Definition: Adapter.cpp:753
virtual std::string SourceDataType()
Gets the source data type.
Definition: Adapter.cpp:154
virtual std::string GetChildString(std::string strElementName)
Gets a string value from the element with the specified name.
Definition: StdXml.cpp:307
virtual AnimatBase * FindByID(std::string strID, bool bThrowError=true)
Searches for the object with the specified ID.
Definition: Simulator.cpp:4008
virtual void AddGain(std::string strXml)
Creates and adds a gain object.
Definition: Adapter.cpp:570
virtual float DelayBufferInterval()
Returns the time interval used for the delay buffer if this adapter is set to use one...
Definition: Adapter.cpp:336
bool Std_ToBool(int iVal)
Converts a value toa bool.
virtual std::string TargetID()
Gets the GUID ID of the target node where we will add the transformed data variable.
Definition: Adapter.cpp:214
virtual void Load(StdUtils::CStdXml &oXml)
Loads the item using an XML data packet.
Definition: AnimatBase.cpp:771
virtual std::string SourceID()
Gets the GUID ID of the source node where we will get the source data variable.
Definition: Adapter.cpp:129
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 GetChildBool(std::string strElementName)
Gets a bool value from the element with the specified name.
Definition: StdXml.cpp:699
bool m_bEnabled
Tells if this item is enabled or not. If it is not enabled then it is not run.
Definition: AnimatBase.h:40
float * m_lpSourceData
Pointer to the source data varaible.
Definition: Adapter.h:55
int m_iSynchCount
Keeps track of the last time we did a synch for the robot.
Definition: Adapter.h:120
virtual float SynchUpdateInterval()
This is how often we need to update this particular adapter.
Definition: Adapter.cpp:423
Base class for body parts and neural network nodes.
Definition: Node.h:25
float m_fltSynchUpdateInterval
This is how often we need to update this particular adapter.
Definition: Adapter.h:103
virtual bool OutOfElem()
Goes out of the element where the cursor is located.
Definition: StdXml.cpp:56
bool Std_IsBlank(std::string strVal)
Trims a string and tests if a string is blank.
Declares the data chart manager class.
float m_fltNextVal
This is the value that will be passed into the adpters target.
Definition: Adapter.h:85
virtual void ResetSimulation()
Resets the simulation back to time 0.
Definition: Node.cpp:106
Declares the rigid body class.
virtual float CalculateGain(float fltInput)=0
Calculates the gain.
std::string Std_CheckString(std::string strVal)
Converts a string to upper case and trims it.
int m_iTargetDataType
The m_strTargetDataType string is converted to an integer for use within the simulation loop to maxim...
Definition: Adapter.h:69
virtual bool SynchWithRobot()
Gets whether the m_bRobotAdpaterSynch flag applies to this adapter.
Definition: Adapter.cpp:401
Declares the structure class.
Declares the odor type class.
virtual Node * SourceNode()
Gets the source node.
Definition: Adapter.cpp:179
virtual ~Adapter()
Destructor.
Definition: Adapter.cpp:82
Declares the odor class.
Declares the simulator class.
Declares the neural module class.
virtual float Time()
Gets the current simulation time in seconds.
Definition: Simulator.cpp:559
virtual void QueryProperties(CStdPtrArray< TypeProperty > &aryProperties)
Queries this object for a list of properties that can be changed using SetData.
Definition: Adapter.cpp:700
Declares the activated item manager class.
Declares the contact sensor class.
Declares the external stimuli manager class.
int m_iSynchUpdateInterval
The number of ticks between each call to update for this adapter till the next update time...
Definition: Adapter.h:106
virtual float InitIODisableDuration()
Gets the duration for how long this adapter is disabled at the start of the simulation.
Definition: Adapter.cpp:508
Gain * LoadGain(Simulator *lpSim, std::string strName, CStdXml &oXml)
Loads a gain object.
Definition: Gain.cpp:287
Declares the receptive field class.
virtual void AddExternalNodeInput(int iTargetDataType, float fltInput)
Adds an external node input.
Definition: Adapter.cpp:539
virtual float GetChildFloat(std::string strElementName)
Gets a float value from the element with the specified name.
Definition: StdXml.cpp:617
virtual bool SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError=true)
Set a variable based on a string data type name.
Definition: Node.cpp:179
virtual std::string TargetDataType()
Gets the target data type.
Definition: Adapter.cpp:240