ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
2

Integrating Tensorflow into ROS

asked 2016-03-13 16:29:59 -0500

ErivaldoJunior gravatar image

Hello, everyone. I would like to the Google's inception neural network that comes with Tensorflow in a ROS Package. However, I don't have any idea on how to do this. The build system of tensorflow is different from cmake (they use bazel). Does anyone know from where can I start this?

Thank you very much for any help!

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
4

answered 2017-01-26 06:59:33 -0500

peci1 gravatar image

updated 2017-01-26 16:20:10 -0500

From now on, you can add

<run_depend>python-tensorflow-pip</run_depend>

into your package.xml, and you're ready to use tensorflow in python (after running rosdep, of course).

If you also need the C++ API, check out the experimental catkin package: https://github.com/tradr-project/tens... .

edit flag offensive delete link more

Comments

Thank you for the answer. Well, I was able to integrate ROS and Tensorflow using Python. I found a sample python code using the Inception network at https://github.com/tensorflow/models/... . I modified this code for my needs and it worked great with ROS.

ErivaldoJunior gravatar image ErivaldoJunior  ( 2017-01-26 16:39:29 -0500 )edit

I will take a look into your code because I still need to learn how to internet tensorflow using C++ and Catkin.

ErivaldoJunior gravatar image ErivaldoJunior  ( 2017-01-26 16:40:07 -0500 )edit
0

answered 2016-09-19 14:44:18 -0500

hector_sab gravatar image

If you check the content of the following link and reads the CMakeLists.txt and the main program, you will find that adding the next lines allows you to use tensorflow with ROS. I'm still new so I only copied things...

https://github.com/flobotics/flobotic...

  • add the following to your package CMakeLists.txt, where script.py is the script you are going to run

    catkin_python_setup()
    

    and

    catkin_install_python(PROGRAMS
        scripts/script.py
        DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
    
  • Copy setup.py files to your package src folder

  • Enjoy

edit flag offensive delete link more

Comments

The referenced package doesn't correctly include tensorflow. Correct would be to list it as a dependency in setup.py. And that's only for the Python part.

peci1 gravatar image peci1  ( 2017-01-25 06:37:30 -0500 )edit
0

answered 2016-03-13 17:10:21 -0500

I am not familiar with Tensorflow, but I think the most usual way is to write a ROS wrapper package that will expose the functionality to ROS topics/services.

If the compiled version of the library that you want to integrate provides pkg-config (i.e. *.pc) file then it should be very easy to add it as a dependency to ROS package. Another way is to write a CMake find module yourself.

Then, you will have to write either a C++ or a Python (if the library has bindings for it) ROS node that does appropriate data conversions and expose necessary interface via ROS topics.

Also, since catkin is based on CMake you can try ExternalProject and build the Tensorflow together with ROS wrapper package. This approach can be preferable if the library cannot be installed with OS package manager (e.g. apt-get on Ubuntu). In this case users will get everything they need from a single repository.

Hope this helps.

edit flag offensive delete link more

Comments

Thank you for the reply. I don't think it is easy to integrate ROS and Tensorflow, because it uses Bazel as its building tool.

ErivaldoJunior gravatar image ErivaldoJunior  ( 2016-07-06 22:06:09 -0500 )edit

Question Tools

3 followers

Stats

Asked: 2016-03-13 16:29:59 -0500

Seen: 9,986 times

Last updated: Jan 26 '17