25
25
#include " drake/multibody/plant/hydroelastic_traction_calculator.h"
26
26
#include " drake/multibody/plant/make_discrete_update_manager.h"
27
27
#include " drake/multibody/plant/slicing_and_indexing.h"
28
- #include " drake/multibody/topology/spanning_forest_model .h"
28
+ #include " drake/multibody/topology/link_joint_graph .h"
29
29
#include " drake/multibody/tree/prismatic_joint.h"
30
30
#include " drake/multibody/tree/quaternion_floating_joint.h"
31
31
#include " drake/multibody/tree/revolute_joint.h"
@@ -992,7 +992,7 @@ void MultibodyPlant<T>::SetFreeBodyPoseInAnchoredFrame(
992
992
DRAKE_MBP_THROW_IF_NOT_FINALIZED ();
993
993
this ->ValidateContext (context);
994
994
995
- if (!internal_tree ().get_topology ().IsBodyAnchored (frame_F.body ().index ())) {
995
+ if (!internal_tree ().get_topology ().IsLinkAnchored (frame_F.body ().index ())) {
996
996
throw std::logic_error (
997
997
" Frame '" + frame_F.name () + " ' must be anchored to the world frame." );
998
998
}
@@ -1016,17 +1016,17 @@ void MultibodyPlant<T>::CalcSpatialAccelerationsFromVdot(
1016
1016
internal_tree ().CalcSpatialAccelerationsFromVdot (
1017
1017
context, internal_tree ().EvalPositionKinematics (context),
1018
1018
internal_tree ().EvalVelocityKinematics (context), known_vdot, A_WB_array);
1019
- // Permute BodyNodeIndex -> BodyIndex .
1019
+ // Permute BodyNodeIndex -> LinkIndex .
1020
1020
// TODO(eric.cousineau): Remove dynamic allocations. Making this in-place
1021
1021
// still required dynamic allocation for recording permutation indices.
1022
1022
// Can change implementation once MultibodyTree becomes fully internal.
1023
1023
std::vector<SpatialAcceleration<T>> A_WB_array_node = *A_WB_array;
1024
1024
const internal::MultibodyTreeTopology& topology =
1025
1025
internal_tree ().get_topology ();
1026
1026
for (internal::BodyNodeIndex node_index (1 );
1027
- node_index < topology.get_num_body_nodes (); ++node_index) {
1028
- const BodyIndex body_index = topology.get_body_node (node_index).body ;
1029
- (*A_WB_array)[body_index ] = A_WB_array_node[node_index];
1027
+ node_index < topology.num_body_nodes (); ++node_index) {
1028
+ const LinkIndex link_index = topology.get_body_node (node_index).link ;
1029
+ (*A_WB_array)[link_index ] = A_WB_array_node[node_index];
1030
1030
}
1031
1031
}
1032
1032
@@ -1097,65 +1097,13 @@ void MultibodyPlant<T>::RenameModelInstance(ModelInstanceIndex model_instance,
1097
1097
1098
1098
template <typename T>
1099
1099
void MultibodyPlant<T>::Finalize() {
1100
- /* Given the user-defined directed graph of Links and Joints, decide how we're
1101
- going to model this using a spanning forest comprised of
1102
- - bodies and their mobilizers, paired as "mobilized bodies" (mobods) and
1103
- directed by inboard/outboard edges, and
1104
- - added constraints where needed to close kinematic loops in the graph.
1105
- The modeler sorts the mobilized bodies into depth-first order.
1106
-
1107
- Every Link will be modeled with one "primary" body and possibly several
1108
- "shadow" bodies. Every Joint will be modeled with a mobilizer, with the
1109
- Joint's parent/child connections mapped to the mobilizer's inboard/outboard
1110
- connection or to the reverse, as necessary for the mobilizers to form a
1111
- properly-directed tree. Every body in the tree must have a path in the
1112
- inboard direction connecting it to World. If necessary, additional "floating"
1113
- (6 dof) or "weld" (0 dof) mobilizers are added to make the final connection
1114
- to World.
1115
-
1116
- During the modeling process, the LinkJointGraph is augmented to have
1117
- additional elements to provide an interface to the additional elements that
1118
- were required to build the model. Below, we will augment the MultibodyPlant
1119
- elements to match, so that advanced users can use the familiar Plant API to
1120
- access and control these elements. */
1121
- this ->mutable_tree ().BuildSpanningForest ();
1122
-
1123
- /* Add Links, Joints, and Constraints that were created during the modeling
1124
- process. */
1125
-
1126
- const internal::LinkJointGraph& graph = internal_tree ().link_joint_graph ();
1127
- unused (graph);
1128
-
1129
- /* TODO(sherm1) why not use MbP as the LinkJointGraph and do away with
1130
- the extra class? Then we wouldn't have to repeat these additions.
1131
- // Added floating mobods are in the order the new joints were added so
1132
- // the index we get in the plant should match the one stored with the mobod.
1133
- for (auto index : graph.added_floating_mobods()) {
1134
- const internal::SpanningForestModel::Mobod& floating_mobod =
1135
- model.mobods()[index];
1136
- const JointIndex floating = AddFloatingJointToWorld(floating_mobod);
1137
- DRAKE_DEMAND(floating == floating_mobod.joint_index);
1138
- }
1139
-
1140
- // Shadow mobods are in the order the new bodies were added so the body
1141
- // index should match.
1142
- for (auto index : model.shadow_mobods()) {
1143
- const internal::SpanningForestModel::Mobod shadow_mobod = model.mobods()[index];
1144
- const BodyIndex shadow = AddShadowBody(shadow_mobod);
1145
- DRAKE_DEMAND(shadow == shadow_mobod.link_index_);
1146
- }
1147
-
1148
- // The modeler only knows about constraints it adds so there is no
1149
- // indexing correspondence.
1150
- for (auto& loop_constraint : model.added_constraints()) {
1151
- const ConstraintIndex constraint =
1152
- AddLoopClosingConstraint(loop_constraint);
1153
- }
1154
- */
1100
+ // After finalizing the base class, tree is read-only.
1101
+ internal::MultibodyTreeSystem<T>::Finalize ();
1155
1102
1156
1103
if (geometry_source_is_registered ()) {
1157
1104
ApplyDefaultCollisionFilters ();
1158
1105
}
1106
+
1159
1107
FinalizePlantOnly ();
1160
1108
1161
1109
// Make the manager of discrete updates.
@@ -1173,12 +1121,6 @@ void MultibodyPlant<T>::Finalize() {
1173
1121
" only supported for discrete models. Refer to MultibodyPlant's "
1174
1122
" documentation for further details." );
1175
1123
}
1176
-
1177
- /* The Plant is complete now. Next, build an efficient computational
1178
- representation structured in accordance with `model`. */
1179
-
1180
- // After finalizing the base class, tree is read-only.
1181
- internal::MultibodyTreeSystem<T>::Finalize ();
1182
1124
}
1183
1125
1184
1126
template <typename T>
0 commit comments