Ask Your Question
1

Python 3 - the state of things

asked 2018-02-09 06:32:05 -0500

n1k31t4 gravatar image

Hello, a newcomer to the ROS scene here,

If this is discussed or described somewhere in depth, and I have just missed it, please let me know!

I am building a ROS programme which will contain a mixture of C++ and Python nodes. I am wondering what the best practice is regarding Python versions? I assume it makes sense to use a consistent version of Python, as in all projects, ROS or not. However, since one basic concept of ROS is that messages are published in a consistent syntax (allowing nodes of C++ and Python to communicate), I am wondering why mixing Python version should pose an issue.

I found this question as a Github issue for rospy. Dirk hints that it is possible if the code works under both python2 and python3, but I wondering if anyone has tips or references for doing this. Are things any different if using ROS2?

P.s. - rospy says that the best place for such questions is here :)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2018-02-09 14:08:12 -0500

allenh1 gravatar image

I am wondering why mixing Python version should pose an issue.

That's a good question. Unfortunately, a lot of code has not yet been ported from Python 2 to Python 3, so there's a lot of core ROS tools that still rely on Python 2. My advice here would be to try and write it in a Python 3 style, and, if you discover you need something that is Python 2 only, you can always fallback on Python 2 (or, better, help the maintainer port to Python 3).

Are things any different if using ROS2?

Yes -- ROS2 is completely Python3 wrapped around C code.

edit flag offensive delete link more

Comments

@allenh1 - Thanks for your response! I"m still unclear about one thing - when you say to 'fall back onto Python 2', will that then mean using Python 2 only for the yet to be ported tools, so mixing versions itself isn't a problem? I shall be looking forward to ROS2! :-)

n1k31t4 gravatar imagen1k31t4 ( 2018-02-14 03:54:51 -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

2 followers

Stats

Asked: 2018-02-09 06:32:05 -0500

Seen: 626 times

Last updated: Feb 09 '18