Skip to content

Commit af66fda

Browse files
committed
Enable the Body alias for RigidBody
1 parent 1d200fe commit af66fda

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

multibody/tree/rigid_body.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -861,10 +861,10 @@ class RigidBody : public MultibodyElement<T> {
861861
systems::NumericParameterIndex spatial_inertia_parameter_index_;
862862
};
863863

864-
// TODO(sherm1) Uncomment this alias for backwards compatibility after
865-
// converting Drake to use RigidBody exclusively.
866-
// template <typename T>
867-
// using Body = RigidBody<T>;
864+
/// (Compatibility) Prefer RigidBody to Body, however this dispreferred alias
865+
/// is available to permit older code to continue working.
866+
template <typename T>
867+
using Body = RigidBody<T>;
868868

869869
} // namespace multibody
870870
} // namespace drake

multibody/tree/test/multibody_tree_creation_test.cc

+5
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ GTEST_TEST(MultibodyTree, BasicAPIToAddBodiesAndJoints) {
6767

6868
// Retrieves the world body.
6969
const RigidBody<double>& world_body = model->world_body();
70+
EXPECT_EQ(world_body.name(), "world");
71+
72+
// Make sure the (dispreferred) Body alias is working.
73+
const Body<double>& also_world_body = model->world_body();
74+
EXPECT_EQ(also_world_body.name(), "world");
7075

7176
// Creates a NaN SpatialInertia to instantiate the RigidBody links of the
7277
// pendulum. Using a NaN spatial inertia is ok so far since we are still

0 commit comments

Comments
 (0)