create node in python as thread [closed]
Hi everyone, I've been stuck with a difficult problem of creating background nodes via threading within a python script. My goal is to create nodes dynamical within a python function.
from threading import Thread
import rospy
import time
def create_node(caller_id=""):
rospy.init_node(caller_id, disable_signals=True, anonymous=True)
rospy.spin()
def main():
b_thread = Thread(target=(create_node), args=("test_node",))
b_thread.daemon = True
b_thread.start()
time.sleep(1)
main()
Do these need to be separate nodes or is it OK if main() calls
rospy.init_node
and then just create publishers or subscribers as necessary in your threads?Thanks for responding so quick! The goal of threading would be to make each call a separate node so that I would be able to manage their subscriptions via the rosmaster.
Can you clarify what you mean with 'each call'? Are you talking about service servers here? And what does "manage their subscriptions via the rosmaster" mean exactly?
Can you perhaps describe what your ultimate goal is?
manage their subscriptions via rosmaster means calling the rosmaster api to manage creating new subscribers/deleting subscribers
Why did you close your question?