AnimatLab  2
Test
LinearHillStretchReceptor.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 "IPhysicsMovableItem.h"
14 #include "IPhysicsBody.h"
15 #include "BoundingBox.h"
16 #include "MovableItem.h"
17 #include "BodyPart.h"
18 #include "Joint.h"
19 #include "ReceptiveField.h"
20 #include "ContactSensor.h"
21 #include "RigidBody.h"
22 #include "Sensor.h"
23 #include "Attachment.h"
24 #include "Structure.h"
25 #include "Organism.h"
26 #include "ActivatedItem.h"
27 #include "ActivatedItemMgr.h"
28 #include "DataChartMgr.h"
29 #include "ExternalStimuliMgr.h"
30 #include "KeyFrame.h"
31 #include "SimulationRecorder.h"
32 #include "OdorType.h"
33 #include "Odor.h"
34 #include "Light.h"
35 #include "LightManager.h"
36 #include "Simulator.h"
37 
38 #include "ExternalStimulus.h"
39 
40 #include "LineBase.h"
41 #include "Gain.h"
42 #include "SigmoidGain.h"
43 #include "LengthTensionGain.h"
44 #include "MuscleBase.h"
45 #include "LinearHillMuscle.h"
46 #include "LinearHillStretchReceptor.h"
47 
48 namespace AnimatSim
49 {
50  namespace Environment
51  {
52  namespace Bodies
53  {
54 
62 {
63  m_bApplyTension = false;
66  m_fltIaRate = 0;
67  m_fltIIRate = 0;
68 }
69 
77 {
78 }
79 
89 
99 
109 
119 {
120  Std_InValidRange((float) 0, (float) 1e11, fltVal, true, "IaDischargeConstant");
121  m_fltIaDischargeConstant = fltVal;
122 }
123 
133 
143 {
144  Std_InValidRange((float) 0, (float) 1e11, fltVal, true, "IIDischargeConstant");
145  m_fltIIDischargeConstant = fltVal;
146 }
147 
157 
167 
169 {
171 
174 }
175 
177 {
179 
180  m_fltIaRate = 0;
181  m_fltIIRate = 0;
182 }
183 
184 float *LinearHillStretchReceptor::GetDataPointer(const std::string &strDataType)
185 {
186  std::string strType = Std_CheckString(strDataType);
187 
188  float *lpData = NULL;
189 
190  if(strType == "IA")
191  lpData = &m_fltIaRate;
192  else if(strType == "IB")
193  lpData = &m_fltIbRate;
194  else if(strType == "II")
195  lpData = &m_fltIIRate;
196  else
197  lpData = LinearHillMuscle::GetDataPointer(strDataType);
198 
199  return lpData;
200 }
201 
202 bool LinearHillStretchReceptor::SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError)
203 {
204  if(LinearHillMuscle::SetData(strDataType, strValue, false))
205  return true;
206 
207  if(strDataType == "APPLYTENSION")
208  {
209  ApplyTension(Std_ToBool(strValue));
210  return true;
211  }
212 
213  if(strDataType == "IADISCHARGE")
214  {
215  IaDischargeConstant((float) atof(strValue.c_str()));
216  return true;
217  }
218 
219  if(strDataType == "IIDISCHARGE")
220  {
221  IIDischargeConstant((float) atof(strValue.c_str()));
222  return true;
223  }
224 
225  //If it was not one of those above then we have a problem.
226  if(bThrowError)
227  THROW_PARAM_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType, "Data Type", strDataType);
228 
229  return false;
230 }
231 
232 void LinearHillStretchReceptor::QueryProperties(CStdPtrArray<TypeProperty> &aryProperties)
233 {
234  LinearHillMuscle::QueryProperties(aryProperties);
235 
236  aryProperties.Add(new TypeProperty("Ia", AnimatPropertyType::Boolean, AnimatPropertyDirection::Get));
237  aryProperties.Add(new TypeProperty("II", AnimatPropertyType::Boolean, AnimatPropertyDirection::Get));
238 
239  aryProperties.Add(new TypeProperty("ApplyTension", AnimatPropertyType::Boolean, AnimatPropertyDirection::Set));
240  aryProperties.Add(new TypeProperty("IaDischarge", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
241  aryProperties.Add(new TypeProperty("IIDischarge", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
242 }
243 
244 void LinearHillStretchReceptor::Load(CStdXml &oXml)
245 {
246  LinearHillMuscle::Load(oXml);
247 
248  oXml.IntoElem(); //Into RigidBody Element
249 
250  ApplyTension(oXml.GetChildBool("ApplyTension", m_bApplyTension));
253 
254  oXml.OutOfElem(); //OutOf RigidBody Element
255 }
256 
257  } //Bodies
258  } //Environment
259 } //AnimatSim
virtual void ResetSimulation()
Resets the simulation back to time 0.
Declares the external stimulus base class.
Base class file for all Animat simulation objects.
Declares the simulation recorder class.
float m_fltIIDischargeConstant
Constant that relates length of muscle segment to discharge rate of type II fibers.
virtual void ResetSimulation()
Resets the simulation back to time 0.
Root namespace for the base simulation library for AnimatLab.
Declares the sigmoid gain class.
virtual bool ApplyTension()
Gets wheter tension is applied by the receptor or not.
Declares the body part class.
virtual float IaDischargeConstant()
Gets the ia discharge constant.
virtual bool IntoElem()
Goes into the next element where the cursor is located.
Definition: StdXml.cpp:42
Class that stores information about types for QueryProperty information.
Definition: TypeProperty.h:35
bool m_bApplyTension
Determines whether the receptor applies tension or not.
Declares the key frame class.
bool Std_InValidRange(int iMinVal, int iMaxVal, int iVal, bool bThrowError, std::string strParamName)
Tests whether a number is within a valid range.
Declares the muscle base class.
Declares the joint class.
Declares the organism class.
Declares a light object.
float m_fltSeLength
The length of the SE section of the muscle. The resting length is one half the total muscle length...
Declares the activated item class.
Declares a light manager object.
Declares the bounding box class.
Declares the gain base class.
A standard xml manipulation class.
Definition: StdXml.h:19
Declares the linear hill muscle class.
Declares the node class.
Declares the line base class.
bool Std_ToBool(int iVal)
Converts a value toa bool.
virtual bool GetChildBool(std::string strElementName)
Gets a bool value from the element with the specified name.
Definition: StdXml.cpp:699
Declares an inverted quadratic gain class used to calculate length-tension relationship for muscle...
virtual bool OutOfElem()
Goes out of the element where the cursor is located.
Definition: StdXml.cpp:56
Declares the sensor class.
Declares the data chart manager class.
Declares the rigid body class.
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 float IIDischargeConstant()
Gets the ii discharge constant.
Declares the odor class.
Declares the simulator class.
Declares the activated item manager class.
Declares the contact sensor class.
Declares the external stimuli manager class.
Declares the attachment class.
Declares the receptive field class.
virtual float GetChildFloat(std::string strElementName)
Gets a float value from the element with the specified name.
Definition: StdXml.cpp:617
float m_fltIaDischargeConstant
Constant that relates length of muscle segment to discharge rate of type Ia fibers.
float m_fltPeLength
The length of the PE section of the muscle. The resting length is one half the total muscle length...
virtual void CalculateTension()
Calculates the tension.