Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quadrotor example: add getter for geometry frame #15046

Merged
merged 1 commit into from
May 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions bindings/pydrake/examples/quadrotor_py.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ PYBIND11_MODULE(quadrotor, m) {

py::class_<QuadrotorGeometry, LeafSystem<double>>(
m, "QuadrotorGeometry", doc.QuadrotorGeometry.doc)
.def("get_frame_id", &QuadrotorGeometry::get_frame_id,
doc.QuadrotorGeometry.get_frame_id.doc)
.def_static("AddToBuilder", &QuadrotorGeometry::AddToBuilder,
py::arg("builder"), py::arg("quadrotor_state_port"),
py::arg("scene_graph"), py::return_value_policy::reference,
Expand Down
3 changes: 2 additions & 1 deletion bindings/pydrake/examples/test/quadrotor_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ def test_geometry(self):
quadrotor = builder.AddSystem(QuadrotorPlant())
scene_graph = builder.AddSystem(SceneGraph())
state_port = quadrotor.get_output_port(0)
QuadrotorGeometry.AddToBuilder(builder, state_port, scene_graph)
geom = QuadrotorGeometry.AddToBuilder(builder, state_port, scene_graph)
self.assertTrue(geom.get_frame_id().is_valid())
4 changes: 4 additions & 0 deletions examples/quadrotor/quadrotor_geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ class QuadrotorGeometry final : public systems::LeafSystem<double> {
DRAKE_NO_COPY_NO_MOVE_NO_ASSIGN(QuadrotorGeometry);
~QuadrotorGeometry() final;

/// Returns the frame of the geometry registered with a SceneGraph. This can
/// be useful, e.g., if one would like to add a camera to the quadrotor.
geometry::FrameId get_frame_id() const { return frame_id_; }

/// Creates, adds, and connects a QuadrotorGeometry system into the given
/// `builder`. Both the `quadrotor_state.get_system()` and `scene_graph`
/// systems must have been added to the given `builder` already.
Expand Down
2 changes: 2 additions & 0 deletions examples/quadrotor/test/quadrotor_geometry_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ GTEST_TEST(QuadrotorGeometryTest, AcceptanceTest) {
&builder, plant->get_output_port(0), scene_graph);
auto diagram = builder.Build();
ASSERT_NE(geom, nullptr);

EXPECT_TRUE(geom->get_frame_id().is_valid());
}

} // namespace
Expand Down