[ROS Q&A] 010 – How to import python modules from different ROS packages

More ROS Learning Resources:

Learn how to import python modules from other packages and make them available for all the system.
Also learn how to correctly install python scripts and modules.

———-Want to advance your ROS learning and master the latest Robotics topics?———–

::Visit Robot Ignite Academy, try the platform for free:

Robot Ignite Academy is an integrated ROS learning platform which contains a series of online ROS…

Similar Posts

4 thoughts on “[ROS Q&A] 010 – How to import python modules from different ROS packages
  1. At 10min you show how you import your python package with "from common_tool_pkg.clock_subscriber import ClockSubscriber". I suppose your "" in your "common_tools_pkg" folder is empty. But it is pretty common to fill the "" with some imports to only expose some classes of your module to be used outside. For example would it be possible to fill the "" with "from .clock_subscriber import ClockSubscriber" so that you can only import the class ClockSubscriber from outside your "common_tool_pkg" with "from common_tool_pkg import ClockSubscriber"? With an empty "" you can for example do something like this "from common_tool_pkg.clock_subscriber import rospy" which shouldnt be possible.

  2. I have a workspace and inside the WS SRC folder I have turtlebot3 packages like this ~/tb3_ws/src/turtlebot3/turtlebot3_teleop/ this turtlebot3_teleop contains a folder nodes which having a python script without .py extension. ~/tb3_ws/src/turtlebot3/turtlebot3_teleop/nodes/turtlebot3_teleop_key.
    So I have to test this script method for that I have created a folder ~/tb3_ws/src/turtlebot3/turtlebot3_teleop/test with a script name
    The issues I am facing to access the method of /nodes/turtlebot3_teleop_key. How to import the /nodes/turtlebot3_teleop_key into my /turtlebot3_teleop/test/ ??

Leave a Reply

Your email address will not be published. Required fields are marked *