2 #include "IMovableItemCallback.h"
3 #include "ISimGUICallback.h"
4 #include "IMotorizedJoint.h"
9 #include "IPhysicsMovableItem.h"
10 #include "IPhysicsBody.h"
12 #include "MovableItem.h"
15 #include "MotorizedJoint.h"
42 MotorizedJoint::MotorizedJoint(
void)
79 MotorizedJoint::~MotorizedJoint(
void)
94 {
Std_TraceMsg(0,
"Caught Error in desctructor of BlMotorizMotorizedJointedJoint\r\n",
"", -1,
false,
true);}
490 return fltDesiredVel;
564 Std_IsAboveMin((
int) 0, iVal,
true,
"Joint.AssistCountdown",
true);
971 Std_IsAboveMin((
float) 0, fltVal,
true,
"Joint.Temperature",
true);
973 m_fltTemperature = fltVal;
1018 Joint::AddRobotPartInterface(lpPart);
1029 Joint::RemoveRobotPartInterface(lpPart);
1104 float *MotorizedJoint::GetDataPointer(
const std::string &strDataType)
1106 if(strDataType ==
"MOTORFORCETOAX")
1111 else if(strDataType ==
"MOTORFORCETOAY")
1116 else if(strDataType ==
"MOTORFORCETOAZ")
1121 else if(strDataType ==
"MOTORFORCETOAMAGNITUDE")
1126 else if(strDataType ==
"MOTORASSISTFORCETOAX")
1128 else if(strDataType ==
"MOTORASSISTFORCETOAY")
1130 else if(strDataType ==
"MOTORASSISTFORCETOAZ")
1132 else if(strDataType ==
"MOTORFORCETOBX")
1137 else if(strDataType ==
"MOTORFORCETOBY")
1142 else if(strDataType ==
"MOTORFORCETOBZ")
1147 else if(strDataType ==
"MOTORFORCETOBMAGNITUDE")
1152 else if(strDataType ==
"MOTORASSISTFORCETOBX")
1154 else if(strDataType ==
"MOTORASSISTFORCETOBY")
1156 else if(strDataType ==
"MOTORASSISTFORCETOBZ")
1158 else if(strDataType ==
"MOTORTORQUETOAX")
1163 else if(strDataType ==
"MOTORTORQUETOAY")
1168 else if(strDataType ==
"MOTORTORQUETOAZ")
1173 else if(strDataType ==
"MOTORTORQUETOAMAGNITUDE")
1178 else if(strDataType ==
"MOTORASSISTTORQUETOAX")
1180 else if(strDataType ==
"MOTORASSISTTORQUETOAY")
1182 else if(strDataType ==
"MOTORASSISTTORQUETOAZ")
1184 else if(strDataType ==
"MOTORTORQUETOBX")
1189 else if(strDataType ==
"MOTORTORQUETOBY")
1194 else if(strDataType ==
"MOTORTORQUETOBZ")
1199 else if(strDataType ==
"MOTORTORQUETOBMAGNITUDE")
1204 else if(strDataType ==
"MOTORASSISTTORQUETOBX")
1206 else if(strDataType ==
"MOTORASSISTTORQUETOBY")
1208 else if(strDataType ==
"MOTORASSISTTORQUETOBZ")
1210 else if(strDataType ==
"MOTORASSISTFORCEMAGNITUDE")
1212 else if(strDataType ==
"TEMPERATURE")
1213 return (&m_fltTemperature);
1214 else if(strDataType ==
"VOLTAGE")
1215 return (&m_fltVoltage);
1217 return Joint::GetDataPointer(strDataType);
1222 bool MotorizedJoint::SetData(
const std::string &strDataType,
const std::string &strValue,
bool bThrowError)
1226 if(Joint::SetData(strType, strValue,
false))
1229 if(strType ==
"ENABLEMOTOR")
1235 if(strType ==
"MOTORTYPE")
1241 if(strType ==
"SERVOGAIN")
1243 ServoGain((
float) atof(strValue.c_str()));
1247 if(strType ==
"MAXFORCE")
1249 MaxForce((
float) atof(strValue.c_str()));
1253 if(strType ==
"MAXVELOCITY")
1261 THROW_PARAM_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType,
"Data Type", strDataType);
1266 void MotorizedJoint::QueryProperties(CStdPtrArray<TypeProperty> &aryProperties)
1268 Joint::QueryProperties(aryProperties);
1270 aryProperties.Add(
new TypeProperty(
"MotorForceToAX", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1271 aryProperties.Add(
new TypeProperty(
"MotorForceToAY", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1272 aryProperties.Add(
new TypeProperty(
"MotorForceToAZ", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1273 aryProperties.Add(
new TypeProperty(
"MotorForceToAMagnitude", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1274 aryProperties.Add(
new TypeProperty(
"MotorAssistForceToAX", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1275 aryProperties.Add(
new TypeProperty(
"MotorAssistForceToAY", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1276 aryProperties.Add(
new TypeProperty(
"MotorAssistForceToAZ", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1278 aryProperties.Add(
new TypeProperty(
"MotorForceToBX", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1279 aryProperties.Add(
new TypeProperty(
"MotorForceToBY", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1280 aryProperties.Add(
new TypeProperty(
"MotorForceToBZ", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1281 aryProperties.Add(
new TypeProperty(
"MotorForceToBMagnitude", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1282 aryProperties.Add(
new TypeProperty(
"MotorAssistForceToBX", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1283 aryProperties.Add(
new TypeProperty(
"MotorAssistForceToBY", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1284 aryProperties.Add(
new TypeProperty(
"MotorAssistForceToBZ", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1286 aryProperties.Add(
new TypeProperty(
"MotorTorqueToAX", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1287 aryProperties.Add(
new TypeProperty(
"MotorTorqueToAY", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1288 aryProperties.Add(
new TypeProperty(
"MotorTorqueToAZ", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1289 aryProperties.Add(
new TypeProperty(
"MotorTorqueToAMagnitude", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1290 aryProperties.Add(
new TypeProperty(
"MotorAssistTorqueToAX", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1291 aryProperties.Add(
new TypeProperty(
"MotorAssistTorqueToAY", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1292 aryProperties.Add(
new TypeProperty(
"MotorAssistTorqueToAZ", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1294 aryProperties.Add(
new TypeProperty(
"MotorTorqueToBX", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1295 aryProperties.Add(
new TypeProperty(
"MotorTorqueToBY", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1296 aryProperties.Add(
new TypeProperty(
"MotorTorqueToBZ", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1297 aryProperties.Add(
new TypeProperty(
"MotorTorqueToBMagnitude", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1298 aryProperties.Add(
new TypeProperty(
"MotorAssistTorqueToBX", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1299 aryProperties.Add(
new TypeProperty(
"MotorAssistTorqueToBY", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1300 aryProperties.Add(
new TypeProperty(
"MotorAssistTorqueToBZ", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1302 aryProperties.Add(
new TypeProperty(
"Temperature", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1303 aryProperties.Add(
new TypeProperty(
"Voltage", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1306 aryProperties.Add(
new TypeProperty(
"EnableMotor", AnimatPropertyType::Boolean, AnimatPropertyDirection::Set));
1307 aryProperties.Add(
new TypeProperty(
"MotorType", AnimatPropertyType::Integer, AnimatPropertyDirection::Set));
1308 aryProperties.Add(
new TypeProperty(
"ServoGain", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1309 aryProperties.Add(
new TypeProperty(
"MaxForce", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1310 aryProperties.Add(
new TypeProperty(
"MaxVelocity", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1358 void MotorizedJoint::Load(
CStdXml &oXml)
1373 m_lpAssistPid =
new PidControl(0, 10, 0.2f, 10,
true,
false,
false, 0, 0, 0, 70);
virtual RobotPartInterface * RobotMotorControl()
Gets the robot motor control interface.
virtual void ResetSimulation()
Resets the simulation back to time 0.
Animatlab PID control system. This implements the CStdPid with extra AnimatBase functionality.
Base class file for all Animat simulation objects.
Declares the nervous system class.
Declares the simulation recorder class.
virtual CStdFPoint MotorAssistForceToAReport()
Gets the force vector that the motor assist is applying to body A. (un-scaled units). This is used for reporting purposes.
virtual void SetSystemPointers(Simulator *lpSim, Structure *lpStructure, NeuralModule *lpModule, Node *lpNode, bool bVerify)
Sets the system pointers.
virtual void ResetSimulation()
Resets the simulation back to time 0.
float m_fltMaxForceNotScaled
The un=scaled maximum force.
virtual bool FindChildElement(std::string strElementName, bool fThrowError=true)
Finds a child element by name.
virtual bool InSimulation()
Used to determine if we are running in a simulation, or in a real control mode.
Root namespace for the base simulation library for AnimatLab.
virtual IMotorizedJoint * PhysicsMotorJoint()
Gets the physics body interface pointer. This is an interface reference to the Vs version of this obj...
virtual float InverseMassUnits()
Gets the inverse mass units.
virtual int AssistCountdown()
Gets the assist countdown.
float m_fltDesiredPosition
virtual float MotorForceToAMagnitude()
Gets the magnitude of the force that the motor is applying to body A. (scaled units).
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 MaxVelocity()
Gets the maximum velocity.
CStdFPoint m_vMotorForceToB
virtual CStdFPoint MotorTorqueToA()
Gets the torque vector that the motor is applying to body A. (un-scaled units). This includes any mot...
float m_fltMotorTorqueAMagnitude
The magnitude of the motor torque being applied to body A. (scaled units)
CStdFPoint m_vMotorTorqueToB
Simulator * m_lpSim
The pointer to a Simulation.
CStdFPoint m_vMotorAssistForceToAReport
Force vector that the motor assist is applying to body A. (un-scaled units).
PidControl * m_lpAssistPid
The PID controller for the motor assist system.
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.
CStdFPoint m_vMotorAssistTorqueToB
Torque vector that the motor assist is applying to body B. (scaled units).
Class that stores information about types for QueryProperty information.
virtual float PrevSetVelocity()
Gets the previous set etVelocity.
virtual float DesiredVelocity()
Gets the desired velocity.
CStdFPoint m_vMotorAssistForceToA
Force vector that the motor assist is applying to body A. (scaled units).
Declares the link base class.
virtual float SetPosition()
Gets the position that is actually set using the physics method.
virtual void DistanceUnits(std::string strUnits)
Sets the distance units.
CStdFPoint m_vMotorForceToA
Declares the key frame class.
virtual float MaxForce()
Gets the maximum torque.
virtual CStdFPoint MotorForceToB()
Gets the force vector that the motor is applying to body B. (un-scaled units). This includes any moto...
float m_fltMotorForceBMagnitude
The magnitude of the motor Force being applied to body B. (scaled units)
float m_fltMotorForceAMagnitude
The magnitude of the motor Force being applied to body A. (scaled units)
virtual void Initialize()
Initializes this object.
Declares the joint class.
Declares the organism class.
virtual bool SimRunning()
Gets whether the simulation is running.
virtual int GetChildInt(std::string strElementName)
Gets an integer value from the element with the specified name.
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 float MotorTorqueToBMagnitude()
Gets the magnitude of the torque that the motor is applying to body B. (scaled units).
virtual bool ReachedSetPosition()
Gets whether the servo motor has reached its target position. If it has then it switches to position ...
virtual CStdFPoint MotorAssistForceToB()
Gets the force vector that the motor assist is applying to body B. (scaled units).
Declares the activated item class.
virtual CStdFPoint MotorTorqueToB()
Gets the torque vector that the motor is applying to body B. (un-scaled units). This includes any mot...
virtual float MaxForceNotScaled()
Gets the maximum force/torque a motor can apply. This is the unscaled value.
Implements a basic PID control algorithm.
RobotPartInterface * m_lpRobotMotorControl
The RobotPartInterface responsible for motor control for this motorized joint.
Declares a light manager object.
virtual void Reset()
Resets this object.
virtual CStdFPoint MotorAssistTorqueToB()
Gets the torque vector that the motor assist is applying to body B. (scaled units).
Declares the bounding box class.
float m_fltPrevSetPosition
virtual float MotorTorqueToAMagnitude()
Gets the magnitude of the torque that the motor is applying to body A. (scaled units).
virtual float Voltage()
Gets the motor voltage.
A standard xml manipulation class.
virtual CStdPID * AssistPid()
Gets a pointer to the motor assist pid controller.
virtual float PrevSetPosition()
Gets the previous set position.
virtual bool EnableMotor()
Tells if the motor is enabled.
virtual bool SynchSim()
Gets whether we need to delay stepping of the physics adapters in the simulation to more closely matc...
virtual CStdFPoint MotorAssistTorqueToA()
Gets the torque vector that the motor assist is applying to body A. (scaled units).
CStdFPoint m_vMotorAssistForceToBReport
Force vector that the motor assist is applying to body B. (un-scaled units).
virtual CStdFPoint MotorAssistForceToA()
Gets the force vector that the motor assist is applying to body A. (scaled units).
virtual float QuantizeServoPosition(float fltPos)
If this is a servo controller interface then it will take a continuous positon and return back a vali...
float m_fltDesiredVelocity
virtual void Physics_EnableMotor(bool bOn, float fltDesiredVelocity, float fltMaxForce, bool bForceWakeup)=0
Enables the motor.
virtual float ServoGain()
Gets the servo gain.
CStdFPoint m_vMotorAssistTorqueToA
Torque vector that the motor assist is applying to body A. (scaled units).
float m_fltPrevSetVelocity
The previous velocity set for the motorized joint in the last time step.
bool Std_ToBool(int iVal)
Converts a value toa bool.
CStdFPoint m_vMotorAssistForceToB
Force vector that the motor assist is applying to body B. (scaled units).
CStdFPoint m_vMotorAssistTorqueToAReport
Torque vector that the motor assist is applying to body A. (un-scaled units).
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.
virtual float Temperature()
Gets the motor temperature.
float m_fltReportSetPosition
This is the variable that is reported to AnimatLab on what the set position was.
virtual bool OutOfElem()
Goes out of the element where the cursor is located.
float m_fltMotorAssistMagnitudeReport
The reportable motor assist Force magnitude.
virtual float DesiredPosition()
Gets the desired Position.
virtual CStdFPoint MotorAssistForceToBReport()
Gets the force vector that the motor assist is applying to body B. (scaled units). This is used for reporting purposes.
float m_fltReportSetVelocity
This is the variable that is reported to AnimatLab on what the set veloicty was.
virtual void SetVelocityToDesired()
Sets the desired velocity to use for the motor.
virtual float MotorForceToBMagnitude()
Gets the magnitude of the force that the motor is applying to body B. (scaled units).
bool m_bEnableMotor
If true then the motor for this joint is enabled.
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.
float m_fltSetPositionDeltaCheck
Used to check whether the set position has changed.
virtual eJointMotorType MotorType()
Gets the type of motor to use for this joint.
float m_fltMotorTorqueBMagnitude
The magnitude of the motor torque being applied to body B. (scaled units)
virtual CStdFPoint MotorAssistTorqueToBReport()
Gets the torque vector that the motor assist is applying to body B. (un-scaled units). This is used for reporting purposes.
float m_ftlServoGain
The gain of the servo motor.
Declares the structure class.
Declares the odor type class.
virtual void EnableFeedback()
Enables joint feedback.
eJointMotorType
The motor control type for this joint.
virtual bool UsesRadians()
Tells whether this joint uses radians or meters for its measurements.
virtual void Initialize()
Initializes this object.
virtual float InverseDistanceUnits()
Gets the inverse distance units.
eJointMotorType m_eMotorType
Determines the type of motor control this joint uses. The default is velocity controlled, but it can be position controlled, or both position and velocity controlled.
virtual float SetVelocity()
Gets the velocity that is actually set using the physics method.
Declares the simulator class.
virtual void ClearAssistForces()
Clears the assist forces.
virtual float PrevVelocity()
Sets the previous velocity that is actually used by the physics method.
Declares the neural module class.
virtual CStdFPoint MotorAssistTorqueToAReport()
Gets the torque vector that the motor assist is applying to body A. (un-scaled units). This is used for reporting purposes.
virtual void Physics_MaxForce(float fltVal)=0
Sets the maximum forces allowed by the motorized joint.
IMotorizedJoint * m_lpPhysicsMotorJoint
The pointer to the physics joint instance.
Declares the activated item manager class.
virtual void MotorInput(float fltInput)
Sets the desired velocity.
virtual CStdFPoint MotorForceToA()
Gets the force vector that the motor is applying to body A. (un-scaled units). This includes any moto...
Declares the external stimuli manager class.
virtual void EnableLock(bool bOn, float fltPosition, float fltMaxLockForce)
Enables/disables the motor lock.
CStdFPoint m_vMotorTorqueToA
CStdFPoint m_vMotorAssistTorqueToBReport
Torque vector that the motor assist is applying to body B. (un-scaled units).
float m_fltMotorAssistMagnitude
The motor assist Force magnitude.
Declares the receptive field class.
virtual float GetChildFloat(std::string strElementName)
Gets a float value from the element with the specified name.
virtual void ApplyMotorAssist()
Applies the motor assist.