ROS Resources: Documentation | Support | Discussion Forum | Service Status | Q&A answers.ros.org

Announcing the tensorflow_ros package: the easy way to get to C++ Tensorflow API in ROS


#1

We needed to execute some pretrained Tensorflow models in C++ on our robot, and found this task to be pretty difficult to get it right. For Python inference, it’s just <depend>python-tensorflow-pip</depend> and that’s it.

So we wrote a support package tensorflow_ros_cpp which is a facade hiding the complicated stuff and allowing you to “just” <depend>tensorflow_ros_cpp</depend> and that’s it. An example of use is shown in package tensorflow_ros_test.

The package supports several ways of Tensorflow installation:

  • It can “steal” from the files installed by Python’s pip, so just installing Tensorflow via pip is enough to get the C++ API! (though it has some problems on newer systems).
  • It supports tensorflow_catkin
  • It supports custom builds using bazel

The good thing is that by depending on tensorflow_ros_cpp you don’t force users of your package into any specific kind of Tensorflow installation, he can freely choose, and your code stays the same (again, except for the systems with C++ ABI problems).

By nature of this package, it will never be distributed as a binary package, it always needs to be compiled from source.

Let us know if you find it useful!


Building a Tensorflow Object Detection and Localization ROS Package
#2

Thanks for putting this together and announcing it.

In light of this please rename your package so as not to collide with the other preexisting publicly indexed package. Package names all share the same namespace and having colliding names will only lead to confusion. Releasing different content with the same name without talking to the original maintainer and having a planned migration path is often referred to as hijacking.

For easier discovery I would encourage you to add your package for indexing. However we cannot accept it for indexing with a name collision.


#3

Yes, I just learned today about this other package.

I’ll rename the announced package to tensorflow_ros_cpp.

Do you have any best practices for the migration?


#4

Great thanks!

In general it can be pretty manual. However in the past we’ve put together scripts that can run sed across repositories. An example I remember writing is here.

Since this will just be a single token substitution I suspect that one or two well written sed rules would be able to handle it relatively well as long as they are clearly scoped to not overmatch. You could probably post the script in a gist for people to use and they can comment and give feedback there. But it won’t need to be a long term option.

There are also some other threads with resources for renaming packages:

Note that there are often two requirements one is to update the internal references and the second is to update downstream users who might be already using the API. Sometimes it’s easier to make two different scripts/sets of rules.


#5

Thanks. The technical part will probably not be that difficult.

I was more curious about how to “handle” people who are already using the package and just git pull from time to time… Probably switching the main development to a different branch than master and adding a build error into master telling the people to switch branches and clean buildfiles?


#6

That will break them anyway so there’s not much point in adding the build error to tell them to switch. You could tag or branch before the rename to allow people to get the older name if they don’t want to update immediately they have to switch to the tag for branch. If you’re checking out code from master there’s a level of expectation that you may have to update things. If they can just switch to the archival branch that should be easy for them.

Or you could just switch development to a new default branch and leave master as the archival branch. Though that may confuse new users down the line when they don’t find the latest content on the master branch.


#7

Renaming done, I’ve already changed the original post to contain the correct references. Thanks for your guidance, @tfoote .

Migration for new users will be easier than I thought - I didn’t rename the repo on github, instead I created a new one. The old repo contains a failing CMakeLists with instructions for update.


#8

tensorflow_ros_cpp is indexed as a regular ROS package now! https://wiki.ros.org/tensorflow_ros_cpp .