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

Revision history [back]

click to hide/show revision 1
initial version

For other noobs like me: I was having trouble even using a class defined in another module of the _same_ package. This is what worked;

[catkin_ws_path]/src/my_package/src/my_package/__init__.py

[catkin_ws_path]/src/my_package/src/my_package/file_checker.py

[catkin_ws_path]/src/my_package/src/my_package/script_im_trying_to_run.py

  • __init__.py is empty
  • file_checker.py is the module; it contains a class called ConfigReader
  • script_im_trying_to_run.py uses an instance of class ConfigReader

script_im_trying_to_run.py contains

....
import file_checker.py
....
....
an_instance = ConfigLoader('~/config.txt')
....
click to hide/show revision 2
No.2 Revision

For other noobs like me: I was having trouble even using a class defined in another module of the _same_ package. This is what worked;

[catkin_ws_path]/src/my_package/src/my_package/__init__.py

[catkin_ws_path]/src/my_package/src/my_package/\__init__.py

[catkin_ws_path]/src/my_package/src/my_package/file_checker.py  

[catkin_ws_path]/src/my_package/src/my_package/file_checker.py

[catkin_ws_path]/src/my_package/src/my_package/script_im_trying_to_run.py

[catkin_ws_path]/src/my_package/src/my_package/script_im_trying_to_run.py
  • __init__.py is empty
  • file_checker.py is the module; it contains a class called ConfigReader
  • script_im_trying_to_run.py uses an instance of class ConfigReader

script_im_trying_to_run.py contains

....
import file_checker.py
....
....
an_instance = ConfigLoader('~/config.txt')
....