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

Ros2 import regular python modules from where

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

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
0

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

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: https://index.ros.org/doc/ros2/Tutori...

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2020-11-15 09:11:13 -0600

Seen: 1,598 times

Last updated: Dec 22 '20