title: How multiple run ros.init_node () in one python script?
body: <p>I have written a program in python with ROS. It contains a GUI for &quot;robot teleoperation&quot;, and in its <em>MainWindow</em> I added 3 widgets (rviz, joystick, button panel). When I start <em>MainWindow</em> I get the following error:</p>
  <blockquote>
  <p>raise rospy.exceptions.ROSException(&quot;rospy.init_node() has already been called with different arguments: &quot;+str(_init_node_args))</p>
  <p>rospy.exceptions.ROSException: rospy.init_node() has already been
  called with different arguments: ('teleop_twist_keyboard',
  ['MainWindow.py'], False, None, False, False).</p>
  </blockquote>
  <p><em>Joystick.py</em> and <em>Button.py</em> contain <code>ros.init_node()</code> function. In <em>MainWindow</em> I instantiate <em>Joystick</em> and <em>Button</em> class  and add them to <em>MainWindow</em>. I need to call <code>ros.init_node()</code> several times to communicate with various nodes.</p>
  <p><a href="https://i.stack.imgur.com/d8vzS.jpg" rel="nofollow noreferrer">directory structure</a></p>
  <p><a href="https://i.stack.imgur.com/Zq4SK.jpg" rel="nofollow noreferrer">main window example</a></p>
  <p><a href="https://i.stack.imgur.com/EyFGN.jpg" rel="nofollow noreferrer">code main window</a></p>
  <pre><code>import sys
  import PyQt5
  import threading
  
  from Joystick import Joystick
  from QWidget_rviz import Rviz
  from BaseArmPosition import BaseArmPosition
  
  class MainWindow(PyQt5.QtWidgets.QMainWindow):
  
      def __init__(self,*args, **kwargs):
          super(MainWindow, self).__init__(*args, **kwargs)
  
          self.title = 'Robot teleoperation'
          self.left = 10
          self.top = 10
          self.width = 1920
          self.height = 1080
  
          self.joy = Joystick(maxDistance=50,MinimumSize=100,EclipseX=-20,EclipseY=40)
          self.rviz = Rviz()
          #self.arm_position = BaseArmPosition()
  
  
          self.initUI()
  
          
      def initUI(self):
          self.central_widget = PyQt5.QtWidgets.QWidget()
          self.setCentralWidget(self.central_widget)
  
          grid = PyQt5.QtWidgets.QGridLayout(self.centralWidget())
  
          grid.addWidget(self.joy, 0, 2)
          grid.addWidget(self.rviz, 0, 0)
          #grid.addWidget(self.arm_position, 0, 1)
  
  
          self.setWindowTitle(self.title)
          self.setGeometry(self.left, self.top, self.width, self.height)
          self.show() 
  
  app = PyQt5.QtWidgets.QApplication(sys.argv)
  window = MainWindow()
  window.show()
  app.exec_()
  </code></pre>
  <p><a href="https://i.stack.imgur.com/mOb9D.jpg" rel="nofollow noreferrer">code buttons widget, joistick.py has the same</a></p>
  <pre><code>import PyQt5
  import rospy
  from std_msgs.msg import String
  
  
  class BaseArmPosition(PyQt5.QtWidgets.QWidget):
      def __init__(self, *args, **kwargs):
          super(BaseArmPosition, self).__init__(*args, **kwargs)            
          self.initUI()
  
      def initUI(self):
          self.pushButton_moveInit = PyQt5.QtWidgets.QPushButton(&quot;moveInit&quot;,self)
          self.pushButton_moveLeft = PyQt5.QtWidgets.QPushButton(&quot;moveLeft&quot;,self)
          self.pushButton_moveRight = PyQt5.QtWidgets.QPushButton(&quot;moveRight&quot;,self)
  
          layout = PyQt5.QtWidgets.QVBoxLayout(self)
          layout.addWidget(self.pushButton_moveRight)
          layout.addWidget(self.pushButton_moveLeft)
          layout.addWidget(self.pushButton_moveInit)
  
          self.pushButton_moveInit.clicked.connect(self.moveInit)
          self.pushButton_moveLeft.clicked.connect(self.moveLeft)
          self.pushButton_moveRight.clicked.connect(self.moveRight)
  
          rospy.init_node(&quot;controller_ur&quot;)
          self.pub_arm = rospy.Publisher(&quot;/controller_ur/order&quot;,String,queue_size=1)
  
      def moveInit(self):
          moveInit = &quot;moveInit&quot;
          msg = String()
          msg.data = moveInit
          self.pub_arm.publish(moveInit)
  
      def moveLeft(self):
          moveInit = &quot;moveLeft&quot;
          msg = String()
          msg.data = moveInit
          self.pub_arm.publish(moveInit)
  
      def moveRight(self):
          moveInit = &quot;moveRight&quot;
          msg = String()
          msg.data = moveInit
          self.pub_arm.publish(moveInit)
  </code></pre>