AnimatLab  2
Test
MotorizedJoint.cpp
1 #include "StdAfx.h"
2 #include "IMovableItemCallback.h"
3 #include "ISimGUICallback.h"
4 #include "IMotorizedJoint.h"
5 #include "AnimatBase.h"
6 
7 #include "Node.h"
8 #include "Link.h"
9 #include "IPhysicsMovableItem.h"
10 #include "IPhysicsBody.h"
11 #include "BoundingBox.h"
12 #include "MovableItem.h"
13 #include "BodyPart.h"
14 #include "Joint.h"
15 #include "MotorizedJoint.h"
16 #include "ReceptiveField.h"
17 #include "ContactSensor.h"
18 #include "RigidBody.h"
19 #include "Structure.h"
20 #include "NeuralModule.h"
21 #include "Adapter.h"
22 #include "NervousSystem.h"
23 #include "Organism.h"
24 #include "ActivatedItem.h"
25 #include "ActivatedItemMgr.h"
26 #include "DataChartMgr.h"
27 #include "ExternalStimuliMgr.h"
28 #include "KeyFrame.h"
29 #include "SimulationRecorder.h"
30 #include "OdorType.h"
31 #include "Odor.h"
32 #include "Light.h"
33 #include "LightManager.h"
34 #include "Simulator.h"
35 
36 
37 namespace AnimatSim
38 {
39  namespace Environment
40  {
41 
42 MotorizedJoint::MotorizedJoint(void)
43 {
44  m_lpPhysicsMotorJoint = NULL;
45  m_fltSetPosition = 0;
49  m_fltSetVelocity = 0;
54  m_fltMaxVelocity = 100;
55  m_fltPrevVelocity = -1000000;
56  m_bEnableMotor = false;
57  m_bEnableMotorInit = false;
58  m_fltMaxForce = 1000;
60  m_eMotorType = eJointMotorType::VelocityControl;
61  m_ftlServoGain = 100;
62  m_lpPhysicsMotorJoint = NULL;
63  m_lpAssistPid = NULL;
68  m_fltTemperature = 0;
69  m_fltVoltage = 0;
70  m_bReachedSetPos = false;
71  m_lpRobotMotorControl = NULL;
72 
77 }
78 
79 MotorizedJoint::~MotorizedJoint(void)
80 {
81  //ConstraintLimits are deleted in the base objects.
82  try
83  {
84 
85  if(m_lpAssistPid)
86  {
87  delete m_lpAssistPid;
88  m_lpAssistPid = NULL;
89  }
90 
91  m_lpRobotMotorControl = NULL;
92  }
93  catch(...)
94  {Std_TraceMsg(0, "Caught Error in desctructor of BlMotorizMotorizedJointedJoint\r\n", "", -1, false, true);}
95 }
96 
108 
120 {
121  m_lpPhysicsMotorJoint = lpJoint;
122 }
123 
133 
148 {
151  m_bEnableMotor = bVal;
152 
153  //If the sim is running then we do not set the history flag. Only set it if changed while the sim is not running.
154  if(!m_lpSim->SimRunning())
156 }
157 
158 
174 
190 
199 void MotorizedJoint::ServoGain(float fltVal)
200 {
201  Std_IsAboveMin((float) 0, fltVal, true, "ServoGain", true);
202  m_ftlServoGain= fltVal;
203 }
204 
214 
224 void MotorizedJoint::MaxForce(float fltVal, bool bUseScaling)
225 {
226  Std_IsAboveMin((float) 0, fltVal, true, "MaxTorque");
227 
228  //If max torque is over 1000 N then assume we mean infinity.
229  if(fltVal >= 5000)
230  fltVal = 1e35f;
231  else
232  {
233  m_fltMaxForceNotScaled = fltVal;
234 
235  if(bUseScaling)
236  {
237  //If it uses radians then this is really a torque and not a force, so we have to scale appropriately.
238  if(this->UsesRadians())
240  else
242  }
243  }
244 
245  m_fltMaxForce = fltVal;
246 
249 }
250 
260 
270 
280 
290 void MotorizedJoint::MaxVelocity(float fltVal, bool bUseScaling)
291 {
292  Std_IsAboveMin((float) 0, fltVal, true, "Joint.MaxVelocity");
293 
294  if(bUseScaling && !UsesRadians())
296  else
297  m_fltMaxVelocity = fltVal;
298 }
299 
309 
318 void MotorizedJoint::SetPosition(float fltVal)
319 {
321  //int i=5;
322  //if(Std_ToLower(m_strID) == "5c9f7a20-c7e0-44a9-b97f-9de1132363ad") // && fabs(fltTargetPos) > 0 && GetSimulator()->Time() >= 2.5
323  // i=6;
324 
326  m_fltSetPosition = fltVal;
327 
328  if(m_lpRobotMotorControl && m_lpStructure && m_lpSim && m_lpSim->InSimulation() && m_lpStructure->GetRobotInterface() && m_lpStructure->GetRobotInterface()->SynchSim())
329  {
330  //If we have a robot interface and are synching with it then we need to quantize the position
331  //values to match what the real robot is capable of using.
333  }
334 
335  if(!UsesRadians())
337  else
339 
340  //If we are changing the set position to a different value then reset the reached position flag.
342  m_bReachedSetPos = false;
343 }
344 
354 {
355  return m_fltDesiredPosition;
356 }
357 
366 void MotorizedJoint::DesiredPosition(float fltPosition)
367 {
368  m_fltDesiredPosition = fltPosition;
369 }
370 
380 
390 
401 
411 
421 
430 void MotorizedJoint::SetVelocity(float fltVal)
431 {
433  m_fltSetVelocity = fltVal;
434 
435  if(m_lpRobotMotorControl && m_lpStructure && m_lpSim && m_lpSim->InSimulation() && m_lpStructure->GetRobotInterface() && m_lpStructure->GetRobotInterface()->SynchSim())
436  {
437  int i = 5;
438  if(m_fltSetVelocity != 0)
439  i=6;
440 
441  //If we have a robot interface and are synching with it then we need to quantize the position
442  //values to match what the real robot is capable of using.
444  }
445 
446  if(!UsesRadians())
448  else
450 }
451 
461 
471 
481 {
482  float fltDesiredVel = m_fltDesiredVelocity;
483 
484  if(fltDesiredVel>m_fltMaxVelocity)
485  fltDesiredVel = m_fltMaxVelocity;
486 
487  if(fltDesiredVel < -m_fltMaxVelocity)
488  fltDesiredVel = -m_fltMaxVelocity;
489 
490  return fltDesiredVel;
491 }
492 
501 void MotorizedJoint::DesiredVelocity(float fltVelocity)
502 {
503  m_fltDesiredVelocity = fltVelocity;
504 }
505 
514 void MotorizedJoint::MotorInput(float fltInput)
515 {
516  m_fltDesiredVelocity = fltInput;
517 }
518 
528 
537 void MotorizedJoint::PrevVelocity(float fltVal) {m_fltPrevVelocity = fltVal;}
538 
552 {return m_iAssistCountdown;}
553 
563 {
564  Std_IsAboveMin((int) 0, iVal, true, "Joint.AssistCountdown", true);
565  m_iAssistCountdown = iVal;
566 }
567 
578 {return m_vMotorForceToA;}
579 
589 void MotorizedJoint::MotorForceToA(CStdFPoint &vVal)
590 {
591  m_vMotorForceToA = vVal;
592  m_fltMotorForceAMagnitude = fabs(m_vMotorForceToA.Magnitude());
593 }
594 
604 
614 
624 {return m_vMotorAssistForceToA;}
625 
635 {m_vMotorAssistForceToA = vVal;}
636 
648 
660 
671 {return m_vMotorForceToB;}
672 
682 void MotorizedJoint::MotorForceToB(CStdFPoint &vVal)
683 {
684  m_vMotorForceToB = vVal;
685  m_fltMotorForceBMagnitude = fabs(m_vMotorForceToB.Magnitude());
686 }
687 
697 
707 
717 {return m_vMotorAssistForceToB;}
718 
728 {m_vMotorAssistForceToB = vVal;}
729 
741 
753 
764 {return m_vMotorTorqueToA;}
765 
775 void MotorizedJoint::MotorTorqueToA(CStdFPoint &vVal)
776 {
777  m_vMotorTorqueToA = vVal;
778  m_fltMotorTorqueAMagnitude = fabs(m_vMotorTorqueToA.Magnitude());
779 }
780 
790 
800 
810 {return m_vMotorAssistTorqueToA;}
811 
821 {m_vMotorAssistTorqueToA = vVal;}
822 
834 
846 
857 {return m_vMotorTorqueToB;}
858 
868 void MotorizedJoint::MotorTorqueToB(CStdFPoint &vVal)
869 {
870  m_vMotorTorqueToB = vVal;
871  m_fltMotorTorqueBMagnitude = fabs(m_vMotorTorqueToB.Magnitude());
872 }
873 
883 
893 
903 {return m_vMotorAssistTorqueToB;}
904 
914 {m_vMotorAssistTorqueToB = vVal;}
915 
927 
939 
949 {return m_lpAssistPid;}
950 
959 float MotorizedJoint::Temperature() {return m_fltTemperature;}
960 
969 void MotorizedJoint::Temperature(float fltVal)
970 {
971  Std_IsAboveMin((float) 0, fltVal, true, "Joint.Temperature", true);
972 
973  m_fltTemperature = fltVal;
974 }
975 
984 float MotorizedJoint::Voltage() {return m_fltVoltage;}
985 
994  void MotorizedJoint::Voltage(float fltVal) {m_fltVoltage = fltVal;}
995 
1005 
1015 
1016 void MotorizedJoint::AddRobotPartInterface(RobotPartInterface *lpPart)
1017 {
1018  Joint::AddRobotPartInterface(lpPart);
1019 
1020  if(lpPart && lpPart->IsMotorControl())
1021  m_lpRobotMotorControl = lpPart;
1022 }
1023 
1024 void MotorizedJoint::RemoveRobotPartInterface(RobotPartInterface *lpPart)
1025 {
1026  if(lpPart == m_lpRobotMotorControl)
1027  m_lpRobotMotorControl = NULL;
1028 
1029  Joint::RemoveRobotPartInterface(lpPart);
1030 }
1031 
1039 {
1041  m_lpPhysicsMotorJoint->Physics_SetVelocityToDesired();
1042 }
1043 
1057 void MotorizedJoint::EnableLock(bool bOn, float fltPosition, float fltMaxLockForce)
1058 {
1060  m_lpPhysicsMotorJoint->Physics_EnableLock(bOn, fltPosition, fltMaxLockForce);
1061 }
1062 
1064 {
1066 
1067  if(!this->UsesRadians())
1069 }
1070 
1072 {
1074 
1075  m_fltSetPosition = 0;
1079  m_bReachedSetPos = false;
1080 
1081  m_fltSetVelocity = 0;
1084  m_fltPrevVelocity = 0;
1085 
1090 
1091  if(!this->UsesRadians())
1093 
1095 
1097 
1098  if(m_lpAssistPid)
1099  m_lpAssistPid->Reset();
1100 
1101  m_iAssistCountdown = 3;
1102 }
1103 
1104 float *MotorizedJoint::GetDataPointer(const std::string &strDataType)
1105 {
1106  if(strDataType == "MOTORFORCETOAX")
1107  {
1108  EnableFeedback();
1109  return (&m_vMotorForceToA[0]);
1110  }
1111  else if(strDataType == "MOTORFORCETOAY")
1112  {
1113  EnableFeedback();
1114  return (&m_vMotorForceToA[1]);
1115  }
1116  else if(strDataType == "MOTORFORCETOAZ")
1117  {
1118  EnableFeedback();
1119  return (&m_vMotorForceToA[2]);
1120  }
1121  else if(strDataType == "MOTORFORCETOAMAGNITUDE")
1122  {
1123  EnableFeedback();
1124  return (&m_fltMotorForceAMagnitude);
1125  }
1126  else if(strDataType == "MOTORASSISTFORCETOAX")
1127  return (&m_vMotorAssistForceToAReport[0]);
1128  else if(strDataType == "MOTORASSISTFORCETOAY")
1129  return (&m_vMotorAssistForceToAReport[1]);
1130  else if(strDataType == "MOTORASSISTFORCETOAZ")
1131  return (&m_vMotorAssistForceToAReport[2]);
1132  else if(strDataType == "MOTORFORCETOBX")
1133  {
1134  EnableFeedback();
1135  return (&m_vMotorForceToB[0]);
1136  }
1137  else if(strDataType == "MOTORFORCETOBY")
1138  {
1139  EnableFeedback();
1140  return (&m_vMotorForceToB[1]);
1141  }
1142  else if(strDataType == "MOTORFORCETOBZ")
1143  {
1144  EnableFeedback();
1145  return (&m_vMotorForceToB[2]);
1146  }
1147  else if(strDataType == "MOTORFORCETOBMAGNITUDE")
1148  {
1149  EnableFeedback();
1150  return (&m_fltMotorForceBMagnitude);
1151  }
1152  else if(strDataType == "MOTORASSISTFORCETOBX")
1153  return (&m_vMotorAssistForceToBReport[0]);
1154  else if(strDataType == "MOTORASSISTFORCETOBY")
1155  return (&m_vMotorAssistForceToBReport[1]);
1156  else if(strDataType == "MOTORASSISTFORCETOBZ")
1157  return (&m_vMotorAssistForceToBReport[2]);
1158  else if(strDataType == "MOTORTORQUETOAX")
1159  {
1160  EnableFeedback();
1161  return (&m_vMotorTorqueToA[0]);
1162  }
1163  else if(strDataType == "MOTORTORQUETOAY")
1164  {
1165  EnableFeedback();
1166  return (&m_vMotorTorqueToA[1]);
1167  }
1168  else if(strDataType == "MOTORTORQUETOAZ")
1169  {
1170  EnableFeedback();
1171  return (&m_vMotorTorqueToA[2]);
1172  }
1173  else if(strDataType == "MOTORTORQUETOAMAGNITUDE")
1174  {
1175  EnableFeedback();
1176  return (&m_fltMotorTorqueAMagnitude);
1177  }
1178  else if(strDataType == "MOTORASSISTTORQUETOAX")
1179  return (&m_vMotorAssistTorqueToAReport[0]);
1180  else if(strDataType == "MOTORASSISTTORQUETOAY")
1181  return (&m_vMotorAssistTorqueToAReport[1]);
1182  else if(strDataType == "MOTORASSISTTORQUETOAZ")
1183  return (&m_vMotorAssistTorqueToAReport[2]);
1184  else if(strDataType == "MOTORTORQUETOBX")
1185  {
1186  EnableFeedback();
1187  return (&m_vMotorTorqueToB[0]);
1188  }
1189  else if(strDataType == "MOTORTORQUETOBY")
1190  {
1191  EnableFeedback();
1192  return (&m_vMotorTorqueToB[1]);
1193  }
1194  else if(strDataType == "MOTORTORQUETOBZ")
1195  {
1196  EnableFeedback();
1197  return (&m_vMotorTorqueToB[2]);
1198  }
1199  else if(strDataType == "MOTORTORQUETOBMAGNITUDE")
1200  {
1201  EnableFeedback();
1202  return (&m_fltMotorTorqueBMagnitude);
1203  }
1204  else if(strDataType == "MOTORASSISTTORQUETOBX")
1205  return (&m_vMotorAssistTorqueToBReport[0]);
1206  else if(strDataType == "MOTORASSISTTORQUETOBY")
1207  return (&m_vMotorAssistTorqueToBReport[1]);
1208  else if(strDataType == "MOTORASSISTTORQUETOBZ")
1209  return (&m_vMotorAssistTorqueToBReport[2]);
1210  else if(strDataType == "MOTORASSISTFORCEMAGNITUDE")
1212  else if(strDataType == "TEMPERATURE")
1213  return (&m_fltTemperature);
1214  else if(strDataType == "VOLTAGE")
1215  return (&m_fltVoltage);
1216  else
1217  return Joint::GetDataPointer(strDataType);
1218 
1219  return NULL;
1220 }
1221 
1222 bool MotorizedJoint::SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError)
1223 {
1224  std::string strType = Std_CheckString(strDataType);
1225 
1226  if(Joint::SetData(strType, strValue, false))
1227  return true;
1228 
1229  if(strType == "ENABLEMOTOR")
1230  {
1231  EnableMotor(Std_ToBool(strValue));
1232  return true;
1233  }
1234 
1235  if(strType == "MOTORTYPE")
1236  {
1237  MotorType((eJointMotorType) atoi(strValue.c_str()));
1238  return true;
1239  }
1240 
1241  if(strType == "SERVOGAIN")
1242  {
1243  ServoGain((float) atof(strValue.c_str()));
1244  return true;
1245  }
1246 
1247  if(strType == "MAXFORCE")
1248  {
1249  MaxForce((float) atof(strValue.c_str()));
1250  return true;
1251  }
1252 
1253  if(strType == "MAXVELOCITY")
1254  {
1255  MaxVelocity((float) atof(strValue.c_str()));
1256  return true;
1257  }
1258 
1259  //If it was not one of those above then we have a problem.
1260  if(bThrowError)
1261  THROW_PARAM_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType, "Data Type", strDataType);
1262 
1263  return false;
1264 }
1265 
1266 void MotorizedJoint::QueryProperties(CStdPtrArray<TypeProperty> &aryProperties)
1267 {
1268  Joint::QueryProperties(aryProperties);
1269 
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));
1277 
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));
1285 
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));
1293 
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));
1301 
1302  aryProperties.Add(new TypeProperty("Temperature", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1303  aryProperties.Add(new TypeProperty("Voltage", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1304 
1305 
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));
1311 }
1312 
1320 {
1321  if(m_lpAssistPid)
1322  m_lpAssistPid->ResetVars();
1323 
1324  m_vMotorForceToA.Set(0,0,0);
1325  m_vMotorAssistForceToA.Set(0,0,0);
1326  m_vMotorAssistForceToAReport.Set(0,0,0);
1327  m_vMotorForceToB.Set(0,0,0);
1328  m_vMotorAssistForceToB.Set(0,0,0);
1329  m_vMotorAssistForceToBReport.Set(0,0,0);
1330  m_vMotorTorqueToA.Set(0,0,0);
1331  m_vMotorAssistTorqueToA.Set(0,0,0);
1332  m_vMotorAssistTorqueToAReport.Set(0,0,0);
1333  m_vMotorTorqueToB.Set(0,0,0);
1334  m_vMotorAssistTorqueToB.Set(0,0,0);
1335  m_vMotorAssistTorqueToBReport.Set(0,0,0);
1338 }
1339 
1347 {}
1348 
1356 {}
1357 
1358 void MotorizedJoint::Load(CStdXml &oXml)
1359 {
1360  Joint::Load(oXml);
1361 
1362  oXml.IntoElem(); //Into Joint Element
1363 
1364  EnableMotor(oXml.GetChildBool("EnableMotor", m_bEnableMotor));
1365  MaxVelocity(oXml.GetChildFloat("MaxVelocity", m_fltMaxVelocity));
1366 
1367  MaxForce(oXml.GetChildFloat("MaxForce", m_fltMaxForce));
1368  MotorType((eJointMotorType) oXml.GetChildInt("MotorType", m_eMotorType));
1369  ServoGain(oXml.GetChildFloat("ServoGain", m_ftlServoGain));
1370 
1371  if(oXml.FindChildElement("PID", false))
1372  {
1373  m_lpAssistPid = new PidControl(0, 10, 0.2f, 10, true, false, false, 0, 0, 0, 70);
1375  m_lpAssistPid->Load(oXml);
1376  }
1377 
1378  oXml.OutOfElem(); //OutOf Joint Element
1379 }
1380 
1381  }
1382 }
virtual RobotPartInterface * RobotMotorControl()
Gets the robot motor control interface.
virtual void ResetSimulation()
Resets the simulation back to time 0.
Definition: Joint.cpp:722
Animatlab PID control system. This implements the CStdPid with extra AnimatBase functionality.
Definition: PidControl.h:11
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.
Definition: StdXml.cpp:256
virtual bool InSimulation()
Used to determine if we are running in a simulation, or in a real control mode.
Definition: Simulator.cpp:1673
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.
Definition: Simulator.cpp:1797
virtual int AssistCountdown()
Gets the assist countdown.
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.
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)
Simulator * m_lpSim
The pointer to a Simulation.
Definition: AnimatBase.h:43
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.
Definition: StdXml.cpp:42
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.
Definition: TypeProperty.h:35
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).
virtual float SetPosition()
Gets the position that is actually set using the physics method.
virtual void DistanceUnits(std::string strUnits)
Sets the distance units.
Definition: Simulator.cpp:1717
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.
Definition: Joint.cpp:605
Declares the joint class.
Declares the organism class.
virtual bool SimRunning()
Gets whether the simulation is running.
Definition: Simulator.cpp:673
virtual int GetChildInt(std::string strElementName)
Gets an integer value from the element with the specified name.
Definition: StdXml.cpp:456
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...
Definition: AnimatBase.h:46
virtual float MotorTorqueToBMagnitude()
Gets the magnitude of the torque that the motor is applying to body B. (scaled units).
Declares a light object.
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.
Definition: StdPID.h:17
RobotPartInterface * m_lpRobotMotorControl
The RobotPartInterface responsible for motor control for this motorized joint.
Declares a light manager object.
virtual void Reset()
Resets this object.
Definition: AnimatBase.cpp:559
virtual CStdFPoint MotorAssistTorqueToB()
Gets the torque vector that the motor assist is applying to body B. (scaled units).
Declares the bounding box class.
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.
Definition: StdXml.h:19
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...
Declares the node class.
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...
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.
Definition: StdXml.cpp:699
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.
Definition: StdXml.cpp:56
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.
Definition: Joint.cpp:97
virtual void Initialize()
Initializes this object.
virtual float InverseDistanceUnits()
Gets the inverse distance units.
Definition: Simulator.cpp:1742
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 odor class.
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 contact sensor class.
Declares the external stimuli manager class.
virtual void EnableLock(bool bOn, float fltPosition, float fltMaxLockForce)
Enables/disables the motor lock.
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.
Definition: StdXml.cpp:617
virtual void ApplyMotorAssist()
Applies the motor assist.