Thanks to do addition of the ExternallyAppliedSpatialForceMultiplexer, there is now an easier way to add multiple propeller or wing objects.
Here is an example of adding two different propellers to a bicopter. Each propeller is attached to a different body, so it is necessary to have two different propeller objects.
# from pydrake.multibody.plant import ExternallyAppliedSpatialForceMultiplexer
mux = ExternallyAppliedSpatialForceMultiplexer(2)
builder.AddNamedSystem("propeller_mux", mux)
builder.Connect(
propeller_right.get_spatial_forces_output_port(),
mux.get_input_port(0),
)
builder.Connect(
propeller_left.get_spatial_forces_output_port(),
mux.get_input_port(1),
)
# finally, we connect the output of the mux to the plant
builder.Connect(
mux.get_output_port(),
plant.get_applied_spatial_force_input_port(),
)
The image below was generated using plot_system_graphviz(diagram)
to show the connections between the propellers, mux, and the multibody plant.
Graph of Diagram with Two Propellers, Mux, and MultibodyPlant