2 #include "IMovableItemCallback.h"
3 #include "ISimGUICallback.h"
4 #include "IMotorizedJoint.h"
9 #include "IPhysicsMovableItem.h"
10 #include "IPhysicsBody.h"
12 #include "MovableItem.h"
38 #include "RobotPartInterface.h"
46 RobotPartInterface::RobotPartInterface(
void)
48 m_lpParentInterface = NULL;
49 m_lpParentIOControl = NULL;
58 m_fltStepIODuration = 0;
61 RobotPartInterface::~RobotPartInterface(
void)
67 m_lpPart->RemoveRobotPartInterface(
this);
70 m_lpParentInterface = NULL;
71 m_lpParentIOControl = NULL;
77 {
Std_TraceMsg(0,
"Caught Error in desctructor of RobotPartInterface\r\n",
"", -1,
false,
true);}
82 m_lpParentIOControl = lpParent;
84 if(m_lpParentIOControl)
88 RobotIOControl *RobotPartInterface::ParentIOControl() {
return m_lpParentIOControl;}
94 float RobotPartInterface::IOValue() {
return m_fltIOValue;}
96 void RobotPartInterface::IOValue(
float fltVal)
102 int RobotPartInterface::IOValueInt() {
return m_iIOValue;}
104 void RobotPartInterface::IOValueInt(
int iVal)
114 bool RobotPartInterface::Changed() {
return m_bChanged;}
116 void RobotPartInterface::Changed(
bool bVal) {
m_bChanged = bVal;}
118 void RobotPartInterface::LinkedPartID(std::string strID)
121 m_strPropertyName =
"";
125 std::string RobotPartInterface::LinkedPartID() {
return m_strPartID;}
127 void RobotPartInterface::PropertyName(std::string strName)
129 m_strPropertyName = strName;
133 std::string RobotPartInterface::PropertyName() {
return m_strPropertyName;}
189 void RobotPartInterface::SetGain(
Gain *lpGain)
229 #pragma region DataAccesMethods
235 if(strType ==
"IOVALUE")
237 else if(strType ==
"IOSCALEDVALUE")
239 else if(strType ==
"STEPIODURATION")
240 return &m_fltStepIODuration;
242 THROW_TEXT_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType,
"Robot Interface ID: " + STR(
m_strName) +
" DataType: " + strDataType);
251 if(strType ==
"IOCOMPONENTID")
253 IOComponentID((
int) atoi(strValue.c_str()));
257 if(strType ==
"LINKEDPARTID")
259 LinkedPartID(strValue);
263 if(strType ==
"PROPERTYNAME")
265 PropertyName(strValue);
269 if(strType ==
"GAIN")
275 if(strType ==
"ENABLED")
286 THROW_PARAM_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType,
"Data Type", strDataType);
295 aryProperties.Add(
new TypeProperty(
"IOValue", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
296 aryProperties.Add(
new TypeProperty(
"IOScaledValue", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
297 aryProperties.Add(
new TypeProperty(
"StepIODuration", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
299 aryProperties.Add(
new TypeProperty(
"IOComponentID", AnimatPropertyType::Integer, AnimatPropertyDirection::Set));
300 aryProperties.Add(
new TypeProperty(
"Gain", AnimatPropertyType::Xml, AnimatPropertyDirection::Set));
301 aryProperties.Add(
new TypeProperty(
"PropertyName", AnimatPropertyType::String, AnimatPropertyDirection::Set));
302 aryProperties.Add(
new TypeProperty(
"LinkedPartID", AnimatPropertyType::String, AnimatPropertyDirection::Set));
361 m_lpProperty = m_lpPart->GetDataPointer(m_strPropertyName);
365 m_lpPart->AddRobotPartInterface(
this);
381 void RobotPartInterface::Load(
CStdXml &oXml)
virtual void ResetSimulation()
Resets the simulation back to time 0.
virtual void Deserialize(std::string &strXml)
Deserializes a string into an xml document.
virtual float StepIODuration()
Gets the time duration required to perform one step of the IO for this part.
Base class file for all Animat simulation objects.
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 void QueryProperties(CStdPtrArray< TypeProperty > &aryProperties)
Queries this object for a list of properties that can be changed using SetData.
Declares the body part class.
virtual float QuantizeServoVelocity(float fltVel)
If this is a servo controller interface then it will take a continuous velocity and return back a val...
virtual float * GetDataPointer(const std::string &strDataType)
Returns a float pointer to a data item of interest in 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.
virtual bool IsMotorControl()
Returns true if this part interface is for controlling a motor.
virtual bool IntoElem()
Goes into the next element where the cursor is located.
virtual void Initialize()
Initializes this object.
virtual void ParentInterface(RobotInterface *lpParent)
Sets the parent robot interface pointer.
Class that stores information about types for QueryProperty information.
Declares the link base class.
Declares the key frame class.
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.
AnimatSim::Environment::Structure * m_lpStructure
The pointer to this items parent Structure. If this is not relevant for this object then this is NULL...
Declares the activated item class.
virtual void AddGain(std::string strXml)
Creates and adds a gain object.
Declares a light manager object.
virtual void SetupIO()
This method is called after all connections to whatever control board have been made. It is meant to be used to setup connection information specific to this part. 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. That is what this method is for.
Declares the bounding box class.
bool m_bChanged
True when the value changes.
Declares the gain base 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.
A Robot IO controller 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.
Base class for all body parts and joints.
virtual std::string GetChildString(std::string strElementName)
Gets a string value from the element with the specified name.
virtual float QuantizeServoPosition(float fltPos)
If this is a servo controller interface then it will take a continuous positon and return back a vali...
virtual AnimatBase * FindByID(std::string strID, bool bThrowError=true)
Searches for the object with the specified ID.
bool Std_ToBool(int iVal)
Converts a value toa bool.
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 void ResetSimulation()
Resets the simulation back to time 0.
virtual void StepIO(int iPartIdx)
This method is used to send/recieve the actual IO. This will often be in a seperate thread than the S...
virtual bool OutOfElem()
Goes out of the element where the cursor is located.
virtual bool SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError=true)
Set a variable based on a string data type name.
bool Std_IsBlank(std::string strVal)
Trims a string and tests if a string is blank.
Declares the data chart manager class.
virtual Gain * GetGain()
Gets the poitner to the gain function.
Declares the rigid body class.
std::string Std_CheckString(std::string strVal)
Converts a string to upper case and trims it.
Gain * m_lpGain
Pointer to the Gain that will be used to convert the source value into the target value...
Declares the structure class.
Declares the odor type class.
Declares the robotics inerface for animatlab.
int m_iIOValue
This stores the temporary IO value to be used later in IO calculations.
Declares the simulator class.
Declares the neural module class.
Declares the activated item manager class.
Declares the external stimuli manager class.
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 ShutdownIO()
This method is called just before the IO thread is closed down. It gives the IO objects a chance to d...
Gain * LoadGain(Simulator *lpSim, std::string strName, CStdXml &oXml)
Loads a gain object.
Declares the receptive field class.
std::string m_strName
The name for this object.