Simple Constraint Demonstration

From neuromechanicwiki
Jump to: navigation, search

The constraintdemo.nmcb file demonstrates motion constraints in Neuromechanic. I'll expand and explain this example later. For now, I'm just recording a few notes:

Initial configuration

  • The body file has 14 degrees of freedom (6 DoF for root body, 2 rotational DoFs for all subsequent bodies).
  • 5 of the root DoFs and 1 DoF for each of the other 4 bodies are locked which leaves 5 active DoFs and planar motion.
  • There is a position constraint demanding that the tip of the final rigid body follow a specified position profile on the first rigid body. This position constraint is not initially satisfied.
  • There are no muscles.
  • Restoring viscoelasticity is present in the motion constraint (<PositionErrorGain> and <VelocityErrorGain> are non-zero).

What to do

  1. To observe the effect of restoring viscoelasticity on a position constraint that is not initially satisfied:
    1. Open the file and run a simulation. (Note that the position constraint is not initially satisfied but the restoring viscoelasticity causes the position constraint to eventually be satisfied)
  2. To satisfy the constraint initially:
    1. Close and reopen the file.
    2. Tools->Satisfy Constraints (Shortcut F7)
    3. Run a simulation (Note that the position constraint is satisfied at all times. Drift is corrected through the restoring viscoelasticity)
  3. Try a simulation without restoring viscoelasticity (Set <PositionErrorGain> and <VelocityErrorGain> to zero or delete them). (Reload and run simulation without satisfying constraints)
  4. Change the Parent attribute from "link1" to "ground" to constrain the motion to the inertial frame (Reload and run simulation)
  5. Try unlocking the other degree of freedom in the universal joints and setting at least one to a non-zero initial position. (Reload and run simulation)
  6. Try removing one dimension of the constraint (e.g. to only constrain motion in the y-axis set <ConstraintManifold>0 1 0</ConstraintManifold>). (Reload and run simulation)
  7. Try a Type="Rotation" rather than Type="Translation" constraint". (Reload and run simulation)
  8. You can change from an endpoint motion constraint to a Degree of Freedom constraint by commenting out the active <Constraints> section and uncommenting the other <Constraints> section. There are four constraints which make the model have effectively 1 degree of freedom. see below
  1.     <Constraints>
  2.       <DegreeOfFreedomConstraint Name="link2zconstraint" Type="DoFLock">
  3.         <FunctionReference>line</FunctionReference>
  4.         <DependentDOF>link2z</DependentDOF>
  5.         <IndependentDOF>link1z</IndependentDOF>
  6.         <PositionErrorGain>1.E2</PositionErrorGain>
  7.         <VelocityErrorGain>1.E1</VelocityErrorGain>
  8.       </DegreeOfFreedomConstraint>
  9.       <DegreeOfFreedomConstraint Name="link3zconstraint" Type="DoFLock">
  10.         <FunctionReference>line</FunctionReference>
  11.         <DependentDOF>link3z</DependentDOF>
  12.         <IndependentDOF>link2z</IndependentDOF>
  13.         <PositionErrorGain>1.E2</PositionErrorGain>
  14.         <VelocityErrorGain>1.E1</VelocityErrorGain>
  15.       </DegreeOfFreedomConstraint>
  16.       <DegreeOfFreedomConstraint Name="link4zconstraint" Type="DoFLock">
  17.         <FunctionReference>line</FunctionReference>
  18.         <DependentDOF>link4z</DependentDOF>
  19.         <IndependentDOF>link3z</IndependentDOF>
  20.         <PositionErrorGain>1.E2</PositionErrorGain>
  21.         <VelocityErrorGain>1.E1</VelocityErrorGain>
  22.       </DegreeOfFreedomConstraint>
  23.       <DegreeOfFreedomConstraint Name="link5zconstraint" Type="DoFLock">
  24.         <FunctionReference>line</FunctionReference>
  25.         <DependentDOF>link5z</DependentDOF>
  26.         <IndependentDOF>link4z</IndependentDOF>
  27.         <PositionErrorGain>1.E2</PositionErrorGain>
  28.         <VelocityErrorGain>1.E1</VelocityErrorGain>
  29.       </DegreeOfFreedomConstraint>
  30.     </Constraints>