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

Ros Melodic, can I mix Python2.7 and Python3.0?

asked 2023-03-09 12:50:25 -0600

mkopack gravatar image

updated 2023-03-09 13:03:15 -0600

Hey gang,

I have a system that was developed for Noetic with python 3.x based stuff. Part of that is a UI we built using TkInterMapView which only is available for Python 3.x.

We have a need to backport our system to run on Melodic (don't ask), and I've been able to convert all my nodes to Python 2.7 no problem, but this UI is turning into a headache because of this TkInterMapView dependency not being available for Python 2.7.

The UI is bidirectional (it both publishes out messages and subscribes to them) so I need to be able to exchange messages with the rest of the system.

Is there some way I can build and run this particular UI running in Python3 and have the other nodes in the system run on Python 2.7? I'm actually running all the pieces of the system in Docker containers (each node in it's own container) so if I absolutely had to, I could run the container that the UI runs in on top of Noetic, but I know that typically you don't want to mix ROS version (Melodic Nodes talking with Noetic Nodes).

Anyone have any ideas how I can get around this issue? Or if somebody knows of a Python 2.7 equivalent of TkInterMapView that I could change the UI over to?

I should also add that we're using custom messages, which use mostly pretty standard simple types like ints, floats, strings, and in some cases geometry_msgs/Vector3 and geometry_msgs/Point32.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-03-09 13:50:00 -0600

gvdhoorn gravatar image

updated 2023-03-09 13:55:31 -0600

I know that typically you don't want to mix ROS version (Melodic Nodes talking with Noetic Nodes).

in ROS 1, I would say unless there are changes in the message definitions between the ROS versions you're trying to use, cross-distro communication typically works (yes, I'm aware of the myriad Q&As and other posts which predict the collapse of reality if you try this, but it's worked for me on countless occasions).

The (de)serialisation code has not changed for I don't know how many years now, and seeing as both Melodic and Noetic are essentially EOL (well, they will be), it's not expected to change at all any more.

Is there some way I can build and run this particular UI running in Python3 and have the other nodes in the system run on Python 2.7?

While you can certainly run nodes "under" different Python versions (they won't care, as the only interaction is via bytes in a TCP/IP stream), I would probably first just try the Melodic <-> Noetic in containers approach. If it works, you'd be done. If it doesn't, you could always try more complex approaches.

We have a need to backport our system to run on Melodic (don't ask), [..] I'm actually running all the pieces of the system in Docker containers (each node in it's own container)

This rather confuses me btw. If things are running in containers, what's there to backport?

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2023-03-09 12:50:25 -0600

Seen: 206 times

Last updated: Mar 09 '23