Skip to content

Commit

Permalink
wip: approximate annotations for examples/
Browse files Browse the repository at this point in the history
  • Loading branch information
rpoyner-tri committed Nov 6, 2024
1 parent 1fb7a26 commit 9098a07
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 9 deletions.
1 change: 1 addition & 0 deletions bindings/pydrake/examples/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ drake_pybind_library(
cc_deps = [
"//bindings/pydrake:documentation_pybind",
"//bindings/pydrake/common:deprecation_pybind",
"//bindings/pydrake/common:ref_cycle_pybind",
],
cc_so_name = "__init__",
cc_srcs = [
Expand Down
6 changes: 3 additions & 3 deletions bindings/pydrake/examples/examples_py_acrobot.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "drake/bindings/pydrake/common/ref_cycle_pybind.h"
#include "drake/bindings/pydrake/documentation_pybind.h"
#include "drake/bindings/pydrake/examples/examples_py.h"
#include "drake/bindings/pydrake/pydrake_pybind.h"
Expand Down Expand Up @@ -161,8 +162,7 @@ void DefineExamplesAcrobot(py::module m) {
geometry::SceneGraph<double>*>(&AcrobotGeometry::AddToBuilder),
py::arg("builder"), py::arg("acrobot_state_port"),
py::arg("acrobot_params"), py::arg("scene_graph"),
// Keep alive, ownership: `return` keeps `builder` alive.
py::keep_alive<0, 1>(),
internal::ref_cycle<0, 1>(),
// See #11531 for why `py_rvp::reference` is needed.
py_rvp::reference, doc.AcrobotGeometry.AddToBuilder.doc_4args)
.def_static("AddToBuilder",
Expand All @@ -172,7 +172,7 @@ void DefineExamplesAcrobot(py::module m) {
py::arg("builder"), py::arg("acrobot_state_port"),
py::arg("scene_graph"),
// Keep alive, ownership: `return` keeps `builder` alive.
py::keep_alive<0, 1>(),
internal::ref_cycle<0, 1>(),
// See #11531 for why `py_rvp::reference` is needed.
py_rvp::reference, doc.AcrobotGeometry.AddToBuilder.doc_3args);
}
Expand Down
5 changes: 3 additions & 2 deletions bindings/pydrake/examples/examples_py_compass_gait.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "drake/bindings/pydrake/common/ref_cycle_pybind.h"
#include "drake/bindings/pydrake/documentation_pybind.h"
#include "drake/bindings/pydrake/examples/examples_py.h"
#include "drake/bindings/pydrake/pydrake_pybind.h"
Expand Down Expand Up @@ -93,7 +94,7 @@ void DefineExamplesCompassGait(py::module m) {
py::arg("builder"), py::arg("floating_base_state_port"),
py::arg("compass_gait_params"), py::arg("scene_graph"),
// Keep alive, ownership: `return` keeps `builder` alive.
py::keep_alive<0, 1>(),
internal::ref_cycle<0, 1>(),
// See #11531 for why `py_rvp::reference` is needed.
py_rvp::reference, doc.CompassGaitGeometry.AddToBuilder.doc_4args)
.def_static("AddToBuilder",
Expand All @@ -104,7 +105,7 @@ void DefineExamplesCompassGait(py::module m) {
py::arg("builder"), py::arg("floating_base_state_port"),
py::arg("scene_graph"),
// Keep alive, ownership: `return` keeps `builder` alive.
py::keep_alive<0, 1>(),
internal::ref_cycle<0, 1>(),
// See #11531 for why `py_rvp::reference` is needed.
py_rvp::reference, doc.CompassGaitGeometry.AddToBuilder.doc_3args);
}
Expand Down
3 changes: 2 additions & 1 deletion bindings/pydrake/examples/examples_py_pendulum.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "drake/bindings/pydrake/common/ref_cycle_pybind.h"
#include "drake/bindings/pydrake/documentation_pybind.h"
#include "drake/bindings/pydrake/examples/examples_py.h"
#include "drake/bindings/pydrake/pydrake_pybind.h"
Expand Down Expand Up @@ -106,7 +107,7 @@ void DefineExamplesPendulum(py::module m) {
py::arg("builder"), py::arg("pendulum_state_port"),
py::arg("scene_graph"),
// Keep alive, ownership: `return` keeps `builder` alive.
py::keep_alive<0, 1>(),
internal::ref_cycle<0, 1>(),
// See #11531 for why `py_rvp::reference` is needed.
py_rvp::reference, doc.PendulumGeometry.AddToBuilder.doc);
}
Expand Down
3 changes: 2 additions & 1 deletion bindings/pydrake/examples/examples_py_quadrotor.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "drake/bindings/pydrake/common/ref_cycle_pybind.h"
#include "drake/bindings/pydrake/documentation_pybind.h"
#include "drake/bindings/pydrake/examples/examples_py.h"
#include "drake/bindings/pydrake/pydrake_pybind.h"
Expand Down Expand Up @@ -45,7 +46,7 @@ void DefineExamplesQuadrotor(py::module m) {
py::arg("builder"), py::arg("quadrotor_state_port"),
py::arg("scene_graph"), py::return_value_policy::reference,
// Keep alive, ownership: `return` keeps `builder` alive.
py::keep_alive<0, 1>(), doc.QuadrotorGeometry.AddToBuilder.doc);
internal::ref_cycle<0, 1>(), doc.QuadrotorGeometry.AddToBuilder.doc);

m.def("StabilizingLQRController", &StabilizingLQRController,
py::arg("quadrotor_plant"), py::arg("nominal_position"),
Expand Down
5 changes: 3 additions & 2 deletions bindings/pydrake/examples/examples_py_rimless_wheel.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "drake/bindings/pydrake/common/ref_cycle_pybind.h"
#include "drake/bindings/pydrake/documentation_pybind.h"
#include "drake/bindings/pydrake/examples/examples_py.h"
#include "drake/bindings/pydrake/pydrake_pybind.h"
Expand Down Expand Up @@ -82,7 +83,7 @@ void DefineExamplesRimlessWheel(py::module m) {
py::arg("builder"), py::arg("floating_base_state_port"),
py::arg("rimless_wheel_params"), py::arg("scene_graph"),
// Keep alive, ownership: `return` keeps `builder` alive.
py::keep_alive<0, 1>(),
internal::ref_cycle<0, 1>(),
// See #11531 for why `py_rvp::reference` is needed.
py_rvp::reference, doc.RimlessWheelGeometry.AddToBuilder.doc_4args)
.def_static("AddToBuilder",
Expand All @@ -93,7 +94,7 @@ void DefineExamplesRimlessWheel(py::module m) {
py::arg("builder"), py::arg("floating_base_state_port"),
py::arg("scene_graph"),
// Keep alive, ownership: `return` keeps `builder` alive.
py::keep_alive<0, 1>(),
internal::ref_cycle<0, 1>(),
// See #11531 for why `py_rvp::reference` is needed.
py_rvp::reference, doc.RimlessWheelGeometry.AddToBuilder.doc_3args);
}
Expand Down

0 comments on commit 9098a07

Please sign in to comment.