Skip to content

Commit

Permalink
Merge pull request #7 from magazino/ubuntu-compat
Browse files Browse the repository at this point in the history
Compatibility with old pybind11 from Ubuntu.
  • Loading branch information
MichaelGrupp authored Jan 9, 2020
2 parents ec3a17f + 34cfdb8 commit 1f5567d
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 23 deletions.
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

1 change: 0 additions & 1 deletion 3rdparty/pybind11
Submodule pybind11 deleted from 80d452
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ find_package(catkin REQUIRED COMPONENTS ${PACKAGE_DEPENDENCIES})
find_package(Boost REQUIRED COMPONENTS filesystem program_options)

# pybind11 is header-only.
add_subdirectory(3rdparty/pybind11)
find_package(pybind11)


##############
Expand Down
1 change: 0 additions & 1 deletion Dockerfile.melodic
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ from ros:melodic

RUN mkdir -p catkin_ws/src/tf_service
COPY . catkin_ws/src/tf_service
RUN git -C catkin_ws/src/tf_service submodule update --init

# Build and test.
RUN bash catkin_ws/src/tf_service/.ci/docker_build_catkin_ws.sh
Expand Down
4 changes: 0 additions & 4 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,3 @@ conditions of the following licenses.
This product includes code from geometry2, copyright Willow Garage, Inc.,
which is available under a BSD license.
For details, see: 3rdparty/geometry2_LICENSE and http://wiki.ros.org/geometry2

This product bundles a Git submodule of pybind11, copyright Wenzel Jakob,
which is available under a BSD-style license.
For details, see: 3rdparty/pybind11/LICENSE
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,10 @@ You can use the `wait_for_server` method with a timeout in case the connection w
### From source
`git clone` the repo into your catkin workspace and run:
`git clone` the repo into your catkin workspace, install the dependencies and run:
```bash
cd tf_service
git submodule update --init # for pybind11 headers
catkin build --this
catkin build tf_service
```

---
Expand Down
5 changes: 1 addition & 4 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@

<buildtool_depend>catkin</buildtool_depend>

<!-- TODO: use this instead of submodule
...once the Ubuntu package is less broken:
https://bugs.launchpad.net/ubuntu/+source/pybind11/+bug/1779578 -->
<!-- <build_depend>pybind11-dev</build_depend> -->
<build_depend>pybind11-dev</build_depend> -->

<depend>boost</depend>
<depend>geometry_msgs</depend>
Expand Down
15 changes: 10 additions & 5 deletions src/python_bindings/buffer_client_py.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,11 @@ static void ros_init_once() {
}

// Python module "client", will be <pkg_name>.client after catkin build.
PYBIND11_MODULE(client_binding, m) {
// TODO: use PYBIND11_MODULE in new versions, see other TODO at end of macro.
PYBIND11_PLUGIN(client_binding) {
py::module m("client_binding");
py::class_<tfs::BufferClient>(m, "BufferClientBinding")
.def(py::init([](const std::string& server_node_name) {
ros_init_once();
return std::make_unique<tfs::BufferClient>(server_node_name);
}),
.def(py::init<const std::string&>(),
/* doc strings for args */
py::arg("server_node_name"))
.def("can_transform",
Expand Down Expand Up @@ -88,6 +87,9 @@ PYBIND11_MODULE(client_binding, m) {
/* doc strings for args */
py::arg("timeout"));

// Needs to be called in Python code.
m.def("roscpp_init_once", &ros_init_once);

// Intended for use in Python shutdown hooks.
m.def("roscpp_shutdown", &ros::requestShutdown);

Expand Down Expand Up @@ -148,4 +150,7 @@ PYBIND11_MODULE(client_binding, m) {
TimeoutExceptionPy(e.what());
}
});

// TODO: obsolete with PYBIND11_MODULE
return m.ptr();
}
1 change: 1 addition & 0 deletions src/tf_service/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def __init__(self, server_node_name):
"""
tf2_ros.BufferInterface.__init__(self)
# All actual work is done by the C++ binding.
client_binding.roscpp_init_once()
self.client = client_binding.BufferClientBinding(server_node_name)
rospy.on_shutdown(client_binding.roscpp_shutdown)

Expand Down

0 comments on commit 1f5567d

Please sign in to comment.