@@ -185,8 +185,11 @@ class BodyNode : public MultibodyElement<T> {
185
185
// @pre CalcPositionKinematicsCache_BaseToTip() must have already been called
186
186
// for the parent node (and, by recursive precondition, all predecessor nodes
187
187
// in the tree.)
188
+
189
+ // TODO(sherm1) This function should not take a context.
188
190
void CalcPositionKinematicsCache_BaseToTip (
189
191
const systems::Context<T>& context,
192
+ const FrameBodyPoseCache<T>& frame_body_pose_cache,
190
193
PositionKinematicsCache<T>* pc) const {
191
194
// This method must not be called for the "world" body node.
192
195
DRAKE_ASSERT (topology_.rigid_body != world_index ());
@@ -203,7 +206,7 @@ class BodyNode : public MultibodyElement<T> {
203
206
// mobilizer. q(W:P) denotes all generalized positions in the kinematics
204
207
// path between World and the parent body P. It assumes we are in a
205
208
// base-to-tip recursion and therefore `X_WP` has already been updated.
206
- CalcAcrossMobilizerBodyPoses_BaseToTip (context , pc);
209
+ CalcAcrossMobilizerBodyPoses_BaseToTip (frame_body_pose_cache , pc);
207
210
208
211
// TODO(amcastro-tri):
209
212
// Update Body specific kinematics. These include:
@@ -241,6 +244,8 @@ class BodyNode : public MultibodyElement<T> {
241
244
// Unit test coverage for this method is provided, among others, in
242
245
// double_pendulum_test.cc, and by any other unit tests making use of
243
246
// MultibodyTree::CalcVelocityKinematicsCache().
247
+
248
+ // TODO(sherm1) This function should not take a context.
244
249
void CalcVelocityKinematicsCache_BaseToTip (
245
250
const systems::Context<T>& context,
246
251
const PositionKinematicsCache<T>& pc,
@@ -379,8 +384,11 @@ class BodyNode : public MultibodyElement<T> {
379
384
// Unit test coverage for this method is provided, among others, in
380
385
// double_pendulum_test.cc, and by any other unit tests making use of
381
386
// MultibodyTree::CalcAccelerationKinematicsCache().
387
+
388
+ // TODO(sherm1) This function should not take a context.
382
389
void CalcSpatialAcceleration_BaseToTip (
383
390
const systems::Context<T>& context,
391
+ const FrameBodyPoseCache<T>& frame_body_poses_cache,
384
392
const PositionKinematicsCache<T>& pc,
385
393
const VelocityKinematicsCache<T>* vc,
386
394
const VectorX<T>& mbt_vdot,
@@ -456,12 +464,11 @@ class BodyNode : public MultibodyElement<T> {
456
464
// =========================================================================
457
465
// Computation of A_PB = DtP(V_PB), Eq. (4).
458
466
459
- // TODO(amcastro-tri): consider caching these. Also used in velocity
460
- // kinematics.
461
- const math::RotationMatrix<T> R_PF =
462
- frame_F.CalcRotationMatrixInBodyFrame (context);
463
- const math::RigidTransform<T> X_MB =
464
- frame_M.CalcPoseInBodyFrame (context).inverse ();
467
+ const math::RigidTransform<T>& X_PF =
468
+ frame_F.get_X_BF (frame_body_poses_cache); // B==P
469
+ const math::RotationMatrix<T>& R_PF = X_PF.rotation ();
470
+ const math::RigidTransform<T>& X_MB =
471
+ frame_M.get_X_FB (frame_body_poses_cache); // F==M
465
472
466
473
// Form the rotation matrix relating the world frame W and parent body P.
467
474
// Available since we are called within a base-to-tip recursion.
@@ -593,8 +600,11 @@ class BodyNode : public MultibodyElement<T> {
593
600
// Unit test coverage for this method is provided, among others, in
594
601
// double_pendulum_test.cc, and by any other unit tests making use of
595
602
// MultibodyTree::CalcInverseDynamics().
603
+
604
+ // TODO(sherm1) This function should not take a context.
596
605
void CalcInverseDynamics_TipToBase (
597
606
const systems::Context<T>& context,
607
+ const FrameBodyPoseCache<T>& frame_body_pose_cache,
598
608
const PositionKinematicsCache<T>& pc,
599
609
const std::vector<SpatialInertia<T>>& M_B_W_cache,
600
610
const std::vector<SpatialForce<T>>* Fb_Bo_W_cache,
@@ -675,7 +685,8 @@ class BodyNode : public MultibodyElement<T> {
675
685
// Compute shift vector from Bo to Mo expressed in the world frame W.
676
686
const Frame<T>& frame_M = outboard_frame ();
677
687
DRAKE_DEMAND (frame_M.body ().index () == body_B.index ());
678
- const math::RigidTransform<T> X_BM = frame_M.CalcPoseInBodyFrame (context);
688
+ const math::RigidTransform<T>& X_BM =
689
+ frame_M.get_X_BF (frame_body_pose_cache); // F==M
679
690
const Vector3<T>& p_BoMo_B = X_BM.translation ();
680
691
const math::RigidTransform<T>& X_WB = get_X_WB (pc);
681
692
const math::RotationMatrix<T>& R_WB = X_WB.rotation ();
@@ -700,8 +711,8 @@ class BodyNode : public MultibodyElement<T> {
700
711
// p_CoMc_W:
701
712
const Frame<T>& frame_Mc = child_node->outboard_frame ();
702
713
const math::RotationMatrix<T>& R_WC = child_node->get_X_WB (pc).rotation ();
703
- const math::RigidTransform<T> X_CMc =
704
- frame_Mc.CalcPoseInBodyFrame (context);
714
+ const math::RigidTransform<T>& X_CMc =
715
+ frame_Mc.get_X_BF (frame_body_pose_cache); // B==C, F==Mc
705
716
const Vector3<T>& p_CoMc_W = R_WC * X_CMc.translation ();
706
717
707
718
// Shift position vector from child C outboard mobilizer frame Mc to body
@@ -773,8 +784,11 @@ class BodyNode : public MultibodyElement<T> {
773
784
//
774
785
// @pre The position kinematics cache `pc` was already updated to be in sync
775
786
// with `context` by MultibodyTree::CalcPositionKinematicsCache().
787
+
788
+ // TODO(sherm1) This function should not take a context.
776
789
void CalcAcrossNodeJacobianWrtVExpressedInWorld (
777
790
const systems::Context<T>& context,
791
+ const FrameBodyPoseCache<T>& frame_body_pose_cache,
778
792
const PositionKinematicsCache<T>& pc,
779
793
EigenPtr<MatrixX<T>> H_PB_W) const {
780
794
// Checks on the input arguments.
@@ -788,10 +802,11 @@ class BodyNode : public MultibodyElement<T> {
788
802
// Outboard frame M of this node's mobilizer.
789
803
const Frame<T>& frame_M = outboard_frame ();
790
804
791
- const math::RotationMatrix<T> R_PF =
792
- frame_F.CalcRotationMatrixInBodyFrame (context);
793
- const math::RigidTransform<T> X_MB =
794
- frame_M.CalcPoseInBodyFrame (context).inverse ();
805
+ const math::RigidTransform<T>& X_PF =
806
+ frame_F.get_X_BF (frame_body_pose_cache); // B==P
807
+ const math::RotationMatrix<T>& R_PF = X_PF.rotation ();
808
+ const math::RigidTransform<T>& X_MB =
809
+ frame_M.get_X_FB (frame_body_pose_cache); // F==M
795
810
796
811
// Form the rotation matrix relating the world frame W and parent body P.
797
812
const math::RotationMatrix<T>& R_WP = get_R_WP (pc);
@@ -900,6 +915,8 @@ class BodyNode : public MultibodyElement<T> {
900
915
// - Revolute: [x y z 0 0 0]
901
916
// - Prismatic: [0 0 0 x y z]
902
917
// - Ball: 3x3 blocks of zeroes.
918
+
919
+ // TODO(sherm1) This function should not take a context.
903
920
void CalcArticulatedBodyInertiaCache_TipToBase (
904
921
const systems::Context<T>& context,
905
922
const PositionKinematicsCache<T>& pc,
@@ -1094,6 +1111,8 @@ class BodyNode : public MultibodyElement<T> {
1094
1111
//
1095
1112
// @throws when called on the _root_ node or `aba_force_cache` is
1096
1113
// nullptr.
1114
+
1115
+ // TODO(sherm1) This function should not take a context.
1097
1116
void CalcArticulatedBodyForceCache_TipToBase (
1098
1117
const systems::Context<T>& context,
1099
1118
const PositionKinematicsCache<T>& pc,
@@ -1186,6 +1205,8 @@ class BodyNode : public MultibodyElement<T> {
1186
1205
// called for the parent node (and, by recursive precondition, all
1187
1206
// predecessor nodes in the tree.)
1188
1207
// @throws when called on the _root_ node of `ac` or `vdot` is nullptr.
1208
+
1209
+ // TODO(sherm1) This function should not take a context.
1189
1210
void CalcArticulatedBodyAccelerations_BaseToTip (
1190
1211
const systems::Context<T>& context,
1191
1212
const PositionKinematicsCache<T>& pc,
@@ -1296,10 +1317,14 @@ class BodyNode : public MultibodyElement<T> {
1296
1317
// @pre pc and vc previously computed to be in sync with `context.
1297
1318
//
1298
1319
// @throws when `Ab_WB` is nullptr.
1299
- void CalcSpatialAccelerationBias (const systems::Context<T>& context,
1300
- const PositionKinematicsCache<T>& pc,
1301
- const VelocityKinematicsCache<T>& vc,
1302
- SpatialAcceleration<T>* Ab_WB) const {
1320
+
1321
+ // TODO(sherm1) This function should not take a context.
1322
+ void CalcSpatialAccelerationBias (
1323
+ const systems::Context<T>& context,
1324
+ const FrameBodyPoseCache<T>& frame_body_pose_cache,
1325
+ const PositionKinematicsCache<T>& pc,
1326
+ const VelocityKinematicsCache<T>& vc,
1327
+ SpatialAcceleration<T>* Ab_WB) const {
1303
1328
DRAKE_THROW_UNLESS (Ab_WB != nullptr );
1304
1329
// As a guideline for developers, please refer to @ref
1305
1330
// abi_computing_accelerations for a detailed description and derivation of
@@ -1311,10 +1336,11 @@ class BodyNode : public MultibodyElement<T> {
1311
1336
const Frame<T>& frame_M = outboard_frame ();
1312
1337
1313
1338
// Compute R_PF and X_MB.
1314
- const math::RotationMatrix<T> R_PF =
1315
- frame_F.CalcRotationMatrixInBodyFrame (context);
1316
- const math::RigidTransform<T> X_MB =
1317
- frame_M.CalcPoseInBodyFrame (context).inverse ();
1339
+ const math::RigidTransform<T>& X_PF =
1340
+ frame_F.get_X_BF (frame_body_pose_cache); // B==P
1341
+ const math::RotationMatrix<T>& R_PF = X_PF.rotation ();
1342
+ const math::RigidTransform<T>& X_MB =
1343
+ frame_M.get_X_FB (frame_body_pose_cache); // F==M
1318
1344
1319
1345
// Parent position in the world is available from the position kinematics.
1320
1346
const math::RotationMatrix<T>& R_WP = get_R_WP (pc);
@@ -1733,7 +1759,7 @@ class BodyNode : public MultibodyElement<T> {
1733
1759
// between the world and the parent body P. It assumes we are in a base-to-tip
1734
1760
// recursion and therefore `X_WP` has already been updated.
1735
1761
void CalcAcrossMobilizerBodyPoses_BaseToTip (
1736
- const systems::Context <T>& context ,
1762
+ const FrameBodyPoseCache <T>& frame_body_pose_cache ,
1737
1763
PositionKinematicsCache<T>* pc) const {
1738
1764
// RigidBody for this node.
1739
1765
const RigidBody<T>& body_B = body ();
@@ -1753,8 +1779,10 @@ class BodyNode : public MultibodyElement<T> {
1753
1779
// - X_FM(q_B)
1754
1780
// - X_WP(q(W:B)), where q(W:B) includes all positions in the kinematics
1755
1781
// path from body B to the world W.
1756
- const math::RigidTransform<T> X_MB =
1757
- frame_M.CalcPoseInBodyFrame (context).inverse ();
1782
+ const math::RigidTransform<T>& X_MB =
1783
+ frame_M.get_X_FB (frame_body_pose_cache); // F==M
1784
+ const math::RigidTransform<T>& X_PF =
1785
+ frame_F.get_X_BF (frame_body_pose_cache); // B==P
1758
1786
const math::RigidTransform<T>& X_FM =
1759
1787
get_X_FM (*pc); // mobilizer.Eval_X_FM(ctx)
1760
1788
const math::RigidTransform<T>& X_WP =
@@ -1771,12 +1799,7 @@ class BodyNode : public MultibodyElement<T> {
1771
1799
// In that case X_FB = X_FM as suggested by setting X_MB = Identity.
1772
1800
const math::RigidTransform<T> X_FB = X_FM * X_MB;
1773
1801
1774
- // Given the pose X_FB of body frame B measured in the mobilizer inboard
1775
- // frame F, we can ask frame F (who's parent body is P) for the pose of body
1776
- // B measured in the frame of the parent body P.
1777
- // In the particular case F = B, this method directly returns X_FB.
1778
- X_PB = frame_F.CalcOffsetPoseInBody (context, X_FB);
1779
-
1802
+ X_PB = X_PF * X_FB;
1780
1803
X_WB = X_WP * X_PB;
1781
1804
1782
1805
// Compute shift vector p_PoBo_W from the parent origin to the body origin.
@@ -1803,6 +1826,8 @@ class BodyNode : public MultibodyElement<T> {
1803
1826
// quantities associated with `this` mobilizer. MultibodyTree will always
1804
1827
// provide a valid PositionKinematicsCache pointer, otherwise this method
1805
1828
// aborts in Debug builds.
1829
+
1830
+ // TODO(sherm1) This function should not take a context.
1806
1831
void CalcAcrossMobilizerPositionKinematicsCache (
1807
1832
const systems::Context<T>& context,
1808
1833
PositionKinematicsCache<T>* pc) const {
0 commit comments