简体   繁体   中英

ROS messages between Python2.7 and Python3 modules

I am currently working on a reinforcement learning module required to receive and send state, action and reward information from ROS in Python 2.7. This is a hard constraint, due to the rest of the system.

I'd like to use the OpenAI gym environment and baselines for my reinforcement learning agent but these come with Python 3.5+.

My question as a novel robotics fellow, is it possible to receive ROS messages from Py2.7 to Py3.5+ and send them back to Py2.7? I was given the advice to use UDPROS for that purpose but I lack the experience on how this would look like. Is this the right way, are there better ways?

Is this not a common problem for larger systems that depend on legacy code in Python2.7?

I've been confused by exactly the same problem for a couple of days. I'm not sure which distro of ROS you are using but I supposed it's Kinetic since you mentioned that it only supports python2.

I've solved the problem on my laptop(ubuntu 16.0.4, ROS Kinetic)by creating a virtual environment of python3, and run both ros and baselines in that virtual environment. It seems like when there is no python2 in the environment the ROS Kinetic can still work well with those basic functions(such as publish and subscribe to a topic...).

Besides, I have solved the problem on my PC(ubuntu 18, ROS Melodic). Melodic supports python3 so that you can run baselines and ROS both on python3 in this way.

Hope this would help you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM