DART  6.6.2
GenericJoint.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2018, The DART development contributors
3  * All rights reserved.
4  *
5  * The list of contributors can be found at:
6  * https://github.com/dartsim/dart/blob/master/LICENSE
7  *
8  * This file is provided under the following "BSD-style" License:
9  * Redistribution and use in source and binary forms, with or
10  * without modification, are permitted provided that the following
11  * conditions are met:
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/or other materials provided
17  * with the distribution.
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
19  * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
26  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef DART_DYNAMICS_DETAIL_GenericJoint_HPP_
34 #define DART_DYNAMICS_DETAIL_GenericJoint_HPP_
35 
37 
38 #include "dart/config.hpp"
39 #include "dart/math/Helpers.hpp"
43 
44 #define GenericJoint_REPORT_DIM_MISMATCH( func, arg )\
45  {\
46  dterr << "[GenericJoint::" #func "] Mismatch beteween size of "\
47  << #arg " [" << arg .size() << "] and the number of "\
48  << "DOFs [" << getNumDofs() << "] for Joint named ["\
49  << this->getName() << "].\n";\
50  assert(false);\
51  }
52 
53 #define GenericJoint_REPORT_OUT_OF_RANGE( func, index )\
54  {\
55  dterr << "[GenericJoint::" << #func << "] The index [" << index\
56  << "] is out of range for Joint named [" << this->getName()\
57  << "] which has " << this->getNumDofs() << " DOFs.\n";\
58  assert(false);\
59  }
60 
61 #define GenericJoint_REPORT_UNSUPPORTED_ACTUATOR( func )\
62  {\
63  dterr << "[GenericJoint::" # func "] Unsupported actuator type ("\
64  << Joint::mAspectProperties.mActuatorType << ") for Joint ["\
65  << this->getName() << "].\n";\
66  assert(false);\
67  }
68 
69 #define GenericJoint_SET_IF_DIFFERENT( mField, value )\
70  if( value == Base::mAspectProperties. mField )\
71  return;\
72  Base::mAspectProperties. mField = value;\
73  Joint::incrementVersion();
74 
75 namespace dart {
76 namespace dynamics {
77 
78 //==============================================================================
79 //
80 // These namespace-level definitions are required to enable ODR-use of static
81 // constexpr member variables.
82 //
83 // See this StackOverflow answer: http://stackoverflow.com/a/14396189/111426
84 //
85 template <class ConfigSpaceT>
87 
88 //==============================================================================
89 template <class ConfigSpaceT>
91 {
92  for (auto i = 0u; i < NumDofs; ++i)
93  delete mDofs[i];
94 }
95 
96 //==============================================================================
97 template <class ConfigSpaceT>
99 {
100  Joint::setProperties(static_cast<const Joint::Properties&>(properties));
101  setProperties(static_cast<const UniqueProperties&>(properties));
102 }
103 
104 //==============================================================================
105 template <class ConfigSpaceT>
108 {
109  setAspectProperties(properties);
110 }
111 
112 //==============================================================================
113 template <class ConfigSpaceT>
115 {
116  setCommands(state.mCommands);
117  setPositionsStatic(state.mPositions);
118  setVelocitiesStatic(state.mVelocities);
119  setAccelerationsStatic(state.mAccelerations);
120  setForces(state.mForces);
121 }
122 
123 //==============================================================================
124 template <class ConfigSpaceT>
127 {
128  for (auto i = 0u; i < NumDofs; ++i)
129  {
130  setDofName(i, properties.mDofNames[i], properties.mPreserveDofNames[i]);
131  setPositionLowerLimit (i, properties.mPositionLowerLimits[i] );
132  setPositionUpperLimit (i, properties.mPositionUpperLimits[i] );
133  setInitialPosition (i, properties.mInitialPositions[i] );
134  setVelocityLowerLimit (i, properties.mVelocityLowerLimits[i] );
135  setVelocityUpperLimit (i, properties.mVelocityUpperLimits[i] );
136  setInitialVelocity (i, properties.mInitialVelocities[i] );
137  setAccelerationLowerLimit(i, properties.mAccelerationLowerLimits[i]);
138  setAccelerationUpperLimit(i, properties.mAccelerationUpperLimits[i]);
139  setForceLowerLimit (i, properties.mForceLowerLimits[i] );
140  setForceUpperLimit (i, properties.mForceUpperLimits[i] );
141  setSpringStiffness (i, properties.mSpringStiffnesses[i] );
142  setRestPosition (i, properties.mRestPositions[i] );
143  setDampingCoefficient (i, properties.mDampingCoefficients[i] );
144  setCoulombFriction (i, properties.mFrictions[i] );
145  }
146 }
147 
148 //==============================================================================
149 template <class ConfigSpaceT>
152 {
154  Joint::mAspectProperties, Base::mAspectProperties);
155 }
156 
157 //==============================================================================
158 template <class ConfigSpaceT>
160  const GenericJoint<ConfigSpaceT>& other)
161 {
162  if (this == &other)
163  return;
164 
165  setProperties(other.getGenericJointProperties());
166 }
167 
168 //==============================================================================
169 template <class ConfigSpaceT>
171  const GenericJoint<ConfigSpaceT>* other)
172 {
173  if (nullptr == other)
174  return;
175 
176  copy(*other);
177 }
178 
179 //==============================================================================
180 template <class ConfigSpaceT>
183  const GenericJoint<ConfigSpaceT>& other)
184 {
185  copy(other);
186  return *this;
187 }
188 
189 //==============================================================================
190 template <class ConfigSpaceT>
192 {
193  if (index < NumDofs)
194  return mDofs[index];
195 
197 
198  return nullptr;
199 }
200 
201 //==============================================================================
202 template <class ConfigSpaceT>
204 {
205  if (index < NumDofs)
206  return mDofs[index];
207 
209 
210  return nullptr;
211 }
212 
213 //==============================================================================
214 template <class ConfigSpaceT>
216 {
217  return NumDofs;
218 }
219 
220 //==============================================================================
221 template <class ConfigSpaceT>
223  size_t index,
224  const std::string& name,
225  bool preserveName)
226 {
227  if (NumDofs <= index)
228  {
229  dterr << "[GenericJoint::setDofName] Attempting to set the name of DOF "
230  << "index " << index << ", which is out of bounds for the Joint ["
231  << this->getName()
232  << "]. We will set the name of DOF index 0 instead.\n";
233  assert(false);
234  index = 0u;
235  }
236 
237  preserveDofName(index, preserveName);
238 
239  std::string& dofName = Base::mAspectProperties.mDofNames[index];
240 
241  if (name == dofName)
242  return dofName;
243 
244  const SkeletonPtr& skel
245  = this->mChildBodyNode ? this->mChildBodyNode->getSkeleton() : nullptr;
246  if (skel)
247  dofName = skel->mNameMgrForDofs.changeObjectName(mDofs[index], name);
248  else
249  dofName = name;
250 
251  return dofName;
252 }
253 
254 //==============================================================================
255 template <class ConfigSpaceT>
257 {
258  if (NumDofs <= index)
259  {
261  return;
262  }
263 
264  GenericJoint_SET_IF_DIFFERENT( mPreserveDofNames[index], preserve );
265 }
266 
267 //==============================================================================
268 template <class ConfigSpaceT>
270 {
271  if(NumDofs <= index)
272  {
273  GenericJoint_REPORT_OUT_OF_RANGE(isDofNamePreserved, index);
274  index = 0;
275  }
276 
277  return Base::mAspectProperties.mPreserveDofNames[index];
278 }
279 
280 //==============================================================================
281 template <class ConfigSpaceT>
282 const std::string& GenericJoint<ConfigSpaceT>::getDofName(size_t index) const
283 {
284  if(NumDofs <= index)
285  {
286  dterr << "[GenericJoint::getDofName] Requested name of DOF index ["
287  << index << "] in Joint [" << this->getName() << "], but that is "
288  << "out of bounds (max " << NumDofs - 1
289  << "). Returning name of DOF 0.\n";
290  assert(false);
291  return Base::mAspectProperties.mDofNames[0];
292  }
293 
294  return Base::mAspectProperties.mDofNames[index];
295 }
296 
297 //==============================================================================
298 template <class ConfigSpaceT>
299 size_t
301 {
302  if (index >= getNumDofs())
303  {
304  GenericJoint_REPORT_OUT_OF_RANGE(getIndexInSkeleton, index);
305  return 0;
306  }
307 
308  return mDofs[index]->mIndexInSkeleton;
309 }
310 
311 //==============================================================================
312 template <class ConfigSpaceT>
314 {
315  if (index >= getNumDofs())
316  {
318  return 0;
319  }
320 
321  return mDofs[index]->mIndexInTree;
322 }
323 
324 //==============================================================================
325 template <class ConfigSpaceT>
326 void GenericJoint<ConfigSpaceT>::setCommand(size_t index, double command)
327 {
328  if (index >= getNumDofs())
330 
331  switch (Joint::mAspectProperties.mActuatorType)
332  {
333  case Joint::FORCE:
334  this->mAspectState.mCommands[index] = math::clip(command,
335  Base::mAspectProperties.mForceLowerLimits[index],
336  Base::mAspectProperties.mForceUpperLimits[index]);
337  break;
339  if (0.0 != command)
340  {
341  dtwarn << "[GenericJoint::setCommand] Attempting to set a non-zero ("
342  << command << ") command for a PASSIVE joint ["
343  << this->getName() << "].\n";
344  }
345  this->mAspectState.mCommands[index] = command;
346  break;
348  this->mAspectState.mCommands[index] = math::clip(command,
349  Base::mAspectProperties.mVelocityLowerLimits[index],
350  Base::mAspectProperties.mVelocityUpperLimits[index]);
351  break;
352  case Joint::ACCELERATION:
353  this->mAspectState.mCommands[index] = math::clip(command,
354  Base::mAspectProperties.mAccelerationLowerLimits[index],
355  Base::mAspectProperties.mAccelerationUpperLimits[index]);
356  break;
357  case Joint::VELOCITY:
358  this->mAspectState.mCommands[index] = math::clip(command,
359  Base::mAspectProperties.mVelocityLowerLimits[index],
360  Base::mAspectProperties.mVelocityUpperLimits[index]);
361  // TODO: This possibly makes the acceleration to exceed the limits.
362  break;
363  case Joint::LOCKED:
364  if (0.0 != command)
365  {
366  dtwarn << "[GenericJoint::setCommand] Attempting to set a non-zero ("
367  << command << ") command for a LOCKED joint [" << this->getName()
368  << "].\n";
369  }
370  this->mAspectState.mCommands[index] = command;
371  break;
372  default:
373  assert(false);
374  break;
375  }
376 }
377 
378 //==============================================================================
379 template <class ConfigSpaceT>
381 {
382  if (index >= getNumDofs())
383  {
385  return 0.0;
386  }
387 
388  return this->mAspectState.mCommands[index];
389 }
390 
391 //==============================================================================
392 template <class ConfigSpaceT>
394  const Eigen::VectorXd& commands)
395 {
396  if (static_cast<size_t>(commands.size()) != getNumDofs())
397  {
398  GenericJoint_REPORT_DIM_MISMATCH(setCommands, commands);
399  return;
400  }
401 
402  switch (Joint::mAspectProperties.mActuatorType)
403  {
405  this->mAspectState.mCommands = math::clip(commands,
406  Base::mAspectProperties.mForceLowerLimits,
407  Base::mAspectProperties.mForceUpperLimits);
408  break;
409  case Joint::PASSIVE:
410  if(Vector::Zero() != commands)
411  {
412  dtwarn << "[GenericJoint::setCommands] Attempting to set a non-zero ("
413  << commands.transpose() << ") command for a PASSIVE joint ["
414  << this->getName() << "].\n";
415  }
416  this->mAspectState.mCommands = commands;
417  break;
418  case Joint::SERVO:
419  this->mAspectState.mCommands = math::clip(commands,
420  Base::mAspectProperties.mVelocityLowerLimits,
421  Base::mAspectProperties.mVelocityUpperLimits);
422  break;
423  case Joint::ACCELERATION:
424  this->mAspectState.mCommands = math::clip(commands,
425  Base::mAspectProperties.mAccelerationLowerLimits,
426  Base::mAspectProperties.mAccelerationUpperLimits);
427  break;
428  case Joint::VELOCITY:
429  this->mAspectState.mCommands = math::clip(commands,
430  Base::mAspectProperties.mVelocityLowerLimits,
431  Base::mAspectProperties.mVelocityUpperLimits);
432  // TODO: This possibly makes the acceleration to exceed the limits.
433  break;
435  if(Vector::Zero() != commands)
436  {
437  dtwarn << "[GenericJoint::setCommands] Attempting to set a non-zero ("
438  << commands.transpose() << ") command for a LOCKED joint ["
439  << this->getName() << "].\n";
440  }
441  this->mAspectState.mCommands = commands;
442  break;
443  default:
444  assert(false);
445  break;
446  }
447 }
448 
449 //==============================================================================
450 template <class ConfigSpaceT>
452 {
453  return this->mAspectState.mCommands;
454 }
455 
456 //==============================================================================
457 template <class ConfigSpaceT>
459 {
460  this->mAspectState.mCommands.setZero();
461 }
462 
463 //==============================================================================
464 template <class ConfigSpaceT>
466 {
467  if (index >= getNumDofs())
468  {
470  return;
471  }
472 
473  if (this->mAspectState.mPositions[index] == position)
474  return;
475  // TODO(JS): Above code should be changed something like:
476 // if (ConfigSpaceT::getEuclideanPoint(mPositions, index) == position)
477 // return;
478 
479  // Note: It would not make much sense to use setPositionsStatic() here
480  this->mAspectState.mPositions[index] = position;
481  this->notifyPositionUpdated();
482 }
483 
484 //==============================================================================
485 template <class ConfigSpaceT>
487 {
488  if (index >= getNumDofs())
489  {
491  return 0.0;
492  }
493 
494  return getPositionsStatic()[index];
495 }
496 
497 //==============================================================================
498 template <class ConfigSpaceT>
500  const Eigen::VectorXd& positions)
501 {
502  if (static_cast<size_t>(positions.size()) != getNumDofs())
503  {
504  GenericJoint_REPORT_DIM_MISMATCH(setPositions, positions);
505  return;
506  }
507 
508  setPositionsStatic(positions);
509 }
510 
511 //==============================================================================
512 template <class ConfigSpaceT>
514 {
515  return getPositionsStatic();
516 }
517 
518 //==============================================================================
519 template <class ConfigSpaceT>
521  size_t index, double position)
522 {
523  if (index >= getNumDofs())
524  {
525  GenericJoint_REPORT_OUT_OF_RANGE(setPositionLowerLimit, index);
526  return;
527  }
528 
529  GenericJoint_SET_IF_DIFFERENT( mPositionLowerLimits[index], position );
530 }
531 
532 //==============================================================================
533 template <class ConfigSpaceT>
535 {
536  if (index >= getNumDofs())
537  {
538  GenericJoint_REPORT_OUT_OF_RANGE(getPositionLowerLimit, index);
539  return 0.0;
540  }
541 
542  return Base::mAspectProperties.mPositionLowerLimits[index];
543 }
544 
545 //==============================================================================
546 template<class ConfigSpaceT>
548  const Eigen::VectorXd& lowerLimits)
549 {
550  if (static_cast<size_t>(lowerLimits.size()) != getNumDofs())
551  {
552  GenericJoint_REPORT_DIM_MISMATCH(setPositionLowerLimits, lowerLimits);
553  return;
554  }
555 
556  GenericJoint_SET_IF_DIFFERENT(mPositionLowerLimits, lowerLimits);
557 }
558 
559 //==============================================================================
560 template<class ConfigSpaceT>
562 {
563  return Base::mAspectProperties.mPositionLowerLimits;
564 }
565 
566 //==============================================================================
567 template <class ConfigSpaceT>
569  double position)
570 {
571  if (index >= getNumDofs())
572  {
573  GenericJoint_REPORT_OUT_OF_RANGE(setPositionUpperLimit, index);
574  return;
575  }
576 
577  GenericJoint_SET_IF_DIFFERENT( mPositionUpperLimits[index], position );
578 }
579 
580 //==============================================================================
581 template <class ConfigSpaceT>
583 {
584  if (index >= getNumDofs())
585  {
586  GenericJoint_REPORT_OUT_OF_RANGE(getPositionUpperLimit, index);
587  return 0.0;
588  }
589 
590  return Base::mAspectProperties.mPositionUpperLimits[index];
591 }
592 
593 //==============================================================================
594 template<class ConfigSpaceT>
596  const Eigen::VectorXd& upperLimits)
597 {
598  if (static_cast<size_t>(upperLimits.size()) != getNumDofs())
599  {
600  GenericJoint_REPORT_DIM_MISMATCH(setPositionUpperLimits, upperLimits);
601  return;
602  }
603 
604  GenericJoint_SET_IF_DIFFERENT(mPositionUpperLimits, upperLimits);
605 }
606 
607 //==============================================================================
608 template<class ConfigSpaceT>
610 {
611  return Base::mAspectProperties.mPositionUpperLimits;
612 }
613 
614 //==============================================================================
615 template <class ConfigSpaceT>
617 {
618  if (index >= getNumDofs())
619  {
620  GenericJoint_REPORT_OUT_OF_RANGE(hasPositionLimit, index);
621  return true;
622  }
623 
624  return std::isfinite(Base::mAspectProperties.mPositionUpperLimits[index])
625  || std::isfinite(Base::mAspectProperties.mPositionLowerLimits[index]);
626 }
627 
628 //==============================================================================
629 template <class ConfigSpaceT>
631 {
632  if (index >= getNumDofs())
633  {
634  GenericJoint_REPORT_OUT_OF_RANGE(resetPosition, index);
635  return;
636  }
637 
638  setPosition(index, Base::mAspectProperties.mInitialPositions[index]);
639 }
640 
641 //==============================================================================
642 template <class ConfigSpaceT>
644 {
645  setPositionsStatic(Base::mAspectProperties.mInitialPositions);
646 }
647 
648 //==============================================================================
649 template <class ConfigSpaceT>
651  size_t index, double initial)
652 {
653  if (index >= getNumDofs())
654  {
655  GenericJoint_REPORT_OUT_OF_RANGE(setInitialPosition, index);
656  return;
657  }
658 
659  GenericJoint_SET_IF_DIFFERENT( mInitialPositions[index], initial );
660 }
661 
662 //==============================================================================
663 template <class ConfigSpaceT>
665 {
666  if (index >= getNumDofs())
667  {
668  GenericJoint_REPORT_OUT_OF_RANGE(getInitialPosition, index);
669  return 0.0;
670  }
671 
672  return Base::mAspectProperties.mInitialPositions[index];
673 }
674 
675 //==============================================================================
676 template <class ConfigSpaceT>
678  const Eigen::VectorXd& initial)
679 {
680  if ( static_cast<size_t>(initial.size()) != getNumDofs() )
681  {
682  GenericJoint_REPORT_DIM_MISMATCH(setInitialPositions, initial);
683  return;
684  }
685 
686  GenericJoint_SET_IF_DIFFERENT( mInitialPositions, initial);
687 }
688 
689 //==============================================================================
690 template <class ConfigSpaceT>
692 {
693  return Base::mAspectProperties.mInitialPositions;
694 }
695 
696 //==============================================================================
697 template <class ConfigSpaceT>
699 {
700  if (this->mAspectState.mPositions == positions)
701  return;
702 
703  this->mAspectState.mPositions = positions;
704  this->notifyPositionUpdated();
705 }
706 
707 //==============================================================================
708 template <class ConfigSpaceT>
711 {
712  return this->mAspectState.mPositions;
713 }
714 
715 //==============================================================================
716 template <class ConfigSpaceT>
718  const Vector& velocities)
719 {
720  if (this->mAspectState.mVelocities == velocities)
721  return;
722 
723  this->mAspectState.mVelocities = velocities;
724  this->notifyVelocityUpdated();
725 }
726 
727 //==============================================================================
728 template <class ConfigSpaceT>
731 {
732  return this->mAspectState.mVelocities;
733 }
734 
735 //==============================================================================
736 template <class ConfigSpaceT>
738 {
739  if (this->mAspectState.mAccelerations == accels)
740  return;
741 
742  this->mAspectState.mAccelerations = accels;
743  this->notifyAccelerationUpdated();
744 }
745 
746 //==============================================================================
747 template <class ConfigSpaceT>
750 {
751  return this->mAspectState.mAccelerations;
752 }
753 
754 //==============================================================================
755 template <class ConfigSpaceT>
757 {
758  if (index >= getNumDofs())
759  {
761  return;
762  }
763 
764  if (this->mAspectState.mVelocities[index] == velocity)
765  return;
766 
767  // Note: It would not make much sense to use setVelocitiesStatic() here
768  this->mAspectState.mVelocities[index] = velocity;
769  this->notifyVelocityUpdated();
770 
771  if (Joint::mAspectProperties.mActuatorType == Joint::VELOCITY)
772  this->mAspectState.mCommands[index] = this->getVelocitiesStatic()[index];
773 }
774 
775 //==============================================================================
776 template <class ConfigSpaceT>
778 {
779  if (index >= getNumDofs())
780  {
782  return 0.0;
783  }
784 
785  return getVelocitiesStatic()[index];
786 }
787 
788 //==============================================================================
789 template <class ConfigSpaceT>
791  const Eigen::VectorXd& velocities)
792 {
793  if (static_cast<size_t>(velocities.size()) != getNumDofs())
794  {
795  GenericJoint_REPORT_DIM_MISMATCH(setVelocities, velocities);
796  return;
797  }
798 
799  setVelocitiesStatic(velocities);
800 
801  if (Joint::mAspectProperties.mActuatorType == Joint::VELOCITY)
802  this->mAspectState.mCommands = this->getVelocitiesStatic();
803 }
804 
805 //==============================================================================
806 template <class ConfigSpaceT>
808 {
809  return getVelocitiesStatic();
810 }
811 
812 //==============================================================================
813 template <class ConfigSpaceT>
815  double velocity)
816 {
817  if (index >= getNumDofs())
818  {
819  GenericJoint_REPORT_OUT_OF_RANGE(setVelocityLowerLimit, index);
820  return;
821  }
822 
823  GenericJoint_SET_IF_DIFFERENT( mVelocityLowerLimits[index], velocity );
824 }
825 
826 //==============================================================================
827 template <class ConfigSpaceT>
829 {
830  if (index >= getNumDofs())
831  {
832  GenericJoint_REPORT_OUT_OF_RANGE(getVelocityLowerLimit, index);
833  return 0.0;
834  }
835 
836  return Base::mAspectProperties.mVelocityLowerLimits[index];
837 }
838 
839 //==============================================================================
840 template<class ConfigSpaceT>
842  const Eigen::VectorXd& lowerLimits)
843 {
844  if (static_cast<size_t>(lowerLimits.size()) != getNumDofs())
845  {
846  GenericJoint_REPORT_DIM_MISMATCH(setVelocityLowerLimits, lowerLimits);
847  return;
848  }
849 
850  GenericJoint_SET_IF_DIFFERENT(mVelocityLowerLimits, lowerLimits);
851 }
852 
853 //==============================================================================
854 template<class ConfigSpaceT>
856 {
857  return Base::mAspectProperties.mVelocityLowerLimits;
858 }
859 
860 //==============================================================================
861 template <class ConfigSpaceT>
863  double velocity)
864 {
865  if (index >= getNumDofs())
866  {
867  GenericJoint_REPORT_OUT_OF_RANGE(setVelocityUpperLimit, index);
868  return;
869  }
870 
871  GenericJoint_SET_IF_DIFFERENT( mVelocityUpperLimits[index], velocity );
872 }
873 
874 //==============================================================================
875 template <class ConfigSpaceT>
877  size_t index) const
878 {
879  if (index >= getNumDofs())
880  {
881  GenericJoint_REPORT_OUT_OF_RANGE(getVelocityUpperLimit, index);
882  return 0.0;
883  }
884 
885  return Base::mAspectProperties.mVelocityUpperLimits[index];
886 }
887 
888 //==============================================================================
889 template<class ConfigSpaceT>
891  const Eigen::VectorXd& upperLimits)
892 {
893  if (static_cast<size_t>(upperLimits.size()) != getNumDofs())
894  {
895  GenericJoint_REPORT_DIM_MISMATCH(setVelocityUpperLimits, upperLimits);
896  return;
897  }
898 
899  GenericJoint_SET_IF_DIFFERENT(mVelocityUpperLimits, upperLimits);
900 }
901 
902 //==============================================================================
903 template<class ConfigSpaceT>
905 {
906  return Base::mAspectProperties.mVelocityUpperLimits;
907 }
908 
909 //==============================================================================
910 template <class ConfigSpaceT>
912 {
913  if (index >= getNumDofs())
914  {
915  GenericJoint_REPORT_OUT_OF_RANGE(resetVelocity, index);
916  return;
917  }
918 
919  setVelocity(index, Base::mAspectProperties.mInitialVelocities[index]);
920 }
921 
922 //==============================================================================
923 template <class ConfigSpaceT>
925 {
926  setVelocitiesStatic(Base::mAspectProperties.mInitialVelocities);
927 }
928 
929 //==============================================================================
930 template <class ConfigSpaceT>
932  double initial)
933 {
934  if (index >= getNumDofs())
935  {
936  GenericJoint_REPORT_OUT_OF_RANGE(setInitialVelocity, index);
937  return;
938  }
939 
940  GenericJoint_SET_IF_DIFFERENT( mInitialVelocities[index], initial );
941 }
942 
943 //==============================================================================
944 template <class ConfigSpaceT>
946 {
947  if (index >= getNumDofs())
948  {
949  GenericJoint_REPORT_OUT_OF_RANGE(getInitialVelocity, index);
950  return 0.0;
951  }
952 
953  return Base::mAspectProperties.mInitialVelocities[index];
954 }
955 
956 //==============================================================================
957 template <class ConfigSpaceT>
959  const Eigen::VectorXd& initial)
960 {
961  if ( static_cast<size_t>(initial.size()) != getNumDofs() )
962  {
963  GenericJoint_REPORT_DIM_MISMATCH( setInitialVelocities, initial );
964  return;
965  }
966 
967  GenericJoint_SET_IF_DIFFERENT( mInitialVelocities, initial );
968 }
969 
970 //==============================================================================
971 template <class ConfigSpaceT>
973 {
974  return Base::mAspectProperties.mInitialVelocities;
975 }
976 
977 //==============================================================================
978 template <class ConfigSpaceT>
980  size_t index, double acceleration)
981 {
982  if (index >= getNumDofs())
983  {
984  GenericJoint_REPORT_OUT_OF_RANGE( setAcceleration, index );
985  return;
986  }
987 
988  if(this->mAspectState.mAccelerations[index] == acceleration)
989  return;
990 
991  // Note: It would not make much sense to use setAccelerationsStatic() here
992  this->mAspectState.mAccelerations[index] = acceleration;
993  this->notifyAccelerationUpdated();
994 
995  if (Joint::mAspectProperties.mActuatorType == Joint::ACCELERATION)
996  this->mAspectState.mCommands[index] = this->getAccelerationsStatic()[index];
997 }
998 
999 //==============================================================================
1000 template <class ConfigSpaceT>
1002 {
1003  if (index >= getNumDofs())
1004  {
1005  GenericJoint_REPORT_OUT_OF_RANGE(getAcceleration, index);
1006  return 0.0;
1007  }
1008 
1009  return getAccelerationsStatic()[index];
1010 }
1011 
1012 //==============================================================================
1013 template <class ConfigSpaceT>
1015  const Eigen::VectorXd& accelerations)
1016 {
1017  if (static_cast<size_t>(accelerations.size()) != getNumDofs())
1018  {
1019  GenericJoint_REPORT_DIM_MISMATCH( setAccelerations, accelerations );
1020  return;
1021  }
1022 
1023  setAccelerationsStatic(accelerations);
1024 
1025  if (Joint::mAspectProperties.mActuatorType == Joint::ACCELERATION)
1026  this->mAspectState.mCommands = this->getAccelerationsStatic();
1027 }
1028 
1029 //==============================================================================
1030 template <class ConfigSpaceT>
1032 {
1033  return getAccelerationsStatic();
1034 }
1035 
1036 //==============================================================================
1037 template <class ConfigSpaceT>
1039  size_t index, double acceleration)
1040 {
1041  if (index >= getNumDofs())
1042  {
1043  GenericJoint_REPORT_OUT_OF_RANGE(setAccelerationLowerLimit, index);
1044  return;
1045  }
1046 
1047  GenericJoint_SET_IF_DIFFERENT( mAccelerationLowerLimits[index],
1048  acceleration );
1049 }
1050 
1051 //==============================================================================
1052 template <class ConfigSpaceT>
1054  size_t index) const
1055 {
1056  if (index >= getNumDofs())
1057  {
1058  GenericJoint_REPORT_OUT_OF_RANGE(getAccelerationLowerLimit, index);
1059  return 0.0;
1060  }
1061 
1062  return Base::mAspectProperties.mAccelerationLowerLimits[index];
1063 }
1064 
1065 //==============================================================================
1066 template<class ConfigSpaceT>
1068  const Eigen::VectorXd& lowerLimits)
1069 {
1070  if (static_cast<size_t>(lowerLimits.size()) != getNumDofs())
1071  {
1072  GenericJoint_REPORT_DIM_MISMATCH(setAccelerationLowerLimits, lowerLimits);
1073  return;
1074  }
1075 
1076  GenericJoint_SET_IF_DIFFERENT(mAccelerationLowerLimits, lowerLimits);
1077 }
1078 
1079 //==============================================================================
1080 template<class ConfigSpaceT>
1082 {
1083  return Base::mAspectProperties.mAccelerationLowerLimits;
1084 }
1085 
1086 //==============================================================================
1087 template <class ConfigSpaceT>
1089  size_t index, double acceleration)
1090 {
1091  if (index >= getNumDofs())
1092  {
1093  GenericJoint_REPORT_OUT_OF_RANGE(setAccelerationUpperLimit, index)
1094  return;
1095  }
1096 
1097  GenericJoint_SET_IF_DIFFERENT( mAccelerationUpperLimits[index],
1098  acceleration);
1099 }
1100 
1101 //==============================================================================
1102 template <class ConfigSpaceT>
1104  size_t index) const
1105 {
1106  if (index >= getNumDofs())
1107  {
1108  GenericJoint_REPORT_OUT_OF_RANGE(getAccelerationUpperLimit, index);
1109  return 0.0;
1110  }
1111 
1112  return Base::mAspectProperties.mAccelerationUpperLimits[index];
1113 }
1114 
1115 //==============================================================================
1116 template<class ConfigSpaceT>
1118  const Eigen::VectorXd& upperLimits)
1119 {
1120  if (static_cast<size_t>(upperLimits.size()) != getNumDofs())
1121  {
1122  GenericJoint_REPORT_DIM_MISMATCH(setAccelerationUpperLimits, upperLimits);
1123  return;
1124  }
1125 
1126  GenericJoint_SET_IF_DIFFERENT(mAccelerationUpperLimits, upperLimits);
1127 }
1128 
1129 //==============================================================================
1130 template<class ConfigSpaceT>
1132 {
1133  return Base::mAspectProperties.mAccelerationUpperLimits;
1134 }
1135 
1136 //==============================================================================
1137 template <class ConfigSpaceT>
1139 {
1140  setAccelerationsStatic(Vector::Zero());
1141 }
1142 
1143 //==============================================================================
1144 template <class ConfigSpaceT>
1146 {
1147  if (index >= getNumDofs())
1148  {
1150  return;
1151  }
1152 
1153  this->mAspectState.mForces[index] = force;
1154 
1155  if (Joint::mAspectProperties.mActuatorType == Joint::FORCE)
1156  this->mAspectState.mCommands[index] = this->mAspectState.mForces[index];
1157 }
1158 
1159 //==============================================================================
1160 template <class ConfigSpaceT>
1162 {
1163  if (index >= getNumDofs())
1164  {
1166  return 0.0;
1167  }
1168 
1169  return this->mAspectState.mForces[index];
1170 }
1171 
1172 //==============================================================================
1173 template <class ConfigSpaceT>
1174 void GenericJoint<ConfigSpaceT>::setForces(const Eigen::VectorXd& forces)
1175 {
1176  if (static_cast<size_t>(forces.size()) != getNumDofs())
1177  {
1178  GenericJoint_REPORT_DIM_MISMATCH(setForces, forces);
1179  return;
1180  }
1181 
1182  this->mAspectState.mForces = forces;
1183 
1184  if (Joint::mAspectProperties.mActuatorType == Joint::FORCE)
1185  this->mAspectState.mCommands = this->mAspectState.mForces;
1186 }
1187 
1188 //==============================================================================
1189 template <class ConfigSpaceT>
1191 {
1192  return this->mAspectState.mForces;
1193 }
1194 
1195 //==============================================================================
1196 template <class ConfigSpaceT>
1198 {
1199  if (index >= getNumDofs())
1200  {
1201  GenericJoint_REPORT_OUT_OF_RANGE(setForceLowerLimit, index);
1202  return;
1203  }
1204 
1205  GenericJoint_SET_IF_DIFFERENT( mForceLowerLimits[index], force );
1206 }
1207 
1208 //==============================================================================
1209 template <class ConfigSpaceT>
1211  size_t index) const
1212 {
1213  if (index >= getNumDofs())
1214  {
1215  GenericJoint_REPORT_OUT_OF_RANGE(getForceLowerLimit, index);
1216  return 0.0;
1217  }
1218 
1219  return Base::mAspectProperties.mForceLowerLimits[index];
1220 }
1221 
1222 //==============================================================================
1223 template<class ConfigSpaceT>
1225  const Eigen::VectorXd& lowerLimits)
1226 {
1227  if (static_cast<size_t>(lowerLimits.size()) != getNumDofs())
1228  {
1229  GenericJoint_REPORT_DIM_MISMATCH(setForceLowerLimits, lowerLimits);
1230  return;
1231  }
1232 
1233  GenericJoint_SET_IF_DIFFERENT(mForceLowerLimits, lowerLimits);
1234 }
1235 
1236 //==============================================================================
1237 template<class ConfigSpaceT>
1239 {
1240  return Base::mAspectProperties.mForceLowerLimits;
1241 }
1242 
1243 //==============================================================================
1244 template <class ConfigSpaceT>
1246 {
1247  if (index >= getNumDofs())
1248  {
1249  GenericJoint_REPORT_OUT_OF_RANGE(setForceUpperLimit, index);
1250  return;
1251  }
1252 
1253  GenericJoint_SET_IF_DIFFERENT( mForceUpperLimits[index], force );
1254 }
1255 
1256 //==============================================================================
1257 template <class ConfigSpaceT>
1259  size_t index) const
1260 {
1261  if (index >= getNumDofs())
1262  {
1263  GenericJoint_REPORT_OUT_OF_RANGE(getForceUpperLimit, index);
1264  return 0.0;
1265  }
1266 
1267  return Base::mAspectProperties.mForceUpperLimits[index];
1268 }
1269 
1270 //==============================================================================
1271 template<class ConfigSpaceT>
1273  const Eigen::VectorXd& upperLimits)
1274 {
1275  if (static_cast<size_t>(upperLimits.size()) != getNumDofs())
1276  {
1277  GenericJoint_REPORT_DIM_MISMATCH(setForceUpperLimits, upperLimits);
1278  return;
1279  }
1280 
1281  GenericJoint_SET_IF_DIFFERENT(mForceUpperLimits, upperLimits);
1282 }
1283 
1284 //==============================================================================
1285 template<class ConfigSpaceT>
1287 {
1288  return Base::mAspectProperties.mForceUpperLimits;
1289 }
1290 
1291 //==============================================================================
1292 template <class ConfigSpaceT>
1294 {
1295  this->mAspectState.mForces.setZero();
1296 
1297  if (Joint::mAspectProperties.mActuatorType == Joint::FORCE)
1298  this->mAspectState.mCommands = this->mAspectState.mForces;
1299 }
1300 
1301 //==============================================================================
1302 template <class ConfigSpaceT>
1304  size_t index, double velocityChange)
1305 {
1306  if (index >= getNumDofs())
1307  {
1308  GenericJoint_REPORT_OUT_OF_RANGE(setVelocityChange, index);
1309  return;
1310  }
1311 
1312  mVelocityChanges[index] = velocityChange;
1313 }
1314 
1315 //==============================================================================
1316 template <class ConfigSpaceT>
1318 {
1319  if (index >= getNumDofs())
1320  {
1321  GenericJoint_REPORT_OUT_OF_RANGE(getVelocityChange, index);
1322  return 0.0;
1323  }
1324 
1325  return mVelocityChanges[index];
1326 }
1327 
1328 //==============================================================================
1329 template <class ConfigSpaceT>
1331 {
1332  mVelocityChanges.setZero();
1333 }
1334 
1335 //==============================================================================
1336 template <class ConfigSpaceT>
1338  double impulse)
1339 {
1340  if (index >= getNumDofs())
1341  {
1342  GenericJoint_REPORT_OUT_OF_RANGE(setConstraintImpulse, index);
1343  return;
1344  }
1345 
1346  mConstraintImpulses[index] = impulse;
1347 }
1348 
1349 //==============================================================================
1350 template <class ConfigSpaceT>
1352 {
1353  if (index >= getNumDofs())
1354  {
1355  GenericJoint_REPORT_OUT_OF_RANGE(getConstraintImpulse, index);
1356  return 0.0;
1357  }
1358 
1359  return mConstraintImpulses[index];
1360 }
1361 
1362 //==============================================================================
1363 template <class ConfigSpaceT>
1365 {
1366  mConstraintImpulses.setZero();
1367 }
1368 
1369 //==============================================================================
1370 template <class ConfigSpaceT>
1372 {
1373  const Point& point = math::integratePosition<ConfigSpaceT>(
1374  math::toManifoldPoint<ConfigSpaceT>(getPositionsStatic()),
1375  getVelocitiesStatic(), dt);
1376 
1377  setPositionsStatic(math::toEuclideanPoint<ConfigSpaceT>(point));
1378 }
1379 
1380 //==============================================================================
1381 template <class ConfigSpaceT>
1383 {
1384  setVelocitiesStatic(math::integrateVelocity<ConfigSpaceT>(
1385  getVelocitiesStatic(),
1386  getAccelerationsStatic(), dt));
1387 }
1388 
1389 //==============================================================================
1390 template <class ConfigSpaceT>
1392  const Eigen::VectorXd& q2, const Eigen::VectorXd& q1) const
1393 {
1394  if (static_cast<size_t>(q1.size()) != getNumDofs()
1395  || static_cast<size_t>(q2.size()) != getNumDofs())
1396  {
1397  dterr << "[GenericJoint::getPositionsDifference] q1's size [" << q1.size()
1398  << "] or q2's size [" << q2.size() << "] must both equal the dof ["
1399  << this->getNumDofs() << "] for Joint [" << this->getName() << "].\n";
1400  assert(false);
1401  return Eigen::VectorXd::Zero(getNumDofs());
1402  }
1403 
1404  return getPositionDifferencesStatic(q2, q1);
1405 }
1406 
1407 //==============================================================================
1408 template <class ConfigSpaceT>
1409 typename ConfigSpaceT::Vector
1411  const Vector& q2, const Vector& q1) const
1412 {
1413  return q2 - q1;
1414  // TODO(JS): Move this implementation to each configuration space classes.
1415 }
1416 
1417 //==============================================================================
1418 template <class ConfigSpaceT>
1420 {
1421  if (index >= getNumDofs())
1422  {
1423  GenericJoint_REPORT_OUT_OF_RANGE(setSpringStiffness, index);
1424  return;
1425  }
1426 
1427  assert(k >= 0.0);
1428 
1429  GenericJoint_SET_IF_DIFFERENT( mSpringStiffnesses[index], k );
1430 }
1431 
1432 //==============================================================================
1433 template <class ConfigSpaceT>
1435 {
1436  if (index >= getNumDofs())
1437  {
1438  GenericJoint_REPORT_OUT_OF_RANGE(getSpringStiffness, index);
1439  return 0.0;
1440  }
1441 
1442  return Base::mAspectProperties.mSpringStiffnesses[index];
1443 }
1444 
1445 //==============================================================================
1446 template <class ConfigSpaceT>
1448 {
1449  if (index >= getNumDofs())
1450  {
1451  GenericJoint_REPORT_OUT_OF_RANGE(setRestPosition, index);
1452  return;
1453  }
1454 
1455  if (Base::mAspectProperties.mPositionLowerLimits[index] > q0
1456  || Base::mAspectProperties.mPositionUpperLimits[index] < q0)
1457  {
1458  dtwarn << "[GenericJoint::setRestPosition] Value of _q0 [" << q0
1459  << "], is out of the limit range ["
1460  << Base::mAspectProperties.mPositionLowerLimits[index] << ", "
1461  << Base::mAspectProperties.mPositionUpperLimits[index]
1462  << "] for index [" << index << "] of Joint [" << this->getName()
1463  << "].\n";
1464  return;
1465  }
1466 
1467  GenericJoint_SET_IF_DIFFERENT( mRestPositions[index], q0 );
1468 }
1469 
1470 //==============================================================================
1471 template <class ConfigSpaceT>
1473 {
1474  if (index >= getNumDofs())
1475  {
1476  GenericJoint_REPORT_OUT_OF_RANGE(getRestPosition, index);
1477  return 0.0;
1478  }
1479 
1480  return Base::mAspectProperties.mRestPositions[index];
1481 }
1482 
1483 //==============================================================================
1484 template <class ConfigSpaceT>
1486  double d)
1487 {
1488  if (index >= getNumDofs())
1489  {
1490  GenericJoint_REPORT_OUT_OF_RANGE(setDampingCoefficient, index);
1491  return;
1492  }
1493 
1494  assert(d >= 0.0);
1495 
1496  GenericJoint_SET_IF_DIFFERENT( mDampingCoefficients[index], d );
1497 }
1498 
1499 //==============================================================================
1500 template <class ConfigSpaceT>
1502 {
1503  if (index >= getNumDofs())
1504  {
1505  GenericJoint_REPORT_OUT_OF_RANGE(getDampingCoefficient, index);
1506  return 0.0;
1507  }
1508 
1509  return Base::mAspectProperties.mDampingCoefficients[index];
1510 }
1511 
1512 //==============================================================================
1513 template <class ConfigSpaceT>
1515  size_t index, double friction)
1516 {
1517  if (index >= getNumDofs())
1518  {
1519  GenericJoint_REPORT_OUT_OF_RANGE(setCoulombFriction, index);
1520  return;
1521  }
1522 
1523  assert(friction >= 0.0);
1524 
1526 }
1527 
1528 //==============================================================================
1529 template <class ConfigSpaceT>
1531 {
1532  if (index >= getNumDofs())
1533  {
1534  GenericJoint_REPORT_OUT_OF_RANGE(getCoulombFriction, index);
1535  return 0.0;
1536  }
1537 
1538  return Base::mAspectProperties.mFrictions[index];
1539 }
1540 
1541 //==============================================================================
1542 template <class ConfigSpaceT>
1544 {
1545  // Spring energy
1546  Vector displacement
1547  = getPositionsStatic() - Base::mAspectProperties.mRestPositions;
1548 
1549  const double pe = 0.5 * displacement.dot(
1550  Base::mAspectProperties.mSpringStiffnesses.cwiseProduct(displacement));
1551 
1552  return pe;
1553 }
1554 
1555 //==============================================================================
1556 template <class ConfigSpaceT>
1557 const math::Jacobian
1559 {
1560  return getRelativeJacobianStatic();
1561 }
1562 
1563 //==============================================================================
1564 template <class ConfigSpaceT>
1567 {
1568  if (this->mIsRelativeJacobianDirty)
1569  {
1570  this->updateRelativeJacobian(false);
1571  this->mIsRelativeJacobianDirty = false;
1572  }
1573 
1574  return mJacobian;
1575 }
1576 
1577 //==============================================================================
1578 template <class ConfigSpaceT>
1580  const Eigen::VectorXd& positions) const
1581 {
1582  return getRelativeJacobianStatic(positions);
1583 }
1584 
1585 //==============================================================================
1586 template <class ConfigSpaceT>
1587 const math::Jacobian
1589 {
1590  return getRelativeJacobianTimeDerivStatic();
1591 }
1592 
1593 //==============================================================================
1594 template <class ConfigSpaceT>
1597 {
1598  if (this->mIsRelativeJacobianTimeDerivDirty)
1599  {
1600  this->updateRelativeJacobianTimeDeriv();
1601  this->mIsRelativeJacobianTimeDerivDirty = false;
1602  }
1603 
1604  return mJacobianDeriv;
1605 }
1606 
1607 //==============================================================================
1608 template <class ConfigSpaceT>
1610  const Properties& properties)
1611  : mVelocityChanges(Vector::Zero()),
1612  mImpulses(Vector::Zero()),
1613  mConstraintImpulses(Vector::Zero()),
1614  mJacobian(JacobianMatrix::Zero()),
1615  mJacobianDeriv(JacobianMatrix::Zero()),
1616  mInvProjArtInertia(Matrix::Zero()),
1617  mInvProjArtInertiaImplicit(Matrix::Zero()),
1618  mTotalForce(Vector::Zero()),
1619  mTotalImpulse(Vector::Zero())
1620 {
1621  for (auto i = 0u; i < NumDofs; ++i)
1622  mDofs[i] = this->createDofPointer(i);
1623 
1624  // Joint and GenericJoint Aspects must be created by the most derived class.
1625  this->mAspectState.mPositions = properties.mInitialPositions;
1626  this->mAspectState.mVelocities = properties.mInitialVelocities;
1627 }
1628 
1629 //==============================================================================
1630 template <class ConfigSpaceT>
1632 {
1633  const SkeletonPtr& skel = this->mChildBodyNode->getSkeleton();
1634  for (auto i = 0u; i < NumDofs; ++i)
1635  {
1636  Base::mAspectProperties.mDofNames[i]
1637  = skel->mNameMgrForDofs.issueNewNameAndAdd(mDofs[i]->getName(),
1638  mDofs[i]);
1639  }
1640 }
1641 
1642 //==============================================================================
1643 template <class ConfigSpaceT>
1646 {
1647  assert(this->mChildBodyNode);
1648  return this->mChildBodyNode->getBodyForce()
1649  - this->getRelativeJacobianStatic() * this->mAspectState.mForces;
1650 }
1651 
1652 //==============================================================================
1653 template <class ConfigSpaceT>
1655 {
1656  this->mSpatialVelocity =
1657  this->getRelativeJacobianStatic() * this->getVelocitiesStatic();
1658 }
1659 
1660 //==============================================================================
1661 template <class ConfigSpaceT>
1663 {
1664  this->mSpatialAcceleration =
1665  this->getRelativePrimaryAcceleration()
1666  + this->getRelativeJacobianTimeDerivStatic() * this->getVelocitiesStatic();
1667 }
1668 
1669 //==============================================================================
1670 template <class ConfigSpaceT>
1672 {
1673  this->mPrimaryAcceleration =
1674  this->getRelativeJacobianStatic() * this->getAccelerationsStatic();
1675 }
1676 
1677 //==============================================================================
1678 template <class ConfigSpaceT>
1680 {
1681  // Add joint velocity to _vel
1682  vel.noalias() += getRelativeJacobianStatic() * getVelocitiesStatic();
1683 
1684  // Verification
1685  assert(!math::isNan(vel));
1686 }
1687 
1688 //==============================================================================
1689 template <class ConfigSpaceT>
1691  Eigen::Vector6d& partialAcceleration,
1692  const Eigen::Vector6d& childVelocity)
1693 {
1694  // ad(V, S * dq) + dS * dq
1695  partialAcceleration = math::ad(childVelocity,
1696  getRelativeJacobianStatic() * getVelocitiesStatic())
1697  + getRelativeJacobianTimeDerivStatic() * getVelocitiesStatic();
1698  // Verification
1699  assert(!math::isNan(partialAcceleration));
1700 }
1701 
1702 //==============================================================================
1703 template <class ConfigSpaceT>
1705  Eigen::Vector6d& acc)
1706 {
1707  // Add joint acceleration to _acc
1708  acc.noalias() += getRelativeJacobianStatic() * getAccelerationsStatic();
1709 
1710  // Verification
1711  assert(!math::isNan(acc));
1712 }
1713 
1714 //==============================================================================
1715 template <class ConfigSpaceT>
1717  Eigen::Vector6d& velocityChange)
1718 {
1719  // Add joint velocity change to velocityChange
1720  velocityChange.noalias() += getRelativeJacobianStatic() * mVelocityChanges;
1721 
1722  // Verification
1723  assert(!math::isNan(velocityChange));
1724 }
1725 
1726 //==============================================================================
1727 template <class ConfigSpaceT>
1728 const typename GenericJoint<ConfigSpaceT>::Matrix&
1730 {
1732 
1733  return mInvProjArtInertia;
1734 }
1735 
1736 //==============================================================================
1737 template <class ConfigSpaceT>
1738 const typename GenericJoint<ConfigSpaceT>::Matrix&
1740 {
1742 
1743  return mInvProjArtInertiaImplicit;
1744 }
1745 
1746 //==============================================================================
1747 template <class ConfigSpaceT>
1749  Eigen::Matrix6d& parentArtInertia,
1750  const Eigen::Matrix6d& childArtInertia)
1751 {
1752  switch (Joint::mAspectProperties.mActuatorType)
1753  {
1754  case Joint::FORCE:
1755  case Joint::PASSIVE:
1756  case Joint::SERVO:
1757  addChildArtInertiaToDynamic(parentArtInertia,
1758  childArtInertia);
1759  break;
1760  case Joint::ACCELERATION:
1761  case Joint::VELOCITY:
1762  case Joint::LOCKED:
1763  addChildArtInertiaToKinematic(parentArtInertia,
1764  childArtInertia);
1765  break;
1766  default:
1767  GenericJoint_REPORT_UNSUPPORTED_ACTUATOR(addChildArtInertiaTo);
1768  break;
1769  }
1770 }
1771 
1772 //==============================================================================
1773 template <class ConfigSpaceT>
1775  Eigen::Matrix6d& parentArtInertia,
1776  const Eigen::Matrix6d& childArtInertia)
1777 {
1778  // Child body's articulated inertia
1779  JacobianMatrix AIS = childArtInertia * getRelativeJacobianStatic();
1780  Eigen::Matrix6d PI = childArtInertia;
1781  PI.noalias() -= AIS * mInvProjArtInertia * AIS.transpose();
1782  assert(!math::isNan(PI));
1783 
1784  // Add child body's articulated inertia to parent body's articulated inertia.
1785  // Note that mT should be updated.
1786  parentArtInertia += math::transformInertia(
1787  this->getRelativeTransform().inverse(), PI);
1788 }
1789 
1790 //==============================================================================
1791 template <class ConfigSpaceT>
1793  Eigen::Matrix6d& parentArtInertia,
1794  const Eigen::Matrix6d& childArtInertia)
1795 {
1796  // Add child body's articulated inertia to parent body's articulated inertia.
1797  // Note that mT should be updated.
1798  parentArtInertia += math::transformInertia(
1799  this->getRelativeTransform().inverse(), childArtInertia);
1800 }
1801 
1802 //==============================================================================
1803 template <class ConfigSpaceT>
1805  Eigen::Matrix6d& parentArtInertia,
1806  const Eigen::Matrix6d& childArtInertia)
1807 {
1808  switch (Joint::mAspectProperties.mActuatorType)
1809  {
1810  case Joint::FORCE:
1811  case Joint::PASSIVE:
1812  case Joint::SERVO:
1813  addChildArtInertiaImplicitToDynamic(parentArtInertia,
1814  childArtInertia);
1815  break;
1816  case Joint::ACCELERATION:
1817  case Joint::VELOCITY:
1818  case Joint::LOCKED:
1819  addChildArtInertiaImplicitToKinematic(parentArtInertia,
1820  childArtInertia);
1821  break;
1822  default:
1823  GenericJoint_REPORT_UNSUPPORTED_ACTUATOR(addChildArtInertiaImplicitTo);
1824  break;
1825  }
1826 }
1827 
1828 //==============================================================================
1829 template <class ConfigSpaceT>
1831  Eigen::Matrix6d& parentArtInertia,
1832  const Eigen::Matrix6d& childArtInertia)
1833 {
1834  // Child body's articulated inertia
1835  JacobianMatrix AIS = childArtInertia * getRelativeJacobianStatic();
1836  Eigen::Matrix6d PI = childArtInertia;
1837  PI.noalias() -= AIS * mInvProjArtInertiaImplicit * AIS.transpose();
1838  assert(!math::isNan(PI));
1839 
1840  // Add child body's articulated inertia to parent body's articulated inertia.
1841  // Note that mT should be updated.
1842  parentArtInertia += math::transformInertia(
1843  this->getRelativeTransform().inverse(), PI);
1844 }
1845 
1846 //==============================================================================
1847 template <class ConfigSpaceT>
1849  Eigen::Matrix6d& parentArtInertia,
1850  const Eigen::Matrix6d& childArtInertia)
1851 {
1852  // Add child body's articulated inertia to parent body's articulated inertia.
1853  // Note that mT should be updated.
1854  parentArtInertia += math::transformInertia(
1855  this->getRelativeTransform().inverse(), childArtInertia);
1856 }
1857 
1858 //==============================================================================
1859 template <class ConfigSpaceT>
1861  const Eigen::Matrix6d& artInertia)
1862 {
1863  switch (Joint::mAspectProperties.mActuatorType)
1864  {
1865  case Joint::FORCE:
1866  case Joint::PASSIVE:
1867  case Joint::SERVO:
1868  updateInvProjArtInertiaDynamic(artInertia);
1869  break;
1870  case Joint::ACCELERATION:
1871  case Joint::VELOCITY:
1872  case Joint::LOCKED:
1873  updateInvProjArtInertiaKinematic(artInertia);
1874  break;
1875  default:
1876  GenericJoint_REPORT_UNSUPPORTED_ACTUATOR(updateInvProjArtInertia);
1877  break;
1878  }
1879 }
1880 
1881 //==============================================================================
1882 template <class ConfigSpaceT>
1884  const Eigen::Matrix6d& artInertia)
1885 {
1886  // Projected articulated inertia
1887  const JacobianMatrix& Jacobian = getRelativeJacobianStatic();
1888  const Matrix projAI = Jacobian.transpose() * artInertia * Jacobian;
1889 
1890  // Inversion of projected articulated inertia
1891  mInvProjArtInertia = math::inverse<ConfigSpaceT>(projAI);
1892 
1893  // Verification
1894  assert(!math::isNan(mInvProjArtInertia));
1895 }
1896 
1897 //==============================================================================
1898 template <class ConfigSpaceT>
1900  const Eigen::Matrix6d& /*_artInertia*/)
1901 {
1902  // Do nothing
1903 }
1904 
1905 //==============================================================================
1906 template <class ConfigSpaceT>
1908  const Eigen::Matrix6d& artInertia,
1909  double timeStep)
1910 {
1911  switch (Joint::mAspectProperties.mActuatorType)
1912  {
1913  case Joint::FORCE:
1914  case Joint::PASSIVE:
1915  case Joint::SERVO:
1916  updateInvProjArtInertiaImplicitDynamic(artInertia, timeStep);
1917  break;
1918  case Joint::ACCELERATION:
1919  case Joint::VELOCITY:
1920  case Joint::LOCKED:
1921  updateInvProjArtInertiaImplicitKinematic(artInertia, timeStep);
1922  break;
1923  default:
1925  updateInvProjArtInertiaImplicit);
1926  break;
1927  }
1928 }
1929 
1930 //==============================================================================
1931 template <class ConfigSpaceT>
1933  const Eigen::Matrix6d& artInertia,
1934  double timeStep)
1935 {
1936  // Projected articulated inertia
1937  const JacobianMatrix& Jacobian = getRelativeJacobianStatic();
1938  Matrix projAI = Jacobian.transpose() * artInertia * Jacobian;
1939 
1940  // Add additional inertia for implicit damping and spring force
1941  projAI +=
1942  (timeStep * Base::mAspectProperties.mDampingCoefficients
1943  + timeStep * timeStep * Base::mAspectProperties.mSpringStiffnesses).asDiagonal();
1944 
1945  // Inversion of projected articulated inertia
1946  mInvProjArtInertiaImplicit = math::inverse<ConfigSpaceT>(projAI);
1947 
1948  // Verification
1949  assert(!math::isNan(mInvProjArtInertiaImplicit));
1950 }
1951 
1952 //==============================================================================
1953 template <class ConfigSpaceT>
1955  const Eigen::Matrix6d& /*artInertia*/, double /*timeStep*/)
1956 {
1957  // Do nothing
1958 }
1959 
1960 //==============================================================================
1961 template <class ConfigSpaceT>
1963  Eigen::Vector6d& parentBiasForce,
1964  const Eigen::Matrix6d& childArtInertia,
1965  const Eigen::Vector6d& childBiasForce,
1966  const Eigen::Vector6d& childPartialAcc)
1967 {
1968  switch (Joint::mAspectProperties.mActuatorType)
1969  {
1970  case Joint::FORCE:
1971  case Joint::PASSIVE:
1972  case Joint::SERVO:
1973  addChildBiasForceToDynamic(parentBiasForce,
1974  childArtInertia,
1975  childBiasForce,
1976  childPartialAcc);
1977  break;
1978  case Joint::ACCELERATION:
1979  case Joint::VELOCITY:
1980  case Joint::LOCKED:
1981  addChildBiasForceToKinematic(parentBiasForce,
1982  childArtInertia,
1983  childBiasForce,
1984  childPartialAcc);
1985  break;
1986  default:
1987  GenericJoint_REPORT_UNSUPPORTED_ACTUATOR(addChildBiasForceTo);
1988  break;
1989  }
1990 }
1991 
1992 //==============================================================================
1993 template <class ConfigSpaceT>
1995  Eigen::Vector6d& parentBiasForce,
1996  const Eigen::Matrix6d& childArtInertia,
1997  const Eigen::Vector6d& childBiasForce,
1998  const Eigen::Vector6d& childPartialAcc)
1999 {
2000  // Compute beta
2001  const Eigen::Vector6d beta
2002  = childBiasForce
2003  + childArtInertia
2004  * (childPartialAcc
2005  + getRelativeJacobianStatic() * getInvProjArtInertiaImplicit()
2006  *mTotalForce);
2007 
2008  // Eigen::Vector6d beta
2009  // = _childBiasForce;
2010  // beta.noalias() += _childArtInertia * _childPartialAcc;
2011  // beta.noalias() += _childArtInertia * mJacobian * getInvProjArtInertiaImplicit() * mTotalForce;
2012 
2013  // Verification
2014  assert(!math::isNan(beta));
2015 
2016  // Add child body's bias force to parent body's bias force. Note that mT
2017  // should be updated.
2018  parentBiasForce += math::dAdInvT(this->getRelativeTransform(), beta);
2019 }
2020 
2021 //==============================================================================
2022 template <class ConfigSpaceT>
2024  Eigen::Vector6d& _parentBiasForce,
2025  const Eigen::Matrix6d& childArtInertia,
2026  const Eigen::Vector6d& childBiasForce,
2027  const Eigen::Vector6d& childPartialAcc)
2028 {
2029  // Compute beta
2030  const Eigen::Vector6d beta
2031  = childBiasForce
2032  + childArtInertia*(childPartialAcc
2033  + getRelativeJacobianStatic()*getAccelerationsStatic());
2034 
2035  // Eigen::Vector6d beta
2036  // = _childBiasForce;
2037  // beta.noalias() += _childArtInertia * _childPartialAcc;
2038  // beta.noalias() += _childArtInertia * mJacobian * getInvProjArtInertiaImplicit() * mTotalForce;
2039 
2040  // Verification
2041  assert(!math::isNan(beta));
2042 
2043  // Add child body's bias force to parent body's bias force. Note that mT
2044  // should be updated.
2045  _parentBiasForce += math::dAdInvT(this->getRelativeTransform(), beta);
2046 }
2047 
2048 //==============================================================================
2049 template <class ConfigSpaceT>
2051  Eigen::Vector6d& parentBiasImpulse,
2052  const Eigen::Matrix6d& childArtInertia,
2053  const Eigen::Vector6d& childBiasImpulse)
2054 {
2055  switch (Joint::mAspectProperties.mActuatorType)
2056  {
2057  case Joint::FORCE:
2058  case Joint::PASSIVE:
2059  case Joint::SERVO:
2060  addChildBiasImpulseToDynamic(parentBiasImpulse,
2061  childArtInertia,
2062  childBiasImpulse);
2063  break;
2064  case Joint::ACCELERATION:
2065  case Joint::VELOCITY:
2066  case Joint::LOCKED:
2067  addChildBiasImpulseToKinematic(parentBiasImpulse,
2068  childArtInertia,
2069  childBiasImpulse);
2070  break;
2071  default:
2072  GenericJoint_REPORT_UNSUPPORTED_ACTUATOR(addChildBiasImpulseTo);
2073  break;
2074  }
2075 }
2076 
2077 //==============================================================================
2078 template <class ConfigSpaceT>
2080  Eigen::Vector6d& _parentBiasImpulse,
2081  const Eigen::Matrix6d& childArtInertia,
2082  const Eigen::Vector6d& childBiasImpulse)
2083 {
2084  // Compute beta
2085  const Eigen::Vector6d beta
2086  = childBiasImpulse
2087  + childArtInertia*getRelativeJacobianStatic()
2088  *getInvProjArtInertia()*mTotalImpulse;
2089 
2090  // Verification
2091  assert(!math::isNan(beta));
2092 
2093  // Add child body's bias force to parent body's bias force. Note that mT
2094  // should be updated.
2095  _parentBiasImpulse += math::dAdInvT(this->getRelativeTransform(), beta);
2096 }
2097 
2098 //==============================================================================
2099 template <class ConfigSpaceT>
2101  Eigen::Vector6d& parentBiasImpulse,
2102  const Eigen::Matrix6d& /*childArtInertia*/,
2103  const Eigen::Vector6d& childBiasImpulse)
2104 {
2105  // Add child body's bias force to parent body's bias force. Note that mT
2106  // should be updated.
2107  parentBiasImpulse += math::dAdInvT(this->getRelativeTransform(), childBiasImpulse);
2108 }
2109 
2110 //==============================================================================
2111 template <class ConfigSpaceT>
2113  const Eigen::Vector6d& bodyForce,
2114  double timeStep)
2115 {
2116  assert(timeStep > 0.0);
2117 
2118  switch (Joint::mAspectProperties.mActuatorType)
2119  {
2120  case Joint::FORCE:
2121  this->mAspectState.mForces = this->mAspectState.mCommands;
2122  updateTotalForceDynamic(bodyForce, timeStep);
2123  break;
2124  case Joint::PASSIVE:
2125  case Joint::SERVO:
2126  this->mAspectState.mForces.setZero();
2127  updateTotalForceDynamic(bodyForce, timeStep);
2128  break;
2129  case Joint::ACCELERATION:
2130  setAccelerationsStatic(this->mAspectState.mCommands);
2131  updateTotalForceKinematic(bodyForce, timeStep);
2132  break;
2133  case Joint::VELOCITY:
2134  setAccelerationsStatic(
2135  (this->mAspectState.mCommands - getVelocitiesStatic()) / timeStep );
2136  updateTotalForceKinematic(bodyForce, timeStep);
2137  break;
2138  case Joint::LOCKED:
2139  setVelocitiesStatic(Vector::Zero());
2140  setAccelerationsStatic(Vector::Zero());
2141  updateTotalForceKinematic(bodyForce, timeStep);
2142  break;
2143  default:
2144  GenericJoint_REPORT_UNSUPPORTED_ACTUATOR(updateTotalForce);
2145  break;
2146  }
2147 }
2148 
2149 //==============================================================================
2150 template <class ConfigSpaceT>
2152  const Eigen::Vector6d& bodyForce,
2153  double timeStep)
2154 {
2155  // Spring force
2156  const Vector springForce
2157  = -Base::mAspectProperties.mSpringStiffnesses.cwiseProduct(
2158  getPositionsStatic()
2159  - Base::mAspectProperties.mRestPositions
2160  + getVelocitiesStatic() * timeStep);
2161 
2162  // Damping force
2163  const Vector dampingForce
2164  = -Base::mAspectProperties.mDampingCoefficients.cwiseProduct(
2165  getVelocitiesStatic());
2166 
2167  //
2168  mTotalForce = this->mAspectState.mForces
2169  + springForce
2170  + dampingForce
2171  - getRelativeJacobianStatic().transpose() * bodyForce;
2172 }
2173 
2174 //==============================================================================
2175 template <class ConfigSpaceT>
2177  const Eigen::Vector6d& /*bodyForce*/,
2178  double /*timeStep*/)
2179 {
2180  // Do nothing
2181 }
2182 
2183 //==============================================================================
2184 template <class ConfigSpaceT>
2186  const Eigen::Vector6d& bodyImpulse)
2187 {
2188  switch (Joint::mAspectProperties.mActuatorType)
2189  {
2190  case Joint::FORCE:
2191  case Joint::PASSIVE:
2192  case Joint::SERVO:
2193  updateTotalImpulseDynamic(bodyImpulse);
2194  break;
2195  case Joint::ACCELERATION:
2196  case Joint::VELOCITY:
2197  case Joint::LOCKED:
2198  updateTotalImpulseKinematic(bodyImpulse);
2199  break;
2200  default:
2201  GenericJoint_REPORT_UNSUPPORTED_ACTUATOR(updateTotalImpulse);
2202  break;
2203  }
2204 }
2205 
2206 //==============================================================================
2207 template <class ConfigSpaceT>
2209  const Eigen::Vector6d& bodyImpulse)
2210 {
2211  //
2212  mTotalImpulse = mConstraintImpulses
2213  - getRelativeJacobianStatic().transpose() * bodyImpulse;
2214 }
2215 
2216 //==============================================================================
2217 template <class ConfigSpaceT>
2219  const Eigen::Vector6d& /*bodyImpulse*/)
2220 {
2221  // Do nothing
2222 }
2223 
2224 //==============================================================================
2225 template <class ConfigSpaceT>
2227 {
2228  mTotalImpulse.setZero();
2229 }
2230 
2231 //==============================================================================
2232 template <class ConfigSpaceT>
2234  const Eigen::Matrix6d& artInertia,
2235  const Eigen::Vector6d& spatialAcc)
2236 {
2237  switch (Joint::mAspectProperties.mActuatorType)
2238  {
2239  case Joint::FORCE:
2240  case Joint::PASSIVE:
2241  case Joint::SERVO:
2242  updateAccelerationDynamic(artInertia, spatialAcc);
2243  break;
2244  case Joint::ACCELERATION:
2245  case Joint::VELOCITY:
2246  case Joint::LOCKED:
2247  updateAccelerationKinematic(artInertia, spatialAcc);
2248  break;
2249  default:
2250  GenericJoint_REPORT_UNSUPPORTED_ACTUATOR(updateAcceleration);
2251  break;
2252  }
2253 }
2254 
2255 //==============================================================================
2256 template <class ConfigSpaceT>
2258  const Eigen::Matrix6d& artInertia,
2259  const Eigen::Vector6d& spatialAcc)
2260 {
2261  //
2262  setAccelerationsStatic( getInvProjArtInertiaImplicit()
2263  * (mTotalForce - getRelativeJacobianStatic().transpose()
2264  *artInertia*math::AdInvT(this->getRelativeTransform(), spatialAcc)) );
2265 
2266  // Verification
2267  assert(!math::isNan(getAccelerationsStatic()));
2268 }
2269 
2270 //==============================================================================
2271 template <class ConfigSpaceT>
2273  const Eigen::Matrix6d& /*artInertia*/,
2274  const Eigen::Vector6d& /*spatialAcc*/)
2275 {
2276  // Do nothing
2277 }
2278 
2279 //==============================================================================
2280 template <class ConfigSpaceT>
2282  const Eigen::Matrix6d& artInertia,
2283  const Eigen::Vector6d& velocityChange)
2284 {
2285  switch (Joint::mAspectProperties.mActuatorType)
2286  {
2287  case Joint::FORCE:
2288  case Joint::PASSIVE:
2289  case Joint::SERVO:
2290  updateVelocityChangeDynamic(artInertia, velocityChange);
2291  break;
2292  case Joint::ACCELERATION:
2293  case Joint::VELOCITY:
2294  case Joint::LOCKED:
2295  updateVelocityChangeKinematic(artInertia, velocityChange);
2296  break;
2297  default:
2298  GenericJoint_REPORT_UNSUPPORTED_ACTUATOR(updateVelocityChange);
2299  break;
2300  }
2301 }
2302 
2303 //==============================================================================
2304 template <class ConfigSpaceT>
2306  const Eigen::Matrix6d& artInertia,
2307  const Eigen::Vector6d& velocityChange)
2308 {
2309  //
2310  mVelocityChanges
2311  = getInvProjArtInertia()
2312  * (mTotalImpulse - getRelativeJacobianStatic().transpose()
2313  *artInertia*math::AdInvT(this->getRelativeTransform(), velocityChange));
2314 
2315  // Verification
2316  assert(!math::isNan(mVelocityChanges));
2317 }
2318 
2319 //==============================================================================
2320 template <class ConfigSpaceT>
2322  const Eigen::Matrix6d& /*artInertia*/,
2323  const Eigen::Vector6d& /*velocityChange*/)
2324 {
2325  // Do nothing
2326 }
2327 
2328 //==============================================================================
2329 template <class ConfigSpaceT>
2331  const Eigen::Vector6d& bodyForce,
2332  double timeStep,
2333  bool withDampingForces,
2334  bool withSpringForces)
2335 {
2336  this->mAspectState.mForces = getRelativeJacobianStatic().transpose() * bodyForce;
2337 
2338  // Damping force
2339  if (withDampingForces)
2340  {
2341  const typename ConfigSpaceT::Vector dampingForces
2342  = -Base::mAspectProperties.mDampingCoefficients.cwiseProduct(
2343  getVelocitiesStatic());
2344  this->mAspectState.mForces -= dampingForces;
2345  }
2346 
2347  // Spring force
2348  if (withSpringForces)
2349  {
2350  const typename ConfigSpaceT::Vector springForces
2351  = -Base::mAspectProperties.mSpringStiffnesses.cwiseProduct(
2352  getPositionsStatic()
2353  - Base::mAspectProperties.mRestPositions
2354  + getVelocitiesStatic() * timeStep);
2355  this->mAspectState.mForces -= springForces;
2356  }
2357 }
2358 
2359 //==============================================================================
2360 template <class ConfigSpaceT>
2362  const Eigen::Vector6d& bodyForce,
2363  double timeStep,
2364  bool withDampingForces,
2365  bool withSpringForces)
2366 {
2367  switch (Joint::mAspectProperties.mActuatorType)
2368  {
2369  case Joint::FORCE:
2370  case Joint::PASSIVE:
2371  case Joint::SERVO:
2372  break;
2373  case Joint::ACCELERATION:
2374  case Joint::VELOCITY:
2375  case Joint::LOCKED:
2376  updateForceID(bodyForce, timeStep, withDampingForces, withSpringForces);
2377  break;
2378  default:
2380  break;
2381  }
2382 }
2383 
2384 //==============================================================================
2385 template <class ConfigSpaceT>
2387  const Eigen::Vector6d& bodyImpulse)
2388 {
2389  mImpulses = getRelativeJacobianStatic().transpose()*bodyImpulse;
2390 }
2391 
2392 //==============================================================================
2393 template <class ConfigSpaceT>
2395  const Eigen::Vector6d& bodyImpulse)
2396 {
2397  switch (Joint::mAspectProperties.mActuatorType)
2398  {
2399  case Joint::FORCE:
2400  case Joint::PASSIVE:
2401  case Joint::SERVO:
2402  break;
2403  case Joint::ACCELERATION:
2404  case Joint::VELOCITY:
2405  case Joint::LOCKED:
2406  updateImpulseID(bodyImpulse);
2407  break;
2408  default:
2410  break;
2411  }
2412 }
2413 
2414 //==============================================================================
2415 template <class ConfigSpaceT>
2417 {
2418  switch (Joint::mAspectProperties.mActuatorType)
2419  {
2420  case Joint::FORCE:
2421  case Joint::PASSIVE:
2422  case Joint::SERVO:
2423  updateConstrainedTermsDynamic(timeStep);
2424  break;
2425  case Joint::ACCELERATION:
2426  case Joint::VELOCITY:
2427  case Joint::LOCKED:
2428  updateConstrainedTermsKinematic(timeStep);
2429  break;
2430  default:
2431  GenericJoint_REPORT_UNSUPPORTED_ACTUATOR(updateConstrainedTerms);
2432  break;
2433  }
2434 }
2435 
2436 //==============================================================================
2437 template <class ConfigSpaceT>
2439  double timeStep)
2440 {
2441  const double invTimeStep = 1.0 / timeStep;
2442 
2443  setVelocitiesStatic(getVelocitiesStatic() + mVelocityChanges);
2444  setAccelerationsStatic(getAccelerationsStatic()
2445  + mVelocityChanges * invTimeStep);
2446  this->mAspectState.mForces.noalias() += mImpulses * invTimeStep;
2447  // Note: As long as this is only called from BodyNode::updateConstrainedTerms
2448 }
2449 
2450 //==============================================================================
2451 template <class ConfigSpaceT>
2453  double timeStep)
2454 {
2455  this->mAspectState.mForces.noalias() += mImpulses / timeStep;
2456 }
2457 
2458 //==============================================================================
2459 template <class ConfigSpaceT>
2461  Eigen::Vector6d& parentBiasForce,
2462  const Eigen::Matrix6d& childArtInertia,
2463  const Eigen::Vector6d& childBiasForce)
2464 {
2465  // Compute beta
2466  Eigen::Vector6d beta = childBiasForce;
2467  beta.noalias() += childArtInertia * getRelativeJacobianStatic()
2468  * getInvProjArtInertia() * mInvM_a;
2469 
2470  // Verification
2471  assert(!math::isNan(beta));
2472 
2473  // Add child body's bias force to parent body's bias force. Note that mT
2474  // should be updated.
2475  parentBiasForce += math::dAdInvT(this->getRelativeTransform(), beta);
2476 }
2477 
2478 //==============================================================================
2479 template <class ConfigSpaceT>
2481  Eigen::Vector6d& parentBiasForce,
2482  const Eigen::Matrix6d& childArtInertia,
2483  const Eigen::Vector6d& childBiasForce)
2484 {
2485  // Compute beta
2486  Eigen::Vector6d beta = childBiasForce;
2487  beta.noalias() += childArtInertia * getRelativeJacobianStatic()
2488  * getInvProjArtInertiaImplicit() * mInvM_a;
2489 
2490  // Verification
2491  assert(!math::isNan(beta));
2492 
2493  // Add child body's bias force to parent body's bias force. Note that mT
2494  // should be updated.
2495  parentBiasForce += math::dAdInvT(this->getRelativeTransform(), beta);
2496 }
2497 
2498 //==============================================================================
2499 template <class ConfigSpaceT>
2501  const Eigen::Vector6d& bodyForce)
2502 {
2503  // Compute alpha
2504  mInvM_a = this->mAspectState.mForces
2505  - getRelativeJacobianStatic().transpose() * bodyForce;
2506 }
2507 
2508 //==============================================================================
2509 template <class ConfigSpaceT>
2511  Eigen::MatrixXd& _invMassMat,
2512  const size_t _col,
2513  const Eigen::Matrix6d& artInertia,
2514  const Eigen::Vector6d& spatialAcc)
2515 {
2516  //
2517  mInvMassMatrixSegment
2518  = getInvProjArtInertia()
2519  * (mInvM_a - getRelativeJacobianStatic().transpose()
2520  * artInertia * math::AdInvT(this->getRelativeTransform(), spatialAcc));
2521 
2522  // Verification
2523  assert(!math::isNan(mInvMassMatrixSegment));
2524 
2525  // Index
2526  size_t iStart = mDofs[0]->mIndexInTree;
2527 
2528  // Assign
2529  _invMassMat.block<NumDofs, 1>(iStart, _col) = mInvMassMatrixSegment;
2530 }
2531 
2532 //==============================================================================
2533 template <class ConfigSpaceT>
2535  Eigen::MatrixXd& invMassMat,
2536  const size_t col,
2537  const Eigen::Matrix6d& artInertia,
2538  const Eigen::Vector6d& spatialAcc)
2539 {
2540  //
2541  mInvMassMatrixSegment
2542  = getInvProjArtInertiaImplicit()
2543  * (mInvM_a - getRelativeJacobianStatic().transpose()
2544  * artInertia * math::AdInvT(this->getRelativeTransform(), spatialAcc));
2545 
2546  // Verification
2547  assert(!math::isNan(mInvMassMatrixSegment));
2548 
2549  // Index
2550  size_t iStart = mDofs[0]->mIndexInTree;
2551 
2552  // Assign
2553  invMassMat.block<NumDofs, 1>(iStart, col) = mInvMassMatrixSegment;
2554 }
2555 
2556 //==============================================================================
2557 template <class ConfigSpaceT>
2559  Eigen::Vector6d& acc)
2560 {
2561  //
2562  acc += getRelativeJacobianStatic() * mInvMassMatrixSegment;
2563 }
2564 
2565 //==============================================================================
2566 template <class ConfigSpaceT>
2568  const Eigen::Vector6d& spatial)
2569 {
2570  return getRelativeJacobianStatic().transpose() * spatial;
2571 }
2572 
2573 } // namespace dynamics
2574 } // namespace dart
2575 
2576 #endif // DART_DYNAMICS_DETAIL_GenericJoint_HPP_
#define dterr
Output an error message.
Definition: Console.hpp:49
#define dtwarn
Output a warning message.
Definition: Console.hpp:46
BodyPropPtr properties
Definition: SdfParser.cpp:80
std::string * name
Definition: SkelParser.cpp:1642
bool * preserveName
Definition: SkelParser.cpp:1641
Eigen::VectorXd velocity
Definition: SkelParser.cpp:108
Eigen::VectorXd force
Definition: SkelParser.cpp:110
std::size_t index
Definition: SkelParser.cpp:1617
Eigen::VectorXd acceleration
Definition: SkelParser.cpp:109
double * friction
Definition: SkelParser.cpp:1639
Eigen::VectorXd position
Definition: SkelParser.cpp:107
AspectProperties mAspectProperties
Aspect::Properties data, directly accessible to your derived class.
Definition: EmbeddedAspect.hpp:237
typename Impl::AspectState AspectState
Definition: EmbeddedAspect.hpp:444
AspectState mAspectState
Aspect::State data, directly accessible to your derived class.
Definition: EmbeddedAspect.hpp:422
typename Impl::AspectProperties AspectProperties
Definition: EmbeddedAspect.hpp:446
DegreeOfFreedom class is a proxy class for accessing single degrees of freedom (aka generalized coord...
Definition: DegreeOfFreedom.hpp:53
Definition: GenericJoint.hpp:49
void setAspectState(const AspectState &state)
Set the AspectState of this GenericJoint.
Definition: GenericJoint.hpp:114
void setForceLowerLimits(const Eigen::VectorXd &lowerLimits) override
Definition: GenericJoint.hpp:1224
double getCommand(std::size_t index) const override
Definition: GenericJoint.hpp:380
typename ConfigSpaceT::Matrix Matrix
Definition: GenericJoint.hpp:61
void addChildArtInertiaImplicitToKinematic(Eigen::Matrix6d &parentArtInertia, const Eigen::Matrix6d &childArtInertia)
Definition: GenericJoint.hpp:1848
Eigen::VectorXd getCommands() const override
Definition: GenericJoint.hpp:451
void resetVelocities() override
Definition: GenericJoint.hpp:924
const Vector & getPositionsStatic() const
Fixed-size version of getPositions()
Definition: GenericJoint.hpp:710
void setAccelerationsStatic(const Vector &accels)
Fixed-size version of setAccelerations()
Definition: GenericJoint.hpp:737
void copy(const ThisClass &otherJoint)
Copy the Properties of another GenericJoint.
Definition: GenericJoint.hpp:159
void setForceUpperLimits(const Eigen::VectorXd &upperLimits) override
Definition: GenericJoint.hpp:1272
void updateTotalImpulseKinematic(const Eigen::Vector6d &bodyImpulse)
Definition: GenericJoint.hpp:2218
void setCoulombFriction(std::size_t index, double friction) override
Definition: GenericJoint.hpp:1514
const JacobianMatrix & getRelativeJacobianTimeDerivStatic() const
Fixed-size version of getRelativeJacobianTimeDeriv()
Definition: GenericJoint.hpp:1596
void setRestPosition(std::size_t index, double q0) override
Definition: GenericJoint.hpp:1447
void setAccelerations(const Eigen::VectorXd &accelerations) override
Definition: GenericJoint.hpp:1014
void updateTotalImpulse(const Eigen::Vector6d &bodyImpulse) override
Definition: GenericJoint.hpp:2185
void updateForceFD(const Eigen::Vector6d &bodyForce, double timeStep, bool withDampingForcese, bool withSpringForces) override
Definition: GenericJoint.hpp:2361
const Matrix & getInvProjArtInertiaImplicit() const
Get the inverse of projected articulated inertia for implicit joint damping and spring forces.
Definition: GenericJoint.hpp:1739
Eigen::VectorXd getPositionUpperLimits() const override
Definition: GenericJoint.hpp:609
void setVelocityUpperLimits(const Eigen::VectorXd &upperLimits) override
Definition: GenericJoint.hpp:890
void updateForceID(const Eigen::Vector6d &bodyForce, double timeStep, bool withDampingForces, bool withSpringForces) override
Definition: GenericJoint.hpp:2330
Eigen::VectorXd getAccelerationUpperLimits() const override
Definition: GenericJoint.hpp:1131
void updateAccelerationKinematic(const Eigen::Matrix6d &artInertia, const Eigen::Vector6d &spatialAcc)
Definition: GenericJoint.hpp:2272
void updateVelocityChangeDynamic(const Eigen::Matrix6d &artInertia, const Eigen::Vector6d &velocityChange)
Definition: GenericJoint.hpp:2305
Eigen::VectorXd getVelocityLowerLimits() const override
Definition: GenericJoint.hpp:855
void updateInvProjArtInertiaImplicit(const Eigen::Matrix6d &artInertia, double timeStep) override
Definition: GenericJoint.hpp:1907
void setVelocityLowerLimits(const Eigen::VectorXd &lowerLimits) override
Definition: GenericJoint.hpp:841
void updateConstrainedTermsDynamic(double timeStep)
Definition: GenericJoint.hpp:2438
void setPositionLowerLimit(std::size_t index, double position) override
Definition: GenericJoint.hpp:520
const GenericJoint< ConfigSpaceT >::JacobianMatrix & getRelativeJacobianStatic() const
Fixed-size version of getRelativeJacobian()
Definition: GenericJoint.hpp:1566
void addChildArtInertiaToDynamic(Eigen::Matrix6d &parentArtInertia, const Eigen::Matrix6d &childArtInertia)
Definition: GenericJoint.hpp:1774
const math::Jacobian getRelativeJacobianTimeDeriv() const override
Definition: GenericJoint.hpp:1588
void setVelocities(const Eigen::VectorXd &velocities) override
Definition: GenericJoint.hpp:790
void addChildBiasImpulseToKinematic(Eigen::Vector6d &parentBiasImpulse, const Eigen::Matrix6d &childArtInertia, const Eigen::Vector6d &childBiasImpulse)
Definition: GenericJoint.hpp:2100
void addChildArtInertiaImplicitTo(Eigen::Matrix6d &parentArtInertiaImplicit, const Eigen::Matrix6d &childArtInertiaImplicit) override
Definition: GenericJoint.hpp:1804
void setPosition(std::size_t index, double position) override
Definition: GenericJoint.hpp:465
void updateVelocityChange(const Eigen::Matrix6d &artInertia, const Eigen::Vector6d &velocityChange) override
Definition: GenericJoint.hpp:2281
void setCommand(std::size_t index, double command) override
Definition: GenericJoint.hpp:326
std::array< DegreeOfFreedom *, NumDofs > mDofs
Array of DegreeOfFreedom objects.
Definition: GenericJoint.hpp:675
void setInitialPosition(std::size_t index, double initial) override
Definition: GenericJoint.hpp:650
Eigen::VectorXd getForces() const override
Definition: GenericJoint.hpp:1190
void resetCommands() override
Definition: GenericJoint.hpp:458
void setVelocityChange(std::size_t index, double velocityChange) override
Definition: GenericJoint.hpp:1303
void setAccelerationUpperLimits(const Eigen::VectorXd &upperLimits) override
Definition: GenericJoint.hpp:1117
void setPartialAccelerationTo(Eigen::Vector6d &partialAcceleration, const Eigen::Vector6d &childVelocity) override
Definition: GenericJoint.hpp:1690
double getVelocity(std::size_t index) const override
Definition: GenericJoint.hpp:777
Eigen::Vector6d getBodyConstraintWrench() const override
Definition: GenericJoint.hpp:1645
void addAccelerationTo(Eigen::Vector6d &acc) override
Definition: GenericJoint.hpp:1704
void updateTotalImpulseDynamic(const Eigen::Vector6d &bodyImpulse)
Definition: GenericJoint.hpp:2208
void setForce(std::size_t index, double force) override
Definition: GenericJoint.hpp:1145
void setInitialVelocity(std::size_t index, double initial) override
Definition: GenericJoint.hpp:931
double getForce(std::size_t index) const override
Definition: GenericJoint.hpp:1161
void setInitialVelocities(const Eigen::VectorXd &initial) override
Definition: GenericJoint.hpp:958
void updateInvProjArtInertiaDynamic(const Eigen::Matrix6d &artInertia)
Definition: GenericJoint.hpp:1883
DegreeOfFreedom * getDof(std::size_t index) override
void setPositionUpperLimit(std::size_t index, double position) override
Definition: GenericJoint.hpp:568
void updateInvProjArtInertiaImplicitKinematic(const Eigen::Matrix6d &artInertia, double timeStep)
Definition: GenericJoint.hpp:1954
const math::Jacobian getRelativeJacobian() const override
Definition: GenericJoint.hpp:1558
std::size_t getNumDofs() const override
Definition: GenericJoint.hpp:215
void resetForces() override
Definition: GenericJoint.hpp:1293
void addChildArtInertiaTo(Eigen::Matrix6d &parentArtInertia, const Eigen::Matrix6d &childArtInertia) override
Definition: GenericJoint.hpp:1748
Eigen::VectorXd getPositionLowerLimits() const override
Definition: GenericJoint.hpp:561
bool isDofNamePreserved(size_t index) const override
Definition: GenericJoint.hpp:269
void addVelocityTo(Eigen::Vector6d &vel) override
Definition: GenericJoint.hpp:1679
void preserveDofName(size_t index, bool preserve) override
Definition: GenericJoint.hpp:256
double getVelocityUpperLimit(std::size_t index) const override
Definition: GenericJoint.hpp:876
double getVelocityChange(std::size_t index) const override
Definition: GenericJoint.hpp:1317
void updateTotalForce(const Eigen::Vector6d &bodyForce, double timeStep) override
Definition: GenericJoint.hpp:2112
void resetConstraintImpulses() override
Definition: GenericJoint.hpp:1364
virtual Vector getPositionDifferencesStatic(const Vector &q2, const Vector &q1) const
Fixed-size version of getPositionDifferences()
Definition: GenericJoint.hpp:1410
void setVelocity(std::size_t index, double velocity) override
Definition: GenericJoint.hpp:756
double getRestPosition(std::size_t index) const override
Definition: GenericJoint.hpp:1472
void updateConstrainedTerms(double timeStep) override
Definition: GenericJoint.hpp:2416
void integrateVelocities(double dt) override
Definition: GenericJoint.hpp:1382
Eigen::VectorXd getPositions() const override
Definition: GenericJoint.hpp:513
void addChildBiasImpulseToDynamic(Eigen::Vector6d &parentBiasImpulse, const Eigen::Matrix6d &childArtInertia, const Eigen::Vector6d &childBiasImpulse)
Definition: GenericJoint.hpp:2079
double getAcceleration(std::size_t index) const override
Definition: GenericJoint.hpp:1001
Eigen::VectorXd getVelocities() const override
Definition: GenericJoint.hpp:807
Eigen::VectorXd getInitialPositions() const override
Definition: GenericJoint.hpp:691
Eigen::VectorXd getPositionDifferences(const Eigen::VectorXd &q2, const Eigen::VectorXd &q1) const override
Definition: GenericJoint.hpp:1391
void setPositionLowerLimits(const Eigen::VectorXd &lowerLimits) override
Definition: GenericJoint.hpp:547
double getAccelerationUpperLimit(std::size_t index) const override
Definition: GenericJoint.hpp:1103
void setForceLowerLimit(size_t index, double force) override
Definition: GenericJoint.hpp:1197
void setSpringStiffness(std::size_t index, double k) override
Definition: GenericJoint.hpp:1419
void updateRelativePrimaryAcceleration() const override
Definition: GenericJoint.hpp:1671
void setProperties(const Properties &properties)
Set the Properties of this GenericJoint.
Definition: GenericJoint.hpp:98
double getForceLowerLimit(std::size_t index) const override
Definition: GenericJoint.hpp:1210
static constexpr std::size_t NumDofs
Definition: GenericJoint.hpp:52
const Vector & getVelocitiesStatic() const
Fixed-size version of getVelocities()
Definition: GenericJoint.hpp:730
double getPositionUpperLimit(std::size_t index) const override
Definition: GenericJoint.hpp:582
const std::string & getDofName(size_t index) const override
Definition: GenericJoint.hpp:282
ThisClass & operator=(const ThisClass &other)
Same as copy(const GenericJoint&)
Definition: GenericJoint.hpp:182
double computePotentialEnergy() const override
Definition: GenericJoint.hpp:1543
double getSpringStiffness(std::size_t index) const override
Definition: GenericJoint.hpp:1434
void setDampingCoefficient(std::size_t index, double coeff) override
Definition: GenericJoint.hpp:1485
void updateInvProjArtInertia(const Eigen::Matrix6d &artInertia) override
Definition: GenericJoint.hpp:1860
void resetVelocity(std::size_t index) override
Definition: GenericJoint.hpp:911
void setPositionsStatic(const Vector &positions)
Fixed-size version of setPositions()
Definition: GenericJoint.hpp:698
void addChildBiasForceForInvAugMassMatrix(Eigen::Vector6d &parentBiasForce, const Eigen::Matrix6d &childArtInertia, const Eigen::Vector6d &childBiasForce) override
Definition: GenericJoint.hpp:2480
void updateConstrainedTermsKinematic(double timeStep)
Definition: GenericJoint.hpp:2452
void setAccelerationLowerLimits(const Eigen::VectorXd &lowerLimits) override
Definition: GenericJoint.hpp:1067
void setAspectProperties(const AspectProperties &properties)
Set the AspectProperties of this GenericJoint.
Definition: GenericJoint.hpp:125
Eigen::VectorXd getForceUpperLimits() const override
Definition: GenericJoint.hpp:1286
detail::GenericJointProperties< ConfigSpaceT > Properties
Definition: GenericJoint.hpp:64
void updateImpulseFD(const Eigen::Vector6d &bodyImpulse) override
Definition: GenericJoint.hpp:2394
GenericJoint(const ThisClass &)=delete
void updateInvProjArtInertiaImplicitDynamic(const Eigen::Matrix6d &artInertia, double timeStep)
Definition: GenericJoint.hpp:1932
void updateTotalForceKinematic(const Eigen::Vector6d &bodyForce, double timeStep)
Definition: GenericJoint.hpp:2176
void resetTotalImpulses() override
Definition: GenericJoint.hpp:2226
void integratePositions(double dt) override
Definition: GenericJoint.hpp:1371
void setPositions(const Eigen::VectorXd &positions) override
Definition: GenericJoint.hpp:499
void addChildBiasForceToDynamic(Eigen::Vector6d &parentBiasForce, const Eigen::Matrix6d &childArtInertia, const Eigen::Vector6d &childBiasForce, const Eigen::Vector6d &childPartialAcc)
Definition: GenericJoint.hpp:1994
Eigen::VectorXd getForceLowerLimits() const override
Definition: GenericJoint.hpp:1238
double getInitialVelocity(std::size_t index) const override
Definition: GenericJoint.hpp:945
Eigen::VectorXd getAccelerations() const override
Definition: GenericJoint.hpp:1031
typename ConfigSpaceT::Vector Vector
Definition: GenericJoint.hpp:59
void updateVelocityChangeKinematic(const Eigen::Matrix6d &artInertia, const Eigen::Vector6d &velocityChange)
Definition: GenericJoint.hpp:2321
const Vector & getAccelerationsStatic() const
Fixed-size version of getAccelerations()
Definition: GenericJoint.hpp:749
Eigen::VectorXd getInitialVelocities() const override
Definition: GenericJoint.hpp:972
void setCommands(const Eigen::VectorXd &commands) override
Definition: GenericJoint.hpp:393
Eigen::VectorXd getSpatialToGeneralized(const Eigen::Vector6d &spatial) override
Definition: GenericJoint.hpp:2567
typename ConfigSpaceT::JacobianMatrix JacobianMatrix
Definition: GenericJoint.hpp:60
void getInvAugMassMatrixSegment(Eigen::MatrixXd &invMassMat, const size_t col, const Eigen::Matrix6d &artInertia, const Eigen::Vector6d &spatialAcc) override
Definition: GenericJoint.hpp:2534
double getVelocityLowerLimit(std::size_t index) const override
Definition: GenericJoint.hpp:828
void updateImpulseID(const Eigen::Vector6d &bodyImpulse) override
Definition: GenericJoint.hpp:2386
void setVelocityLowerLimit(std::size_t index, double velocity) override
Definition: GenericJoint.hpp:814
double getInitialPosition(std::size_t index) const override
Definition: GenericJoint.hpp:664
void updateAcceleration(const Eigen::Matrix6d &artInertia, const Eigen::Vector6d &spatialAcc) override
Definition: GenericJoint.hpp:2233
void addChildBiasForceToKinematic(Eigen::Vector6d &parentBiasForce, const Eigen::Matrix6d &childArtInertia, const Eigen::Vector6d &childBiasForce, const Eigen::Vector6d &childPartialAcc)
Definition: GenericJoint.hpp:2023
void setVelocityUpperLimit(std::size_t index, double velocity) override
Definition: GenericJoint.hpp:862
typename ConfigSpaceT::Point Point
Definition: GenericJoint.hpp:57
void updateInvProjArtInertiaKinematic(const Eigen::Matrix6d &artInertia)
Definition: GenericJoint.hpp:1899
bool hasPositionLimit(std::size_t index) const override
Definition: GenericJoint.hpp:616
void setInitialPositions(const Eigen::VectorXd &initial) override
Definition: GenericJoint.hpp:677
virtual ~GenericJoint()
Destructor.
Definition: GenericJoint.hpp:90
void addChildBiasForceTo(Eigen::Vector6d &parentBiasForce, const Eigen::Matrix6d &childArtInertia, const Eigen::Vector6d &childBiasForce, const Eigen::Vector6d &childPartialAcc) override
Definition: GenericJoint.hpp:1962
double getCoulombFriction(std::size_t index) const override
Definition: GenericJoint.hpp:1530
void addInvMassMatrixSegmentTo(Eigen::Vector6d &acc) override
Definition: GenericJoint.hpp:2558
void setConstraintImpulse(std::size_t index, double impulse) override
Definition: GenericJoint.hpp:1337
void resetPosition(std::size_t index) override
Definition: GenericJoint.hpp:630
double getForceUpperLimit(size_t index) const override
Definition: GenericJoint.hpp:1258
void registerDofs() override
Definition: GenericJoint.hpp:1631
void addVelocityChangeTo(Eigen::Vector6d &velocityChange) override
Definition: GenericJoint.hpp:1716
const std::string & setDofName(std::size_t index, const std::string &name, bool preserveName=true) override
Definition: GenericJoint.hpp:222
void setAccelerationUpperLimit(std::size_t index, double acceleration) override
Definition: GenericJoint.hpp:1088
double getDampingCoefficient(std::size_t index) const override
Definition: GenericJoint.hpp:1501
void setPositionUpperLimits(const Eigen::VectorXd &upperLimits) override
Definition: GenericJoint.hpp:595
Eigen::VectorXd getAccelerationLowerLimits() const override
Definition: GenericJoint.hpp:1081
void updateTotalForceDynamic(const Eigen::Vector6d &bodyForce, double timeStep)
Definition: GenericJoint.hpp:2151
void setVelocitiesStatic(const Vector &velocities)
Fixed-size version of setVelocities()
Definition: GenericJoint.hpp:717
void updateRelativeSpatialAcceleration() const override
Definition: GenericJoint.hpp:1662
void updateRelativeSpatialVelocity() const override
Definition: GenericJoint.hpp:1654
void setForceUpperLimit(size_t index, double force) override
Definition: GenericJoint.hpp:1245
size_t getIndexInTree(size_t index) const override
Definition: GenericJoint.hpp:313
Eigen::VectorXd getVelocityUpperLimits() const override
Definition: GenericJoint.hpp:904
void setAccelerationLowerLimit(size_t index, double acceleration) override
Definition: GenericJoint.hpp:1038
double getPosition(std::size_t index) const override
Definition: GenericJoint.hpp:486
void addChildArtInertiaImplicitToDynamic(Eigen::Matrix6d &parentArtInertia, const Eigen::Matrix6d &childArtInertia)
Definition: GenericJoint.hpp:1830
double getAccelerationLowerLimit(std::size_t index) const override
Definition: GenericJoint.hpp:1053
void addChildBiasImpulseTo(Eigen::Vector6d &parentBiasImpulse, const Eigen::Matrix6d &childArtInertia, const Eigen::Vector6d &childBiasImpulse) override
Definition: GenericJoint.hpp:2050
double getPositionLowerLimit(std::size_t index) const override
Definition: GenericJoint.hpp:534
void updateAccelerationDynamic(const Eigen::Matrix6d &artInertia, const Eigen::Vector6d &spatialAcc)
Definition: GenericJoint.hpp:2257
void resetPositions() override
Definition: GenericJoint.hpp:643
void addChildBiasForceForInvMassMatrix(Eigen::Vector6d &parentBiasForce, const Eigen::Matrix6d &childArtInertia, const Eigen::Vector6d &childBiasForce) override
Definition: GenericJoint.hpp:2460
void getInvMassMatrixSegment(Eigen::MatrixXd &invMassMat, const size_t col, const Eigen::Matrix6d &artInertia, const Eigen::Vector6d &spatialAcc) override
Definition: GenericJoint.hpp:2510
Properties getGenericJointProperties() const
Get the Properties of this GenericJoint.
Definition: GenericJoint.hpp:151
const Matrix & getInvProjArtInertia() const
Get the inverse of the projected articulated inertia.
Definition: GenericJoint.hpp:1729
void setForces(const Eigen::VectorXd &forces) override
Definition: GenericJoint.hpp:1174
void updateTotalForceForInvMassMatrix(const Eigen::Vector6d &bodyForce) override
Definition: GenericJoint.hpp:2500
void resetAccelerations() override
Definition: GenericJoint.hpp:1138
void setAcceleration(std::size_t index, double acceleration) override
Definition: GenericJoint.hpp:979
void addChildArtInertiaToKinematic(Eigen::Matrix6d &parentArtInertia, const Eigen::Matrix6d &childArtInertia)
Definition: GenericJoint.hpp:1792
double getConstraintImpulse(std::size_t index) const override
Definition: GenericJoint.hpp:1351
size_t getIndexInSkeleton(size_t index) const override
Definition: GenericJoint.hpp:300
void resetVelocityChanges() override
Definition: GenericJoint.hpp:1330
static constexpr ActuatorType PASSIVE
Definition: Joint.hpp:67
static constexpr ActuatorType SERVO
Definition: Joint.hpp:68
static constexpr ActuatorType ACCELERATION
Definition: Joint.hpp:69
void updateArticulatedInertia() const
Tells the Skeleton to update the articulated inertia if it needs updating.
Definition: Joint.cpp:528
static constexpr ActuatorType LOCKED
Definition: Joint.hpp:71
static constexpr ActuatorType FORCE
Definition: Joint.hpp:66
void setProperties(const Properties &properties)
Set the Properties of this Joint.
Definition: Joint.cpp:103
static constexpr ActuatorType VELOCITY
Definition: Joint.hpp:70
#define GenericJoint_REPORT_UNSUPPORTED_ACTUATOR(func)
Definition: GenericJoint.hpp:61
#define GenericJoint_REPORT_DIM_MISMATCH(func, arg)
Definition: GenericJoint.hpp:44
#define GenericJoint_REPORT_OUT_OF_RANGE(func, index)
Definition: GenericJoint.hpp:53
#define GenericJoint_SET_IF_DIFFERENT(mField, value)
Definition: GenericJoint.hpp:69
Matrix< double, 6, 1 > Vector6d
Definition: MathTypes.hpp:49
Matrix< double, 6, 6 > Matrix6d
Definition: MathTypes.hpp:50
std::shared_ptr< Skeleton > SkeletonPtr
Definition: SmartPointer.hpp:60
SpaceT::Matrix inverse(const typename SpaceT::Matrix &mat)
Definition: ConfigurationSpace.hpp:188
T clip(const T &val, const T &lower, const T &upper)
Definition: Helpers.hpp:145
Eigen::Matrix< double, 6, Eigen::Dynamic > Jacobian
Definition: MathTypes.hpp:108
Eigen::Vector6d AdInvT(const Eigen::Isometry3d &_T, const Eigen::Vector6d &_V)
fast version of Ad(Inv(T), V)
Definition: Geometry.cpp:714
Eigen::Vector6d dAdInvT(const Eigen::Isometry3d &_T, const Eigen::Vector6d &_F)
fast version of dAd(Inv(T), F)
Definition: Geometry.cpp:784
Eigen::Vector6d ad(const Eigen::Vector6d &_X, const Eigen::Vector6d &_Y)
adjoint mapping
Definition: Geometry.cpp:744
Inertia transformInertia(const Eigen::Isometry3d &_T, const Inertia &_I)
Definition: Geometry.cpp:1311
bool isNan(double _v)
Returns whether _v is a NaN (Not-A-Number) value.
Definition: Helpers.hpp:171
Definition: BulletCollisionDetector.cpp:63
Definition: GenericJointAspect.hpp:178
Definition: GenericJointAspect.hpp:87
EuclideanPoint mInitialPositions
Initial positions.
Definition: GenericJointAspect.hpp:101
Vector mInitialVelocities
Initial velocities.
Definition: GenericJointAspect.hpp:110
Definition: JointAspect.hpp:104