AnimatLab  2
Test
BlHinge.cpp
Go to the documentation of this file.
1 
7 #include "StdAfx.h"
8 #include "BlJoint.h"
9 #include "BlMotorizedJoint.h"
10 #include "BlRigidBody.h"
11 #include "BlJoint.h"
12 #include "BlHingeLimit.h"
13 #include "BlHinge.h"
14 #include "BlSimulator.h"
15 
16 namespace BulletAnimatSim
17 {
18  namespace Environment
19  {
20  namespace Joints
21  {
22 
23 
31 {
32  SetThisPointers();
33  m_btHinge = NULL;
34  m_fltChildMassWithChildren = 0;
35  m_fltBounce = 1;
36 
39  m_lpPosFlap = new BlHingeLimit();
40 
41  m_lpUpperLimit->LimitPos(0.25*osg::PI, false);
42  m_lpLowerLimit->LimitPos(-0.25*osg::PI, false);
43  m_lpPosFlap->LimitPos(Hinge::JointPosition(), false);
45 
46  m_lpUpperLimit->Color(1, 0, 0, 1);
47  m_lpLowerLimit->Color(1, 1, 1, 1);
48  m_lpPosFlap->Color(0, 0, 1, 1);
49 
52 }
53 
61 {
62  //ConstraintLimits are deleted in the base objects.
63  try
64  {
65  DeleteGraphics();
66  DeletePhysics(false);
67  }
68  catch(...)
69  {Std_TraceMsg(0, "Caught Error in desctructor of BlHinge\r\n", "", -1, false, true);}
70 }
71 
72 void BlHinge::EnableLimits(bool bVal)
73 {
74  Hinge::EnableLimits(bVal);
75 
76  SetLimitValues();
77 }
78 
79 void BlHinge::SetLimitValues()
80 {
81  if(m_btHinge)
82  {
83  GetLimitsFromRelaxations(m_vLowerLinear, m_vUpperLinear, m_vLowerAngular, m_vUpperAngular);
84 
85  float fltErp = 0, fltCfm=0;
86 
87  if(m_bEnableLimits)
88  {
89  m_bJointLocked = false;
90 
91  m_vLowerAngular[0] = m_lpLowerLimit->LimitPos();
92  m_vUpperAngular[0] = m_lpUpperLimit->LimitPos();
93 
94  //float fltKp = m_lpUpperLimit->Stiffness();
95  //float fltKd = m_lpUpperLimit->Damping();
96  //float fltH = m_lpSim->PhysicsTimeStep()*1000;
97  //
98  //fltErp = (fltH*fltKp)/((fltH*fltKp) + fltKd);
99  //fltCfm = 1/((fltH*fltKp) + fltKd);
100  }
101  else
102  {
103  //To disable limits in bullet we need the lower limit to be bigger than the upper limit
104  m_bJointLocked = false;
105 
106  //Disable rotation about the axis for the prismatic joint.
107  m_vLowerAngular[0] = 1;
108  m_vUpperAngular[0] = -1;
109  }
110 
111  //m_btHinge->setParam(BT_CONSTRAINT_STOP_CFM, fltCfm, 3);
112  //m_btHinge->setParam(BT_CONSTRAINT_STOP_ERP, fltErp, 3);
113  float fltBounce = m_lpUpperLimit->Restitution();
114  m_btHinge->getRotationalLimitMotor(0)->m_bounce = fltBounce;
115 
116  m_btHinge->setLinearLowerLimit(m_vLowerLinear);
117  m_btHinge->setLinearUpperLimit(m_vUpperLinear);
118  m_btHinge->setAngularLowerLimit(m_vLowerAngular);
119  m_btHinge->setAngularUpperLimit(m_vUpperAngular);
120  }
121 }
122 
123 void BlHinge::JointPosition(float fltPos)
124 {
125  m_fltPosition = fltPos;
126  if(m_lpPosFlap)
127  m_lpPosFlap->LimitPos(fltPos);
128 }
129 
130 void BlHinge::SetAlpha()
131 {
132  BlJoint::SetAlpha();
133 
137 
138  if(m_osgCylinderMat.valid() && m_osgCylinderSS.valid())
139  SetMaterialAlpha(m_osgCylinderMat.get(), m_osgCylinderSS.get(), m_fltAlpha);
140 
141 }
142 
143 void BlHinge::DeleteJointGraphics()
144 {
145  OsgHingeLimit *lpUpperLimit = dynamic_cast<OsgHingeLimit *>(m_lpUpperLimit);
146  OsgHingeLimit *lpLowerLimit = dynamic_cast<OsgHingeLimit *>(m_lpLowerLimit);
147  OsgHingeLimit *lpPosFlap = dynamic_cast<OsgHingeLimit *>(m_lpPosFlap);
148 
149  OsgHinge::DeleteHingeGraphics(m_osgJointMT, lpUpperLimit, lpLowerLimit, lpPosFlap);
150 
154 }
155 
156 void BlHinge::CreateJointGraphics()
157 {
158  OsgHingeLimit *lpUpperLimit = dynamic_cast<OsgHingeLimit *>(m_lpUpperLimit);
159  OsgHingeLimit *lpLowerLimit = dynamic_cast<OsgHingeLimit *>(m_lpLowerLimit);
160  OsgHingeLimit *lpPosFlap = dynamic_cast<OsgHingeLimit *>(m_lpPosFlap);
161 
162  float fltLimitPos = Hinge::JointPosition();
163  m_lpPosFlap->LimitPos(fltLimitPos);
164 
165  OsgHinge::CreateHingeGraphics(CylinderHeight(), CylinderRadius(), FlapWidth(),
166  m_osgJointMT, lpUpperLimit, lpLowerLimit, lpPosFlap);
167 }
168 
169 
170 void BlHinge::Physics_UpdateAbsolutePosition()
171 {
172  //If we are here then we did not have a physics component, just and OSG one.
173  CStdFPoint vPos = OsgMovableItem::GetOSGWorldCoords();
174  vPos.ClearNearZero();
175  m_lpThisMI->AbsolutePosition(vPos.x, vPos.y, vPos.z);
176 }
177 
178 void BlHinge::SetupPhysics()
179 {
180  if(m_btJoint)
181  DeletePhysics(false);
182 
183  InitBaseJointPointers(m_lpParent, m_lpChild, m_aryRelaxations, 3);
184 
185  btTransform mtJointRelParent, mtJointRelChild;
186  CalculateRelativeJointMatrices(mtJointRelParent, mtJointRelChild);
187 
188  m_btHinge = new btAnimatGeneric6DofConstraint(*m_lpBlParent->Part(), *m_lpBlChild->Part(), mtJointRelParent, mtJointRelChild, false);
189 
190  m_btHinge->setDbgDrawSize(btScalar(5.f));
191 
192  GetBlSimulator()->DynamicsWorld()->addConstraint(m_btHinge, true);
193 
194  BlHingeLimit *lpUpperLimit = dynamic_cast<BlHingeLimit *>(m_lpUpperLimit);
195  BlHingeLimit *lpLowerLimit = dynamic_cast<BlHingeLimit *>(m_lpLowerLimit);
196 
197  //Re-enable the limits once we have initialized the joint
199 
200  m_btJoint = m_btHinge;
201  m_bt6DofJoint = m_btHinge;
202 
203  //Init the current position.
204  m_btHinge->getRotationalLimitMotor(0)->m_currentPosition = 0;
205 
206  //If the motor is enabled then it will start out with a velocity of zero.
208 
209  //Turn off sleeping thresholds for parent and child of hinge joints to prevent the parts from
210  //falling asleep. If it does the joint motor has a tendency to not work.
211  if(m_lpBlParent && m_lpBlParent->Part())
212  {
213  m_lpBlParent->Part()->setSleepingThresholds(0, 0);
214  m_lpBlParent->Part()->setActivationState(DISABLE_DEACTIVATION);
215  }
216 
217  if(m_lpBlChild && m_lpBlChild->Part())
218  {
219  m_lpBlChild->Part()->setSleepingThresholds(0, 0);
220  m_lpBlChild->Part()->setActivationState(DISABLE_DEACTIVATION);
221  }
222 
223  m_btHinge->setJointFeedback(&m_btJointFeedback);
224 
225  Hinge::Initialize();
226  BlJoint::Initialize();
227 
228  m_fltChildMassWithChildren = m_lpChild->MassWithChildren();
229  m_fltChildMassWithChildren *= (m_lpThisAB->GetSimulator()->MassUnits());
230 }
231 
233 {
234  SetupGraphics();
235  SetupPhysics();
236 }
237 
238 #pragma region DataAccesMethods
239 
240 float *BlHinge::GetDataPointer(const std::string &strDataType)
241 {
242  float *lpData=NULL;
243  std::string strType = Std_CheckString(strDataType);
244 
245  if(strType == "JOINTROTATION")
246  return &m_fltPosition;
247  else if(strType == "JOINTPOSITION")
248  return &m_fltPosition;
249  else if(strType == "JOINTACTUALVELOCITY")
250  return &m_fltVelocity;
251  else if(strType == "JOINTFORCE")
252  return &m_fltForce;
253  else if(strType == "JOINTROTATIONDEG")
254  return &m_fltRotationDeg;
255  else if(strType == "JOINTDESIREDPOSITION")
256  return &m_fltReportSetPosition;
257  else if(strType == "JOINTDESIREDPOSITIONDEG")
258  return &m_fltDesiredPositionDeg;
259  else if(strType == "JOINTSETPOSITION")
260  return &m_fltReportSetPosition;
261  else if(strType == "JOINTDESIREDVELOCITY")
262  return &m_fltReportSetVelocity;
263  else if(strType == "JOINTSETVELOCITY")
264  return &m_fltReportSetVelocity;
265  else if(strType == "ENABLE")
266  return &m_fltEnabled;
267  else if(strType == "CONTACTCOUNT")
268  THROW_PARAM_ERROR(Al_Err_lMustBeContactBodyToGetCount, Al_Err_strMustBeContactBodyToGetCount, "JointID", m_strName);
269  else
270  {
271  lpData = BlMotorizedJoint::Physics_GetDataPointer(strType);
272  if(lpData) return lpData;
273 
274  lpData = Hinge::GetDataPointer(strType);
275  if(lpData) return lpData;
276 
277  THROW_TEXT_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType, "JointID: " + STR(m_strName) + " DataType: " + strDataType);
278  }
279 
280  return lpData;
281 }
282 
283 bool BlHinge::SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError)
284 {
285  if(BlJoint::Physics_SetData(strDataType, strValue))
286  return true;
287 
288  if(Hinge::SetData(strDataType, strValue, false))
289  return true;
290 
291  //If it was not one of those above then we have a problem.
292  if(bThrowError)
293  THROW_PARAM_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType, "Data Type", strDataType);
294 
295  return false;
296 }
297 
298 void BlHinge::QueryProperties(CStdPtrArray<TypeProperty> &aryProperties)
299 {
300  BlJoint::Physics_QueryProperties(aryProperties);
301  Hinge::QueryProperties(aryProperties);
302 
303  aryProperties.Add(new TypeProperty("JointRotation", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
304  aryProperties.Add(new TypeProperty("JointPosition", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
305  aryProperties.Add(new TypeProperty("JointActualVelocity", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
306  aryProperties.Add(new TypeProperty("JointForce", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
307  aryProperties.Add(new TypeProperty("JointRotationDeg", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
308  aryProperties.Add(new TypeProperty("JointDesiredPosition", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
309  aryProperties.Add(new TypeProperty("JointDesiredPositionDeg", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
310  aryProperties.Add(new TypeProperty("JointSetPosition", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
311  aryProperties.Add(new TypeProperty("JointDesiredVelocity", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
312  aryProperties.Add(new TypeProperty("JointSetVelocity", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
313  aryProperties.Add(new TypeProperty("Enable", AnimatPropertyType::Boolean, AnimatPropertyDirection::Get));
314 }
315 
316 #pragma endregion
317 
319 {
321  //int iTest = 0;
322  //if(Std_ToLower(m_strID) == "efb767d8-8361-466e-99b8-2f8bf6681243")
323  // iTest = 1;
324 
325  UpdateData();
328 }
329 
330 bool BlHinge::JointIsLocked()
331 {
332  btVector3 vLower, vUpper;
333  m_btHinge->getAngularLowerLimit(vLower);
334  m_btHinge->getAngularUpperLimit(vUpper);
335  if( (vLower[0] == vUpper[0]) || (vLower[0] > vUpper[0]) )
336  return true;
337  else
338  return false;
339 }
340 
341 void BlHinge::Physics_EnableLock(bool bOn, float fltPosition, float fltMaxLockForce)
342 {
343  if (m_btJoint && m_btHinge)
344  {
345  if(bOn)
346  {
347  m_bJointLocked = true;
348 
349  m_vLowerAngular[0] = m_vUpperAngular[0] = fltPosition;
350 
351  m_btHinge->setAngularLowerLimit(m_vLowerAngular);
352  m_btHinge->setAngularUpperLimit(m_vUpperAngular);
353 
354  m_btHinge->enableSpring(3, false);
355  m_btHinge->getRotationalLimitMotor(0)->m_enableMotor = true;
356  m_btHinge->getRotationalLimitMotor(0)->m_targetVelocity = 0;
357  m_btHinge->getRotationalLimitMotor(0)->m_maxMotorForce = fltMaxLockForce;
358  }
359  else if (m_bMotorOn)
360  Physics_EnableMotor(true, 0, fltMaxLockForce, false);
361  else
362  SetLimitValues();
363  }
364 }
365 
366 void BlHinge::Physics_EnableMotor(bool bOn, float fltDesiredVelocity, float fltMaxForce, bool bForceWakeup)
367 {
368  if (m_btJoint && m_btHinge)
369  {
370  if(bOn)
371  {
372  if(!m_bMotorOn || bForceWakeup || m_bJointLocked || JointIsLocked())
373  {
374  m_fltNextPredictedPos = m_lpThisJoint->JointPosition();
375  m_fltPredictedPos = m_fltNextPredictedPos;
376  }
377 
378  //I had to move these statements out of the if above. I kept running into one instance after another where I ran inot a problem if I did not do this every single time.
379  // It is really annoying and inefficient, but I cannot find another way to reiably guarantee that the motor will behave coorectly under all conditions without
380  // doing this every single time I set the motor velocity.
381  SetLimitValues();
382  m_lpThisJoint->WakeDynamics();
383 
384  //NOTE: spring enable MUST be called before enable motor because enable spring turns the motor on/off
385  m_btHinge->enableSpring(3, false);
386  m_btHinge->getRotationalLimitMotor(0)->m_enableMotor = true;
387  m_btHinge->getRotationalLimitMotor(0)->m_targetVelocity = fltDesiredVelocity;
388  m_btHinge->getRotationalLimitMotor(0)->m_maxMotorForce = fltMaxForce;
389  }
390  else
391  {
392  TurnMotorOff();
393 
394  if(m_bMotorOn || bForceWakeup || m_bJointLocked || JointIsLocked())
395  {
396  m_iAssistCountdown = 3;
398  m_lpThisJoint->WakeDynamics();
399  SetLimitValues();
400  }
401  }
402 
403  m_bMotorOn = bOn;
404  }
405 }
406 
407 void BlHinge::Physics_MaxForce(float fltVal)
408 {
409  if(m_btJoint && m_btHinge)
410  m_btHinge->getRotationalLimitMotor(0)->m_maxMotorForce = fltVal;
411 }
412 
413 float BlHinge::GetCurrentBtPosition()
414 {
415  if(m_btJoint && m_btHinge)
416  return m_btHinge->getRotationalLimitMotor(0)->m_currentPosition;
417  else
418  return 0;
419 }
420 
421 void BlHinge::TurnMotorOff()
422 {
423  if(m_btHinge)
424  {
426  {
427  //If we have the spring enabled then use that.
428  m_btHinge->enableSpring(3, true);
429  }
430  else if(m_lpFriction && m_lpFriction->Enabled())
431  {
432  //Otherwise if we have friction enable use it.
433 
434  //0.032 is a coefficient that produces friction behavior in bullet using the same coefficient values
435  //that were specified in vortex engine. This way I get similar behavior between the two.
436  float maxMotorImpulse = m_lpFriction->Coefficient()*0.032f*(m_lpThisAB->GetSimulator()->InverseMassUnits() * m_lpThisAB->GetSimulator()->InverseDistanceUnits());
437  m_btHinge->enableSpring(3, false);
438  m_btHinge->getRotationalLimitMotor(0)->m_enableMotor = true;
439  m_btHinge->getRotationalLimitMotor(0)->m_targetVelocity = 0;
440  m_btHinge->getRotationalLimitMotor(0)->m_maxMotorForce = maxMotorImpulse;
441  }
442  else //Otherwise just turn the motor off
443  {
444  m_btHinge->enableSpring(3, false);
445  m_btHinge->getRotationalLimitMotor(0)->m_enableMotor = false;
446  }
447 
448  m_btHinge->getRotationalLimitMotor(0)->m_accumulatedImpulse = 0;
449  m_btHinge->getRotationalLimitMotor(0)->m_currentLimit = 0;
450  m_btHinge->getRotationalLimitMotor(0)->m_currentLimitError = 0;
451  m_btHinge->getRotationalLimitMotor(0)->m_targetVelocity = 0;
452  }
453 }
454 
455 void BlHinge::AxisConstraintSpringEnableChanged(bool bEnabled)
456 {
457  if(!m_bMotorOn)
458  m_btHinge->enableSpring(3, bEnabled);
459 }
460 
461 void BlHinge::SetConstraintFriction()
462 {
463  if(m_btHinge && !m_bJointLocked && !m_bMotorOn && m_bEnabled)
464  TurnMotorOff();
465 }
466 
468 {
469  Hinge::ResetSimulation();
470 
471  for(int iIdx=0; iIdx<3; iIdx++)
472  {
473  m_btHinge->getRotationalLimitMotor(iIdx)->m_currentPosition = 0;
474  m_btHinge->getRotationalLimitMotor(iIdx)->m_accumulatedImpulse = 0;
475  m_btHinge->getRotationalLimitMotor(iIdx)->m_currentLimit = 0;
476  m_btHinge->getRotationalLimitMotor(iIdx)->m_currentLimitError = 0;
477  m_btHinge->getRotationalLimitMotor(iIdx)->m_targetVelocity = 0;
478  }
479 
480  m_btHinge->getTranslationalLimitMotor()->m_currentLinearDiff = btVector3(0, 0, 0);
481  m_btHinge->getTranslationalLimitMotor()->m_accumulatedImpulse = btVector3(0, 0, 0);
482  m_btHinge->getTranslationalLimitMotor()->m_targetVelocity = btVector3(0, 0, 0);
483  m_btHinge->getTranslationalLimitMotor()->m_currentLimit[0] = 0;
484  m_btHinge->getTranslationalLimitMotor()->m_currentLimit[1] = 0;
485  m_btHinge->getTranslationalLimitMotor()->m_currentLimit[2] = 0;
486  m_btHinge->getTranslationalLimitMotor()->m_currentLimitError = btVector3(0, 0, 0);
487 
488 }
489 
491 {
492  if(m_btHinge) m_btHinge->enableFeedback(true);
493  GetSimulator()->AddToExtractExtraData(m_lpThisJoint);
494 }
495 
496 bool BlHinge::NeedApplyAssist()
497 {
498  //int i = 4;
499  //if(GetSimulator()->Time() >= 1.1)
500  // i=5;
501 
502  if(m_btHinge && m_bMotorOn && m_lpBlParent && m_lpBlChild && m_btParent && m_btChild && m_lpAssistPid && m_lpAssistPid->Enabled())
503  {
504  float fltSetVel = SetVelocity();
505  float fltPos = m_btHinge->getRotationalLimitMotor(0)->m_currentPosition;
506  float fltLow = m_btHinge->getRotationalLimitMotor(0)->m_loLimit;
507  float fltHigh = m_btHinge->getRotationalLimitMotor(0)->m_hiLimit;
508 
509  float fltLow1Perc = fabs(fltLow)*0.001;
510  float fltHigh1Perc = fabs(fltHigh)*0.001;
511 
512  //If we are moving upwards and are not at upper limit then apply force.
513  if(fltSetVel > 0 && fabs(fltHigh-fltPos)>=fltHigh1Perc)
514  return true;
515 
516  //If we are moving downwards and are not at lower limit then apply force.
517  if(fltSetVel < 0 && fabs(fltPos-fltLow)>=fltLow1Perc)
518  return true;
519 
520  //If we get here then we should be applying assist forces, but we are at the limit, so clear the
521  //vectors so we are not actually applying anything.
523  }
524 
525  return false;
526 }
527 
529 {
530  //If the motor is on and moving then give it an assisst if it is not making its velocity goal.
531  if(NeedApplyAssist())
532  {
533  if(m_iAssistCountdown<=0)
534  {
535  float fDisUnits = m_lpThisAB->GetSimulator()->InverseDistanceUnits();
536  float fMassUnits = m_lpThisAB->GetSimulator()->InverseMassUnits();
537  float fltRatio = fMassUnits * fDisUnits;
538 
539  float fltDt = GetSimulator()->PhysicsTimeStep();
540  float fltSetPoint = m_fltPredictedPos;
541  float fltInput = m_lpThisJoint->JointPosition();
542  float fltSetVel = SetVelocity();
543  float fltVelDiffSign = (fltSetVel-m_lpThisJoint->JointVelocity());
544 
545  m_lpAssistPid->Setpoint(fltSetPoint);
546  m_fltMotorAssistMagnitudeReport = fabs(m_lpAssistPid->Calculate(fltDt, fltInput)) * Std_Sign(fltVelDiffSign);
547  float fltForceMag = m_fltMotorAssistMagnitudeReport * m_fltChildMassWithChildren;
548  if(fltForceMag > m_fltMaxForceNotScaled)
549  fltForceMag = m_fltMaxForceNotScaled;
550  if(fltForceMag < -m_fltMaxForceNotScaled)
551  fltForceMag = -m_fltMaxForceNotScaled;
552 
553  btVector3 vbtMotorAxis = m_btHinge->GetAngularForceAxis(0);
554 
555  CStdFPoint vMotorAxis(vbtMotorAxis[0], vbtMotorAxis[1], vbtMotorAxis[2]);
556  CStdFPoint vBodyA = m_lpThisJoint->Parent()->AbsolutePosition();
557  CStdFPoint vBodyB = m_lpThisJoint->Child()->AbsolutePosition();
558  CStdFPoint vHinge = m_lpThisJoint->AbsolutePosition();
559 
560  CStdFPoint vBodyAxisA = (vHinge - vBodyA);
561  vBodyAxisA.Normalize();
562  vBodyAxisA = vMotorAxis ^ vBodyAxisA;
563 
564  CStdFPoint vBodyAxisB = (vHinge - vBodyB);
565  vBodyAxisB.Normalize();
566  vBodyAxisB = vMotorAxis ^ vBodyAxisB;
567 
568  CStdFPoint vBodyAForceReport = vBodyAxisA * -fltForceMag;
569  CStdFPoint vBodyBForceReport = vBodyAxisB * fltForceMag;
570  CStdFPoint vBodyAForce = vBodyAForceReport * fltRatio;
571  CStdFPoint vBodyBForce = vBodyBForceReport * fltRatio;
573 
574  m_vMotorAssistForceToA = vBodyAForce;
575  m_vMotorAssistForceToB = vBodyBForce;
576  m_vMotorAssistForceToAReport = vBodyAForceReport;
577  m_vMotorAssistForceToBReport = vBodyBForceReport;
578 
579  btVector3 vbtMotorAForce(vBodyAForce.x, vBodyAForce.y, vBodyAForce.z);
580  btVector3 vbtMotorBForce(vBodyBForce.x, vBodyBForce.y, vBodyBForce.z);
581 
582  m_btParent->applyCentralForce(vbtMotorAForce);
583  m_btChild->applyCentralForce(vbtMotorBForce);
584  m_iAssistCountdown = 0;
585  }
586  else
588  }
589 }
590 
591  } //Joints
592  } // Environment
593 } //BulletAnimatSim
float CylinderHeight()
Gets the height of the cylinder used to display the hinge in the environment.
Definition: Hinge.cpp:114
virtual void PhysicsTimeStep(float fltVal)
Sets the integration time step for the physics engine.
Definition: Simulator.cpp:1126
virtual void ApplyMotorAssist()
Applies the motor assist.
Definition: BlHinge.cpp:528
float m_fltMaxForceNotScaled
The un=scaled maximum force.
Declares the vortex hinge class.
virtual float LimitPos()
Gets the limit position.
virtual float Restitution()
Gets the restitution coefficient of the constraint.
virtual void StepSimulation()
Step the simulation for this object.
Definition: BlHinge.cpp:318
virtual void Alpha(float fltA)=0
Sets the alpha color value for this constraint.
virtual void CreateJoint()
Creates the joint.
Definition: BlHinge.cpp:232
CStdFPoint m_vMotorAssistForceToAReport
Force vector that the motor assist is applying to body A. (un-scaled units).
float m_fltEnabled
This is used for reporting the enabled state in a GetDataPointer call.
Definition: Node.h:35
virtual float Coefficient()
Gets the Coefficient of friction for this constraint.
PidControl * m_lpAssistPid
The PID controller for the motor assist system.
ConstraintFriction * m_lpFriction
The friction for this joint.
Definition: Joint.h:67
ConstraintLimit * m_lpUpperLimit
Upper limit constring pointer.
Definition: Hinge.h:43
CStdFPoint m_vMotorAssistForceToA
Force vector that the motor assist is applying to body A. (scaled units).
virtual void EnableFeedback()
Enables joint feedback.
Definition: BlHinge.cpp:490
int Std_Sign(float fltVal)
Determines the sign of a number.
virtual Simulator * GetSimulator()
Gets the simulator pointer.
Definition: AnimatBase.cpp:123
virtual void ResetSimulation()
Resets the simulation back to time 0.
Definition: BlHinge.cpp:467
virtual void IsShowPosition(bool bVal)
Sets whether this contstraint is actually just being used to show the current position of the joint...
Classes for implementing the cm-labs vortex physics engine for AnimatLab.
osg::ref_ptr< osg::StateSet > m_osgCylinderSS
The osg cylinder state set.
Definition: OsgHinge.h:48
virtual bool Enabled()
Tells whether this node is enabled.
Definition: Node.cpp:84
float m_fltRotationDeg
The rotation of the hinge in degrees.
Definition: Hinge.h:52
BlConstraintRelaxation * m_aryBlRelaxations[6]
The bullet relaxation for the primary displacement relaxation.
Definition: BlJoint.h:45
float CylinderRadius()
Gets the radius cylinder of the cylinder used to display the hinge in the environment.
Definition: Hinge.cpp:101
float m_fltDesiredPositionDeg
The desired rotation of the hinge in degrees.
Definition: Hinge.h:55
virtual bool EnableMotor()
Tells if the motor is enabled.
CStdFPoint m_vMotorAssistForceToBReport
Force vector that the motor assist is applying to body B. (un-scaled units).
RigidBody * m_lpChild
The child rigid body for this joint.
Definition: Joint.h:44
bool m_bEnableLimits
If true then any ConstraintLimits for this joint are enabled.
Definition: Joint.h:47
CStdFPoint m_vMotorAssistForceToB
Force vector that the motor assist is applying to body B. (scaled units).
ConstraintLimit * m_lpLowerLimit
Lower limit constring pointer.
Definition: Hinge.h:46
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.
float m_fltForce
The current force being applied to the joint by the motor.
Definition: Joint.h:58
virtual bool Enabled()
Tells whether this node is enabled.
Definition: PidControl.cpp:94
btAnimatGeneric6DofConstraint * m_btHinge
The bullet hinge class.
Definition: BlHinge.h:36
bool m_bEnabled
Tells if this item is enabled or not. If it is not enabled then it is not run.
Definition: AnimatBase.h:40
float m_fltReportSetPosition
This is the variable that is reported to AnimatLab on what the set position was.
osg::ref_ptr< osg::Material > m_osgCylinderMat
The osg cylinder material.
Definition: OsgHinge.h:45
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.
ConstraintLimit * m_lpPosFlap
Pointer to a constraint that is used to represent the position flap.
Definition: Hinge.h:49
float m_fltMotorAssistMagnitudeReport
The reportable motor assist Force magnitude.
float m_fltAlpha
The current alpha transparency for this body part.
Definition: MovableItem.h:76
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 JointPosition()
Gets the joint position.
Definition: Joint.cpp:532
virtual void DeleteGraphics()=0
Deletes up the graphics for the constraint.
virtual void Color(float fltR, float fltG, float fltB, float fltA)
Sets the color to use when displaying this contraint.
virtual void IsLowerLimit(bool bVal)
Sets whether this is a lower limit or not..
std::string Std_CheckString(std::string strVal)
Converts a string to upper case and trims it.
float FlapWidth()
Gets the width of the flaps used to display the hinge in the environment.
Definition: Hinge.cpp:127
virtual float SetVelocity()
Gets the velocity that is actually set using the physics method.
virtual void ClearAssistForces()
Clears the assist forces.
virtual void UpdateData()
Called to collect any body data for this part.
Definition: Hinge.cpp:219
virtual bool EnableLimits()
Tells if ConstraintLimits are enabled.
Definition: Joint.cpp:139
float m_fltMotorAssistMagnitude
The motor assist Force magnitude.
ConstraintRelaxation * m_aryRelaxations[6]
The relaxations for the constraints.
Definition: Joint.h:64
std::string m_strName
The name for this object.
Definition: AnimatBase.h:61