Simbody 3.9
Loading...
Searching...
No Matches
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"
43
44#include <cassert>
45
46namespace SimTK {
47
48class SimbodyMatterSubsystem;
49class Motion;
50class MobilizedBody;
51class 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//==============================================================================
170public:
171
182 Forward = 0,
183 Reverse = 1
185
186//------------------------------------------------------------------------------
220void lock(State& state, Motion::Level level=Motion::Position) const;
221
230void lockAt(State& state, Real value,
231 Motion::Level level=Motion::Position) const;
232
241void lockAt(State& state, const Vector& value,
242 Motion::Level level=Motion::Position) const;
243
253template <int N> SimTK_SIMBODY_EXPORT // instantiated in library
254void lockAt(State& state, const Vec<N>& value,
255 Motion::Level level=Motion::Position) const;
256
260void unlock(State& state) const;
261
263bool isLocked(const State& state) const
264{ return getLockLevel(state)!=Motion::NoLevel; }
265
268Motion::Level getLockLevel(const State& state) const;
269
274
284
286bool isLockedByDefault() const
287{ return getLockByDefaultLevel()!=Motion::NoLevel; }
288
295 // STATE ACCESS METHODS //
297
298//------------------------------------------------------------------------------
316const Transform& getBodyTransform(const State& state) const; // X_GB
317
326const Rotation& getBodyRotation(const State& state) const {
327 return getBodyTransform(state).R();
328}
333const Vec3& getBodyOriginLocation(const State& state) const {
334 return getBodyTransform(state).p();
335}
336
340const Transform& getMobilizerTransform(const State& state) const; // X_FM
341
348const SpatialVec& getBodyVelocity(const State& state) const; // V_GB
349
354const Vec3& getBodyAngularVelocity(const State& state) const { // w_GB
355 return getBodyVelocity(state)[0];
356}
361const Vec3& getBodyOriginVelocity(const State& state) const { // v_GB
362 return getBodyVelocity(state)[1];
363}
364
369const SpatialVec& getMobilizerVelocity(const State& state) const; // V_FM
370
377const SpatialVec& getBodyAcceleration(const State& state) const; // A_GB
378
383const Vec3& getBodyAngularAcceleration(const State& state) const { // b_GB
384 return getBodyAcceleration(state)[0];
385}
386
391const Vec3& getBodyOriginAcceleration(const State& state) const { // a_GB
392 return getBodyAcceleration(state)[1];
393}
394
400const SpatialVec& getMobilizerAcceleration(const State& state) const { // A_FM
401 SimTK_ASSERT_ALWAYS(!"unimplemented method",
402"MobilizedBody::getMobilizerAcceleration() not yet implemented -- volunteers?");
403 return *(new SpatialVec());
404}
405
408const MassProperties& getBodyMassProperties(const State& state) const;
409
414
417Real getBodyMass(const State& state) const {
418 return getBodyMassProperties(state).getMass();
419}
420
424const Vec3& getBodyMassCenterStation(const State& state) const {
425 return getBodyMassProperties(state).getMassCenter();
426}
427
432 return getBodyMassProperties(state).getUnitInertia();
433}
434
440const Transform& getInboardFrame (const State& state) const; // X_PF
446const Transform& getOutboardFrame(const State& state) const; // X_BM
447
453void setInboardFrame(State& state, const Transform& X_PF) const;
459void setOutboardFrame(State& state, const Transform& X_BM) const;
460
461// End of State Access - Bodies
465//------------------------------------------------------------------------------
472int getNumQ(const State& state) const;
475int getNumU(const State& state) const;
476
479QIndex getFirstQIndex(const State& state) const;
480
483UIndex getFirstUIndex(const State& state) const;
484
494
499Real getOneQ(const State& state, int which) const;
500
504Real getOneU(const State& state, int which) const;
505
509Vector getQAsVector(const State& state) const;
513Vector getUAsVector(const State& state) const;
514
519Real getOneQDot (const State& state, int which) const;
523Vector getQDotAsVector(const State& state) const;
524
529Real getOneUDot(const State& state, int which) const;
534Real getOneQDotDot(const State& state, int which) const;
538Vector getUDotAsVector(const State& state) const;
543Vector getQDotDotAsVector(const State& state) const;
544
554Vector getTauAsVector(const State& state) const;
555
560Real getOneTau(const State& state, MobilizerUIndex which) const;
561
566void setOneQ(State& state, int which, Real v) const;
571void setOneU(State& state, int which, Real v) const;
572
576void setQFromVector(State& state, const Vector& v) const;
580void setUFromVector(State& state, const Vector& v) const;
581
615void setQToFitTransform(State& state, const Transform& X_FM) const;
616
621void setQToFitRotation(State& state, const Rotation& R_FM) const;
622
628void setQToFitTranslation(State& state, const Vec3& p_FM) const;
629
636void setUToFitVelocity(State& state, const SpatialVec& V_FM) const;
637
642void setUToFitAngularVelocity(State& state, const Vec3& w_FM) const;
643
649void setUToFitLinearVelocity(State& state, const Vec3& v_FM) const;
650
660SpatialVec getHCol(const State& state, MobilizerUIndex ux) const;
661
669
670// End of State Access Methods.
673
674 // BASIC OPERATORS //
676
677//------------------------------------------------------------------------------
722 const MobilizedBody& inBodyA) const
723{
724 const Transform& X_GA = inBodyA.getBodyTransform(state);
725 const Transform& X_GB = this->getBodyTransform(state);
726
727 return ~X_GA*X_GB; // X_AB=X_AG*X_GB
728}
729
736 const MobilizedBody& inBodyA) const
737{
738 const Rotation& R_GA = inBodyA.getBodyRotation(state);
739 const Rotation& R_GB = this->getBodyRotation(state);
740
741 return ~R_GA*R_GB; // R_AB=R_AG*R_GB
742}
743
751 (const State& state, const MobilizedBody& toBodyA) const {
752 return toBodyA.findStationAtGroundPoint(state,
753 getBodyOriginLocation(state));
754}
755
762 (const State& state, const MobilizedBody& inBodyA) const
763{
764 const SpatialVec& V_GB = this->getBodyVelocity(state);
765 const SpatialVec& V_GA = inBodyA.getBodyVelocity(state);
766 // angular velocity of B in A, exp in G
767 const Vec3 w_AB_G = V_GB[0]-V_GA[0]; // 3 flops
768
769 // Angular vel. was easy, but for linear vel. we have to add in an wXr term.
770
771 const Transform& X_GB = getBodyTransform(state);
772 const Transform& X_GA = inBodyA.getBodyTransform(state);
773 // vector from Ao to Bo, exp in G
774 const Vec3 p_AB_G = X_GB.p() - X_GA.p(); // 3 flops
775 // d/dt p taken in G
776 const Vec3 p_AB_G_dot = V_GB[1] - V_GA[1]; // 3 flops
777
778 // d/dt p taken in A, exp in G
779 const Vec3 v_AB_G = p_AB_G_dot - V_GA[0] % p_AB_G; // 12 flops
780
781 // We're done, but answer is expressed in Ground. Reexpress in A and return.
782 return ~X_GA.R()*SpatialVec(w_AB_G, v_AB_G); // 30 flops
783}
784
791 const MobilizedBody& inBodyA) const
792{
793 const Vec3& w_GB = getBodyAngularVelocity(state);
794 const Vec3& w_GA = inBodyA.getBodyAngularVelocity(state);
795 // angular velocity of B in A, exp in G
796 const Vec3 w_AB_G = w_GB-w_GA; // 3 flops
797
798 // Now reexpress in A.
799 return inBodyA.expressGroundVectorInBodyFrame(state, w_AB_G); // 15 flops
800}
801
808 const MobilizedBody& inBodyA) const
809{
810 // Doesn't save much to special case this one.
811 return findBodyVelocityInAnotherBody(state,inBodyA)[1];
812}
813
821 const MobilizedBody& inBodyA) const
822{
823 const Transform& X_GA = inBodyA.getBodyTransform(state);
824 const SpatialVec& V_GA = inBodyA.getBodyVelocity(state);
825 const SpatialVec& A_GA = inBodyA.getBodyAcceleration(state);
826 const Transform& X_GB = this->getBodyTransform(state);
827 const SpatialVec& V_GB = this->getBodyVelocity(state);
828 const SpatialVec& A_GB = this->getBodyAcceleration(state);
829
830 return findRelativeAcceleration(X_GA, V_GA, A_GA,
831 X_GB, V_GB, A_GB);
832}
833
840 (const State& state, const MobilizedBody& inBodyA) const
841{
842 const Rotation& R_GA = inBodyA.getBodyRotation(state);
843 const Vec3& w_GA = inBodyA.getBodyAngularVelocity(state);
844 const Vec3& w_GB = this->getBodyAngularVelocity(state);
845 const Vec3& b_GA = inBodyA.getBodyAngularAcceleration(state);
846 const Vec3& b_GB = this->getBodyAngularAcceleration(state);
847
848 // relative ang. vel. of B in A, exp. in G
849 const Vec3 w_AB_G = w_GB - w_GA; // 3 flops
850 const Vec3 w_AB_G_dot = b_GB - b_GA; // d/dt of w_AB_G taken in G; 3 flops
851
852 // We have the derivative in G; change it to derivative in A by adding
853 // in contribution caused by motion of G in A, that is w_AG X w_AB_G.
854 // (Note that w_AG=-w_GA.)
855 const Vec3 b_AB_G = w_AB_G_dot - w_GA % w_AB_G; // ang. accel. of B in A
856 // 12 flops
857
858 return ~R_GA * b_AB_G; // taken in A, expressed in A; 15 flops
859}
860
868 const MobilizedBody& inBodyA) const
869{
870 // Not much to be saved by trying to optimize this since the linear part
871 // is the most expensive to calculate.
872 return findBodyAccelerationInAnotherBody(state,inBodyA)[1];
873}
874
883
891 (const State& state) const;
892
902
911 (const State& state) const;
912
920 (const State& state, const Vec3& stationOnB) const {
921 return getBodyTransform(state) * stationOnB;
922}
923
924
934 (const State& state, const Vec3& stationOnB, const MobilizedBody& toBodyA)
935 const
936{
937 return toBodyA.findStationAtGroundPoint(state,
938 findStationLocationInGround(state,stationOnB));
939}
940
948 (const State& state, const Vec3& stationOnB) const {
949 const Vec3& w = getBodyAngularVelocity(state); // in G
950 const Vec3& v = getBodyOriginVelocity(state); // in G
951 const Vec3 r = expressVectorInGroundFrame(state,stationOnB); // 15 flops
952 return v + w % r; // 12 flops
953}
954
955
962 const Vec3& stationOnBodyB,//p_BS
963 const MobilizedBody& inBodyA) const
964{
965 const SpatialVec V_AB =
966 findBodyVelocityInAnotherBody(state, inBodyA); //51 flops
967 // Bo->S rexpressed in A but not shifted to Ao
968 const Vec3 p_BS_A =
969 expressVectorInAnotherBodyFrame(state, stationOnBodyB, inBodyA); //30
970 return V_AB[1] + (V_AB[0] % p_BS_A); //12 flops
971}
972
973
982 (const State& state, const Vec3& stationOnB) const {
983 const Vec3& w = getBodyAngularVelocity(state); // in G
984 const Vec3& b = getBodyAngularAcceleration(state); // in G
985 const Vec3& a = getBodyOriginAcceleration(state); // in G
986
987 const Vec3 r = expressVectorInGroundFrame(state,stationOnB); // 15 flops
988 return a + b % r + w % (w % r); // 33 flops
989}
990
997 const Vec3& stationOnBodyB,
998 const MobilizedBody& inBodyA) const
999{
1000 const Vec3 w_AB =
1001 findBodyAngularVelocityInAnotherBody(state,inBodyA); // 18 flops
1002 const SpatialVec A_AB =
1003 findBodyAccelerationInAnotherBody(state,inBodyA); // 105 flops
1004 // Bo->S rexpressed in A but not shifted to Ao
1005 const Vec3 p_BS_A =
1006 expressVectorInAnotherBodyFrame(state, stationOnBodyB, inBodyA); // 30
1007
1008 return A_AB[1] + (A_AB[0] % p_BS_A) + w_AB % (w_AB % p_BS_A); // 33 flops
1009}
1010
1015 (const State& state, const Vec3& locationOnB,
1016 Vec3& locationOnGround, Vec3& velocityInGround) const
1017{
1018 const Vec3& p_GB = getBodyOriginLocation(state);
1019 const Vec3 p_BS_G = expressVectorInGroundFrame(state,locationOnB);//15flops
1020 locationOnGround = p_GB + p_BS_G; // 3flops
1021
1022 const Vec3& w_GB = getBodyAngularVelocity(state);
1023 const Vec3& v_GB = getBodyOriginVelocity(state);
1024 velocityInGround = v_GB + w_GB % p_BS_G; // 12 flops
1025}
1026
1027
1033 (const State& state, const Vec3& locationOnB,
1034 Vec3& locationOnGround, Vec3& velocityInGround, Vec3& accelerationInGround)
1035 const
1036{
1037 const Rotation& R_GB = getBodyRotation(state);
1038 const Vec3& p_GB = getBodyOriginLocation(state);
1039
1040 // re-express station vector p_BS in G
1041 const Vec3 r = R_GB*locationOnB; // 15 flops
1042 locationOnGround = p_GB + r; // 3 flops
1043
1044 const Vec3& w = getBodyAngularVelocity(state); // in G
1045 const Vec3& v = getBodyOriginVelocity(state); // in G
1046 const Vec3& b = getBodyAngularAcceleration(state); // in G
1047 const Vec3& a = getBodyOriginAcceleration(state); // in G
1048
1049 const Vec3 wXr = w % r; // "whipping" velocity w X r due to ang vel; 9 flops
1050 velocityInGround = v + wXr; // v + w X r (3 flops)
1051 accelerationInGround = a + b % r + w % wXr; // 24 flops
1052}
1053
1057 return findStationLocationInGround(state,getBodyMassCenterStation(state));
1058}
1059
1064 (const State& state, const MobilizedBody& toBodyA) const {
1065 return findStationLocationInAnotherBody(state,
1066 getBodyMassCenterStation(state),toBodyA);
1067}
1068
1076 (const State& state, const Vec3& locationInG) const {
1077 return ~getBodyTransform(state) * locationInG;
1078}
1079
1086 (const State& state, const MobilizedBody& fromBodyA,
1087 const Vec3& stationOnA) const {
1088 return fromBodyA.findStationLocationInAnotherBody(state, stationOnA, *this);
1089}
1090
1095 (const State& state, const MobilizedBody& fromBodyA) const {
1096 return findStationAtGroundPoint(state,
1097 fromBodyA.getBodyOriginLocation(state));
1098}
1099
1104 (const State& state, const MobilizedBody& fromBodyA) const {
1105 return fromBodyA.findStationLocationInAnotherBody(state,
1106 getBodyMassCenterStation(state),*this);
1107}
1108
1113 (const State& state, const Transform& frameOnB) const {
1114 return getBodyTransform(state) * frameOnB;
1115}
1116
1123 (const State& state, const Transform& frameOnB) const {
1124 return SpatialVec(getBodyAngularVelocity(state),
1125 findStationVelocityInGround(state,frameOnB.p()));
1126}
1127
1134 (const State& state, const Transform& frameOnB) const {
1135 return SpatialVec(getBodyAngularAcceleration(state),
1136 findStationAccelerationInGround(state,frameOnB.p()));
1137}
1138
1143 (const State& state, const Vec3& vectorInB) const {
1144 return getBodyRotation(state)*vectorInB;
1145}
1146
1152 (const State& state, const Vec3& vectorInG) const {
1153 return ~getBodyRotation(state)*vectorInG;
1154}
1155
1162 (const State& state, const Vec3& vectorInB,
1163 const MobilizedBody& inBodyA) const
1164{
1165 return inBodyA.expressGroundVectorInBodyFrame(state,
1166 expressVectorInGroundFrame(state,vectorInB));
1167}
1168
1174 const MassProperties& M_Bo_B = getBodyMassProperties(state);
1175 const Rotation& R_GB = getBodyRotation(state);
1176 return M_Bo_B.reexpress(~R_GB);
1177}
1178
1184 (const State& state, const MobilizedBody& inBodyA) const {
1185 const MassProperties& M_Bo_B = getBodyMassProperties(state);
1186 const Rotation R_AB = findBodyRotationInAnotherBody(state,inBodyA);
1187 return M_Bo_B.reexpress(~R_AB);
1188}
1189
1190// End of Basic Operators.
1193//------------------------------------------------------------------------------
1217{
1218 if (isGround())
1219 return SpatialMat(Mat33(Infinity)); // sets diagonals to Inf
1220
1221 const MassProperties& mp = getBodyMassProperties(state);
1222 const Rotation& R_GB = getBodyRotation(state);
1223 // re-express in Ground without shifting, convert to spatial mat.
1224 return mp.reexpress(~R_GB).toSpatialMat();
1225}
1226
1230
1233 MobilizedBodyIndex objectBodyB) const
1234{
1235 return getBodyMassProperties(state).calcCentralInertia();
1236}
1237
1242 (const State& state, const MobilizedBody& inBodyA,
1243 const Vec3& aboutLocationOnBodyA) const
1244{
1245 // get B's mass props MB, measured about Bo, exp. in B
1246 const MassProperties& MB_Bo_B = getBodyMassProperties(state);
1247
1248 // Calculate the vector from the body B origin (current "about" point) to
1249 // the new "about" point PA, expressed in B.
1250 const Vec3 p_Bo_PA =
1251 findStationAtAnotherBodyStation(state, inBodyA, aboutLocationOnBodyA);
1252
1253 // Now shift the "about" point for body B's inertia IB to PA, but still
1254 // expressed in B.
1255 const Inertia IB_PA_B = MB_Bo_B.calcShiftedInertia(p_Bo_PA);
1256
1257 // Finally reexpress the inertia in the A frame.
1258 const Rotation R_BA =
1259 inBodyA.findBodyRotationInAnotherBody(state, *this);
1260 const Inertia IB_PA_A = IB_PA_B.reexpress(R_BA);
1261 return IB_PA_A;
1262}
1263
1264
1268 const MassProperties M_Bo_G = expressMassPropertiesInGroundFrame(state);
1269 const SpatialVec& V_GB = getBodyVelocity(state);
1270 return M_Bo_G.toSpatialMat() * V_GB;
1271}
1272
1276 (const State& state) const {
1277 const MassProperties& M_Bo_B = getBodyMassProperties(state);
1278 const Rotation& R_GB = getBodyRotation(state);
1279
1280 // Given a central inertia matrix I, angular velocity w, and mass center
1281 // velocity v, the central angular momentum is Iw and linear momentum is mv.
1282 const Inertia I_Bc_B = M_Bo_B.calcCentralInertia();
1283 const Inertia I_Bc_G = I_Bc_B.reexpress(~R_GB);
1284 const Real mb = M_Bo_B.getMass();
1285 const Vec3& w_GB = getBodyAngularVelocity(state);
1286 Vec3 v_GBc =
1287 findStationVelocityInGround(state, M_Bo_B.getMassCenter());
1288
1289 return SpatialVec( I_Bc_G*w_GB, mb*v_GBc );
1290}
1291
1296 const Vec3& locationOnBodyB,
1297 const MobilizedBody& bodyA,
1298 const Vec3& locationOnBodyA) const
1299{
1300 if (isSameMobilizedBody(bodyA))
1301 return (locationOnBodyA-locationOnBodyB).norm();
1302
1303 const Vec3 r_Go_PB =
1304 this->findStationLocationInGround(state,locationOnBodyB);
1305 const Vec3 r_Go_PA =
1306 bodyA.findStationLocationInGround(state,locationOnBodyA);
1307 return (r_Go_PA - r_Go_PB).norm();
1308}
1309
1316 (const State& state,
1317 const Vec3& locationOnBodyB,
1318 const MobilizedBody& bodyA,
1319 const Vec3& locationOnBodyA) const
1320{
1321 if (isSameMobilizedBody(bodyA))
1322 return 0;
1323
1324 Vec3 rB, rA, vB, vA;
1325 this->findStationLocationAndVelocityInGround(state,locationOnBodyB,rB,vB);
1326 bodyA.findStationLocationAndVelocityInGround(state,locationOnBodyA,rA,vA);
1327 const Vec3 r = rA-rB, v = vA-vB;
1328 const Real d = r.norm();
1329
1330 // When the points are coincident, the rate of change of distance is just
1331 // their relative speed. Otherwise, it is the speed along the direction of
1332 // separation.
1333 if (d==0) return v.norm();
1334 else return dot(v, r/d);
1335}
1336
1337
1344 (const State& state,
1345 const Vec3& locationOnBodyB,
1346 const MobilizedBody& bodyA,
1347 const Vec3& locationOnBodyA) const
1348{
1349 if (isSameMobilizedBody(bodyA))
1350 return 0;
1351
1352 Vec3 rB, rA, vB, vA, aB, aA;
1353 this->findStationLocationVelocityAndAccelerationInGround
1354 (state,locationOnBodyB,rB,vB,aB);
1356 (state,locationOnBodyA,rA,vA,aA);
1357
1358 const Vec3 r = rA-rB, v = vA-vB, a = aA-aB;
1359 const Real d = r.norm();
1360
1361 // This method is the time derivative of
1362 // calcFixedPointToPointDistanceTimeDerivative(), so it must follow the same
1363 // two cases. That is, when the points are coincident the change in
1364 // separation rate is the time derivative of the speed |v|, otherwise it is
1365 // the time derivative of the speed along the separation vector.
1366
1367 if (d==0) {
1368 // Return d/dt |v|. This has two cases: if |v| is zero, the rate of
1369 // change of speed is just the points' relative acceleration magnitude.
1370 // Otherwise, it is the acceleration in the direction of the current
1371 // relative velocity vector.
1372 const Real s = v.norm(); // speed
1373 if (s==0) return a.norm();
1374 else return dot(a, v/s);
1375 }
1376
1377 // Points are separated.
1378 const Vec3 u = r/d; // u is separation direction (a unit vector from B to A)
1379 const Vec3 vp = v - dot(v,u)*u; // velocity perp. to separation direction
1380 return dot(a,u) + dot(vp,v)/d;
1381}
1382
1383
1387 (const State& state,
1388 const Vec3& locationOnBodyB,
1389 const Vec3& velocityOnBodyB,
1390 const MobilizedBody& inBodyA) const
1391{
1392 SimTK_ASSERT_ALWAYS(!"unimplemented method",
1393 "MobilizedBody::calcBodyMovingPointVelocityInBody()"
1394 " is not yet implemented -- any volunteers?");
1395 return Vec3::getNaN();
1396}
1397
1398
1403 (const State& state,
1404 const Vec3& locationOnBodyB,
1405 const Vec3& velocityOnBodyB,
1406 const Vec3& accelerationOnBodyB,
1407 const MobilizedBody& inBodyA) const
1408{
1409 SimTK_ASSERT_ALWAYS(!"unimplemented method",
1410 "MobilizedBody::calcBodyMovingPointAccelerationInBody()"
1411 " is not yet implemented -- any volunteers?");
1412 return Vec3::getNaN();
1413}
1414
1422 (const State& state,
1423 const Vec3& locationOnBodyB,
1424 const Vec3& velocityOnBodyB,
1425 const MobilizedBody& bodyA,
1426 const Vec3& locationOnBodyA,
1427 const Vec3& velocityOnBodyA) const
1428{
1429 SimTK_ASSERT_ALWAYS(!"unimplemented method",
1430 "MobilizedBody::calcMovingPointToPointDistanceTimeDerivative()"
1431 " is not yet implemented -- any volunteers?");
1432 return NaN;
1433}
1434
1443 (const State& state,
1444 const Vec3& locationOnBodyB,
1445 const Vec3& velocityOnBodyB,
1446 const Vec3& accelerationOnBodyB,
1447 const MobilizedBody& bodyA,
1448 const Vec3& locationOnBodyA,
1449 const Vec3& velocityOnBodyA,
1450 const Vec3& accelerationOnBodyA) const
1451{
1452 SimTK_ASSERT_ALWAYS(!"unimplemented method",
1453 "MobilizedBody::calcMovingPointToPointDistance2ndTimeDerivative()"
1454 " is not yet implemented -- any volunteers?");
1455 return NaN;
1456}
1457
1458
1459// End of High Level Operators.
1463
1464 // CONSTRUCTION METHODS //
1466
1470
1472explicit MobilizedBody(MobilizedBodyImpl* r);
1473
1474//------------------------------------------------------------------------------
1484const Body& getBody() const;
1485
1491
1498
1509 const DecorativeGeometry& geometry) {
1510 return updBody().addDecoration(X_BD, geometry);
1511}
1515 return updBody().addDecoration(geometry);
1516}
1517
1525 const DecorativeGeometry& geometry);
1532
1540 const DecorativeGeometry& geometry);
1547
1555 updBody().setDefaultRigidBodyMassProperties(m); // might not be allowed
1556 return *this;
1557}
1558
1561 // every body type can do this
1562 return getBody().getDefaultRigidBodyMassProperties();
1563}
1564
1572void adoptMotion(Motion& ownerHandle);
1573
1578
1582bool hasMotion() const;
1583
1590const Motion& getMotion() const;
1591
1604
1609const Transform& getDefaultInboardFrame() const; // X_PF
1613const Transform& getDefaultOutboardFrame() const; // X_BM
1614
1619operator MobilizedBodyIndex() const {return getMobilizedBodyIndex();}
1620
1627
1632
1638
1647
1650bool isInSubsystem() const;
1651
1655bool isInSameSubsystem(const MobilizedBody& mobod) const;
1656
1661bool isSameMobilizedBody(const MobilizedBody& mobod) const;
1662
1665bool isGround() const;
1666
1672
1677
1678
1679 // Utility operators //
1680
1685 (const State& state, int which, const Vector& qlike) const;
1686
1692 (const State& state, int which, Vector& qlike) const;
1693
1698 (const State& state, int which, const Vector& ulike) const;
1699
1704Real& updOneFromUPartition(const State& state, int which, Vector& ulike) const;
1705
1711void applyOneMobilityForce(const State& state, int which, Real f,
1712 Vector& mobilityForces) const
1713{
1714 updOneFromUPartition(state,which,mobilityForces) += f;
1715}
1716
1756
1763void applyBodyForce(const State& state, const SpatialVec& spatialForceInG,
1764 Vector_<SpatialVec>& bodyForcesInG) const;
1765
1771void applyBodyTorque(const State& state, const Vec3& torqueInG,
1772 Vector_<SpatialVec>& bodyForcesInG) const;
1773
1785 (const State& state, const Vec3& pointInB, const Vec3& forceInG,
1786 Vector_<SpatialVec>& bodyForcesInG) const;
1787
1788// End of Construction and Misc Methods.
1791
1792 // BUILT IN MOBILIZER DECLARATIONS //
1794
1795//------------------------------------------------------------------------------
1796// These are the built-in MobilizedBody types. Each of these has a known
1797// number of coordinates and speeds (at least a default number) so
1798// can define routines which return and accept specific-size arguments, e.g.
1799// Real (for 1-dof mobilizer) and Vec5 (for 5-dof mobilizer). Here is the
1800// conventional interface that each built-in should provide. The base type
1801// provides similar routines but using variable-sized or "one at a time"
1802// arguments. (Vec<1> here will actually be a Real; assume the built-in
1803// MobilizedBody class is "BuiltIn")
1804//
1805// BuiltIn& setDefaultQ(const Vec<nq>&);
1806// const Vec<nq>& getDefaultQ() const;
1807//
1808// const Vec<nq>& getQ[Dot[Dot]](const State&) const;
1809// const Vec<nu>& getU[Dot](const State&) const;
1810//
1811// void setQ(State&, const Vec<nq>&) const;
1812// void setU(State&, const Vec<nu>&) const;
1813//
1814// const Vec<nq>& getMyPartQ(const State&, const Vector& qlike) const;
1815// const Vec<nu>& getMyPartU(const State&, const Vector& ulike) const;
1816//
1817// Vec<nq>& updMyPartQ(const State&, Vector& qlike) const;
1818// Vec<nu>& updMyPartU(const State&, Vector& ulike) const;
1819//
1820// Each built in mobilized body type is declared in its own header
1821// file using naming convention MobilizedBody_Pin.h, for example. All the
1822// built-in headers are collected in MobilizedBody_BuiltIns.h; you should
1823// include new ones there also.
1824
1825
1826class Pin;
1827typedef Pin Torsion;
1828typedef Pin Revolute;
1829
1830class Universal;
1831class Cylinder;
1832class Weld;
1833
1834class Slider;
1836
1837class Translation;
1840
1841class BendStretch;
1843
1844class SphericalCoords;
1845class LineOrientation;
1846
1847class Planar;
1848class Gimbal;
1849class Bushing;
1850
1851class Ball;
1854
1855class Free;
1856class FreeLine;
1857class Screw;
1858class Ellipsoid;
1859class Custom;
1860class Ground;
1861class FunctionBased;
1862class CantileverFreeBeam;
1863
1864// Internal use only.
1865class PinImpl;
1866class SliderImpl;
1867class UniversalImpl;
1868class CylinderImpl;
1869class BendStretchImpl;
1870class PlanarImpl;
1871class GimbalImpl;
1872class BushingImpl;
1873class BallImpl;
1874class TranslationImpl;
1875class SphericalCoordsImpl;
1876class FreeImpl;
1877class LineOrientationImpl;
1878class FreeLineImpl;
1879class WeldImpl;
1880class ScrewImpl;
1881class EllipsoidImpl;
1882class CustomImpl;
1883class GroundImpl;
1884class FunctionBasedImpl;
1885class CantileverFreeBeamImpl;
1886};
1887
1888} // namespace SimTK
1889
1890#endif // SimTK_SIMBODY_MOBILIZED_BODY_H_
1891
1892
1893
This defines the API for the Body base class and concrete Body types like Body::Rigid that are derive...
#define SimTK_ASSERT_ALWAYS(cond, msg)
Definition ExceptionMacros.h:349
This defines the Motion class, which is used to specify how the mobilities associated with a particul...
Every Simbody header and source file should include this header before any other Simbody header.
#define SimTK_SIMBODY_EXPORT
Definition Simbody/include/simbody/internal/common.h:68
The Array_<T> container class is a plug-compatible replacement for the C++ standard template library ...
Definition Array.h:1520
The Body class represents a reference frame that can be used to describe mass properties and geometry...
Definition Body.h:55
This is the client-side interface to an implementation-independent representation of "Decorations" su...
Definition DecorativeGeometry.h:87
The physical meaning of an inertia is the distribution of a rigid body's mass about a particular poin...
Definition MassProperties.h:193
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:371
This class contains the mass, center of mass, and unit inertia matrix of a rigid body B.
Definition MassProperties.h:1363
Inertia_< P > calcShiftedInertia(const Vec< 3, P > &newOriginB) const
Return the inertia of this MassProperties object, but with the "measured about" point shifted from th...
Definition MassProperties.h:1434
MassProperties_ reexpress(const Rotation_< P > &R_BC) const
Re-express these mass properties from the current frame "B" to a new frame "C", given the orientation...
Definition MassProperties.h:1475
Mat< 2, 2, Mat< 3, 3, P > > toSpatialMat() const
Convert this MassProperties object to a spatial inertia matrix and return it as a SpatialMat,...
Definition MassProperties.h:1526
const P & getMass() const
Return the mass currently stored in this MassProperties object.
Definition MassProperties.h:1401
Inertia_< P > calcCentralInertia() const
Return the inertia of this MassProperties object, but measured about the mass center rather than abou...
Definition MassProperties.h:1427
const Vec< 3, P > & getMassCenter() const
Return the mass center currently stored in this MassProperties object; this is expressed in an implic...
Definition MassProperties.h:1406
This class represents a small matrix whose size is known at compile time, containing elements of any ...
Definition Mat.h:100
This is for arrays indexed by mobilized body number within a subsystem (typically the SimbodyMatterSu...
Three mobilities – unrestricted orientation modeled with a quaternion which is never singular.
Definition MobilizedBody_Ball.h:44
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
Six mobilities – arbitrary relative motion modeled as x-y-z translation followed by an x-y-z body-fix...
Definition MobilizedBody_Bushing.h:86
Although this mobilizer has only three mobilities (all rotational), the mobilized frame M translates ...
Definition MobilizedBody_CantileverFreeBeam.h:142
The handle class MobilizedBody::Custom (dataless) and its companion class MobilizedBody::Custom::Impl...
Definition MobilizedBody_Custom.h:72
Two mobilities – rotation and translation along the common z axis of the inboard and outboard mobiliz...
Definition MobilizedBody_Cylinder.h:42
Three mobilities – coordinated rotation and translation along the surface of an ellipsoid fixed to th...
Definition MobilizedBody_Ellipsoid.h:126
Five mobilities, representing unrestricted motion for a body which is inertialess along its own z axi...
Definition MobilizedBody_FreeLine.h:58
Unrestricted motion for a rigid body (six mobilities).
Definition MobilizedBody_Free.h:52
This is a subclass of MobilizedBody::Custom which uses a set of Function objects to define the behavi...
Definition MobilizedBody_FunctionBased.h:47
Three mobilities – unrestricted orientation modeled as a 1-2-3 body-fixed Euler angle sequence,...
Definition MobilizedBody_Gimbal.h:69
This is a special type of "mobilized" body generated automatically by Simbody as a placeholder for Gr...
Definition MobilizedBody_Ground.h:45
Two mobilities, representing unrestricted orientation for a body which is inertialess along its own z...
Definition MobilizedBody_LineOrientation.h:59
Provides one rotational mobility about the common z axis of the F and M frames of the mobilizer.
Definition MobilizedBody_Pin.h:46
Three mobilities – z rotation and x,y translation.
Definition MobilizedBody_Planar.h:38
One mobility – coordinated rotation and translation along the common z axis of the inboard and outboa...
Definition MobilizedBody_Screw.h:39
One mobility – translation along the common x axis of the F (inboard) and M (outboard) mobilizer fram...
Definition MobilizedBody_Slider.h:46
Three mobilities – body fixed 3-2 (z-y) rotation followed by translation along body z or body x.
Definition MobilizedBody_SphericalCoords.h:77
Three translational mobilities describing the Cartesian motion of a point.
Definition MobilizedBody_Translation.h:38
Two mobilities – rotation about the x axis, followed by a rotation about the new y axis.
Definition MobilizedBody_Universal.h:40
Zero mobilities.
Definition MobilizedBody_Weld.h:43
A MobilizedBody is Simbody's fundamental body-and-joint object used to parameterize a system's motion...
Definition MobilizedBody.h:169
int getNumU(const State &state) const
Return the number of generalized speeds u currently in use by this mobilizer.
int addBodyDecoration(const Transform &X_BD, const DecorativeGeometry &geometry)
Convenience method to add DecorativeGeometry specified relative to the new (outboard) body's referenc...
Definition MobilizedBody.h:1508
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:807
const SpatialInertia & getBodySpatialInertiaInGround(const State &state) const
Return a reference to the already-calculated SpatialInertia of this body, taken about the body's orig...
SimbodyMatterSubsystem & updMatterSubsystem()
Obtain a writable reference to the SimbodyMatterSubsystem which contains this MobilizedBody.
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:934
const MobilizedBody & getBaseMobilizedBody() const
Return a reference to this MobilizedBody's oldest ancestor other than Ground, or return Ground if thi...
MobilizedBody & cloneForNewParent(MobilizedBody &parent) const
Create a new MobilizedBody which is identical to this one, except that it has a different parent (and...
Slider Prismatic
Synonym for Slider mobilizer.
Definition MobilizedBody.h:1835
const DecorativeGeometry & getOutboardDecoration(int i) const
Return a const reference to the i'th outboard decoration.
int getLevelInMultibodyTree() const
Return this mobilized body's level in the tree of bodies, starting with Ground at 0,...
const Transform & getInboardFrame(const State &state) const
Return a reference to this mobilizer's frame F fixed on the parent body P, as the fixed Transform X_P...
SpatialVec findMobilizerReactionOnBodyAtOriginInGround(const State &state) const
Return the spatial reaction force (moment and force) applied by the mobilizer to body B but shifted t...
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:820
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:1216
const Transform & getDefaultOutboardFrame() const
Return a reference to this MobilizedBody's default for mobilizer frame M, as the fixed Transform from...
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...
Motion::Method getUDotMotionMethod(const State &state) const
Determine how generalized acceleration udot values are being determined.
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:391
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:961
void applyBodyTorque(const State &state, const Vec3 &torqueInG, Vector_< SpatialVec > &bodyForcesInG) const
This utility adds in the supplied pure torque torqueInG to the appropriate slot of the supplied bodyF...
Vec3 calcBodyMovingPointAccelerationInBody(const State &state, const Vec3 &locationOnBodyB, const Vec3 &velocityOnBodyB, const Vec3 &accelerationOnBodyB, const MobilizedBody &inBodyA) const
TODO: not implemented yet – any volunteers? Return the velocity of a point P moving (and possibly acc...
Definition MobilizedBody.h:1403
SpatialVec calcBodyMomentumAboutBodyMassCenterInGround(const State &state) const
Calculate body B's momentum (angular, linear) measured and expressed in Ground, but taken about the b...
Definition MobilizedBody.h:1276
int addBodyDecoration(const DecorativeGeometry &geometry)
Convenience method for use when the geometry is supplied in the body frame.
Definition MobilizedBody.h:1514
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:333
Ball Orientation
Synonym for Ball mobilizer.
Definition MobilizedBody.h:1852
void lockAt(State &state, const Vector &value, Motion::Level level=Motion::Position) const
Lock this mobilizer's q, u, or udot to the given Vector value, depending on level.
Vector getLockValueAsVector(const State &state) const
Return the q, u, or udot value at which this mobilizer is locked, depending on the lock level,...
const Transform & getOutboardFrame(const State &state) const
Return a reference to this mobilizer's frame M fixed on the child body B, as the fixed Transform X_BM...
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:1232
void applyBodyForce(const State &state, const SpatialVec &spatialForceInG, Vector_< SpatialVec > &bodyForcesInG) const
This utility adds in the supplied spatial force spatialForceInG (consisting of a torque vector,...
DecorativeGeometry & updInboardDecoration(int i)
Return a writable reference to the i'th inboard decoration.
MobilizedBody & setDefaultOutboardFrame(const Transform &X_BM)
Change this mobilizer's frame M fixed on this (the outboard) body B.
SpatialVec getH_FMCol(const State &state, MobilizerUIndex ux) const
Expert use only: obtain a column of the mobilizer-local hinge matrix H_FM which maps generalized spee...
MassProperties expressMassPropertiesInAnotherBodyFrame(const State &state, const MobilizedBody &inBodyA) const
Re-express this body B's mass properties in another body A's frame by applying only a rotation,...
Definition MobilizedBody.h:1184
Translation Cartesian
Synonym for Translation mobilizer.
Definition MobilizedBody.h:1838
int addOutboardDecoration(const Transform &X_MD, const DecorativeGeometry &geometry)
Add decorative geometry specified relative to the outboard mobilizer frame M attached to body B,...
Translation CartesianCoords
Synonym for Translation mobilizer.
Definition MobilizedBody.h:1839
bool isLocked(const State &state) const
Check whether this mobilizer is currently locked in the given state.
Definition MobilizedBody.h:263
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...
bool isInSubsystem() const
Determine whether the current MobilizedBody object is owned by a matter subsystem.
Real getOneQDot(const State &state, int which) const
Return one of the generalized coordinate derivatives qdot from this mobilizer's partition of the matt...
Real getOneQDotDot(const State &state, int which) const
Return one of the generalized coordinate second derivatives qdotdot from this mobilizer's partition o...
Real calcMovingPointToPointDistance2ndTimeDerivative(const State &state, const Vec3 &locationOnBodyB, const Vec3 &velocityOnBodyB, const Vec3 &accelerationOnBodyB, const MobilizedBody &bodyA, const Vec3 &locationOnBodyA, const Vec3 &velocityOnBodyA, const Vec3 &accelerationOnBodyA) const
TODO: not implemented yet – any volunteers? Calculate the second time derivative of distance from a m...
Definition MobilizedBody.h:1443
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:361
Pin Torsion
Synonym for Pin mobilizer.
Definition MobilizedBody.h:1827
SpatialVec getHCol(const State &state, MobilizerUIndex ux) const
Expert use only: obtain a column of the hinge matrix H corresponding to one of this mobilizer's mobil...
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:1076
void setInboardFrame(State &state, const Transform &X_PF) const
Set this mobilizer's frame F fixed on the parent body P, as the fixed Transform from P's body frame t...
void setQToFitTransform(State &state, const Transform &X_FM) const
Adjust this mobilizer's q's to best approximate the supplied Transform which requests a particular re...
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:1033
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:326
Direction
Constructors can take an argument of this type to indicate that the mobilizer is being defined in the...
Definition MobilizedBody.h:181
void lock(State &state, Motion::Level level=Motion::Position) const
Lock this mobilizer's position or velocity at its current value, or lock the acceleration to zero,...
Real calcMovingPointToPointDistanceTimeDerivative(const State &state, const Vec3 &locationOnBodyB, const Vec3 &velocityOnBodyB, const MobilizedBody &bodyA, const Vec3 &locationOnBodyA, const Vec3 &velocityOnBodyA) const
TODO: not implemented yet – any volunteers? Calculate the time rate of change of distance from a movi...
Definition MobilizedBody.h:1422
Motion::Method getUMotionMethod(const State &state) const
Determine how generalized speed u values are being determined.
Motion::Method getQMotionMethod(const State &state) const
Determine how generalized coordinate q values are being determined.
SpatialVec findMobilizerReactionOnParentAtOriginInGround(const State &state) const
Return the spatial reaction force (moment and force) applied by the mobilizer to the parent (inboard)...
Vec3 findStationAtAnotherBodyStation(const State &state, const MobilizedBody &fromBodyA, const Vec3 &stationOnA) const
Return the station (point) on this body B that is coincident with the given station on another body A...
Definition MobilizedBody.h:1086
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:1015
Vector getQAsVector(const State &state) const
Return as a Vector of length getNumQ() all the generalized coordinates q currently in use by this mob...
const DecorativeGeometry & getInboardDecoration(int i) const
Return a const reference to the i'th inboard decoration.
MobilizedBody()
The default constructor provides an empty MobilizedBody handle that can be assigned to reference any ...
Definition MobilizedBody.h:1469
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:735
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:424
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:867
void setUToFitAngularVelocity(State &state, const Vec3 &w_FM) const
Adjust this mobilizer's u's (generalized speeds) to best approximate the supplied angular velocity w_...
Real & updOneFromUPartition(const State &state, int which, Vector &ulike) const
This utility returns a writable reference to one of the u's (generalized speeds) associated with this...
const SpatialVec & getMobilizerAcceleration(const State &state) const
TODO: Not implemented yet – any volunteers? At stage Acceleration, return the cross-mobilizer acceler...
Definition MobilizedBody.h:400
bool isInSameSubsystem(const MobilizedBody &mobod) const
Determine whether a given MobilizedBody mobod is in the same matter subsystem as the current body.
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,...
Definition MobilizedBody.h:996
Real calcStationToStationDistanceTimeDerivative(const State &state, const Vec3 &locationOnBodyB, const MobilizedBody &bodyA, const Vec3 &locationOnBodyA) const
Calculate the time rate of change of distance from a fixed point PB on body B to a fixed point PA on ...
Definition MobilizedBody.h:1316
Vec3 calcBodyMovingPointVelocityInBody(const State &state, const Vec3 &locationOnBodyB, const Vec3 &velocityOnBodyB, const MobilizedBody &inBodyA) const
TODO: not implemented yet – any volunteers? Return the velocity of a point P moving on body B,...
Definition MobilizedBody.h:1387
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:354
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:1173
const SpatialVec & getBodyAcceleration(const State &state) const
Extract from the state cache the already-calculated spatial acceleration A_GB of this body's referenc...
SpatialVec findMobilizerReactionOnBodyAtMInGround(const State &state) const
Return the spatial reaction force (moment and force) applied by the mobilizer to body B at the locati...
int getNumQ(const State &state) const
Return the number of generalized coordinates q currently in use by this mobilizer.
void applyForceToBodyPoint(const State &state, const Vec3 &pointInB, const Vec3 &forceInG, Vector_< SpatialVec > &bodyForcesInG) const
This utility adds in the supplied force forceInG applied at a point pointInB to the appropriate slot ...
const SpatialVec & getMobilizerVelocity(const State &state) const
At stage Velocity or higher, return the cross-mobilizer velocity V_FM, the relative velocity of this ...
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:383
BendStretch PolarCoords
Synonym for BendStretch mobilizer.
Definition MobilizedBody.h:1842
SpatialVec calcBodyMomentumAboutBodyOriginInGround(const State &state) const
Calculate body B's momentum (angular, linear) measured and expressed in Ground, but taken about the b...
Definition MobilizedBody.h:1267
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:431
void lockAt(State &state, Real value, Motion::Level level=Motion::Position) const
Lock this mobilizer's q, u, or udot to the given scalar value, depending on level.
UIndex getFirstUIndex(const State &state) const
Return the global UIndex of the first u for this mobilizer; all the u's range from getFirstUIndex() t...
Motion::Level getLockLevel(const State &state) const
Returns the lock level if the mobilizer is locked in the given state, otherwise Motion::NoLevel.
void convertQForceToUForce(const State &state, const Array_< Real, MobilizerQIndex > &fq, Array_< Real, MobilizerUIndex > &fu) const
Given a generalized force in the q-space of this mobilizer, convert it to the equivalent generalized ...
void adoptMotion(Motion &ownerHandle)
Provide a unique Motion object for this MobilizedBody.
const Transform & getDefaultInboardFrame() const
Return a reference to this mobilizer's default for the frame F fixed on the parent (inboard) body P,...
Real getOneU(const State &state, int which) const
Return one of the generalized speeds u from this mobilizer's partition of the matter subsystem's full...
Real getOneUDot(const State &state, int which) const
Return one of the generalized accelerations udot from this mobilizer's partition of the matter subsys...
const MobilizedBody & getParentMobilizedBody() const
Return a reference to the MobilizedBody serving as the parent body of the current MobilizedBody.
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:1711
void setQToFitRotation(State &state, const Rotation &R_FM) const
Adjust this mobilizer's q's to best approximate the supplied Rotation matrix which requests a particu...
DecorativeGeometry & updOutboardDecoration(int i)
Return a writable reference to the i'th outboard decoration.
Inertia calcBodyInertiaAboutAnotherBodyStation(const State &state, const MobilizedBody &inBodyA, const Vec3 &aboutLocationOnBodyA) const
Return the inertia of this body B, taken about an arbitrary point PA of body A, and expressed in body...
Definition MobilizedBody.h:1242
const MassProperties & getDefaultMassProperties() const
Return the mass properties of the Body stored within this MobilizedBody.
Definition MobilizedBody.h:1560
void setOneU(State &state, int which, Real v) const
Set one of the generalized speeds u to value v, in this mobilizer's partition of the matter subsystem...
Vec3 findStationAccelerationInGround(const State &state, const Vec3 &stationOnB) const
Given a station fixed on body B, return its inertial (Cartesian) acceleration, that is,...
Definition MobilizedBody.h:982
Vector getUDotAsVector(const State &state) const
Return as a Vector of length getNumU() all the generalized accelerations udot currently in use by thi...
Vec3 findBodyOriginLocationInAnotherBody(const State &state, const MobilizedBody &toBodyA) const
Return the station on another body A (that is, a point measured and expressed in A) that is currently...
Definition MobilizedBody.h:751
Real getBodyMass(const State &state) const
Return the mass of this body.
Definition MobilizedBody.h:417
const Body & getBody() const
Return a const reference to the Body contained within this MobilizedBody.
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:1152
Body & updBody()
Return a writable reference to the Body contained within this MobilizedBody.
bool isLockedByDefault() const
Check whether this mobilizer is to be locked in the default state.
Definition MobilizedBody.h:286
Motion::Level getLockByDefaultLevel() const
Returns the level at which the mobilizer is locked by default, if it is locked by default,...
Real getOneTau(const State &state, MobilizerUIndex which) const
Return one of the tau forces resulting from prescribed (known) acceleration, corresponding to one of ...
void setUFromVector(State &state, const Vector &v) const
Set all of the generalized speeds u to value v (a Vector of length getNumU()), in this mobilizer's pa...
Vector getTauAsVector(const State &state) const
Return the generalized forces tau resulting from prescribed (known) acceleration, corresponding to ea...
Vec3 expressVectorInGroundFrame(const State &state, const Vec3 &vectorInB) const
Re-express a vector expressed in this body B's frame into the same vector in G, by applying only a ro...
Definition MobilizedBody.h:1143
bool isSameMobilizedBody(const MobilizedBody &mobod) const
Determine whether a given MobilizedBody mobod is the same MobilizedBody as this one.
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:920
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:721
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 findStationAtAnotherBodyOrigin(const State &state, const MobilizedBody &fromBodyA) const
Return the station S of this body that is currently coincident in space with the origin Ao of another...
Definition MobilizedBody.h:1095
Ball Spherical
Synonym for Ball mobilizer.
Definition MobilizedBody.h:1853
int getNumInboardDecorations() const
Return the count of decorations added with addInboardDecoration().
SpatialVec findFrameVelocityInGround(const State &state, const Transform &frameOnB) const
Return the current Ground-frame spatial velocity V_GF (that is, angular and linear velocity) of a fra...
Definition MobilizedBody.h:1123
int addInboardDecoration(const Transform &X_FD, const DecorativeGeometry &geometry)
Add decorative geometry specified relative to the inboard mobilizer frame F attached to the parent bo...
void setQFromVector(State &state, const Vector &v) const
Set all of the generalized coordinates q to value v (a Vector of length getNumQ()),...
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:1295
Real calcStationToStationDistance2ndTimeDerivative(const State &state, const Vec3 &locationOnBodyB, const MobilizedBody &bodyA, const Vec3 &locationOnBodyA) const
Calculate the second time derivative of distance from a fixed point PB on body B to a fixed point PA ...
Definition MobilizedBody.h:1344
MobilizedBodyIndex getMobilizedBodyIndex() const
Return the MobilizedBodyIndex of this MobilizedBody within the owning SimbodyMatterSubsystem.
bool hasMotion() const
Check whether this MobilizedBody has an associated Motion object.
Vec3 findMassCenterLocationInGround(const State &state) const
Return the Cartesian (ground) location of this body B's mass center.
Definition MobilizedBody.h:1056
MobilizedBody & setDefaultInboardFrame(const Transform &X_PF)
Change this mobilizer's frame F on the parent body P.
int getNumOutboardDecorations() const
Return the count of decorations added with addOutboardDecoration().
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:790
Vec3 expressVectorInAnotherBodyFrame(const State &state, const Vec3 &vectorInB, const MobilizedBody &inBodyA) const
Re-express a vector expressed in this body B into the same vector expressed in body A,...
Definition MobilizedBody.h:1162
Real getOneFromQPartition(const State &state, int which, const Vector &qlike) const
This utility selects one of the q's (generalized coordinates) associated with this mobilizer from a s...
const SimbodyMatterSubsystem & getMatterSubsystem() const
Obtain a reference to the SimbodyMatterSubsystem which contains this MobilizedBody.
const Motion & getMotion() const
If there is a Motion object associated with this MobilizedBody, this returns a const reference to it.
Real getOneFromUPartition(const State &state, int which, const Vector &ulike) const
This utility selects one of the u's (generalized speeds) associated with this mobilizer from a suppli...
SpatialVec findFrameAccelerationInGround(const State &state, const Transform &frameOnB) const
Return the current Ground-frame spatial acceleration A_GF (that is, angular and linear acceleration) ...
Definition MobilizedBody.h:1134
Real getOneQ(const State &state, int which) const
Return one of the generalized coordinates q from this mobilizer's partition of the matter subsystem's...
void lockAt(State &state, const Vec< N > &value, Motion::Level level=Motion::Position) const
Lock this mobilizer's q, u, or udot to the given Vec<N> value, depending on the level.
void setUToFitLinearVelocity(State &state, const Vec3 &v_FM) const
Adjust any of this mobilizer's u's (generalized speeds) to best approximate the supplied linear veloc...
Vector getQDotAsVector(const State &state) const
Return as a Vector of length getNumQ() all the generalized coordinate derivatives qdot currently in u...
Vec3 findMassCenterLocationInAnotherBody(const State &state, const MobilizedBody &toBodyA) const
Return the point of another body A that is currently coincident in space with the mass center CB of t...
Definition MobilizedBody.h:1064
MobilizedBody(MobilizedBodyImpl *r)
Internal use only.
Real & updOneFromQPartition(const State &state, int which, Vector &qlike) const
This utility returns a writable reference to one of the q's (generalized coordinates) associated with...
MobilizedBody & lockByDefault(Motion::Level level=Motion::Position)
Change whether this mobilizer is initially locked.
void clearMotion()
If there is a Motion object associated with this MobilizedBody it is removed; otherwise,...
void unlock(State &state) const
Unlock this mobilizer, returning it to its normal behavior which may be free motion or may be control...
Vec3 findStationAtAnotherBodyMassCenter(const State &state, const MobilizedBody &fromBodyA) const
Return the station S of this body that is currently coincident in space with the mass center Ac of an...
Definition MobilizedBody.h:1104
const MassProperties & getBodyMassProperties(const State &state) const
Return a reference to this body's mass properties in the State cache.
void setOneQ(State &state, int which, Real v) const
Set one of the generalized coordinates q to value v, in this mobilizer's partition of the matter subs...
SpatialVec findBodyVelocityInAnotherBody(const State &state, const MobilizedBody &inBodyA) const
Return the angular and linear velocity of body B's frame in body A's frame, expressed in body A,...
Definition MobilizedBody.h:762
SpatialVec findMobilizerReactionOnParentAtFInGround(const State &state) const
Return the spatial reaction force (moment and force) applied by the mobilizer to the parent (inboard)...
Pin Revolute
Synonym for Pin mobilizer.
Definition MobilizedBody.h:1828
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:1554
Vec3 findBodyAngularAccelerationInAnotherBody(const State &state, const MobilizedBody &inBodyA) const
Return the angular acceleration of body B's frame in body A's frame, expressed in body A.
Definition MobilizedBody.h:840
Vector getQDotDotAsVector(const State &state) const
Return as a Vector of length getNumQ() all the generalized coordinate second derivatives qdotdot curr...
MobilizedBody & setBody(const Body &)
Replace the Body contained within this MobilizedBody with a new one.
Transform findFrameTransformInGround(const State &state, const Transform &frameOnB) const
Return the current Ground-frame pose (position and orientation) of a frame F that is fixed to body B.
Definition MobilizedBody.h:1113
const Transform & getMobilizerTransform(const State &state) const
At stage Position or higher, return the cross-mobilizer transform X_FM, the body's inboard mobilizer ...
Vector getUAsVector(const State &state) const
Return as a Vector of length getNumU() all the generalized speeds u currently in use by this mobilize...
Vec3 findStationVelocityInGround(const State &state, const Vec3 &stationOnB) const
Given a station fixed on body B, return its inertial (Cartesian) velocity, that is,...
Definition MobilizedBody.h:948
void setQToFitTranslation(State &state, const Vec3 &p_FM) const
Adjust this mobilizer's q's to best approximate the supplied position vector which requests a particu...
bool isGround() const
Determine whether this MobilizedBody is Ground, meaning that it is actually body 0 of some matter sub...
QIndex getFirstQIndex(const State &state) const
Return the global QIndex of the first q for this mobilizer; all the q's range from getFirstQIndex() t...
void setUToFitVelocity(State &state, const SpatialVec &V_FM) const
Adjust this mobilizer's u's (generalized speeds) to best approximate the supplied spatial velocity V_...
void setOutboardFrame(State &state, const Transform &X_BM) const
Set this mobilizer's frame M fixed on the child body B, as the fixed Transform from B's body frame to...
The Mobilizer associated with each MobilizedBody, once modeled, has a specific number of generalized ...
A Motion object belongs to a particular MobilizedBody and prescribes how the associated motion is to ...
Definition Motion.h:107
Method
There are several ways to specify the motion at this Level, and the selected method also determines l...
Definition Motion.h:126
Level
What is the highest level of motion that is driven? Lower levels are also driven; higher levels are d...
Definition Motion.h:112
@ NoLevel
invalid level
Definition Motion.h:113
@ Position
we know q, u, and udot
Definition Motion.h:116
This class provides some infrastructure useful in making SimTK Private Implementation (PIMPL) classes...
Definition PrivateImplementation.h:106
Unique integer type for Subsystem-local q indexing.
This subsystem contains the bodies ("matter") in the multibody system, the mobilizers (joints) that d...
Definition SimbodyMatterSubsystem.h:133
A spatial inertia contains the mass, center of mass point, and inertia matrix for a rigid body.
Definition MassProperties.h:993
This object is intended to contain all state information for a SimTK::System, except topological info...
Definition State.h:280
const Vec< 3, P > & p() const
Return a read-only reference to our translation vector p_BF.
Definition Transform.h:239
Unique integer type for Subsystem-local u indexing.
A UnitInertia matrix is a unit-mass inertia matrix; you can convert it to an Inertia by multiplying i...
Definition MassProperties.h:669
This is a fixed-length column vector designed for no-overhead inline computation.
Definition Vec.h:186
CNT< ScalarNormSq >::TSqrt norm() const
Definition Vec.h:660
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:965
Mat< 3, 3 > Mat33
This is the most common 3x3 matrix type: three packed columns of 3 Real values each.
Definition SmallMatrix.h:142
Vec< 2, Vec3 > SpatialVec
Spatial vectors are used for (rotation,translation) quantities and consist of a pair of Vec3 objects,...
Definition MassProperties.h:50
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
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
constexpr Real NaN
This is the IEEE "not a number" constant for this implementation of the default-precision Real type; ...
Definition Scalar.h:85
constexpr Real Infinity
This is the IEEE positive infinity constant for this implementation of the default-precision Real typ...
Definition Scalar.h:89
This is the top-level SimTK namespace into which all SimTK names are placed to avoid collision with o...
Definition Assembler.h:37
CNT< typenameCNT< E1 >::THerm >::template Result< E2 >::Mul dot(const Vec< M, E1, S1 > &r, const Vec< M, E2, S2 > &v)
Definition SmallMatrixMixed.h:86
SimTK_Real Real
This is the default compiled-in floating point type for SimTK, either float or double.
Definition SimTKcommon/include/SimTKcommon/internal/common.h:626