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

Python TF/TF2 without ROS

asked 2018-09-18 12:09:19 -0600

Jari gravatar image

Okay that's kind of a shitty title, allow me to explain: for one of my "mostly python" projects (which was built initially using ROS conventions, catkin for the build system, and rosdep for dependency resolution) makes extensive use of TF but only to build and query an in memory transformation tree. I'm currently trying to chart a path to transition the project away from ROS and make it a python package (pip for dependency resolution, setuptools for build/deploy etc). I can probably make a library myself that replaces all the uses of TF but if there is already a "ROS free" version of TF or TF2 on PyPi (or in a state where it would be easy to put it on PyPi) that would save me a lot of time.

An alternative approach is to shamelessly copy tf2 and tf2_py from geometry2 and turn it into a python package. I've been considering that and I might end up doing that if the devops burden is less than the linear algebra burden of writing my own library.

Soooo yeah. Is there a TF or TF2 library already that I can install from apt or pip that doesn't need any other ROS dependencies? Thanks :)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2018-09-18 14:03:21 -0600

tfoote gravatar image

The core tf2 library only has dependencies on a few ROS datatypes, but does not depend on the communication layer.

And the tf2_py bindings do add rospy but I believe that's only to access the rospy Time constructs. This likely could easily be stubbed out for you to package up. Or even better refactored to be in the rostime that the c++ implementation uses.

It's not packaged and release on PyPi with these changes already but it is designed that you you could relatively trivially fork the geometry2 repository and strip it down to just the elements you want by deleting the packages you don't want.

edit flag offensive delete link more

Comments

That is what I was leaning towards, just wanted to see if someone else had maybe already done it. No such luck I guess, will do it now.

Jari gravatar image Jari  ( 2018-09-18 15:00:47 -0600 )edit

Okay, turns out I'm not a smart man and got too confused trying to de-ROS tf2. Ended up writing a python library that's very similar in interface. It works for my use case so far.

Jari gravatar image Jari  ( 2018-10-02 10:14:50 -0600 )edit

@tfoote After removing the parts depending on pModulerospy from tf2_py.cpp, would the _tf2 binary have to be compiled for each OS to make it a library? I guess this touches upon releasing a Python package in general, but if you could shed some light on the next steps that may be helpful.

fvd gravatar image fvd  ( 2019-03-27 04:27:53 -0600 )edit

Yes, the _tf2 binary has to be compiled for your target platform. It's a c module which has a python accessible API.

tfoote gravatar image tfoote  ( 2019-03-27 18:40:07 -0600 )edit

To add to this, the "python way" (at least for linux) is to compile everything from source on an old centos release (centos 6 right now, codenamed manylinux2010 for python's purposes). Then they use a tool called auditwheel (which in turn uses another tool called patch-elf) to inject the necessary shared objects into the python wheel and update the RPATH so that the compiled extension does not look to LD to find these.

@fvd if you still need help with the releasing part DM me and I can explain further.

Jari gravatar image Jari  ( 2019-09-21 16:55:03 -0600 )edit

Question Tools

Stats

Asked: 2018-09-18 12:09:19 -0600

Seen: 2,158 times

Last updated: Sep 18 '18