ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
I solved this problem thanks for a tip of Edouard Renard (Udemy: ROS for Beginners Course). I implemented a singleton in each class and I did not use inheritance, but composition. This helped me to solve the problem. The code was something like this:
class db_connect(object):
# Some stuff to connect with DB
class ROSController(objetc):
# singleton flag
_instance = None
@classmethod
def instance(cls):
if cls._instance is None:
cls._instance = cls()
return cls._instance
def __init__(self, parent=None):
super(ROSController, self).__init__(parent)
...
class MainController(db_connect):
def __init__(self):
super(MainController, self).__init__()
self.ros_node = RosController.instance()
class Window_1(object):
# Main window containing buttons and other things.
def __init__(self):
super(Window_1, self).__init__()
self.setupUi(self)
self.ros_node = RosController.instance()