Skip to content

Commit 761c4ff

Browse files
committed
Name changes in support of composites to come
1 parent 507350a commit 761c4ff

71 files changed

Lines changed: 735 additions & 537 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

bindings/generated_docstrings/multibody_plant.h

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -186,32 +186,6 @@ This method must be called pre-Finalize.
186186
Raises:
187187
RuntimeError if ``plant`` is finalized or if time_step is changed.)""";
188188
} ApplyMultibodyPlantConfig;
189-
// Symbol: drake::multibody::BaseBodyJointType
190-
struct /* BaseBodyJointType */ {
191-
// Source: drake/multibody/plant/multibody_plant.h
192-
const char* doc =
193-
R"""(The kind of joint to be used to connect base bodies to world at
194-
Finalize(). See mbp_working_with_free_bodies "Working with free
195-
bodies" for definitions and discussion.
196-
197-
See also:
198-
SetBaseBodyJointType() for details.)""";
199-
// Symbol: drake::multibody::BaseBodyJointType::kQuaternionFloatingJoint
200-
struct /* kQuaternionFloatingJoint */ {
201-
// Source: drake/multibody/plant/multibody_plant.h
202-
const char* doc = R"""(6 dofs, unrestricted orientation.)""";
203-
} kQuaternionFloatingJoint;
204-
// Symbol: drake::multibody::BaseBodyJointType::kRpyFloatingJoint
205-
struct /* kRpyFloatingJoint */ {
206-
// Source: drake/multibody/plant/multibody_plant.h
207-
const char* doc = R"""(6 dofs using 3 angles; has singularity.)""";
208-
} kRpyFloatingJoint;
209-
// Symbol: drake::multibody::BaseBodyJointType::kWeldJoint
210-
struct /* kWeldJoint */ {
211-
// Source: drake/multibody/plant/multibody_plant.h
212-
const char* doc = R"""(0 dofs, fixed to World.)""";
213-
} kWeldJoint;
214-
} BaseBodyJointType;
215189
// Symbol: drake::multibody::CalcContactFrictionFromSurfaceProperties
216190
struct /* CalcContactFrictionFromSurfaceProperties */ {
217191
// Source: drake/multibody/plant/coulomb_friction.h
@@ -4968,7 +4942,7 @@ be used by Finalize(); post-finalize it returns the joint type that
49684942
*was* used if there were any base bodies in need of a joint.
49694943
49704944
See also:
4971-
SetBaseBodyJointType())""";
4945+
SetBaseBodyJointType(), Finalize())""";
49724946
} GetBaseBodyJointType;
49734947
// Symbol: drake::multibody::MultibodyPlant::GetBodiesKinematicallyAffectedBy
49744948
struct /* GetBodiesKinematicallyAffectedBy */ {
@@ -6625,7 +6599,10 @@ Parameter ``model_instance``:
66256599
is to be applied.
66266600
66276601
Raises:
6628-
RuntimeError if called after Finalize().)""";
6602+
RuntimeError if called after Finalize().
6603+
6604+
See also:
6605+
GetBaseBodyJointType(), Finalize())""";
66296606
} SetBaseBodyJointType;
66306607
// Symbol: drake::multibody::MultibodyPlant::SetConstraintActiveStatus
66316608
struct /* SetConstraintActiveStatus */ {

bindings/generated_docstrings/multibody_tree.h

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,32 @@ representation.)""";
589589
const char* doc = R"""()""";
590590
} type_name;
591591
} BallRpyJoint;
592+
// Symbol: drake::multibody::BaseBodyJointType
593+
struct /* BaseBodyJointType */ {
594+
// Source: drake/multibody/tree/multibody_tree.h
595+
const char* doc =
596+
R"""(The kind of joint to be used to connect base bodies to world at
597+
Finalize(). See mbp_working_with_free_bodies "Working with free
598+
bodies" for definitions and discussion.
599+
600+
See also:
601+
SetBaseBodyJointType() for details.)""";
602+
// Symbol: drake::multibody::BaseBodyJointType::kQuaternionFloatingJoint
603+
struct /* kQuaternionFloatingJoint */ {
604+
// Source: drake/multibody/tree/multibody_tree.h
605+
const char* doc = R"""(6 dofs, unrestricted orientation.)""";
606+
} kQuaternionFloatingJoint;
607+
// Symbol: drake::multibody::BaseBodyJointType::kRpyFloatingJoint
608+
struct /* kRpyFloatingJoint */ {
609+
// Source: drake/multibody/tree/multibody_tree.h
610+
const char* doc = R"""(6 dofs using 3 angles; has singularity.)""";
611+
} kRpyFloatingJoint;
612+
// Symbol: drake::multibody::BaseBodyJointType::kWeldJoint
613+
struct /* kWeldJoint */ {
614+
// Source: drake/multibody/tree/multibody_tree.h
615+
const char* doc = R"""(0 dofs, fixed to World.)""";
616+
} kWeldJoint;
617+
} BaseBodyJointType;
592618
// Symbol: drake::multibody::BodyIndex
593619
struct /* BodyIndex */ {
594620
// Source: drake/multibody/tree/multibody_tree_indexes.h
@@ -2778,7 +2804,7 @@ extract X_BF for this Frame from it.
27782804
since the last parameter change; we can't check here.
27792805
27802806
Returns ``X_BF``:
2781-
pose of this frame in its body's frame)""";
2807+
pose of this frame in its Mobod's frame)""";
27822808
} get_X_BF;
27832809
// Symbol: drake::multibody::Frame::get_X_FB
27842810
struct /* get_X_FB */ {
@@ -5115,6 +5141,17 @@ body frame B.)""";
51155141
const char* doc = R"""()""";
51165142
} stiffness;
51175143
} LinearSpringDamper;
5144+
// Symbol: drake::multibody::LinkIndex
5145+
struct /* LinkIndex */ {
5146+
// Source: drake/multibody/tree/multibody_tree_indexes.h
5147+
const char* doc = R"""(This is a synonym for BodyIndex.)""";
5148+
} LinkIndex;
5149+
// Symbol: drake::multibody::LinkOrdinal
5150+
struct /* LinkOrdinal */ {
5151+
// Source: drake/multibody/tree/multibody_tree_indexes.h
5152+
const char* doc =
5153+
R"""(Type used to identify links by ordinal within a multibody plant.)""";
5154+
} LinkOrdinal;
51185155
// Symbol: drake::multibody::ModelInstanceIndex
51195156
struct /* ModelInstanceIndex */ {
51205157
// Source: drake/multibody/tree/multibody_tree_indexes.h
@@ -7676,6 +7713,14 @@ the index into all associated quantities.)""";
76767713
R"""(Gets the ``name`` associated with this rigid body. The name will never
76777714
be empty.)""";
76787715
} name;
7716+
// Symbol: drake::multibody::RigidBody::ordinal
7717+
struct /* ordinal */ {
7718+
// Source: drake/multibody/tree/rigid_body.h
7719+
const char* doc =
7720+
R"""((Internal use only) Returns this Link's (RigidBody's) unique ordinal.
7721+
Currently identical to the index but will differ when we permit
7722+
removal of Links as we do for Joints.)""";
7723+
} ordinal;
76797724
// Symbol: drake::multibody::RigidBody::scoped_name
76807725
struct /* scoped_name */ {
76817726
// Source: drake/multibody/tree/rigid_body.h

bindings/pydrake/multibody/plant_py.cc

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,17 +1775,6 @@ PYBIND11_MODULE(plant, m) {
17751775
.value("kLagged", Class::kLagged, cls_doc.kLagged.doc);
17761776
}
17771777

1778-
{
1779-
using Class = BaseBodyJointType;
1780-
constexpr auto& cls_doc = doc.BaseBodyJointType;
1781-
py::enum_<Class> cls(m, "BaseBodyJointType", cls_doc.doc);
1782-
cls.value("kQuaternionFloatingJoint", Class::kQuaternionFloatingJoint,
1783-
cls_doc.kQuaternionFloatingJoint.doc)
1784-
.value("kRpyFloatingJoint", Class::kRpyFloatingJoint,
1785-
cls_doc.kRpyFloatingJoint.doc)
1786-
.value("kWeldJoint", Class::kWeldJoint, cls_doc.kWeldJoint.doc);
1787-
}
1788-
17891778
{
17901779
using Class = MultibodyPlantConfig;
17911780
constexpr auto& cls_doc = doc.MultibodyPlantConfig;

bindings/pydrake/multibody/test/plant_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
AddMultibodyPlant,
6060
AddMultibodyPlantSceneGraph,
6161
ApplyMultibodyPlantConfig,
62-
BaseBodyJointType,
6362
CalcContactFrictionFromSurfaceProperties,
6463
ConnectContactResultsToDrakeVisualizer,
6564
ContactModel,
@@ -81,6 +80,7 @@
8180
)
8281
from pydrake.multibody.tree import (
8382
BallRpyJoint_,
83+
BaseBodyJointType,
8484
Body_, # dispreferred alias for RigidBody_
8585
BodyIndex,
8686
CalcSpatialInertia,

bindings/pydrake/multibody/tree_py.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,17 @@ void DoScalarIndependentDefinitions(py::module m) {
148148
.value("kV", Enum::kV, enum_doc.kV.doc);
149149
}
150150

151+
{
152+
using Enum = BaseBodyJointType;
153+
constexpr auto& cls_doc = doc.BaseBodyJointType;
154+
py::enum_<Enum> cls(m, "BaseBodyJointType", cls_doc.doc);
155+
cls.value("kQuaternionFloatingJoint", Enum::kQuaternionFloatingJoint,
156+
cls_doc.kQuaternionFloatingJoint.doc)
157+
.value("kRpyFloatingJoint", Enum::kRpyFloatingJoint,
158+
cls_doc.kRpyFloatingJoint.doc)
159+
.value("kWeldJoint", Enum::kWeldJoint, cls_doc.kWeldJoint.doc);
160+
}
161+
151162
{
152163
using Class = ScopedName;
153164
constexpr auto& cls_doc = doc.ScopedName;

multibody/benchmarks/kuka_iiwa_robot/drake_kuka_iiwa_robot.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class DrakeKukaIIwaRobot {
8585
MakeKukaIiwaModel<T>(false /* finalized model */,
8686
gravity /* acceleration of gravity */));
8787

88-
linkN_ = &tree().world_body();
88+
linkN_ = &tree().world_link();
8989

9090
// Get this robot's seven links.
9191
linkA_ = &tree().GetRigidBodyByName("iiwa_link_1");
@@ -111,7 +111,7 @@ class DrakeKukaIIwaRobot {
111111

112112
/// This method gets the number of rigid bodies in this robot.
113113
/// @returns the number of rigid bodies in this robot.
114-
int get_number_of_rigid_bodies() const { return tree().num_bodies(); }
114+
int get_number_of_rigid_bodies() const { return tree().num_links(); }
115115

116116
/// This method calculates kinematic properties of the end-effector (herein
117117
/// denoted as rigid body G) of a 7-DOF KUKA LBR iiwa robot (14 kg payload).
@@ -145,7 +145,7 @@ class DrakeKukaIIwaRobot {
145145
const SpatialVelocity<T>& V_NG_N = vc.get_V_WB(linkG_->mobod_index());
146146

147147
// Retrieve end-effector spatial acceleration from acceleration cache.
148-
std::vector<SpatialAcceleration<T>> A_WB(tree().num_bodies());
148+
std::vector<SpatialAcceleration<T>> A_WB(tree().num_links());
149149
// TODO(eric.cousineau): For this model, the end effector's BodyIndex
150150
// matches its MobodIndex, thus we're not really checking the difference
151151
// between MultibodyPlant and MultibodyTree's ordering.

multibody/benchmarks/kuka_iiwa_robot/make_kuka_iiwa_model.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ KukaIiwaModelBuilder<T>::Build() const {
9191
// angles and a position vector. Alternately, frame An is regarded as
9292
// coincident with linkA.
9393
const Joint<T>* joint{nullptr};
94-
const RigidBody<T>& linkN = model->world_body();
94+
const RigidBody<T>& linkN = model->world_link();
9595
joint = &AddRevoluteJointFromSpaceXYZAnglesAndXYZ(
9696
"iiwa_joint_1", linkN, joint_1_rpy_, joint_1_xyz_, linkA,
9797
Eigen::Vector3d::UnitZ(), model.get());

multibody/optimization/test/toppra_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ TEST_F(IiwaToppraTest, JointTorqueLimit) {
210210
auto s_path = result.value();
211211

212212
// This tolerance was tuned to work with the given gridpoints.
213-
const double tol = 1e-14;
213+
const double tol = 1e-13;
214214
Eigen::MatrixXd M(7, 7);
215215
Eigen::VectorXd Cv(7);
216216
Eigen::VectorXd G(7);

multibody/plant/multibody_plant.cc

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,7 +1350,7 @@ void MultibodyPlant<T>::CalcSpatialAccelerationsFromVdot(
13501350
// Make sure there aren't any inactives for now.
13511351
DRAKE_DEMAND(ssize(mobod.follower_link_ordinals()) == 1);
13521352
const BodyIndex active_link_index =
1353-
forest.links(mobod.link_ordinal()).index();
1353+
forest.links(mobod.active_link_ordinal()).index();
13541354
(*A_WB_array)[active_link_index] = A_WB_array_mobod[mobod.index()];
13551355
}
13561356
}
@@ -1418,43 +1418,13 @@ template <typename T>
14181418
void MultibodyPlant<T>::SetBaseBodyJointType(
14191419
BaseBodyJointType joint_type,
14201420
std::optional<ModelInstanceIndex> model_instance) {
1421-
std::optional<internal::ForestBuildingOptions> options;
1422-
switch (joint_type) {
1423-
case BaseBodyJointType::kQuaternionFloatingJoint:
1424-
options = internal::ForestBuildingOptions::kDefault;
1425-
break;
1426-
case BaseBodyJointType::kRpyFloatingJoint:
1427-
options = internal::ForestBuildingOptions::kUseRpyFloatingJoints;
1428-
break;
1429-
case BaseBodyJointType::kWeldJoint:
1430-
options = internal::ForestBuildingOptions::kUseFixedBase;
1431-
break;
1432-
}
1433-
DRAKE_DEMAND(options.has_value());
1434-
DRAKE_THROW_UNLESS(!is_finalized());
1435-
internal::LinkJointGraph& graph = mutable_tree().mutable_graph();
1436-
if (model_instance.has_value()) {
1437-
graph.SetForestBuildingOptions(*model_instance, *options);
1438-
} else {
1439-
graph.SetGlobalForestBuildingOptions(*options);
1440-
}
1421+
mutable_tree().SetBaseBodyJointType(joint_type, model_instance);
14411422
}
14421423

14431424
template <typename T>
14441425
BaseBodyJointType MultibodyPlant<T>::GetBaseBodyJointType(
14451426
std::optional<ModelInstanceIndex> model_instance) const {
1446-
const internal::LinkJointGraph& graph = internal_tree().graph();
1447-
const internal::ForestBuildingOptions options =
1448-
model_instance.has_value()
1449-
? graph.get_forest_building_options_in_use(*model_instance)
1450-
: graph.get_global_forest_building_options();
1451-
if (static_cast<bool>(options &
1452-
internal::ForestBuildingOptions::kUseRpyFloatingJoints))
1453-
return BaseBodyJointType::kRpyFloatingJoint;
1454-
if (static_cast<bool>(options &
1455-
internal::ForestBuildingOptions::kUseFixedBase))
1456-
return BaseBodyJointType::kWeldJoint;
1457-
return BaseBodyJointType::kQuaternionFloatingJoint;
1427+
return internal_tree().GetBaseBodyJointType(model_instance);
14581428
}
14591429

14601430
template <typename T>

multibody/plant/multibody_plant.h

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -245,16 +245,6 @@ enum class DiscreteContactApproximation {
245245
kLagged,
246246
};
247247

248-
/// The kind of joint to be used to connect base bodies to world at Finalize().
249-
/// See @ref mbp_working_with_free_bodies "Working with free bodies"
250-
/// for definitions and discussion.
251-
/// @see SetBaseBodyJointType() for details.
252-
enum class BaseBodyJointType {
253-
kQuaternionFloatingJoint, ///< 6 dofs, unrestricted orientation.
254-
kRpyFloatingJoint, ///< 6 dofs using 3 angles; has singularity.
255-
kWeldJoint, ///< 0 dofs, fixed to World.
256-
};
257-
258248
/// @cond
259249
// Helper macro to throw an exception within methods that should not be called
260250
// post-finalize.
@@ -1267,6 +1257,10 @@ class MultibodyPlant final : public internal::MultibodyTreeSystem<T> {
12671257
const systems::OutputPort<T>& get_generalized_contact_forces_output_port(
12681258
ModelInstanceIndex model_instance) const;
12691259

1260+
// TODO(sherm1) Modify the next comment to explain that unmodeled joints will
1261+
// have NaN reaction force entries here. (Joints can be unmodeled because
1262+
// they were removed or because they are internal to a composite body.)
1263+
12701264
/// Reports joint reaction forces as an @ref AbstractValue "abstract-valued"
12711265
/// output port containing an `std::vector<SpatialForce<T>>` of size
12721266
/// num_joints().
@@ -1766,6 +1760,7 @@ class MultibodyPlant final : public internal::MultibodyTreeSystem<T> {
17661760
/// @param[in] model_instance (optional) the index of the model instance to
17671761
/// which `joint_type` is to be applied.
17681762
/// @throws std::exception if called after Finalize().
1763+
/// @see GetBaseBodyJointType(), Finalize()
17691764
void SetBaseBodyJointType(
17701765
BaseBodyJointType joint_type,
17711766
std::optional<ModelInstanceIndex> model_instance = {});
@@ -1778,7 +1773,7 @@ class MultibodyPlant final : public internal::MultibodyTreeSystem<T> {
17781773
/// This can be called any time -- pre-finalize it returns the joint type
17791774
/// that will be used by Finalize(); post-finalize it returns the joint type
17801775
/// that _was_ used if there were any base bodies in need of a joint.
1781-
/// @see SetBaseBodyJointType()
1776+
/// @see SetBaseBodyJointType(), Finalize()
17821777
BaseBodyJointType GetBaseBodyJointType(
17831778
std::optional<ModelInstanceIndex> model_instance = {}) const;
17841779

@@ -5195,7 +5190,7 @@ class MultibodyPlant final : public internal::MultibodyTreeSystem<T> {
51955190

51965191
/// Returns a constant reference to the *world* body.
51975192
const RigidBody<T>& world_body() const {
5198-
return internal_tree().world_body();
5193+
return internal_tree().world_link();
51995194
}
52005195

52015196
/// Returns a constant reference to the *world* frame.
@@ -5206,7 +5201,7 @@ class MultibodyPlant final : public internal::MultibodyTreeSystem<T> {
52065201
/// Returns the number of RigidBody elements in the model, including the
52075202
/// "world" RigidBody, which is always part of the model.
52085203
/// @see AddRigidBody().
5209-
int num_bodies() const { return internal_tree().num_bodies(); }
5204+
int num_bodies() const { return internal_tree().num_links(); }
52105205

52115206
/// Returns `true` if plant has a rigid body with unique index `body_index`.
52125207
bool has_body(BodyIndex body_index) const {

0 commit comments

Comments
 (0)