Ask Your Question

Ros2 import regular python modules from where

asked 2020-11-15 09:11:13 -0500

seandburke99 gravatar image

Ubuntu 20.04 ros2 foxy This may be a dumb question but I have not yet run into it so I feel the need to ask. If I am writing a python node and I want some modules from pip (or conda I suppose) such as pyserial, to what do I install the module in order to be able to use it in a ros2 node? If I wanted to use pyserial in a regular python script for a project, I would go to my venv that I use for misc projects and pip install pyserial from that environment, then use it. Am I supposed to run

python3 -m pip install -U pyserial

just for my system python? Because I've always made some sort of venv for my projects because gumming up the system with random modules usually results in me breaking something or causing some sort of package conflict. I know I can run limited ros functions from a venv (done it through an anaconda env once before to be able to run tensorflow2 in python3 in ros melodic) but I cant see that being something that is regular practice. For C++ I can just put the header/source files in a library type folder inside the ros package so that isn't an issue.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-12-22 12:32:38 -0500

mjcarroll gravatar image

There are several options available for using third-party python packages in your ROS nodes.

Based on this question (and several similar ones), we have added some documentation to cover these use cases:

edit flag offensive delete link more

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: 2020-11-15 09:11:13 -0500

Seen: 666 times

Last updated: Dec 22 '20