Ask Your Question

How to write a custom ros control plugin using tensor flow in c++ ?

asked 2019-01-22 17:35:53 -0500

microbot gravatar image

Hello, I am quite new to ROS and Tensor flow. From a basic google search, I found out that tensor flow c++ API is only supported by bazel build but I intend to use tensor flow in my custom plugin in ROS and the problem is Bazel build can not read cmake files that are built with catkin workspace, Is there any method to use tensor flow with c++ API in ROS ? like can I somehow use the tensor flow standalone C API by including it to my code in C++ ? or If you can think of any particular direction where I can use tensor flow C++ API in ROS, please point me towards it. Thank you.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2019-01-22 18:00:11 -0500

The simplest way by far to do this, is compile your tensorflow controller into a shared object library using bazel. Then you can add a dependency to that library to your catkin workspace. That way you can use bazel for tensorflow and catkin for ROS.

The downside is that you'll have to develop your controller with no dependencies on ROS, then take the controller library and link it into ROS later.

Hope this helps.

edit flag offensive delete link more


Thank you, this pointed me in the right direction, although I am wondering wouldn't it be a bit complicated to develop the controller with no dependencies on ROS i.e. not calling any ros functions in the source file and then linking it to ROS later ?

microbot gravatar image microbot  ( 2019-01-23 02:58:41 -0500 )edit

the "controller" can be ROS-dependent (ie: the ros_control controller implementation). But the tensorflow side of it should not (need to) be. Use an intermediate representations of your state and control variables fi. Don't use any ROS msgs/types in the tensorflow-based library.

Essentially ..

gvdhoorn gravatar image gvdhoorn  ( 2019-01-23 03:06:47 -0500 )edit

.. treat the tensorflow library as a system dependency, which your ros_control Controller implementation uses.

This could mean that the ros_control Controller is a very thin wrapper, and only "forwards" information to tensorflow. But that would be fine.

gvdhoorn gravatar image gvdhoorn  ( 2019-01-23 03:07:43 -0500 )edit

Thank you very much, I guess I have got a basic idea now, this really is helpful.

microbot gravatar image microbot  ( 2019-01-23 03:10:10 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2019-01-22 17:35:53 -0500

Seen: 124 times

Last updated: Jan 22 '19