Simbody  3.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MobilizedBody.h
Go to the documentation of this file.
1 #ifndef SimTK_SIMBODY_MOBILIZED_BODY_H_
2 #define SimTK_SIMBODY_MOBILIZED_BODY_H_
3 
4 /* -------------------------------------------------------------------------- *
5  * Simbody(tm) *
6  * -------------------------------------------------------------------------- *
7  * This is part of the SimTK biosimulation toolkit originating from *
8  * Simbios, the NIH National Center for Physics-Based Simulation of *
9  * Biological Structures at Stanford, funded under the NIH Roadmap for *
10  * Medical Research, grant U54 GM072970. See https://simtk.org/home/simbody. *
11  * *
12  * Portions copyright (c) 2007-13 Stanford University and the Authors. *
13  * Authors: Michael Sherman *
14  * Contributors: Paul Mitiguy, Peter Eastman *
15  * *
16  * Licensed under the Apache License, Version 2.0 (the "License"); you may *
17  * not use this file except in compliance with the License. You may obtain a *
18  * copy of the License at http://www.apache.org/licenses/LICENSE-2.0. *
19  * *
20  * Unless required by applicable law or agreed to in writing, software *
21  * distributed under the License is distributed on an "AS IS" BASIS, *
22  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
23  * See the License for the specific language governing permissions and *
24  * limitations under the License. *
25  * -------------------------------------------------------------------------- */
26 
39 #include "SimTKmath.h"
41 #include "simbody/internal/Body.h"
43 
44 #include <cassert>
45 
46 namespace SimTK {
47 
48 class SimbodyMatterSubsystem;
49 class Motion;
50 class MobilizedBody;
51 class MobilizedBodyImpl;
52 
53 // We only want the template instantiation to occur once. This symbol is
54 // defined in the SimTK core compilation unit that instantiates the mobilized
55 // body class but should not be defined any other time.
56 #ifndef SimTK_SIMBODY_DEFINING_MOBILIZED_BODY
57  extern template class PIMPLHandle<MobilizedBody, MobilizedBodyImpl, true>;
58 #endif
59 
64 
65 
66 
67 //==============================================================================
68 // MOBILIZED BODY
69 //==============================================================================
169 public:
170 
180 enum Direction {
181  Forward = 0,
182  Reverse = 1
183 };
184 
185 //------------------------------------------------------------------------------
219 void lock(State& state, Motion::Level level=Motion::Position) const;
220 
229 void lockAt(State& state, Real value,
230  Motion::Level level=Motion::Position) const;
231 
240 void lockAt(State& state, const Vector& value,
241  Motion::Level level=Motion::Position) const;
242 
252 template <int N> SimTK_SIMBODY_EXPORT // instantiated in library
253 void lockAt(State& state, const Vec<N>& value,
254  Motion::Level level=Motion::Position) const;
255 
259 void unlock(State& state) const;
260 
262 bool isLocked(const State& state) const
263 { return getLockLevel(state)!=Motion::NoLevel; }
264 
267 Motion::Level getLockLevel(const State& state) const;
268 
272 Vector getLockValueAsVector(const State& state) const;
273 
282 MobilizedBody& lockByDefault(Motion::Level level=Motion::Position);
283 
285 bool isLockedByDefault() const
286 { return getLockByDefaultLevel()!=Motion::NoLevel; }
287 
290 Motion::Level getLockByDefaultLevel() const;
293  // STATE ACCESS METHODS //
296 
297 //------------------------------------------------------------------------------
315 const Transform& getBodyTransform(const State& state) const; // X_GB
316 
325 const Rotation& getBodyRotation(const State& state) const {
326  return getBodyTransform(state).R();
327 }
332 const Vec3& getBodyOriginLocation(const State& state) const {
333  return getBodyTransform(state).p();
334 }
335 
339 const Transform& getMobilizerTransform(const State& state) const; // X_FM
340 
347 const SpatialVec& getBodyVelocity(const State& state) const; // V_GB
348 
353 const Vec3& getBodyAngularVelocity(const State& state) const { // w_GB
354  return getBodyVelocity(state)[0];
355 }
360 const Vec3& getBodyOriginVelocity(const State& state) const { // v_GB
361  return getBodyVelocity(state)[1];
362 }
363 
368 const SpatialVec& getMobilizerVelocity(const State& state) const; // V_FM
369 
376 const SpatialVec& getBodyAcceleration(const State& state) const; // A_GB
377 
382 const Vec3& getBodyAngularAcceleration(const State& state) const { // b_GB
383  return getBodyAcceleration(state)[0];
384 }
385 
390 const Vec3& getBodyOriginAcceleration(const State& state) const { // a_GB
391  return getBodyAcceleration(state)[1];
392 }
393 
399 const SpatialVec& getMobilizerAcceleration(const State& state) const { // A_FM
400  SimTK_ASSERT_ALWAYS(!"unimplemented method",
401 "MobilizedBody::getMobilizerAcceleration() not yet implemented -- volunteers?");
402  return *(new SpatialVec());
403 }
404 
407 const MassProperties& getBodyMassProperties(const State& state) const;
408 
412 const SpatialInertia& getBodySpatialInertiaInGround(const State& state) const;
413 
416 Real getBodyMass(const State& state) const {
417  return getBodyMassProperties(state).getMass();
418 }
419 
423 const Vec3& getBodyMassCenterStation(const State& state) const {
424  return getBodyMassProperties(state).getMassCenter();
425 }
426 
431  return getBodyMassProperties(state).getUnitInertia();
432 }
433 
439 const Transform& getInboardFrame (const State& state) const; // X_PF
445 const Transform& getOutboardFrame(const State& state) const; // X_BM
446 
450 void setInboardFrame (State& state, const Transform& X_PF) const;
454 void setOutboardFrame(State& state, const Transform& X_BM) const;
455 
456 // End of State Access - Bodies
460 //------------------------------------------------------------------------------
467 int getNumQ(const State& state) const;
470 int getNumU(const State& state) const;
471 
474 QIndex getFirstQIndex(const State& state) const;
475 
478 UIndex getFirstUIndex(const State& state) const;
479 
482 Motion::Method getQMotionMethod(const State& state) const;
485 Motion::Method getUMotionMethod(const State& state) const;
488 Motion::Method getUDotMotionMethod(const State& state) const;
489 
494 Real getOneQ(const State& state, int which) const;
495 
499 Real getOneU(const State& state, int which) const;
500 
504 Vector getQAsVector(const State& state) const;
508 Vector getUAsVector(const State& state) const;
509 
514 Real getOneQDot (const State& state, int which) const;
518 Vector getQDotAsVector(const State& state) const;
519 
524 Real getOneUDot(const State& state, int which) const;
529 Real getOneQDotDot(const State& state, int which) const;
533 Vector getUDotAsVector(const State& state) const;
538 Vector getQDotDotAsVector(const State& state) const;
539 
549 Vector getTauAsVector(const State& state) const;
550 
555 Real getOneTau(const State& state, MobilizerUIndex which) const;
556 
561 void setOneQ(State& state, int which, Real v) const;
566 void setOneU(State& state, int which, Real v) const;
567 
571 void setQFromVector(State& state, const Vector& v) const;
575 void setUFromVector(State& state, const Vector& v) const;
576 
610 void setQToFitTransform(State& state, const Transform& X_FM) const;
611 
616 void setQToFitRotation(State& state, const Rotation& R_FM) const;
617 
623 void setQToFitTranslation(State& state, const Vec3& p_FM) const;
624 
631 void setUToFitVelocity(State& state, const SpatialVec& V_FM) const;
632 
637 void setUToFitAngularVelocity(State& state, const Vec3& w_FM) const;
638 
644 void setUToFitLinearVelocity(State& state, const Vec3& v_FM) const;
645 
655 SpatialVec getHCol(const State& state, MobilizerUIndex ux) const;
656 
663 SpatialVec getH_FMCol(const State& state, MobilizerUIndex ux) const;
664 
665 // End of State Access Methods.
668  // BASIC OPERATORS //
671 
672 //------------------------------------------------------------------------------
717  const MobilizedBody& inBodyA) const
718 {
719  const Transform& X_GA = inBodyA.getBodyTransform(state);
720  const Transform& X_GB = this->getBodyTransform(state);
721 
722  return ~X_GA*X_GB; // X_AB=X_AG*X_GB
723 }
724 
731  const MobilizedBody& inBodyA) const
732 {
733  const Rotation& R_GA = inBodyA.getBodyRotation(state);
734  const Rotation& R_GB = this->getBodyRotation(state);
735 
736  return ~R_GA*R_GB; // R_AB=R_AG*R_GB
737 }
738 
745 Vec3 findBodyOriginLocationInAnotherBody
746  (const State& state, const MobilizedBody& toBodyA) const {
747  return toBodyA.findStationAtGroundPoint(state,
748  getBodyOriginLocation(state));
749 }
750 
756 SpatialVec findBodyVelocityInAnotherBody
757  (const State& state, const MobilizedBody& inBodyA) const
758 {
759  const SpatialVec& V_GB = this->getBodyVelocity(state);
760  const SpatialVec& V_GA = inBodyA.getBodyVelocity(state);
761  // angular velocity of B in A, exp in G
762  const Vec3 w_AB_G = V_GB[0]-V_GA[0]; // 3 flops
763 
764  // Angular vel. was easy, but for linear vel. we have to add in an wXr term.
765 
766  const Transform& X_GB = getBodyTransform(state);
767  const Transform& X_GA = inBodyA.getBodyTransform(state);
768  // vector from Ao to Bo, exp in G
769  const Vec3 p_AB_G = X_GB.p() - X_GA.p(); // 3 flops
770  // d/dt p taken in G
771  const Vec3 p_AB_G_dot = V_GB[1] - V_GA[1]; // 3 flops
772 
773  // d/dt p taken in A, exp in G
774  const Vec3 v_AB_G = p_AB_G_dot - V_GA[0] % p_AB_G; // 12 flops
775 
776  // We're done, but answer is expressed in Ground. Reexpress in A and return.
777  return ~X_GA.R()*SpatialVec(w_AB_G, v_AB_G); // 30 flops
778 }
779 
786  const MobilizedBody& inBodyA) const
787 {
788  const Vec3& w_GB = getBodyAngularVelocity(state);
789  const Vec3& w_GA = inBodyA.getBodyAngularVelocity(state);
790  // angular velocity of B in A, exp in G
791  const Vec3 w_AB_G = w_GB-w_GA; // 3 flops
792 
793  // Now reexpress in A.
794  return inBodyA.expressGroundVectorInBodyFrame(state, w_AB_G); // 15 flops
795 }
796 
803  const MobilizedBody& inBodyA) const
804 {
805  // Doesn't save much to special case this one.
806  return findBodyVelocityInAnotherBody(state,inBodyA)[1];
807 }
808 
816  const MobilizedBody& inBodyA) const
817 {
818  const Transform& X_GA = inBodyA.getBodyTransform(state);
819  const SpatialVec& V_GA = inBodyA.getBodyVelocity(state);
820  const SpatialVec& A_GA = inBodyA.getBodyAcceleration(state);
821  const Transform& X_GB = this->getBodyTransform(state);
822  const SpatialVec& V_GB = this->getBodyVelocity(state);
823  const SpatialVec& A_GB = this->getBodyAcceleration(state);
824 
825  return findRelativeAcceleration(X_GA, V_GA, A_GA,
826  X_GB, V_GB, A_GB);
827 }
828 
834 Vec3 findBodyAngularAccelerationInAnotherBody
835  (const State& state, const MobilizedBody& inBodyA) const
836 {
837  const Rotation& R_GA = inBodyA.getBodyRotation(state);
838  const Vec3& w_GA = inBodyA.getBodyAngularVelocity(state);
839  const Vec3& w_GB = this->getBodyAngularVelocity(state);
840  const Vec3& b_GA = inBodyA.getBodyAngularAcceleration(state);
841  const Vec3& b_GB = this->getBodyAngularAcceleration(state);
842 
843  // relative ang. vel. of B in A, exp. in G
844  const Vec3 w_AB_G = w_GB - w_GA; // 3 flops
845  const Vec3 w_AB_G_dot = b_GB - b_GA; // d/dt of w_AB_G taken in G; 3 flops
846 
847  // We have the derivative in G; change it to derivative in A by adding
848  // in contribution caused by motion of G in A, that is w_AG X w_AB_G.
849  // (Note that w_AG=-w_GA.)
850  const Vec3 b_AB_G = w_AB_G_dot - w_GA % w_AB_G; // ang. accel. of B in A
851  // 12 flops
852 
853  return ~R_GA * b_AB_G; // taken in A, expressed in A; 15 flops
854 }
855 
863  const MobilizedBody& inBodyA) const
864 {
865  // Not much to be saved by trying to optimize this since the linear part
866  // is the most expensive to calculate.
867  return findBodyAccelerationInAnotherBody(state,inBodyA)[1];
868 }
869 
877 SpatialVec findMobilizerReactionOnBodyAtMInGround(const State& state) const;
878 
885 SpatialVec findMobilizerReactionOnBodyAtOriginInGround
886  (const State& state) const;
887 
896 SpatialVec findMobilizerReactionOnParentAtFInGround(const State& state) const;
897 
905 SpatialVec findMobilizerReactionOnParentAtOriginInGround
906  (const State& state) const;
907 
914 Vec3 findStationLocationInGround
915  (const State& state, const Vec3& stationOnB) const {
916  return getBodyTransform(state) * stationOnB;
917 }
918 
919 
928 Vec3 findStationLocationInAnotherBody
929  (const State& state, const Vec3& stationOnB, const MobilizedBody& toBodyA)
930  const
931 {
932  return toBodyA.findStationAtGroundPoint(state,
933  findStationLocationInGround(state,stationOnB));
934 }
935 
942 Vec3 findStationVelocityInGround
943  (const State& state, const Vec3& stationOnB) const {
944  const Vec3& w = getBodyAngularVelocity(state); // in G
945  const Vec3& v = getBodyOriginVelocity(state); // in G
946  const Vec3 r = expressVectorInGroundFrame(state,stationOnB); // 15 flops
947  return v + w % r; // 12 flops
948 }
949 
950 
957  const Vec3& stationOnBodyB,//p_BS
958  const MobilizedBody& inBodyA) const
959 {
960  const SpatialVec V_AB =
961  findBodyVelocityInAnotherBody(state, inBodyA); //51 flops
962  // Bo->S rexpressed in A but not shifted to Ao
963  const Vec3 p_BS_A =
964  expressVectorInAnotherBodyFrame(state, stationOnBodyB, inBodyA); //30
965  return V_AB[1] + (V_AB[0] % p_BS_A); //12 flops
966 }
967 
968 
976 Vec3 findStationAccelerationInGround
977  (const State& state, const Vec3& stationOnB) const {
978  const Vec3& w = getBodyAngularVelocity(state); // in G
979  const Vec3& b = getBodyAngularAcceleration(state); // in G
980  const Vec3& a = getBodyOriginAcceleration(state); // in G
981 
982  const Vec3 r = expressVectorInGroundFrame(state,stationOnB); // 15 flops
983  return a + b % r + w % (w % r); // 33 flops
984 }
985 
992  const Vec3& stationOnBodyB,
993  const MobilizedBody& inBodyA) const
994 {
995  const Vec3 w_AB =
996  findBodyAngularVelocityInAnotherBody(state,inBodyA); // 18 flops
997  const SpatialVec A_AB =
998  findBodyAccelerationInAnotherBody(state,inBodyA); // 105 flops
999  // Bo->S rexpressed in A but not shifted to Ao
1000  const Vec3 p_BS_A =
1001  expressVectorInAnotherBodyFrame(state, stationOnBodyB, inBodyA); // 30
1002 
1003  return A_AB[1] + (A_AB[0] % p_BS_A) + w_AB % (w_AB % p_BS_A); // 33 flops
1004 }
1005 
1009 void findStationLocationAndVelocityInGround
1010  (const State& state, const Vec3& locationOnB,
1011  Vec3& locationOnGround, Vec3& velocityInGround) const
1012 {
1013  const Vec3& p_GB = getBodyOriginLocation(state);
1014  const Vec3 p_BS_G = expressVectorInGroundFrame(state,locationOnB);//15flops
1015  locationOnGround = p_GB + p_BS_G; // 3flops
1016 
1017  const Vec3& w_GB = getBodyAngularVelocity(state);
1018  const Vec3& v_GB = getBodyOriginVelocity(state);
1019  velocityInGround = v_GB + w_GB % p_BS_G; // 12 flops
1020 }
1021 
1022 
1027 void findStationLocationVelocityAndAccelerationInGround
1028  (const State& state, const Vec3& locationOnB,
1029  Vec3& locationOnGround, Vec3& velocityInGround, Vec3& accelerationInGround)
1030  const
1031 {
1032  const Rotation& R_GB = getBodyRotation(state);
1033  const Vec3& p_GB = getBodyOriginLocation(state);
1034 
1035  // re-express station vector p_BS in G
1036  const Vec3 r = R_GB*locationOnB; // 15 flops
1037  locationOnGround = p_GB + r; // 3 flops
1038 
1039  const Vec3& w = getBodyAngularVelocity(state); // in G
1040  const Vec3& v = getBodyOriginVelocity(state); // in G
1041  const Vec3& b = getBodyAngularAcceleration(state); // in G
1042  const Vec3& a = getBodyOriginAcceleration(state); // in G
1043 
1044  const Vec3 wXr = w % r; // "whipping" velocity w X r due to ang vel; 9 flops
1045  velocityInGround = v + wXr; // v + w X r (3 flops)
1046  accelerationInGround = a + b % r + w % wXr; // 24 flops
1047 }
1048 
1052  return findStationLocationInGround(state,getBodyMassCenterStation(state));
1053 }
1054 
1058 Vec3 findMassCenterLocationInAnotherBody
1059  (const State& state, const MobilizedBody& toBodyA) const {
1060  return findStationLocationInAnotherBody(state,
1061  getBodyMassCenterStation(state),toBodyA);
1062 }
1063 
1070 Vec3 findStationAtGroundPoint
1071  (const State& state, const Vec3& locationInG) const {
1072  return ~getBodyTransform(state) * locationInG;
1073 }
1074 
1080 Vec3 findStationAtAnotherBodyStation
1081  (const State& state, const MobilizedBody& fromBodyA,
1082  const Vec3& stationOnA) const {
1083  return fromBodyA.findStationLocationInAnotherBody(state, stationOnA, *this);
1084 }
1085 
1089 Vec3 findStationAtAnotherBodyOrigin
1090  (const State& state, const MobilizedBody& fromBodyA) const {
1091  return findStationAtGroundPoint(state,
1092  fromBodyA.getBodyOriginLocation(state));
1093 }
1094 
1098 Vec3 findStationAtAnotherBodyMassCenter
1099  (const State& state, const MobilizedBody& fromBodyA) const {
1100  return fromBodyA.findStationLocationInAnotherBody(state,
1101  getBodyMassCenterStation(state),*this);
1102 }
1103 
1107 Transform findFrameTransformInGround
1108  (const State& state, const Transform& frameOnB) const {
1109  return getBodyTransform(state) * frameOnB;
1110 }
1111 
1117 SpatialVec findFrameVelocityInGround
1118  (const State& state, const Transform& frameOnB) const {
1119  return SpatialVec(getBodyAngularVelocity(state),
1120  findStationVelocityInGround(state,frameOnB.p()));
1121 }
1122 
1128 SpatialVec findFrameAccelerationInGround
1129  (const State& state, const Transform& frameOnB) const {
1130  return SpatialVec(getBodyAngularAcceleration(state),
1131  findStationAccelerationInGround(state,frameOnB.p()));
1132 }
1133 
1137 Vec3 expressVectorInGroundFrame
1138  (const State& state, const Vec3& vectorInB) const {
1139  return getBodyRotation(state)*vectorInB;
1140 }
1141 
1146 Vec3 expressGroundVectorInBodyFrame
1147  (const State& state, const Vec3& vectorInG) const {
1148  return ~getBodyRotation(state)*vectorInG;
1149 }
1150 
1156 Vec3 expressVectorInAnotherBodyFrame
1157  (const State& state, const Vec3& vectorInB,
1158  const MobilizedBody& inBodyA) const
1159 {
1160  return inBodyA.expressGroundVectorInBodyFrame(state,
1161  expressVectorInGroundFrame(state,vectorInB));
1162 }
1163 
1169  const MassProperties& M_Bo_B = getBodyMassProperties(state);
1170  const Rotation& R_GB = getBodyRotation(state);
1171  return M_Bo_B.reexpress(~R_GB);
1172 }
1173 
1178 MassProperties expressMassPropertiesInAnotherBodyFrame
1179  (const State& state, const MobilizedBody& inBodyA) const {
1180  const MassProperties& M_Bo_B = getBodyMassProperties(state);
1181  const Rotation R_AB = findBodyRotationInAnotherBody(state,inBodyA);
1182  return M_Bo_B.reexpress(~R_AB);
1183 }
1184 
1185 // End of Basic Operators.
1188 //------------------------------------------------------------------------------
1212 {
1213  if (isGround())
1214  return SpatialMat(Mat33(Infinity)); // sets diagonals to Inf
1215 
1216  const MassProperties& mp = getBodyMassProperties(state);
1217  const Rotation& R_GB = getBodyRotation(state);
1218  // re-express in Ground without shifting, convert to spatial mat.
1219  return mp.reexpress(~R_GB).toSpatialMat();
1220 }
1221 
1225 
1228  MobilizedBodyIndex objectBodyB) const
1229 {
1230  return getBodyMassProperties(state).calcCentralInertia();
1231 }
1232 
1236 Inertia calcBodyInertiaAboutAnotherBodyStation
1237  (const State& state, const MobilizedBody& inBodyA,
1238  const Vec3& aboutLocationOnBodyA) const
1239 {
1240  // get B's mass props MB, measured about Bo, exp. in B
1241  const MassProperties& MB_Bo_B = getBodyMassProperties(state);
1242 
1243  // Calculate the vector from the body B origin (current "about" point) to
1244  // the new "about" point PA, expressed in B.
1245  const Vec3 p_Bo_PA =
1246  findStationAtAnotherBodyStation(state, inBodyA, aboutLocationOnBodyA);
1247 
1248  // Now shift the "about" point for body B's inertia IB to PA, but still
1249  // expressed in B.
1250  const Inertia IB_PA_B = MB_Bo_B.calcShiftedInertia(p_Bo_PA);
1251 
1252  // Finally reexpress the inertia in the A frame.
1253  const Rotation R_BA =
1254  inBodyA.findBodyRotationInAnotherBody(state, *this);
1255  const Inertia IB_PA_A = IB_PA_B.reexpress(R_BA);
1256  return IB_PA_A;
1257 }
1258 
1259 
1263  const MassProperties M_Bo_G = expressMassPropertiesInGroundFrame(state);
1264  const SpatialVec& V_GB = getBodyVelocity(state);
1265  return M_Bo_G.toSpatialMat() * V_GB;
1266 }
1267 
1270 SpatialVec calcBodyMomentumAboutBodyMassCenterInGround
1271  (const State& state) const {
1272  const MassProperties& M_Bo_B = getBodyMassProperties(state);
1273  const Rotation& R_GB = getBodyRotation(state);
1274 
1275  // Given a central inertia matrix I, angular velocity w, and mass center
1276  // velocity v, the central angular momentum is Iw and linear momentum is mv.
1277  const Inertia I_Bc_B = M_Bo_B.calcCentralInertia();
1278  const Inertia I_Bc_G = I_Bc_B.reexpress(~R_GB);
1279  const Real mb = M_Bo_B.getMass();
1280  const Vec3& w_GB = getBodyAngularVelocity(state);
1281  Vec3 v_GBc =
1282  findStationVelocityInGround(state, M_Bo_B.getMassCenter());
1283 
1284  return SpatialVec( I_Bc_G*w_GB, mb*v_GBc );
1285 }
1286 
1291  const Vec3& locationOnBodyB,
1292  const MobilizedBody& bodyA,
1293  const Vec3& locationOnBodyA) const
1294 {
1295  if (isSameMobilizedBody(bodyA))
1296  return (locationOnBodyA-locationOnBodyB).norm();
1297 
1298  const Vec3 r_Go_PB =
1299  this->findStationLocationInGround(state,locationOnBodyB);
1300  const Vec3 r_Go_PA =
1301  bodyA.findStationLocationInGround(state,locationOnBodyA);
1302  return (r_Go_PA - r_Go_PB).norm();
1303 }
1304 
1310 Real calcStationToStationDistanceTimeDerivative
1311  (const State& state,
1312  const Vec3& locationOnBodyB,
1313  const MobilizedBody& bodyA,
1314  const Vec3& locationOnBodyA) const
1315 {
1316  if (isSameMobilizedBody(bodyA))
1317  return 0;
1318 
1319  Vec3 rB, rA, vB, vA;
1320  this->findStationLocationAndVelocityInGround(state,locationOnBodyB,rB,vB);
1321  bodyA.findStationLocationAndVelocityInGround(state,locationOnBodyA,rA,vA);
1322  const Vec3 r = rA-rB, v = vA-vB;
1323  const Real d = r.norm();
1324 
1325  // When the points are coincident, the rate of change of distance is just
1326  // their relative speed. Otherwise, it is the speed along the direction of
1327  // separation.
1328  if (d==0) return v.norm();
1329  else return dot(v, r/d);
1330 }
1331 
1332 
1338 Real calcStationToStationDistance2ndTimeDerivative
1339  (const State& state,
1340  const Vec3& locationOnBodyB,
1341  const MobilizedBody& bodyA,
1342  const Vec3& locationOnBodyA) const
1343 {
1344  if (isSameMobilizedBody(bodyA))
1345  return 0;
1346 
1347  Vec3 rB, rA, vB, vA, aB, aA;
1348  this->findStationLocationVelocityAndAccelerationInGround
1349  (state,locationOnBodyB,rB,vB,aB);
1351  (state,locationOnBodyA,rA,vA,aA);
1352 
1353  const Vec3 r = rA-rB, v = vA-vB, a = aA-aB;
1354  const Real d = r.norm();
1355 
1356  // This method is the time derivative of
1357  // calcFixedPointToPointDistanceTimeDerivative(), so it must follow the same
1358  // two cases. That is, when the points are coincident the change in
1359  // separation rate is the time derivative of the speed |v|, otherwise it is
1360  // the time derivative of the speed along the separation vector.
1361 
1362  if (d==0) {
1363  // Return d/dt |v|. This has two cases: if |v| is zero, the rate of
1364  // change of speed is just the points' relative acceleration magnitude.
1365  // Otherwise, it is the acceleration in the direction of the current
1366  // relative velocity vector.
1367  const Real s = v.norm(); // speed
1368  if (s==0) return a.norm();
1369  else return dot(a, v/s);
1370  }
1371 
1372  // Points are separated.
1373  const Vec3 u = r/d; // u is separation direction (a unit vector from B to A)
1374  const Vec3 vp = v - dot(v,u)*u; // velocity perp. to separation direction
1375  return dot(a,u) + dot(vp,v)/d;
1376 }
1377 
1378 
1381 Vec3 calcBodyMovingPointVelocityInBody
1382  (const State& state,
1383  const Vec3& locationOnBodyB,
1384  const Vec3& velocityOnBodyB,
1385  const MobilizedBody& inBodyA) const
1386 {
1387  SimTK_ASSERT_ALWAYS(!"unimplemented method",
1388  "MobilizedBody::calcBodyMovingPointVelocityInBody()"
1389  " is not yet implemented -- any volunteers?");
1390  return Vec3::getNaN();
1391 }
1392 
1393 
1397 Vec3 calcBodyMovingPointAccelerationInBody
1398  (const State& state,
1399  const Vec3& locationOnBodyB,
1400  const Vec3& velocityOnBodyB,
1401  const Vec3& accelerationOnBodyB,
1402  const MobilizedBody& inBodyA) const
1403 {
1404  SimTK_ASSERT_ALWAYS(!"unimplemented method",
1405  "MobilizedBody::calcBodyMovingPointAccelerationInBody()"
1406  " is not yet implemented -- any volunteers?");
1407  return Vec3::getNaN();
1408 }
1409 
1416 Real calcMovingPointToPointDistanceTimeDerivative
1417  (const State& state,
1418  const Vec3& locationOnBodyB,
1419  const Vec3& velocityOnBodyB,
1420  const MobilizedBody& bodyA,
1421  const Vec3& locationOnBodyA,
1422  const Vec3& velocityOnBodyA) const
1423 {
1424  SimTK_ASSERT_ALWAYS(!"unimplemented method",
1425  "MobilizedBody::calcMovingPointToPointDistanceTimeDerivative()"
1426  " is not yet implemented -- any volunteers?");
1427  return NaN;
1428 }
1429 
1437 Real calcMovingPointToPointDistance2ndTimeDerivative
1438  (const State& state,
1439  const Vec3& locationOnBodyB,
1440  const Vec3& velocityOnBodyB,
1441  const Vec3& accelerationOnBodyB,
1442  const MobilizedBody& bodyA,
1443  const Vec3& locationOnBodyA,
1444  const Vec3& velocityOnBodyA,
1445  const Vec3& accelerationOnBodyA) const
1446 {
1447  SimTK_ASSERT_ALWAYS(!"unimplemented method",
1448  "MobilizedBody::calcMovingPointToPointDistance2ndTimeDerivative()"
1449  " is not yet implemented -- any volunteers?");
1450  return NaN;
1451 }
1452 
1453 
1454 // End of High Level Operators.
1458  // CONSTRUCTION METHODS //
1461 
1465 
1467 explicit MobilizedBody(MobilizedBodyImpl* r);
1468 
1469 //------------------------------------------------------------------------------
1479 const Body& getBody() const;
1480 
1485 Body& updBody();
1486 
1492 MobilizedBody& setBody(const Body&);
1493 
1501 int addBodyDecoration(const Transform& X_BD,
1502  const DecorativeGeometry& geometry) {
1503  return updBody().addDecoration(X_BD, geometry);
1504 }
1508  return updBody().addDecoration(geometry);
1509 }
1510 
1517 int addOutboardDecoration(const Transform& X_MD,
1518  const DecorativeGeometry& geometry);
1520 int getNumOutboardDecorations() const;
1522 const DecorativeGeometry& getOutboardDecoration(int i) const;
1524 DecorativeGeometry& updOutboardDecoration(int i);
1525 
1532 int addInboardDecoration(const Transform& X_FD,
1533  const DecorativeGeometry& geometry);
1535 int getNumInboardDecorations() const;
1537 const DecorativeGeometry& getInboardDecoration(int i) const;
1539 DecorativeGeometry& updInboardDecoration(int i);
1540 
1548  updBody().setDefaultRigidBodyMassProperties(m); // might not be allowed
1549  return *this;
1550 }
1551 
1554  // every body type can do this
1555  return getBody().getDefaultRigidBodyMassProperties();
1556 }
1557 
1565 void adoptMotion(Motion& ownerHandle);
1566 
1570 void clearMotion();
1571 
1575 bool hasMotion() const;
1576 
1583 const Motion& getMotion() const;
1584 
1590 MobilizedBody& setDefaultInboardFrame (const Transform& X_PF);
1596 MobilizedBody& setDefaultOutboardFrame(const Transform& X_BM);
1597 
1602 const Transform& getDefaultInboardFrame() const; // X_PF
1606 const Transform& getDefaultOutboardFrame() const; // X_BM
1607 
1612 operator MobilizedBodyIndex() const {return getMobilizedBodyIndex();}
1613 
1619 MobilizedBodyIndex getMobilizedBodyIndex() const;
1620 
1624 const MobilizedBody& getParentMobilizedBody() const;
1625 
1630 const MobilizedBody& getBaseMobilizedBody() const;
1631 
1635 const SimbodyMatterSubsystem& getMatterSubsystem() const;
1639 SimbodyMatterSubsystem& updMatterSubsystem();
1640 
1643 bool isInSubsystem() const;
1644 
1648 bool isInSameSubsystem(const MobilizedBody& mobod) const;
1649 
1654 bool isSameMobilizedBody(const MobilizedBody& mobod) const;
1655 
1658 bool isGround() const;
1659 
1664 int getLevelInMultibodyTree() const;
1665 
1669 MobilizedBody& cloneForNewParent(MobilizedBody& parent) const;
1670 
1671 
1672  // Utility operators //
1673 
1677 Real getOneFromQPartition
1678  (const State& state, int which, const Vector& qlike) const;
1679 
1684 Real& updOneFromQPartition
1685  (const State& state, int which, Vector& qlike) const;
1686 
1690 Real getOneFromUPartition
1691  (const State& state, int which, const Vector& ulike) const;
1692 
1697 Real& updOneFromUPartition(const State& state, int which, Vector& ulike) const;
1698 
1704 void applyOneMobilityForce(const State& state, int which, Real f,
1705  Vector& mobilityForces) const
1706 {
1707  updOneFromUPartition(state,which,mobilityForces) += f;
1708 }
1709 
1746 void convertQForceToUForce(const State& state,
1747  const Array_<Real,MobilizerQIndex>& fq,
1748  Array_<Real,MobilizerUIndex>& fu) const;
1749 
1756 void applyBodyForce(const State& state, const SpatialVec& spatialForceInG,
1757  Vector_<SpatialVec>& bodyForcesInG) const;
1758 
1764 void applyBodyTorque(const State& state, const Vec3& torqueInG,
1765  Vector_<SpatialVec>& bodyForcesInG) const;
1766 
1777 void applyForceToBodyPoint
1778  (const State& state, const Vec3& pointInB, const Vec3& forceInG,
1779  Vector_<SpatialVec>& bodyForcesInG) const;
1780 
1781 // End of Construction and Misc Methods.
1784  // BUILT IN MOBILIZER DECLARATIONS //
1787 
1788 //------------------------------------------------------------------------------
1789 // These are the built-in MobilizedBody types. Each of these has a known
1790 // number of coordinates and speeds (at least a default number) so
1791 // can define routines which return and accept specific-size arguments, e.g.
1792 // Real (for 1-dof mobilizer) and Vec5 (for 5-dof mobilizer). Here is the
1793 // conventional interface that each built-in should provide. The base type
1794 // provides similar routines but using variable-sized or "one at a time"
1795 // arguments. (Vec<1> here will actually be a Real; assume the built-in
1796 // MobilizedBody class is "BuiltIn")
1797 //
1798 // BuiltIn& setDefaultQ(const Vec<nq>&);
1799 // const Vec<nq>& getDefaultQ() const;
1800 //
1801 // const Vec<nq>& getQ[Dot[Dot]](const State&) const;
1802 // const Vec<nu>& getU[Dot](const State&) const;
1803 //
1804 // void setQ(State&, const Vec<nq>&) const;
1805 // void setU(State&, const Vec<nu>&) const;
1806 //
1807 // const Vec<nq>& getMyPartQ(const State&, const Vector& qlike) const;
1808 // const Vec<nu>& getMyPartU(const State&, const Vector& ulike) const;
1809 //
1810 // Vec<nq>& updMyPartQ(const State&, Vector& qlike) const;
1811 // Vec<nu>& updMyPartU(const State&, Vector& ulike) const;
1812 //
1813 // Each built in mobilized body type is declared in its own header
1814 // file using naming convention MobilizedBody_Pin.h, for example. All the
1815 // built-in headers are collected in MobilizedBody_BuiltIns.h; you should
1816 // include new ones there also.
1817 
1818 
1819 class Pin;
1820 typedef Pin Torsion;
1821 typedef Pin Revolute;
1822 
1823 class Universal;
1824 class Cylinder;
1825 class Weld;
1826 
1827 class Slider;
1828 typedef Slider Prismatic;
1829 
1831 typedef Translation Cartesian;
1833 
1835 typedef BendStretch PolarCoords;
1836 
1837 class SphericalCoords;
1838 class LineOrientation;
1839 
1840 class Planar;
1841 class Gimbal;
1842 class Bushing;
1843 
1844 class Ball;
1845 typedef Ball Orientation;
1846 typedef Ball Spherical;
1847 
1848 class Free;
1849 class FreeLine;
1850 class Screw;
1851 class Ellipsoid;
1852 class Custom;
1853 class Ground;
1854 class FunctionBased;
1855 
1856 // Internal use only.
1857 class PinImpl;
1858 class SliderImpl;
1859 class UniversalImpl;
1860 class CylinderImpl;
1861 class BendStretchImpl;
1862 class PlanarImpl;
1863 class GimbalImpl;
1864 class BushingImpl;
1865 class BallImpl;
1866 class TranslationImpl;
1867 class SphericalCoordsImpl;
1868 class FreeImpl;
1869 class LineOrientationImpl;
1870 class FreeLineImpl;
1871 class WeldImpl;
1872 class ScrewImpl;
1873 class EllipsoidImpl;
1874 class CustomImpl;
1875 class GroundImpl;
1876 class FunctionBasedImpl;
1877 };
1878 
1879 } // namespace SimTK
1880 
1881 #endif // SimTK_SIMBODY_MOBILIZED_BODY_H_
1882 
1883 
1884 
Three translational mobilities describing the Cartesian motion of a point.
Definition: MobilizedBody_Translation.h:38
Vec< 2, Vec3 > SpatialVec
Spatial vectors are used for (rotation,translation) quantities and consist of a pair of Vec3 objects...
Definition: MassProperties.h:50
const MassProperties & getDefaultMassProperties() const
Return the mass properties of the Body stored within this MobilizedBody.
Definition: MobilizedBody.h:1553
void findStationLocationVelocityAndAccelerationInGround(const State &state, const Vec3 &locationOnB, Vec3 &locationOnGround, Vec3 &velocityInGround, Vec3 &accelerationInGround) const
It is cheaper to calculate a station's ground location, velocity, and acceleration together than to d...
Definition: MobilizedBody.h:1028
This is for arrays indexed by mobilized body number within a subsystem (typically the SimbodyMatterSu...
static Vec< M, ELT, 1 > getNaN()
Return a Vec of the same length and element type as this one but with all elements set to NaN...
Definition: Vec.h:860
Vec3 findStationLocationInAnotherBody(const State &state, const Vec3 &stationOnB, const MobilizedBody &toBodyA) const
Given a station S on this body B, return the location on another body A which is at the same location...
Definition: MobilizedBody.h:929
InertiaP calcCentralInertia() const
Return the inertia of this MassProperties object, but measured about the mass center rather than abou...
Definition: MassProperties.h:1429
Vec3 findStationLocationInGround(const State &state, const Vec3 &stationOnB) const
Return the Cartesian (ground) location that is currently coincident with a station (point) S fixed on...
Definition: MobilizedBody.h:915
const Vec3P & getMassCenter() const
Return the mass center currently stored in this MassProperties object; this is expressed in an implic...
Definition: MassProperties.h:1408
Three mobilities – z rotation and x,y translation.
Definition: MobilizedBody_Planar.h:38
This is a special type of "mobilized" body generated automatically by Simbody as a placeholder for ...
Definition: MobilizedBody_Ground.h:45
we know q, u, and udot
Definition: Motion.h:116
MobilizedBody Mobod
Mobod is the approved abbreviation for MobilizedBody. Feel free to use it if you get tired of typing ...
Definition: MobilizedBody.h:63
Vec3 findBodyOriginAccelerationInAnotherBody(const State &state, const MobilizedBody &inBodyA) const
Return the acceleration of body B's origin point in body A's frame, expressed in body A...
Definition: MobilizedBody.h:862
Five mobilities, representing unrestricted motion for a body which is inertialess along its own z axi...
Definition: MobilizedBody_FreeLine.h:58
The Body class represents a reference frame that can be used to describe mass properties and geometry...
Definition: Body.h:55
Unique integer type for Subsystem-local u indexing.
One mobility – coordinated rotation and translation along the common z axis of the inboard and outboa...
Definition: MobilizedBody_Screw.h:39
Two mobilities, representing unrestricted orientation for a body which is inertialess along its own z...
Definition: MobilizedBody_LineOrientation.h:59
#define SimTK_ASSERT_ALWAYS(cond, msg)
Definition: ExceptionMacros.h:349
const Vec3 & getBodyAngularVelocity(const State &state) const
Extract from the state cache the already-calculated inertial angular velocity vector w_GB of this bod...
Definition: MobilizedBody.h:353
This defines the API for the Body base class and concrete Body types like Body::Rigid that are derive...
SpatialMatP toSpatialMat() const
Convert this MassProperties object to a spatial inertia matrix and return it as a SpatialMat...
Definition: MassProperties.h:1528
const SpatialVec & getMobilizerAcceleration(const State &state) const
TODO: Not implemented yet – any volunteers? At stage Acceleration, return the cross-mobilizer acceler...
Definition: MobilizedBody.h:399
A Motion object belongs to a particular MobilizedBody and prescribes how the associated motion is to ...
Definition: Motion.h:107
const UnitInertia & getBodyUnitInertiaAboutBodyOrigin(const State &state) const
Return a reference to this body's unit inertia matrix in the State cache, taken about the body origin...
Definition: MobilizedBody.h:430
Slider Prismatic
Synonym for Slider mobilizer.
Definition: MobilizedBody.h:1827
Two mobilities – rotation and translation along the common z axis of the inboard and outboard mobiliz...
Definition: MobilizedBody_Cylinder.h:42
Vec3 findMassCenterLocationInGround(const State &state) const
Return the Cartesian (ground) location of this body B's mass center.
Definition: MobilizedBody.h:1051
const Vec3 & getBodyMassCenterStation(const State &state) const
Return this body's center of mass station (i.e., the vector fixed in the body, going from body origin...
Definition: MobilizedBody.h:423
Three mobilities – coordinated rotation and translation along the surface of an ellipsoid fixed to th...
Definition: MobilizedBody_Ellipsoid.h:45
SpatialVec findBodyAccelerationInAnotherBody(const State &state, const MobilizedBody &inBodyA) const
Return the angular and linear acceleration of body B's frame in body A's frame, expressed in body A...
Definition: MobilizedBody.h:815
Translation Cartesian
Synonym for Translation mobilizer.
Definition: MobilizedBody.h:1830
const RealP & getMass() const
Return the mass currently stored in this MassProperties object.
Definition: MassProperties.h:1403
Every Simbody header and source file should include this header before any other Simbody header...
This class contains the mass, center of mass, and unit inertia matrix of a rigid body B...
Definition: MassProperties.h:85
Ball Spherical
Synonym for Ball mobilizer.
Definition: MobilizedBody.h:1846
Vec3 expressGroundVectorInBodyFrame(const State &state, const Vec3 &vectorInG) const
Re-express a vector expressed in Ground into the same vector expressed in this body B...
Definition: MobilizedBody.h:1147
MassProperties expressMassPropertiesInGroundFrame(const State &state) const
Re-express this body B's mass properties in Ground by applying only a rotation, not a shift of refere...
Definition: MobilizedBody.h:1168
Vec3 findBodyAngularVelocityInAnotherBody(const State &state, const MobilizedBody &inBodyA) const
Return the angular velocity w_AB of body B's frame in body A's frame, expressed in body A...
Definition: MobilizedBody.h:785
This is the handle class for the hidden State implementation.
Definition: State.h:264
const Real NaN
This is the IEEE "not a number" constant for this implementation of the default-precision Real type; ...
Inertia calcBodyCentralInertia(const State &state, MobilizedBodyIndex objectBodyB) const
Return the central inertia for body B, that is, the inertia taken about body B's mass center Bc...
Definition: MobilizedBody.h:1227
Mat< 3, 3 > Mat33
Definition: SmallMatrix.h:184
int addBodyDecoration(const Transform &X_BD, const DecorativeGeometry &geometry)
Add decorative geometry specified relative to the new (outboard) body's reference frame B...
Definition: MobilizedBody.h:1501
Three mobilities – unrestricted orientation modeled as a 1-2-3 body-fixed Euler angle sequence...
Definition: MobilizedBody_Gimbal.h:69
SpatialMat calcBodySpatialInertiaMatrixInGround(const State &state) const
Return the mass properties of body B, measured from and about the B origin Bo, but expressed in Groun...
Definition: MobilizedBody.h:1211
const Vec3 & getBodyOriginAcceleration(const State &state) const
Extract from the state cache the already-calculated inertial linear acceleration vector a_GB (more ex...
Definition: MobilizedBody.h:390
const Vec3 & getBodyOriginLocation(const State &state) const
Extract from the state cache the already-calculated spatial location of body B's body frame origin Bo...
Definition: MobilizedBody.h:332
Level
What is the highest level of motion that is driven? Lower levels are also driven; higher levels are d...
Definition: Motion.h:112
The SimTK::Array_<T> container class is a plug-compatible replacement for the C++ standard template l...
Definition: Array.h:50
Pin Torsion
Synonym for Pin mobilizer.
Definition: MobilizedBody.h:1819
Real getBodyMass(const State &state) const
Return the mass of this body.
Definition: MobilizedBody.h:416
SpatialVec calcBodyMomentumAboutBodyOriginInGround(const State &state)
Calculate body B's momentum (angular, linear) measured and expressed in Ground, but taken about the b...
Definition: MobilizedBody.h:1262
MassProperties_ reexpress(const RotationP &R_BC) const
Re-express these mass properties from the current frame "B" to a new frame "C", given the orientation...
Definition: MassProperties.h:1477
Vec3 findBodyOriginVelocityInAnotherBody(const State &state, const MobilizedBody &inBodyA) const
Return the velocity of body B's origin point in body A's frame, expressed in body A...
Definition: MobilizedBody.h:802
Three mobilities – unrestricted orientation modeled with a quaternion which is never singular...
Definition: MobilizedBody_Ball.h:44
Rotation findBodyRotationInAnotherBody(const State &state, const MobilizedBody &inBodyA) const
Return R_AB, the rotation matrix giving this body B's axes in body A's frame.
Definition: MobilizedBody.h:730
int addBodyDecoration(const DecorativeGeometry &geometry)
Convenience method for use when the geometry is supplied in the body frame.
Definition: MobilizedBody.h:1507
MobilizedBody()
The default constructor provides an empty MobilizedBody handle that can be assigned to reference any ...
Definition: MobilizedBody.h:1464
Unique integer type for Subsystem-local q indexing.
Vec3 findStationAtGroundPoint(const State &state, const Vec3 &locationInG) const
Return the station (point) S of this body B that is coincident with the given Ground location...
Definition: MobilizedBody.h:1071
const Vec3 & getBodyOriginVelocity(const State &state) const
Extract from the state cache the already-calculated inertial linear velocity vector v_GB (more explic...
Definition: MobilizedBody.h:360
Pin Revolute
Synonym for Pin mobilizer.
Definition: MobilizedBody.h:1821
InertiaP calcShiftedInertia(const Vec3P &newOriginB) const
Return the inertia of this MassProperties object, but with the "measured about" point shifted from th...
Definition: MassProperties.h:1436
Provides one rotational mobility about the common z axis of the F and M frames of the mobilizer...
Definition: MobilizedBody_Pin.h:46
const Vec< 3, P > & p() const
Return a read-only reference to our translation vector p_BF.
Definition: Transform.h:239
invalid level
Definition: Motion.h:113
One mobility – translation along the common x axis of the F (inboard) and M (outboard) mobilizer fram...
Definition: MobilizedBody_Slider.h:46
Direction
Constructors can take an argument of this type to indicate that the mobilizer is being defined in the...
Definition: MobilizedBody.h:180
This is a subclass of MobilizedBody::Custom which uses a set of Function objects to define the behavi...
Definition: MobilizedBody_FunctionBased.h:46
Mat< 2, 2, Mat33 > SpatialMat
Spatial matrices are used to hold 6x6 matrices that are best viewed as 2x2 matrices of 3x3 matrices; ...
Definition: MassProperties.h:72
This defines the Motion class, which is used to specify how the mobilities associated with a particul...
const Real Infinity
This is the IEEE positive infinity constant for this implementation of the default-precision Real typ...
The physical meaning of an inertia is the distribution of a rigid body's mass about a particular poin...
Definition: MassProperties.h:82
This is the client-side interface to an implementation-independent representation of "Decorations" su...
Definition: DecorativeGeometry.h:86
CNT< typename CNT< E1 >::THerm >::template Result< E2 >::Mul dot(const Vec< M, E1, S1 > &r, const Vec< M, E2, S2 > &v)
Definition: SmallMatrixMixed.h:86
void applyOneMobilityForce(const State &state, int which, Real f, Vector &mobilityForces) const
This utility adds in the supplied generalized force f (a scalar) to the appropriate slot of the suppl...
Definition: MobilizedBody.h:1704
A UnitInertia matrix is a unit-mass inertia matrix; you can convert it to an Inertia by multiplying i...
Definition: MassProperties.h:81
bool isLocked(const State &state) const
Check whether this mobilizer is currently locked in the given state.
Definition: MobilizedBody.h:262
Vec3 findStationVelocityInAnotherBody(const State &state, const Vec3 &stationOnBodyB, const MobilizedBody &inBodyA) const
Return the velocity of a station S fixed on body B, in body A's frame, expressed in body A...
Definition: MobilizedBody.h:956
#define SimTK_SIMBODY_EXPORT
Definition: Simbody/include/simbody/internal/common.h:72
Two mobilities – rotation about the x axis, followed by a rotation about the new y axis...
Definition: MobilizedBody_Universal.h:40
A MobilizedBody is Simbody's fundamental body-and-joint object used to parameterize a system's motion...
Definition: MobilizedBody.h:167
CNT< ScalarNormSq >::TSqrt norm() const
Definition: Vec.h:555
A spatial inertia contains the mass, center of mass point, and inertia matrix for a rigid body...
Definition: MassProperties.h:83
bool isLockedByDefault() const
Check whether this mobilizer is to be locked in the default state.
Definition: MobilizedBody.h:285
Ball Orientation
Synonym for Ball mobilizer.
Definition: MobilizedBody.h:1844
The handle class MobilizedBody::Custom (dataless) and its companion class MobilizedBody::Custom::Impl...
Definition: MobilizedBody_Custom.h:72
Unrestricted motion for a rigid body (six mobilities).
Definition: MobilizedBody_Free.h:52
This class represents a small matrix whose size is known at compile time, containing elements of any ...
Definition: Mat.h:51
const Rotation & getBodyRotation(const State &state) const
Extract from the state cache the already-calculated spatial orientation R_GB of body B's body frame x...
Definition: MobilizedBody.h:325
This subsystem contains the bodies ("matter") in the multibody system, the mobilizers (joints) that d...
Definition: SimbodyMatterSubsystem.h:130
SpatialVec findRelativeAcceleration(const Transform &X_FA, const SpatialVec &V_FA, const SpatialVec &A_FA, const Transform &X_FB, const SpatialVec &V_FB, const SpatialVec &A_FB)
Find the relative spatial acceleration between two frames A and B whose individual spatial accelerati...
Definition: SpatialAlgebra.h:245
Zero mobilities.
Definition: MobilizedBody_Weld.h:43
Method
There are several ways to specify the motion at this Level, and the selected method also determines l...
Definition: Motion.h:126
BendStretch PolarCoords
Synonym for BendStretch mobilizer.
Definition: MobilizedBody.h:1834
const SpatialVec & getBodyVelocity(const State &state) const
Extract from the state cache the already-calculated spatial velocity V_GB of this body's reference fr...
Real calcStationToStationDistance(const State &state, const Vec3 &locationOnBodyB, const MobilizedBody &bodyA, const Vec3 &locationOnBodyA) const
Calculate the distance from a station PB on body B to a station PA on body A.
Definition: MobilizedBody.h:1290
const Vec3 & getBodyAngularAcceleration(const State &state) const
Extract from the state cache the already-calculated inertial angular acceleration vector b_GB of this...
Definition: MobilizedBody.h:382
Transform findBodyTransformInAnotherBody(const State &state, const MobilizedBody &inBodyA) const
Return X_AB, the spatial transform giving this body B's frame in body A's frame.
Definition: MobilizedBody.h:716
Vec3 findStationAccelerationInAnotherBody(const State &state, const Vec3 &stationOnBodyB, const MobilizedBody &inBodyA) const
Return the acceleration of a station S fixed on body B, in another body A's frame, expressed in body A.
Definition: MobilizedBody.h:991
const Transform & getBodyTransform(const State &state) const
Extract from the state cache the already-calculated spatial configuration X_GB of body B's body frame...
const Rotation_< P > & R() const
Return a read-only reference to the contained rotation R_BF.
Definition: Transform.h:215
The Mobilizer associated with each MobilizedBody, once modeled, has a specific number of generalized ...
Three mobilities – body fixed 3-2 (z-y) rotation followed by translation along body z or body x...
Definition: MobilizedBody_SphericalCoords.h:77
void findStationLocationAndVelocityInGround(const State &state, const Vec3 &locationOnB, Vec3 &locationOnGround, Vec3 &velocityInGround) const
It is cheaper to calculate a station's ground location and velocity together than to do them separate...
Definition: MobilizedBody.h:1010
Two mobilities: The z axis of the parent's F frame is used for rotation (and that is always aligned w...
Definition: MobilizedBody_BendStretch.h:42
const SpatialVec & getBodyAcceleration(const State &state) const
Extract from the state cache the already-calculated spatial acceleration A_GB of this body's referenc...
MobilizedBody & setDefaultMassProperties(const MassProperties &m)
If the contained Body can have its mass properties set to the supplied value m its mass properties ar...
Definition: MobilizedBody.h:1547
Translation CartesianCoords
Synonym for Translation mobilizer.
Definition: MobilizedBody.h:1832
Six mobilities – arbitrary relative motion modeled as x-y-z translation followed by an x-y-z body-fix...
Definition: MobilizedBody_Bushing.h:86
Inertia_ reexpress(const Rotation_< P > &R_FB) const
Return a new inertia matrix like this one but re-expressed in another frame (leaving the origin point...
Definition: MassProperties.h:375