8 #include "IMovableItemCallback.h"
9 #include "ISimGUICallback.h"
14 #include "IPhysicsMovableItem.h"
15 #include "IPhysicsBody.h"
17 #include "MovableItem.h"
95 m_fltAvgMuscleVel = 0;
113 {
Std_TraceMsg(0,
"Caught Error in desctructor of LinearHillMuscle\r\n",
"", -1,
false,
true);}
232 Std_InValidRange((
float) 0, (
float) 1e11, fltVal,
true,
"IbDischargeConstant");
351 if(fltTl<0) fltTl = 0;
409 m_fltAvgMuscleVel = 0;
445 m_fltAvgMuscleVel = 0;
472 if(m_fltInternalTension >= 0)
503 m_fltInternalTension = 0;
518 float fltTl =
Ftl(fltLength);
544 THROW_TEXT_ERROR(Al_Err_lInvalidMusc_Vel_Avg, Al_Err_strInvalidMusc_Vel_Avg,
"Muscle Velocity Average: " + STR(
m_iMuscleVelAvgCount));
553 float *LinearHillMuscle::GetDataPointer(
const std::string &strDataType)
560 if(strType ==
"VMUSCLE")
562 else if(strType ==
"VSE")
564 else if(strType ==
"VPE")
566 else if(strType ==
"AVGVMUSCLE")
567 lpData = &m_fltAvgMuscleVel;
568 else if(strType ==
"DISPLACEMENT")
570 else if(strType ==
"DISPLACEMENTRATIO")
572 else if(strType ==
"ACTIVATION")
574 else if(strType ==
"A")
576 else if(strType ==
"SELENGTH")
578 else if(strType ==
"PELENGTH")
580 else if(strType ==
"SEDISPLACEMENT")
582 else if(strType ==
"IB")
584 else if(strType ==
"TL")
587 lpData = MuscleBase::GetDataPointer(strDataType);
592 bool LinearHillMuscle::SetData(
const std::string &strDataType,
const std::string &strValue,
bool bThrowError)
594 if(MuscleBase::SetData(strDataType, strValue,
false))
597 if(strDataType ==
"KSE")
599 Kse((
float) atof(strValue.c_str()));
603 if(strDataType ==
"KPE")
605 Kpe((
float) atof(strValue.c_str()));
609 if(strDataType ==
"B")
611 B((
float) atof(strValue.c_str()));
615 if(strDataType ==
"IBDISCHARGE")
623 THROW_PARAM_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType,
"Data Type", strDataType);
628 void LinearHillMuscle::QueryProperties(CStdPtrArray<TypeProperty> &aryProperties)
630 MuscleBase::QueryProperties(aryProperties);
632 aryProperties.Add(
new TypeProperty(
"Vmuscle", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
633 aryProperties.Add(
new TypeProperty(
"Vse", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
634 aryProperties.Add(
new TypeProperty(
"Vpe", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
635 aryProperties.Add(
new TypeProperty(
"AvgVMuscle", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
636 aryProperties.Add(
new TypeProperty(
"Displacement", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
637 aryProperties.Add(
new TypeProperty(
"DisplacementRatio", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
638 aryProperties.Add(
new TypeProperty(
"Activation", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
639 aryProperties.Add(
new TypeProperty(
"A", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
640 aryProperties.Add(
new TypeProperty(
"SeLength", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
641 aryProperties.Add(
new TypeProperty(
"PeLength", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
642 aryProperties.Add(
new TypeProperty(
"SeDisplacement", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
643 aryProperties.Add(
new TypeProperty(
"Ib", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
644 aryProperties.Add(
new TypeProperty(
"Tl", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
646 aryProperties.Add(
new TypeProperty(
"Kse", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
647 aryProperties.Add(
new TypeProperty(
"Kpe", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
648 aryProperties.Add(
new TypeProperty(
"B", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
649 aryProperties.Add(
new TypeProperty(
"IbDischarge", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
652 void LinearHillMuscle::Load(
CStdXml &oXml)
654 MuscleBase::Load(oXml);
virtual float Vmuscle()
Gets the muscle membrane voltage.
virtual void AfterResetSimulation()
Called after a simulation reset for some objects.
virtual void ResetSimulation()
Resets the simulation back to time 0.
Declares the external stimulus base class.
Base class file for all Animat simulation objects.
virtual float CalculateLength()
Calculates the length of the line.
virtual void ResetSimulation()
Resets the simulation back to time 0.
virtual void CalculateInverseDynamics(float fltLength, float fltVelocity, float fltT, float &fltVm, float &fltA)
Calculates the activation needed for a given tension value.
virtual void PhysicsTimeStep(float fltVal)
Sets the integration time step for the physics engine.
Declares the simulation recorder class.
virtual float MinPeLength()
Gets the minimum pe length.
Root namespace for the base simulation library for AnimatLab.
virtual float A()
Gets activation.
Declares the sigmoid gain class.
float m_fltPrevLength
Length of the line in the previous timestep.
float m_fltTLPerc
The Tl percentage. This is primarily used for reporting purposes. It is m_fltTl*100. It ranges from 0-100 %.
Declares the body part class.
float m_fltVse
The velocity of change of the SE section of the muscle.
virtual float PeLength()
Gets the pe length.
float Fact(float fltStim)
Calculates the muscle activation.
float m_fltSeLPrev
The previous length of the se section of the muscle.
Simulator * m_lpSim
The pointer to a Simulation.
float m_fltPrevA
Used to store the previous value of A when calculating the inverse muscle dynamics.
virtual bool IntoElem()
Goes into the next element where the cursor is located.
Class that stores information about types for QueryProperty information.
float m_fltPeLPrev
The previous length of the pe section of the muscle.
float * m_aryMuscleVelocities
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.
virtual float Kse()
Gets the serial elastic spring constant.
Declares the muscle base class.
Declares the joint class.
Declares the organism class.
SigmoidGain m_gainStimTension
The stimulus-tension gain.
virtual void AfterResetSimulation()
Called after a simulation reset for some objects.
float m_fltDisplacementRatio
This is the ratio of displacement of this muscle from its resting length.
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.
float m_fltA
The total active force that is developed from both the current stimulus level and the tension-length ...
float m_fltB
Damping coefficient.
Declares a light manager object.
float m_fltIbDischargeConstant
Constant that relates length of muscle segment to discharge rate of type Ib fibers.
virtual float B()
Gets the damping value.
Declares the bounding box class.
Declares the gain base class.
A standard xml manipulation class.
Declares the linear hill muscle class.
float C()
Gets C parameter of sigmoidal eqation: Out = D+(B/(1+e^(C*(A-In))))
virtual float RestingLength()
Gets the resting length.
virtual float InternalTension()
Gets the internal tension.
float m_fltVpe
The velocity of change of the PE section of the muscle.
virtual void CreateJoints()
Allows the rigid body to create its joints using the chosen physics engine.
float m_fltPrevTension
Tension of the muscle in the last time slice.
float m_fltMaxTension
The maximum tension that this muscle can ever generate. This is an upper limit to prevent unrealistic...
float m_fltSeDisplacement
The displacement of the SE section of the muscle.
Declares the line base class.
float m_fltTL
The proportion of active force developed that can actually be used at this muscle length...
virtual float SeRestLength()
Gets the se rest length.
virtual float Displacement()
Gets the displacement.
float m_fltKse
Spring constant for the series spring.
float m_fltAct
The active force that is developed from the current stimulus level before the tension-length relation...
virtual float CalculateGain(float fltInput)
Calculates the gain.
float m_fltKseByB
Precalculation of Kse divided by B.
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 CreateJoints()
Allows the rigid body to create its joints using the chosen physics engine.
float B()
Gets B parameter of sigmoidal eqation: Out = D+(B/(1+e^(C*(A-In))))
virtual float IbDischargeConstant()
Gets the ib discharge constant.
float m_fltVmuscle
The velocity of shortenting of the muscle.
bool m_bEnabled
Tells if this item is enabled or not. If it is not enabled then it is not run.
virtual ~LinearHillMuscle()
Destructor.
float m_fltTension
Tension of the muscle.
float A()
Gets A parameter of sigmoidal eqation: Out = D+(B/(1+e^(C*(A-In))))
virtual float SeLength()
Gets the se length.
int m_iMuscleVelAvgCount
The number of instantanious velocity readings to average to calculate the average velocity...
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.
Declares the sensor class.
virtual bool Enabled()
Gets whether the muscle is enabled.
float m_fltLength
Current length of the line.
Declares the data chart manager class.
Declares the rigid body class.
virtual float Kpe()
Gets the parallel elastic spring constant.
std::string Std_CheckString(std::string strVal)
Converts a string to upper case and trims it.
virtual float DisplacementRatio()
Gets the displacement ratio.
LengthTensionGain m_gainLengthTension
The length-tension gain.
Declares the structure class.
Declares the odor type class.
float Ftl(float fltLce)
Calculates the length tension relationship..
virtual float CalculateGain(float fltInput)
Calculates the gain.
float m_fltIbRate
Ib fiber discharge rate.
Declares the simulator class.
virtual float TL()
Gets the tl.
float m_fltInternalTension
Internal tension.
Declares the activated item manager class.
LinearHillMuscle()
Default constructor.
Declares the external stimuli manager class.
float m_fltTdot
The derivative of tension at the current time step.
virtual float Act()
Gets the muscle activation value.
Declares the attachment class.
float m_fltDisplacement
This is the amount of displacement of this muscle from its resting length.
Declares the receptive field class.
float m_fltKpeByKse
Precalculation of (1+(Kpe/Kse))
virtual float GetChildFloat(std::string strElementName)
Gets a float value from the element with the specified name.
float m_fltKpe
Spring constant for the parrallel spring.
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.