2 #include "IMovableItemCallback.h"
3 #include "ISimGUICallback.h"
4 #include "IMotorizedJoint.h"
9 #include "IPhysicsMovableItem.h"
10 #include "IPhysicsBody.h"
12 #include "MovableItem.h"
37 #include "RemoteControlLinkage.h"
38 #include "RemoteControl.h"
45 RemoteControl::RemoteControl(
void)
51 RemoteControl::~RemoteControl(
void)
58 {
Std_TraceMsg(0,
"Caught Error in desctructor of RemoteControl\r\n",
"", -1,
false,
true);}
91 CStdMap<std::string, int>* RemoteControl::DataIDMap() {
return &
m_aryDataIDMap;};
93 void RemoteControl::ChangeSimStepCount(
int iRate)
101 for(
int iIndex=0; iIndex<iCount; iIndex++)
109 #pragma region DataAccesMethods
111 bool RemoteControl::AddItem(
const std::string &strItemType,
const std::string &strXml,
bool bThrowError,
bool bDoNotInit)
115 if(strType ==
"REMOTECONTROLLINKAGE")
128 if(strType ==
"REMOTECONTROLLINKAGE")
136 #pragma region DataAccesMethods
143 for(
int iIndex=0; iIndex<iCount; iIndex++)
146 int iLen = strType.length();
147 if(((iLen-5) >= 0) && strType.substr(strType.length() - 5, 5) ==
"START")
148 return &
m_aryLinks[iIndex]->m_Data.m_fltStart;
149 else if(((iLen-4) >= 0) && strType.substr(strType.length() - 4, 4) ==
"STOP")
152 return &
m_aryLinks[iIndex]->m_Data.m_fltValue;
165 if(strType ==
"CHANGESIMSTEPCOUNT")
167 ChangeSimStepCount((
int) atoi(strValue.c_str()));
173 THROW_PARAM_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType,
"Data Type", strDataType);
182 aryProperties.Add(
new TypeProperty(
"ChangeSimStepCount", AnimatPropertyType::Integer, AnimatPropertyDirection::Set));
185 for(
int iIndex=0; iIndex<iCount; iIndex++)
187 aryProperties.Add(
new TypeProperty(
m_aryLinks[iIndex]->m_Data.m_strProperty, AnimatPropertyType::Float, AnimatPropertyDirection::Get));
188 aryProperties.Add(
new TypeProperty(
m_aryLinks[iIndex]->m_Data.m_strProperty +
"START", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
189 aryProperties.Add(
new TypeProperty(
m_aryLinks[iIndex]->m_Data.m_strProperty +
"STOP", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
267 for(
int iIndex=0; iIndex<iCount; iIndex++)
272 THROW_PARAM_ERROR(Al_Err_lPartInterfaceIDNotFound, Al_Err_strPartInterfaceIDNotFound,
"ID", strID);
294 int iCount = aryLinks.GetSize();
295 for(
int iIndex=0; iIndex<iCount; iIndex++)
296 if(aryLinks[iIndex]->
ID() == sID)
300 THROW_PARAM_ERROR(Al_Err_lPartInterfaceIDNotFound, Al_Err_strPartInterfaceIDNotFound,
"ID", strID);
305 RemoteControlLinkage *RemoteControl::FindLinkageWithPropertyName(std::string strName,
bool bThrowError)
308 for(
int iIndex=0; iIndex<iCount; iIndex++)
309 if(
m_aryLinks[iIndex]->PropertyName() == strName)
313 THROW_PARAM_ERROR(Al_Err_lPartInterfaceIDNotFound, Al_Err_strPartInterfaceIDNotFound,
"PropertyName", strName);
320 void RemoteControl::ResetData()
323 for(
int iIndex=0; iIndex<iCount; iIndex++)
327 void RemoteControl::CheckStartedStopped()
330 for(
int iIndex=0; iIndex<iCount; iIndex++)
331 m_aryLinks[iIndex]->m_Data.CheckStartedStopped();
337 void RemoteControl::ClearStartStops()
341 for(
int iIndex=0; iIndex<iCount; iIndex++)
366 for(
int iIndex=0; iIndex<iCount; iIndex++)
388 for(
int iIndex=0; iIndex<iCount; iIndex++)
408 for(
int iIndex=0; iIndex<iCount; iIndex++)
416 void RemoteControl::CreateDataIDMap()
420 bool RemoteControl::FindDataToWrite(CStdArray<RemoteControlLinkage *> &aryWrites)
423 for(
int iIndex=0; iIndex<iCount; iIndex++)
432 if(aryWrites.GetSize() > 0)
438 void RemoteControl::SetDataValue(
int iID,
float fltVal)
441 for(
int iIndex=0; iIndex<iCount; iIndex++)
443 if(
m_aryInLinks[iIndex]->m_Data.m_iButtonID == iID && fabs(fltVal -
m_aryInLinks[iIndex]->m_Data.m_fltValue) > 1e-10)
456 for(
int iIndex=0; iIndex<iCount; iIndex++)
468 for(
int iIndex=0; iIndex<iCount; iIndex++)
479 for(
int iIndex=0; iIndex<iCount; iIndex++)
488 for(
int iIndex=0; iIndex<iCount; iIndex++)
495 void RemoteControl::Load(
CStdXml &oXml)
497 RobotIOControl::Load(oXml);
510 for(
int iIndex=0; iIndex<iChildCount; iIndex++)
546 THROW_TEXT_ERROR(Al_Err_lConvertingClassToType, Al_Err_strConvertingClassToType,
"RemoteControlLinkage");
548 lpChild->ParentRemoteControl(
this);
564 if(lpChild)
delete lpChild;
570 if(lpChild)
delete lpChild;
571 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
virtual bool RemoveItem(const std::string &strItemType, const std::string &strID, bool bThrowError=true)
Removes a child item from this parent.
virtual void Deserialize(std::string &strXml)
Deserializes a string into an xml document.
virtual CStdArray< RemoteControlLinkage * > * InLinks()
Gets the array of remote control in links.
virtual void StepSimulation()
Step the simulation for this object.
Base class file for all Animat simulation objects.
CStdPtrArray< RemoteControlLinkage > m_aryLinks
Declares the nervous system class.
Declares the simulation recorder class.
Declares the Robot IO control interface base class.
virtual void SetSystemPointers(Simulator *lpSim, Structure *lpStructure, NeuralModule *lpModule, Node *lpNode, bool bVerify)
Sets the system pointers.
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 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 QueryProperties(CStdPtrArray< TypeProperty > &aryProperties)
Queries this object for a list of properties that can be changed using SetData.
virtual void Initialize()
Initializes this object.
virtual void Initialize()
Initializes this object.
Declares the body part class.
virtual void StepSimulation()
Step the simulation for this object.
CStdArray< RemoteControlLinkage * > m_aryOutLinks
Only the linkages that are outlinks.
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.
virtual void ShutdownIO()
This method is called just before the IO thread is closed down. It gives the IO objects a chance to d...
virtual float * GetDataPointer(const std::string &strDataType)
Returns a float pointer to a data item of interest in this object.
Class that stores information about types for QueryProperty information.
virtual void RemoveRemoteControlLinkage(std::string strID, bool bThrowError=true)
Removes the rigid body with the specified ID.
Declares the link base class.
Declares the key frame class.
virtual void ResetSimulation()
Resets the simulation back to time 0.
virtual void ExitPause()
This method is waits until the m_bIOPaused flag is set back to false.
virtual bool SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError=true)
Set a variable based on a string data type name.
Declares the joint class.
Declares the organism class.
virtual int GetChildInt(std::string strElementName)
Gets an integer value from the element with the specified name.
virtual void StepIO()
This method is called from within the IO thread. It calls StepIO for each part.
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...
virtual void ShutdownIO()
This method is called just before the IO thread is closed down. It gives the IO objects a chance to d...
std::string Std_Trim(std::string strVal)
Trims a string.
virtual void QueryProperties(CStdPtrArray< TypeProperty > &aryProperties)
Queries this object for a list of properties that can be changed using SetData.
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.
virtual float * GetDataPointer(const std::string &strDataType)
Returns a float pointer to a data item of interest in this object.
Declares a light manager object.
Declares the bounding box class.
virtual bool Enabled()
Tells whether this item is enabled or not. This is not actually used for all objects, only specific ones. I am putting it in the base class though to prevent numerous duplications.
virtual bool AddItem(const std::string &strItemType, const std::string &strXml, bool bThrowError=true, bool bDoNotInit=false)
Adds a new object to this parent.
A standard xml manipulation class.
virtual RemoteControlLinkage * AddRemoteControlLinkage(std::string strXml)
Creates and adds a robot IO control.
virtual CStdArray< RemoteControlLinkage * > * OutLinks()
Gets the array of remote control out links.
virtual void StepIO()
This method is called from within the IO thread. It calls StepIO for each part.
virtual std::string GetChildString(std::string strElementName)
Gets a string value from the element with the specified name.
virtual void ResetSimulation()
Resets the simulation back to time 0.
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.
bool m_bEnabled
Tells if this item is enabled or not. If it is not enabled then it is not run.
virtual int NumberOfChildren()
Gets the number of children of the current element.
virtual bool OutOfElem()
Goes out of the element where the cursor is located.
int m_iCyclePartIdx
The index of the part that should be processed on the current step.
virtual void Initialize()
Initializes this object.
CStdMap< std::string, int > m_aryDataIDMap
Used to map property names to IDs when UseRemoteDataTypes is true.
Declares the data chart manager class.
virtual void SetupIO()
This method is called after all connections to whatever control board have been made. It calls each parts SetupIO method. For example, We connect to a Firmata microcontroller like an Arduino, and then do a setup that could take some time. We should not attempt to setup any of the pins until after the board itself has been setup. After that we need to loop through and setup all the parts.
virtual RemoteControlLinkage * LoadRemoteControlLinkage(CStdXml &oXml)
Loads a child IO Control.
Declares the rigid body class.
virtual void AfterResetSimulation()
Called after a simulation reset for some objects.
virtual void AfterResetSimulation()
Called after a simulation reset for some objects.
std::string Std_CheckString(std::string strVal)
Converts a string to upper case and trims it.
bool m_bUseRemoteDataTypes
Declares the structure class.
Declares the odor type class.
virtual CStdPtrArray< RemoteControlLinkage > * Links()
Gets the array ofremote control links.
virtual bool RemoveItem(const std::string &strItemType, const std::string &strID, bool bThrowError=true)
Removes a child item from this parent.
virtual void SetupIO()
This method is called after all connections to whatever control board have been made. It calls each parts SetupIO method. For example, We connect to a Firmata microcontroller like an Arduino, and then do a setup that could take some time. We should not attempt to setup any of the pins until after the board itself has been setup. After that we need to loop through and setup all the parts.
Declares the robotics inerface for animatlab.
int m_iChangeSimStepCount
The number of simulation time slices to keep a start/stop signal active.
Declares the simulator class.
Declares the neural module class.
virtual bool FindChildByIndex(int iIndex, bool bThrowError=true)
Finds a child element by index.
virtual bool InLink()
Gets the inlink value.
std::string Std_ToUpper(std::string strVal)
Converts a string to upper case.
Declares the activated item manager class.
virtual int FindLinkageChildListPos(std::string strID, bool bThrowError=true)
Finds the array index for the child part with the specified ID.
Declares the external stimuli manager class.
CStdArray< RemoteControlLinkage * > m_aryInLinks
Only the linkages that are inlinks.
virtual void StartPause()
This method is waits until the m_bIOPaused flag is set to true.
virtual bool AddItem(const std::string &strItemType, const std::string &strXml, bool bThrowError=true, bool bDoNotInit=false)
Adds a new object to this parent.
Declares the receptive field class.