Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To create a new thread in ROS using Python, you may use the threading module in Python. Here's an example of creating a thread:

import rospy
import threading

def my_thread_function():
    # Do something here
    pass

if __name__ == '__main__':
    rospy.init_node('my_node')
    my_thread = threading.Thread(target=my_thread_function)
    my_thread.start()
    # Continue with the main program execution

In this example, my_thread_function() is the function that you want to run in a new thread. You create a new thread using the Thread class from the threading module and passing the function as the target. Finally, you start the thread using the start() method.